diff --git a/templates/themes/categories/frames.html b/templates/themes/categories/frames.html new file mode 100644 index 00000000..d1d23aaa --- /dev/null +++ b/templates/themes/categories/frames.html @@ -0,0 +1,16 @@ + + + + + + {{ settings.title }} + + + + + + diff --git a/templates/themes/categories/info.php b/templates/themes/categories/info.php index 108cc254..45b4d6f0 100644 --- a/templates/themes/categories/info.php +++ b/templates/themes/categories/info.php @@ -7,14 +7,14 @@ $theme['description'] = 'Group-ordered, category-aware modification of the Frameset theme, with removable sidebar frame. -Requires $config[\'boards\'] and $config[\'categories\'].'; - $theme['version'] = 'v0.2.1'; +Requires $config[\'categories\'].'; + $theme['version'] = 'v0.2.2'; // Theme configuration $theme['config'] = Array(); $theme['config'][] = Array( - 'title' => 'Title', + 'title' => 'Site title', 'name' => 'title', 'type' => 'text' ); @@ -22,18 +22,43 @@ Requires $config[\'boards\'] and $config[\'categories\'].'; $theme['config'][] = Array( 'title' => 'Slogan', 'name' => 'subtitle', - 'type' => 'text' + 'type' => 'text', + 'comment' => '(optional)' + ); + + $theme['config'][] = Array( + 'title' => 'Main HTML file', + 'name' => 'file_main', + 'type' => 'text', + 'default' => $config['file_index'], + 'comment' => '(eg. "index.html")' + ); + + $theme['config'][] = Array( + 'title' => 'Sidebar file', + 'name' => 'file_sidebar', + 'type' => 'text', + 'default' => 'sidebar.html', + 'comment' => '(eg. "sidebar.html")' + ); + + $theme['config'][] = Array( + 'title' => 'News file', + 'name' => 'file_news', + 'type' => 'text', + 'default' => 'news.html', + 'comment' => '(eg. "news.html")' ); // Unique function name for building everything $theme['build_function'] = 'categories_build'; - $theme['install_callback'] = 'categories_install'; + if(!function_exists('categories_install')) { function categories_install($settings) { global $config; - if(!isset($config['boards']) || !isset($config['categories'])) { + if(!isset($config['categories'])) { return Array(false, '

Prerequisites not met!

' . 'This theme requires $config[\'boards\'] and $config[\'categories\'] to be set.'); } diff --git a/templates/themes/categories/news.html b/templates/themes/categories/news.html new file mode 100644 index 00000000..538eb945 --- /dev/null +++ b/templates/themes/categories/news.html @@ -0,0 +1,33 @@ +{% filter remove_whitespace %} + + + + {{ settings.title }} + + + +

{{ settings.title }}

+
{{ settings.subtitle }}
+ +
+ {% if news|count == 0 %} +

(No news to show.)

+ {% else %} + {% for entry in news %} +

+ {% if entry.subject %} + {{ entry.subject }} + {% else %} + no subject + {% endif %} + — by {{ entry.name }} at {{ entry.time|date(config.post_date) }} +

+

{{ entry.body }}

+ {% endfor %} + {% endif %} +
+ +

Powered by Tinyboard {{ config.version }} | Tinyboard Copyright © 2010-2012 Tinyboard Development Group

+ + +{% endfilter %} diff --git a/templates/themes/categories/sidebar.html b/templates/themes/categories/sidebar.html new file mode 100644 index 00000000..171e4e93 --- /dev/null +++ b/templates/themes/categories/sidebar.html @@ -0,0 +1,40 @@ +{% filter remove_whitespace %} + + + + {{ settings.title }} + + + + + +
+ {{ settings.title }} + +
+ +
+ Boards + +
+ + +{% endfilter %} 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'] . '

'; - } - } + $news = $query->fetchAll(PDO::FETCH_ASSOC); - // Finish page - $body .= ''; - - 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 + )); } };