From d3fb010a8fd2862ed6619b9cbdefb22aa9bace9c Mon Sep 17 00:00:00 2001 From: "Michael D. Reiley" Date: Tue, 20 Sep 2011 12:49:07 -0700 Subject: New "Categories" theme, modifications for support. --- inc/config.php | 11 +++ inc/functions.php | 10 +++ templates/themes/categories/info.php | 30 +++++++ templates/themes/categories/theme.php | 144 ++++++++++++++++++++++++++++++++++ templates/themes/categories/thumb.png | Bin 0 -> 8442 bytes 5 files changed, 195 insertions(+) create mode 100644 templates/themes/categories/info.php create mode 100644 templates/themes/categories/theme.php create mode 100644 templates/themes/categories/thumb.png diff --git a/inc/config.php b/inc/config.php index 0a8b982d..1b36f210 100644 --- a/inc/config.php +++ b/inc/config.php @@ -710,6 +710,17 @@ // 'status' => 'http://status.example.org/' //); + // Categories + // Required for the Categories theme. Array of the names of board groups in order, from $config['boards']. + //$config['categories'] = Array('groupname', 'name', 'anothername', 'kangaroos'); + + // Custom_categories + // Optional for the Categories theme. Array of name => (title, url) groups for categories with non-board links. + //$config['custom_categories'] = Array( 'Links' => + // Array('Tinyboard' => 'http://tinyboard.org', + // 'AnotherName' => 'url') + //); + // Set custom locations for stylesheets, scripts and maybe a banner. // This can be good for load balancing across multiple servers or hostnames. // $config['url_stylesheet'] = 'http://static.example.org/style.css'; // main/base stylesheet diff --git a/inc/functions.php b/inc/functions.php index a5c8a518..7ba2278b 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -228,6 +228,16 @@ } else return false; } + function boardTitle($uri) { + $query = prepare("SELECT `title` FROM `boards` WHERE `uri` = :uri LIMIT 1"); + $query->bindValue(':uri', $uri); + $query->execute() or error(db_error($query)); + + if($title = $query->fetch()) { + return $title['title']; + } else return false; + } + function purge($uri) { global $config, $debug; if(preg_match($config['url_match'], $config['root'])) { diff --git a/templates/themes/categories/info.php b/templates/themes/categories/info.php new file mode 100644 index 00000000..d0cedb13 --- /dev/null +++ b/templates/themes/categories/info.php @@ -0,0 +1,30 @@ + 'Title', + 'name' => 'title', + 'type' => 'text' + ); + + $theme['config'][] = Array( + 'title' => 'Slogan', + 'name' => 'subtitle', + 'type' => 'text' + ); + + // Unique function name for building everything + $theme['build_function'] = 'categories_build'; +?> diff --git a/templates/themes/categories/theme.php b/templates/themes/categories/theme.php new file mode 100644 index 00000000..c126f8da --- /dev/null +++ b/templates/themes/categories/theme.php @@ -0,0 +1,144 @@ +' + . '' + . '' + . '' + . '' . $settings['title'] . '' + . '' + // Sidebar + . '' + // Main + . '' + // Finish page + . ''; + } + + // Build news page + public static function news($settings) { + global $config; + + // HTML5 + $body = '' + . '' + . '' + . 'News' + . ''; + + $body .= '

' . $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 ' . + date($config['post_date'], $news['time']) . + '

' . $news['body'] . '

'; + } + } + + // Finish page + $body .= ''; + + return $body; + } + + // Build sidebar + public static function sidebar($settings) { + global $config, $board; + + $body = '' + . '' + . '' + . '' + . '' + . '' . $settings['title'] . '' + . ''; + + $body .= '
' . $settings['title'] . '
'; + + for($cat = 0; $cat < count($config['categories']); $cat++) { + $body .= '
' . $config['categories'][$cat] . '
'; + } + + foreach($config['custom_categories'] as $name => &$group) { + $body .= '
' . $name . '
'; + } + + // Finish page + $body .= ''; + + return $body; + } + }; + +?> diff --git a/templates/themes/categories/thumb.png b/templates/themes/categories/thumb.png new file mode 100644 index 00000000..4326ee35 Binary files /dev/null and b/templates/themes/categories/thumb.png differ -- cgit v1.3 From 33a6d69c06fc7015febfbb04140ef12630910d35 Mon Sep 17 00:00:00 2001 From: "Michael D. Reiley" Date: Thu, 22 Sep 2011 00:10:06 -0700 Subject: Small fix for unicode oops in two themes. --- templates/themes/categories/theme.php | 2 +- templates/themes/frameset/theme.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/themes/categories/theme.php b/templates/themes/categories/theme.php index c126f8da..f625fe79 100644 --- a/templates/themes/categories/theme.php +++ b/templates/themes/categories/theme.php @@ -75,7 +75,7 @@ : 'no subject' ) . - ' — by ' . + ' — by ' . $news['name'] . ' at ' . date($config['post_date'], $news['time']) . diff --git a/templates/themes/frameset/theme.php b/templates/themes/frameset/theme.php index 3724e02e..d626103a 100644 --- a/templates/themes/frameset/theme.php +++ b/templates/themes/frameset/theme.php @@ -75,7 +75,7 @@ : 'no subject' ) . - ' — by ' . + ' — by ' . $news['name'] . ' at ' . date($config['post_date'], $news['time']) . -- cgit v1.3 From c210cdbfea79834873a78f114f5c33e161cfe140 Mon Sep 17 00:00:00 2001 From: "Michael D. Reiley" Date: Thu, 22 Sep 2011 14:47:19 -0700 Subject: Categories theme v0.2 --- templates/themes/categories/info.php | 4 ++-- templates/themes/categories/theme.php | 12 +++++++++++- templates/themes/categories/thumb.png | Bin 8442 -> 9965 bytes 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/templates/themes/categories/info.php b/templates/themes/categories/info.php index d0cedb13..3718344c 100644 --- a/templates/themes/categories/info.php +++ b/templates/themes/categories/info.php @@ -5,10 +5,10 @@ $theme['name'] = 'Categories'; // Description (you can use Tinyboard markup here) $theme['description'] = -'Group-ordered, category-aware modification of the Frameset theme. +'Group-ordered, category-aware modification of the Frameset theme, with removable sidebar frame. Requires $config[\'boards\'] and $config[\'categories\'].'; - $theme['version'] = 'v0.1'; + $theme['version'] = 'v0.2'; // Theme configuration $theme['config'] = Array(); diff --git a/templates/themes/categories/theme.php b/templates/themes/categories/theme.php index f625fe79..393ad5bd 100644 --- a/templates/themes/categories/theme.php +++ b/templates/themes/categories/theme.php @@ -59,7 +59,11 @@ . 'News' . ''; - $body .= '

' . $settings['title'] . '

' + $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()); @@ -105,10 +109,16 @@ . '' . '' . '' . $settings['title'] . '' + . '' . ''; $body .= '
' . $settings['title'] . '
'; for($cat = 0; $cat < count($config['categories']); $cat++) { diff --git a/templates/themes/categories/thumb.png b/templates/themes/categories/thumb.png index 4326ee35..35d747e2 100644 Binary files a/templates/themes/categories/thumb.png and b/templates/themes/categories/thumb.png differ -- cgit v1.3 From a59b915b0a94fe621503deeeca5eef17c5fababc Mon Sep 17 00:00:00 2001 From: "Michael D. Reiley" Date: Thu, 22 Sep 2011 15:07:25 -0700 Subject: Categories theme v0.2.1 (Frame removal works correctly.) --- templates/themes/categories/info.php | 2 +- templates/themes/categories/theme.php | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/templates/themes/categories/info.php b/templates/themes/categories/info.php index 3718344c..0090f39d 100644 --- a/templates/themes/categories/info.php +++ b/templates/themes/categories/info.php @@ -8,7 +8,7 @@ 'Group-ordered, category-aware modification of the Frameset theme, with removable sidebar frame. Requires $config[\'boards\'] and $config[\'categories\'].'; - $theme['version'] = 'v0.2'; + $theme['version'] = 'v0.2.1'; // Theme configuration $theme['config'] = Array(); diff --git a/templates/themes/categories/theme.php b/templates/themes/categories/theme.php index 393ad5bd..de1b4a5b 100644 --- a/templates/themes/categories/theme.php +++ b/templates/themes/categories/theme.php @@ -39,6 +39,11 @@ . 'iframe#main{border-left:1px solid black;left:15%;top:0;width:85%}' . '' . '' . $settings['title'] . '' + . '' . '' // Sidebar . '' @@ -109,16 +114,11 @@ . '' . '' . '' . $settings['title'] . '' - . '' . ''; $body .= '
' . $settings['title'] . '
'; for($cat = 0; $cat < count($config['categories']); $cat++) { -- cgit v1.3