From 3c20a558d8e043ab12d6caca3c45a947a56838ef Mon Sep 17 00:00:00 2001 From: discomrade Date: Fri, 13 Jan 2023 03:49:08 -0100 Subject: [PATCH] Add overboard support to mod catalog --- inc/mod/pages.php | 14 +++++++++++++- templates/themes/catalog/theme.php | 20 ++++++++++++-------- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/inc/mod/pages.php b/inc/mod/pages.php index 96179e3e..16c848c3 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -766,7 +766,19 @@ function mod_view_catalog($boardName) { $settings['title'] = 'Catalog'; $settings['use_tooltipster'] = true; $catalog = new Catalog($settings); - echo $catalog->build($boardName, $mod); + + $query = prepare(sprintf('SELECT * FROM ``theme_settings`` WHERE `name` = "uri" AND `value` = :uri', $board)); + $query->bindValue(':uri', $boardName); + $query->execute() or error(db_error($query)); + + if ($theme = $query->fetch(PDO::FETCH_ASSOC)){ + if ($theme['theme'] == "rand") + echo $catalog->buildRand($mod); + if ($theme['theme'] == "ukko") + echo $catalog->buildUkko($mod); + } else { + echo $catalog->build($boardName, $mod); + } } function mod_view_board($boardName, $page_no = 1) { diff --git a/templates/themes/catalog/theme.php b/templates/themes/catalog/theme.php index 41bf198e..a853f24f 100644 --- a/templates/themes/catalog/theme.php +++ b/templates/themes/catalog/theme.php @@ -67,7 +67,7 @@ /** * Build and save the HTML of the catalog for the Ukko theme */ - public function buildUkko() { + public function buildUkko($mod = false) { global $board, $config; $ukkoSettings = themeSettings('ukko'); @@ -97,7 +97,7 @@ return strcmp($b['bump'], $a['bump']); }); // Generate data for the template - $recent_posts = $this->generateRecentPosts($threads); + $recent_posts = $this->generateRecentPosts($threads, $mod); // Generate board data for building $board_original = $board; @@ -106,16 +106,18 @@ $board['title'] = $ukkoSettings['title']; $board['subtitle'] = $ukkoSettings['subtitle']; - $this->saveForBoard($ukkoSettings['uri'], $recent_posts, - $config['root'] . $ukkoSettings['uri']); + $ret = $this->saveForBoard($ukkoSettings['uri'], $recent_posts, + $config['root'] . $ukkoSettings['uri'], $mod); $board = $board_original; + + return $ret; } /** * Build and save the HTML of the catalog for the Rand theme */ - public function buildRand() { + public function buildRand($mod = false) { global $board, $config; $randSettings = themeSettings('rand'); @@ -143,7 +145,7 @@ // Randomize order shuffle($threads); // Generate data for the template - $recent_posts = $this->generateRecentPosts($threads); + $recent_posts = $this->generateRecentPosts($threads, $mod); // Generate board data for building $board_original = $board; @@ -152,10 +154,12 @@ $board['title'] = $randSettings['title']; $board['subtitle'] = $randSettings['subtitle']; - $this->saveForBoard($randSettings['uri'], $recent_posts, - $config['root'] . $randSettings['uri']); + $ret = $this->saveForBoard($randSettings['uri'], $recent_posts, + $config['root'] . $randSettings['uri'], $mod); $board = $board_original; + + return $ret; } /**