forked from Cavemanon/cavepaintings
much theme docs, and some display_my_foo_error replaced with generic display_error
git-svn-id: file:///home/shish/svn/shimmie2/trunk@395 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
parent
29829efc66
commit
0b7c038f52
@ -1,6 +1,12 @@
|
||||
<?php
|
||||
|
||||
class AdminUtilsTheme extends Themelet {
|
||||
/*
|
||||
* Show a form which links to admin_utils with POST[action] set to one of:
|
||||
* 'lowercase all tags'
|
||||
* 'recount tag use'
|
||||
* 'purge unused tags'
|
||||
*/
|
||||
public function display_form($page) {
|
||||
$html = "
|
||||
<p><form action='".make_link("admin_utils")."' method='POST'>
|
||||
|
@ -1,6 +1,13 @@
|
||||
<?php
|
||||
|
||||
class WikiTheme {
|
||||
/*
|
||||
* Show a page
|
||||
*
|
||||
* $page = the shimmie page object
|
||||
* $wiki_page = the wiki page, has ->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();
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,13 +1,21 @@
|
||||
<?php
|
||||
|
||||
class AdminPageTheme extends Themelet {
|
||||
/*
|
||||
* Show the basics of a page, for other extensions to add to
|
||||
*/
|
||||
public function display_page($page) {
|
||||
$page->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 = "
|
||||
<form action='".make_link("admin/delete_image")."' method='POST'>
|
||||
|
@ -1,6 +1,12 @@
|
||||
<?php
|
||||
|
||||
class AliasEditorTheme extends Themelet {
|
||||
/*
|
||||
* Show a page of aliases:
|
||||
*
|
||||
* $aliases = an array of ($old_tag => $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 = "<td>Action</td>";
|
||||
|
@ -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
|
||||
|
@ -1,6 +1,12 @@
|
||||
<?php
|
||||
|
||||
class CommentListTheme extends Themelet {
|
||||
/*
|
||||
* Do the basics of the comments page
|
||||
*
|
||||
* $page_number = the current page number
|
||||
* $total_pages = the total number of comment pages
|
||||
*/
|
||||
public function display_page_start($page, $page_number, $total_pages) {
|
||||
$prev = $page_number - 1;
|
||||
$next = $page_number + 1;
|
||||
@ -19,12 +25,20 @@ class CommentListTheme extends Themelet {
|
||||
$this->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 .= "<p><a class='more' href='".make_link("comment/list")."'>Full List</a>";
|
||||
$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 = "<div style='text-align: left'>";
|
||||
$html .= "<div style='float: left; margin-right: 16px;'>" . build_thumb_html($image) . "</div>";
|
||||
$html .= $this->comments_to_html($comments);
|
||||
$html .= "</div>";
|
||||
if($with_postbox) {
|
||||
$html .= "<div style='clear:both;'>".($this->build_postbox($image->id))."</div>";
|
||||
}
|
||||
else {
|
||||
$html .= "<div style='clear:both;'><p><small>You need to create an account before you can comment</small></p></div>";
|
||||
}
|
||||
|
||||
$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 "<p class='comment'>$h_userlink: $h_comment $h_imagelink $h_dellink</p>";
|
||||
}
|
||||
|
||||
// FIXME: privatise this
|
||||
public function build_postbox($image_id) {
|
||||
private function build_postbox($image_id) {
|
||||
$i_image_id = int_escape($image_id);
|
||||
return "
|
||||
<form action='".make_link("comment/add")."' method='POST'>
|
||||
@ -79,21 +115,5 @@ class CommentListTheme extends Themelet {
|
||||
</form>
|
||||
";
|
||||
}
|
||||
|
||||
|
||||
public function add_comment_list($page, $image, $comments, $position, $with_postbox) {
|
||||
$html = "<div style='text-align: left'>";
|
||||
$html .= "<div style='float: left; margin-right: 16px;'>" . build_thumb_html($image) . "</div>";
|
||||
$html .= $this->comments_to_html($comments);
|
||||
$html .= "</div>";
|
||||
if($with_postbox) {
|
||||
$html .= "<div style='clear:both;'>".($this->build_postbox($image->id))."</div>";
|
||||
}
|
||||
else {
|
||||
$html .= "<div style='clear:both;'><p><small>You need to create an account before you can comment</small></p></div>";
|
||||
}
|
||||
|
||||
$page->add_block(new Block("{$image->id}: ".($image->get_tag_list()), $html, "main", $position));
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -1,11 +1,17 @@
|
||||
<?php
|
||||
|
||||
class DowntimeTheme Extends Themelet {
|
||||
/*
|
||||
* Show the admin that downtime mode is enabled
|
||||
*/
|
||||
public function display_notification($page) {
|
||||
$page->add_block(new Block("Downtime",
|
||||
"<span style='font-size: 1.5em'><b>DOWNTIME MODE IS ON!</b></span>", "left", 0));
|
||||
}
|
||||
|
||||
/*
|
||||
* Display $message and exit
|
||||
*/
|
||||
public function display_message($message) {
|
||||
header("HTTP/1.0 503 Service Temporarily Unavailable");
|
||||
print <<<EOD
|
||||
|
@ -1,6 +1,11 @@
|
||||
<?php
|
||||
|
||||
class ETTheme extends Themelet {
|
||||
/*
|
||||
* Create a page showing info
|
||||
*
|
||||
* $info = an array of ($name => $value)
|
||||
*/
|
||||
public function display_info_page($page, $info) {
|
||||
$page->set_title("System Info");
|
||||
$page->set_heading("System Info");
|
||||
|
@ -1,6 +1,16 @@
|
||||
<?php
|
||||
|
||||
class IPBanTheme extends Themelet {
|
||||
/*
|
||||
* Show all the bans
|
||||
*
|
||||
* $bans = an array of (
|
||||
* 'ip' => 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) {
|
||||
|
@ -1,6 +1,9 @@
|
||||
<?php
|
||||
|
||||
class NewsTheme extends Themelet {
|
||||
/*
|
||||
* Show $text on the $page
|
||||
*/
|
||||
public function display_news($page, $text) {
|
||||
$page->add_block(new Block("Note", $text, "left", 5));
|
||||
}
|
||||
|
@ -1,6 +1,9 @@
|
||||
<?php
|
||||
|
||||
class RegenThumbTheme extends Themelet {
|
||||
/*
|
||||
* Show a form which offers to regenerate the thumb of an image with ID #$image_id
|
||||
*/
|
||||
public function display_buttons($page, $image_id) {
|
||||
$html = "
|
||||
<form action='".make_link("regen_thumb")."' method='POST'>
|
||||
@ -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");
|
||||
|
@ -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") {
|
||||
|
@ -1,30 +1,23 @@
|
||||
<?php
|
||||
|
||||
class SetupTheme extends Themelet {
|
||||
public function display_not_admin($page) {
|
||||
$page->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
|
||||
|
@ -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") {
|
||||
|
@ -1,6 +1,15 @@
|
||||
<?php
|
||||
|
||||
class TagEditTheme extends Themelet {
|
||||
/*
|
||||
* Display a form to edit tags for $image
|
||||
* The form should link to tag_edit/set, with the following set:
|
||||
* POST[image_id]
|
||||
* POST[query] = when redirecting to post/view, what the search string should be set to
|
||||
* POST[tags]
|
||||
*
|
||||
* Note $image->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 = "
|
||||
<form action='".make_link("tag_edit/replace")."' method='POST'>
|
||||
@ -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"));
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,14 +1,9 @@
|
||||
<?php
|
||||
|
||||
class ViewTheme extends Themelet {
|
||||
public function display_image_not_found($page, $image_id) {
|
||||
$page->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()));
|
||||
|
Loading…
Reference in New Issue
Block a user