From 5ea4de048a8371597fef2c33b0132084005976b1 Mon Sep 17 00:00:00 2001 From: Michael Save Date: Tue, 14 Feb 2012 21:26:08 +1100 Subject: categories theme v0.3 --- templates/themes/categories/theme.php | 130 ++++++---------------------------- 1 file changed, 22 insertions(+), 108 deletions(-) (limited to 'templates/themes/categories/theme.php') diff --git a/templates/themes/categories/theme.php b/templates/themes/categories/theme.php index 9689f207..ebaca5e9 100644 --- a/templates/themes/categories/theme.php +++ b/templates/themes/categories/theme.php @@ -16,142 +16,56 @@ global $config; if($action == 'all') - file_write($config['dir']['home'] . $config['file_index'], Categories::homepage($settings)); + file_write($config['dir']['home'] . $settings['file_main'], Categories::homepage($settings)); if($action == 'all' || $action == 'boards') - file_write($config['dir']['home'] . 'sidebar.html', Categories::sidebar($settings)); + file_write($config['dir']['home'] . $settings['file_sidebar'], Categories::sidebar($settings)); if($action == 'all' || $action == 'news') - file_write($config['dir']['home'] . 'news.html', Categories::news($settings)); + file_write($config['dir']['home'] . $settings['file_news'], Categories::news($settings)); } // Build homepage public static function homepage($settings) { global $config; - // HTML5 - return '' - . '' - . '' - . '' - . '' . $settings['title'] . '' - . '' - . '' - // Sidebar - . '' - // Main - . '' - // Finish page - . ''; + return Element('themes/frameset/frames.html', Array('config' => $config, 'settings' => $settings)); } // Build news page public static function news($settings) { global $config; - // HTML5 - $body = '' - . '' - . '' - . 'News' - . ''; - - $boardlist = createBoardlist(); - - $body .= $boardlist['top'] - - . '

' . $settings['title'] . '

' - . '
' . ($settings['subtitle'] ? utf8tohtml($settings['subtitle']) : '') . '
'; - $query = query("SELECT * FROM `news` ORDER BY `time` DESC") or error(db_error()); - if($query->rowCount() == 0) { - $body .= '

(No news to show.)

'; - } else { - // List news - while($news = $query->fetch()) { - $body .= '
' . - '

' . - ($news['subject'] ? - $news['subject'] - : - 'no subject' - ) . - ' — by ' . - $news['name'] . - ' at ' . - strftime($config['post_date'], $news['time']) . - '

' . $news['body'] . '

'; - } - } - - // Finish page - $body .= ''; + $news = $query->fetchAll(PDO::FETCH_ASSOC); - return $body; + return Element('themes/frameset/news.html', Array( + 'settings' => $settings, + 'config' => $config, + 'news' => $news + )); } // Build sidebar public static function sidebar($settings) { global $config, $board; - $body = '' - . '' - . '' - . '' - . '' - . '' . $settings['title'] . '' - . ''; + $categories = $config['categories']; - $body .= '
' . $settings['title'] . '
'; - - if(isset($config['categories'])) { - for($cat = 0; $cat < count($config['categories']); $cat++) { - $body .= '
' . $config['categories'][$cat] . '
'; + foreach($categories as &$boards) { + foreach($boards as &$board) { + $title = boardTitle($board); + if(!$title) + $title = $board; // board doesn't exist, but for some reason you want to display it anyway + $board = Array('title' => $title, 'uri' => sprintf($config['board_path'], $board)); } } - if(isset($config['custom_categories'])) { - foreach($config['custom_categories'] as $name => &$group) { - $body .= '
' . $name . '
'; - } - } - - // Finish page - $body .= ''; - - return $body; + return Element('themes/frameset/sidebar.html', Array( + 'settings' => $settings, + 'config' => $config, + 'categories' => $categories + )); } }; -- cgit v1.3