diff --git a/contrib/admin_utils/theme.php b/contrib/admin_utils/theme.php index bc9f8f82..4e53f158 100644 --- a/contrib/admin_utils/theme.php +++ b/contrib/admin_utils/theme.php @@ -1,6 +1,12 @@
diff --git a/contrib/wiki/theme.php b/contrib/wiki/theme.php index 39d8980a..de03f0ea 100644 --- a/contrib/wiki/theme.php +++ b/contrib/wiki/theme.php @@ -1,6 +1,13 @@ title and ->body + * $nav_page = a wiki page object with navigation, has ->body + */ public function display_page($page, $wiki_page, $nav_page) { if(is_null($nav_page)) { $nav_page = new WikiPage(); diff --git a/ext/admin/main.php b/ext/admin/main.php index fd70d9b0..85bdbcb5 100644 --- a/ext/admin/main.php +++ b/ext/admin/main.php @@ -45,7 +45,7 @@ class AdminPage extends Extension { if(is_a($event, 'DisplayingImageEvent')) { global $user; if($user->is_admin()) { - $this->theme->display_delete_block($event->page, $event->image->id); + $this->theme->display_deleter($event->page, $event->image->id); } } diff --git a/ext/admin/theme.php b/ext/admin/theme.php index b60c9d0c..172fd49e 100644 --- a/ext/admin/theme.php +++ b/ext/admin/theme.php @@ -1,13 +1,21 @@ set_title("Admin Tools"); $page->set_heading("Admin Tools"); $page->add_block(new NavBlock()); } - public function display_delete_block($page, $image_id) { + /* + * Display a link to delete an image + * + * $image_id = the image to delete + */ + public function display_deleter($page, $image_id) { $i_image_id = int_escape($image_id); $html = " diff --git a/ext/alias_editor/theme.php b/ext/alias_editor/theme.php index 03966d20..b5cd3e07 100644 --- a/ext/alias_editor/theme.php +++ b/ext/alias_editor/theme.php @@ -1,6 +1,12 @@ $new_tag) + * $is_admin = whether things like "add new alias" should be shown + */ public function display_aliases($page, $aliases, $is_admin) { if($is_admin) { $action = "Action"; diff --git a/ext/bulk_add/theme.php b/ext/bulk_add/theme.php index 2081f416..961f58ee 100644 --- a/ext/bulk_add/theme.php +++ b/ext/bulk_add/theme.php @@ -3,6 +3,9 @@ class BulkAddTheme extends Themelet { var $messages = array(); + /* + * Show a standard page for results to be put into + */ public function display_upload_results($page) { $page->set_title("Adding folder"); $page->set_heading("Adding folder"); @@ -12,6 +15,11 @@ class BulkAddTheme extends Themelet { } } + /* + * Add a section to the admin page. This should contain a form which + * links to bulk_add with POST[dir] set to the name of a server-side + * directory full of images + */ public function display_admin_block($page) { $html = " Add a folder full of images; any subfolders will have their names diff --git a/ext/comment/theme.php b/ext/comment/theme.php index e4b74d7c..bc7bb8da 100644 --- a/ext/comment/theme.php +++ b/ext/comment/theme.php @@ -1,6 +1,12 @@ display_paginator($page, "comment/list", null, $page_number, $total_pages); } + /* + * Add some comments to the page, probably in a sidebar + * + * $comments = an array of Comment objects to be shown + */ public function display_recent_comments($page, $comments) { $html = $this->comments_to_html($comments, true); $html .= "

Full List"; $page->add_block(new Block("Comments", $html, "left")); } + /* + * + */ public function display_comments($page, $comments, $postbox, $image_id) { if($postbox) { $page->add_block(new Block("Comments", @@ -37,6 +51,29 @@ class CommentListTheme extends Themelet { } } + /* + * + */ + public function add_comment_list($page, $image, $comments, $position, $with_postbox) { + $html = "

"; + $html .= "
" . build_thumb_html($image) . "
"; + $html .= $this->comments_to_html($comments); + $html .= "
"; + if($with_postbox) { + $html .= "
".($this->build_postbox($image->id))."
"; + } + else { + $html .= "

You need to create an account before you can comment

"; + } + + $page->add_block(new Block("{$image->id}: ".($image->get_tag_list()), $html, "main", $position)); + } + + + /* + * Various functions which are only used by this theme + */ + private function comments_to_html($comments, $trim=false) { $html = ""; @@ -68,8 +105,7 @@ class CommentListTheme extends Themelet { return "

$h_userlink: $h_comment $h_imagelink $h_dellink

"; } - // FIXME: privatise this - public function build_postbox($image_id) { + private function build_postbox($image_id) { $i_image_id = int_escape($image_id); return " @@ -79,21 +115,5 @@ class CommentListTheme extends Themelet {
"; } - - - public function add_comment_list($page, $image, $comments, $position, $with_postbox) { - $html = "
"; - $html .= "
" . build_thumb_html($image) . "
"; - $html .= $this->comments_to_html($comments); - $html .= "
"; - if($with_postbox) { - $html .= "
".($this->build_postbox($image->id))."
"; - } - else { - $html .= "

You need to create an account before you can comment

"; - } - - $page->add_block(new Block("{$image->id}: ".($image->get_tag_list()), $html, "main", $position)); - } } ?> diff --git a/ext/downtime/theme.php b/ext/downtime/theme.php index 4f0fabe5..6d81f67e 100644 --- a/ext/downtime/theme.php +++ b/ext/downtime/theme.php @@ -1,11 +1,17 @@ add_block(new Block("Downtime", "DOWNTIME MODE IS ON!", "left", 0)); } + /* + * Display $message and exit + */ public function display_message($message) { header("HTTP/1.0 503 Service Temporarily Unavailable"); print << $value) + */ public function display_info_page($page, $info) { $page->set_title("System Info"); $page->set_heading("System Info"); diff --git a/ext/ipban/theme.php b/ext/ipban/theme.php index 785b15c0..e5e3d498 100644 --- a/ext/ipban/theme.php +++ b/ext/ipban/theme.php @@ -1,6 +1,16 @@ the banned IP + * 'reason' => why the IP was banned + * 'date' => when the ban started + * 'end' => when the ban will end + * ) + */ public function display_bans($page, $bans) { $h_bans = ""; foreach($bans as $ban) { diff --git a/ext/news/theme.php b/ext/news/theme.php index c651c475..bf7195e9 100644 --- a/ext/news/theme.php +++ b/ext/news/theme.php @@ -1,6 +1,9 @@ add_block(new Block("Note", $text, "left", 5)); } diff --git a/ext/regen_thumb/theme.php b/ext/regen_thumb/theme.php index 46db77bf..4e3ad357 100644 --- a/ext/regen_thumb/theme.php +++ b/ext/regen_thumb/theme.php @@ -1,6 +1,9 @@ @@ -16,6 +19,9 @@ class RegenThumbTheme extends Themelet { $page->add_block(new Block("Regen Thumb", $html, "left")); } + /* + * Show a link to the new thumbnail + */ public function display_results($page, $image) { $page->set_title("Thumbnail Regenerated"); $page->set_heading("Thumbnail Regenerated"); diff --git a/ext/setup/main.php b/ext/setup/main.php index 661cd605..763a94f4 100644 --- a/ext/setup/main.php +++ b/ext/setup/main.php @@ -138,7 +138,7 @@ class Setup extends Extension { if(is_a($event, 'PageRequestEvent') && ($event->page_name == "setup")) { global $user; if(!$user->is_admin()) { - $this->theme->display_not_admin($event->page); + $this->theme->display_error($event->page, "Permission Denied", "This page is for admins only"); } else { if($event->get_arg(0) == "save") { diff --git a/ext/setup/theme.php b/ext/setup/theme.php index 66424886..2f669afb 100644 --- a/ext/setup/theme.php +++ b/ext/setup/theme.php @@ -1,30 +1,23 @@ set_title("Error"); - $page->set_heading("Error"); - $page->add_block(new NavBlock()); - $page->add_block(new Block("Permission Denied", "This page is for admins only")); - } - + /* + * Display a set of setup option blocks + * + * $panel = the container of the blocks + * $panel->blocks the blocks to be displayed, unsorted + * + * It's recommented that the theme sort the blocks before doing anything + * else, using: usort($panel->blocks, "blockcmp"); + * + * The page should wrap all the options in a form which links to setup_save + */ public function display_page($page, $panel) { $setupblock_html1 = ""; $setupblock_html2 = ""; usort($panel->blocks, "blockcmp"); - /* - $flip = true; - foreach($panel->mainblocks as $block) { - if(is_a($block, 'SetupBlock')) { - if($flip) $setupblock_html1 .= $this->sb_to_html($block); - else $setupblock_html2 .= $this->sb_to_html($block); - $flip = !$flip; - } - } - */ - /* * Try and keep the two columns even; count the line breaks in * each an calculate where a block would work best diff --git a/ext/tag_edit/main.php b/ext/tag_edit/main.php index c48b0cbc..6facc918 100644 --- a/ext/tag_edit/main.php +++ b/ext/tag_edit/main.php @@ -18,7 +18,7 @@ class TagEdit extends Extension { $page->set_redirect(make_link("post/view/$i_image_id", $query)); } else { - $this->theme->display_anon_denied($event->page); + $this->theme->display_error($event->page, "Error", "Anonymous tag editing is disabled"); } } else if($event->get_arg(0) == "replace") { diff --git a/ext/tag_edit/theme.php b/ext/tag_edit/theme.php index 32561fe3..f1db4312 100644 --- a/ext/tag_edit/theme.php +++ b/ext/tag_edit/theme.php @@ -1,6 +1,15 @@ get_tag_list() + */ public function display_editor($page, $image) { global $database; @@ -26,6 +35,10 @@ class TagEditTheme extends Themelet { $page->add_block(new Block(null, $html, "main", 5)); } + /* + * Display a form which links to tag_edit/replace with POST[search] + * and POST[replace] set appropriately + */ public function display_mass_editor($page) { $html = "
@@ -38,12 +51,5 @@ class TagEditTheme extends Themelet { "; $page->add_block(new Block("Mass Tag Edit", $html)); } - - public function display_anon_denied($page) { - $page->set_title("Tag Edit Denied"); - $page->set_heading("Tag Edit Denied"); - $page->add_block(new NavBlock()); - $page->add_block(new Block("Error", "Anonymous tag editing is disabled")); - } } ?> diff --git a/ext/tag_list/theme.php b/ext/tag_list/theme.php index 31ce192e..7650d0f3 100644 --- a/ext/tag_list/theme.php +++ b/ext/tag_list/theme.php @@ -25,6 +25,12 @@ class TagListTheme extends Themelet { // ======================================================================= + /* + * $tag_infos = array( + * array('tag' => $tag, 'count' => $number_of_uses), + * ... + * ) + */ public function display_related_block($page, $tag_infos) { global $config; diff --git a/ext/view/main.php b/ext/view/main.php index db5c7136..c10e592e 100644 --- a/ext/view/main.php +++ b/ext/view/main.php @@ -16,7 +16,7 @@ class ViewImage extends Extension { send_event(new DisplayingImageEvent($image, $event->page)); } else { - $this->theme->display_image_not_found($event->page, $image_id); + $this->theme->display_error($event->page, "Image not found", "No image in the database has the ID #$image_id"); } } diff --git a/ext/view/theme.php b/ext/view/theme.php index 28dde43b..2d7295ed 100644 --- a/ext/view/theme.php +++ b/ext/view/theme.php @@ -1,14 +1,9 @@ set_title("Image not found"); - $page->set_heading("Image not found"); - $page->add_block(new NavBlock()); - $page->add_block(new Block("Image not found", - "No image in the database has the ID #$image_id")); - } - + /* + * Build a page showing $image and some info about it + */ public function display_page($page, $image) { $page->set_title("Image {$image->id}: ".html_escape($image->get_tag_list())); $page->set_heading(html_escape($image->get_tag_list()));