diff --git a/contrib/admin_utils/main.php b/contrib/admin_utils/main.php index 0b6bc8c3..0c743737 100644 --- a/contrib/admin_utils/main.php +++ b/contrib/admin_utils/main.php @@ -8,8 +8,11 @@ */ class AdminUtils extends Extension { + var $theme; // event handler {{{ public function receive_event($event) { + if(is_null($this->theme)) $this->theme = get_theme_object("admin_utils", "AdminUtilsTheme"); + if(is_a($event, 'PageRequestEvent') && ($event->page == "admin_utils")) { global $user; if($user->is_admin()) { @@ -29,7 +32,7 @@ class AdminUtils extends Extension { if(is_a($event, 'AdminBuildingEvent')) { global $page; - $page->add_main_block(new Block("Misc Admin Tools", $this->build_form())); + $this->theme->display_form($page); } } // }}} @@ -50,17 +53,6 @@ class AdminUtils extends Extension { } } // }}} -// admin page HTML {{{ - private function build_form() { - $html = " -
- "; - return $html; - } -// }}} } add_event_listener(new AdminUtils()); ?> diff --git a/contrib/admin_utils/theme.php b/contrib/admin_utils/theme.php new file mode 100644 index 00000000..f92b13d3 --- /dev/null +++ b/contrib/admin_utils/theme.php @@ -0,0 +1,14 @@ + + "; + $page->add_block(new Block("Misc Admin Tools", $html)); + } +} +?> diff --git a/contrib/autocomplete/main.php b/contrib/autocomplete/main.php index c758828b..8f34b174 100644 --- a/contrib/autocomplete/main.php +++ b/contrib/autocomplete/main.php @@ -5,7 +5,7 @@ class AutoComplete extends Extension { public function receive_event($event) { if(is_a($event, 'PageRequestEvent') && ($event->page == "index" || $event->page == "view")) { global $page; - $page->add_side_block(new Block(null, $this->build_autocomplete_script())); + $page->add_header(""); } if(is_a($event, 'PageRequestEvent') && ($event->page == "autocomplete")) { global $page; @@ -22,52 +22,6 @@ class AutoComplete extends Extension { return implode("\n", $tags); } // }}} -// html {{{ - private function build_autocomplete_script() { - global $database; - $ac_url = html_escape(make_link("autocomplete")); - - return <<".
build_thumb_html($existing)));
@@ -178,7 +178,7 @@ class ImageIO extends Extension {
* insert the image info into the database
*/
if(!copy($image->temp_filename, $image->get_image_filename())) {
- $page->add_main_block(new Block("Error uploading {$image->filename}",
+ $page->add_block(new Block("Error uploading {$image->filename}",
"The image couldn't be moved from the temporary area to the
main data store -- is the web server allowed to write to '".
($image->get_image_filename())."'?"));
@@ -188,7 +188,7 @@ class ImageIO extends Extension {
chmod($image->get_image_filename(), 0644);
if(!$this->make_thumb($image->get_image_filename(), $image->get_thumb_filename())) {
- $page->add_main_block(new Block("Error uploading {$image->filename}",
+ $page->add_block(new Block("Error uploading {$image->filename}",
"The image thumbnail couldn't be generated -- is the web
server allowed to write to '".($image->get_thumb_filename())."'?"));
send_event(new ImageDeletionEvent($image->id));
@@ -240,8 +240,8 @@ class ImageIO extends Extension {
else {
$page->set_title("Not Found");
$page->set_heading("Not Found");
- $page->add_side_block(new Block("Navigation", "Index"), 0);
- $page->add_main_block(new Block("Image not in database",
+ $page->add_block(new Block("Navigation", "Index", "left", 0));
+ $page->add_block(new Block("Image not in database",
"The requested image was not found in the database"));
}
}
diff --git a/core/ext/index.ext.php b/core/ext/index.ext.php
index eea0d919..153795e4 100644
--- a/core/ext/index.ext.php
+++ b/core/ext/index.ext.php
@@ -51,18 +51,19 @@ class Index extends Extension {
$page->set_title($page_title);
$page->set_heading($page_title);
- $page->add_side_block(new Block("Navigation", $this->build_navigation($page_number, $total_pages, $search_terms)), 0);
+ $page->add_block(new Block("Navigation", $this->build_navigation($page_number, $total_pages, $search_terms), "left", 0));
if(count($images) > 0) {
- $page->add_main_block(new Block("Images", $this->build_table($images, $query)), 10);
- $page->add_main_block(new Paginator("index", $query, $page_number, $total_pages), 90);
+ $page->add_block(new Block("Images", $this->build_table($images, $query), "main", 10));
+ $page->add_block(new Paginator("index", $query, $page_number, $total_pages));
}
else {
- $page->add_main_block(new Block("No Images Found", "No images were found to match the search criteria"));
+ $page->add_block(new Block("No Images Found", "No images were found to match the search criteria"));
}
}
if(is_a($event, 'SetupBuildingEvent')) {
$sb = new SetupBlock("Index Options");
+ $sb->position = 20;
$sb->add_label("Index table size ");
$sb->add_int_option("index_width");
@@ -72,7 +73,7 @@ class Index extends Extension {
$sb->add_text_option("image_tip", "
Image tooltip ");
- $event->panel->add_main_block($sb, 20);
+ $event->panel->add_block($sb);
}
if(is_a($event, 'ConfigSaveEvent')) {
$event->config->set_int_from_post("index_width");
diff --git a/core/ext/setup.ext.php b/core/ext/setup.ext.php
index ca1f9063..1eca938f 100644
--- a/core/ext/setup.ext.php
+++ b/core/ext/setup.ext.php
@@ -19,7 +19,12 @@ class SetupBuildingEvent extends Event {
/* SetupPanel {{{
*
*/
-class SetupPanel extends Page {
+class SetupPanel {
+ var $blocks = array();
+
+ public function add_block($block) {
+ $this->blocks[] = $block;
+ }
}
// }}}
/* SetupBlock {{{
@@ -31,6 +36,8 @@ class SetupBlock extends Block {
public function SetupBlock($title) {
$this->header = $title;
+ $this->section = "main";
+ $this->position = 50;
}
public function add_label($text) {
@@ -118,8 +125,8 @@ class Setup extends Extension {
global $page;
$page->set_title("Error");
$page->set_heading("Error");
- $page->add_side_block(new NavBlock(), 0);
- $page->add_main_block(new Block("Permission Denied", "This page is for admins only"), 0);
+ $page->add_block(new NavBlock());
+ $page->add_block(new Block("Permission Denied", "This page is for admins only"));
}
else {
if($event->get_arg(0) == "save") {
@@ -147,6 +154,7 @@ class Setup extends Extension {
}
$sb = new SetupBlock("General");
+ $sb->position = 0;
$sb->add_text_option("title", "Site title: ");
$sb->add_text_option("front_page", "
Front page: ");
$sb->add_text_option("base_href", "
Base URL: ");
@@ -155,7 +163,7 @@ class Setup extends Extension {
$sb->add_choice_option("theme", $themes, "
Theme: ");
// $sb->add_int_option("anon_id", "
Anonymous ID: "); // FIXME: create advanced options page
$sb->add_hidden_option("anon_id");
- $event->panel->add_main_block($sb, 0);
+ $event->panel->add_block($sb);
}
if(is_a($event, 'ConfigSaveEvent')) {
$event->config->set_string_from_post("title");
@@ -179,7 +187,7 @@ class Setup extends Extension {
$setupblock_html1 = "";
$setupblock_html2 = "";
- ksort($panel->mainblocks);
+ usort($panel->blocks, "blockcmp");
/*
$flip = true;
@@ -198,7 +206,7 @@ class Setup extends Extension {
*/
$len1 = 0;
$len2 = 0;
- foreach($panel->mainblocks as $block) {
+ foreach($panel->blocks as $block) {
if(is_a($block, 'SetupBlock')) {
$html = $this->sb_to_html($block);
$len = count(explode("
", $html));
@@ -223,8 +231,8 @@ class Setup extends Extension {
global $page;
$page->set_title("Shimmie Setup");
$page->set_heading("Shimmie Setup");
- $page->add_side_block(new Block("Navigation", $this->build_navigation()), 0);
- $page->add_main_block(new Block("Setup", $table));
+ $page->add_block(new Block("Navigation", $this->build_navigation(), "left", 0));
+ $page->add_block(new Block("Setup", $table));
}
private function build_navigation() {
diff --git a/core/ext/tag_edit.ext.php b/core/ext/tag_edit.ext.php
index b3bd9ebb..c0b2ab59 100644
--- a/core/ext/tag_edit.ext.php
+++ b/core/ext/tag_edit.ext.php
@@ -17,8 +17,8 @@ class TagEdit extends Extension {
else {
$page->set_title("Tag Edit Denied");
$page->set_heading("Tag Edit Denied");
- $page->add_side_block(new NavBlock());
- $page->add_main_block(new Block("Error", "Anonymous tag editing is disabled"));
+ $page->add_block(new NavBlock());
+ $page->add_block(new Block("Error", "Anonymous tag editing is disabled"));
}
}
else if($event->get_arg(0) == "replace") {
@@ -34,7 +34,7 @@ class TagEdit extends Extension {
if(is_a($event, 'DisplayingImageEvent')) {
global $page;
- $page->add_main_block(new Block(null, $this->build_tag_editor($event->image)), 5);
+ $page->add_block(new Block(null, $this->build_tag_editor($event->image)), "main", 5);
}
if(is_a($event, 'TagSetEvent')) {
@@ -49,7 +49,7 @@ class TagEdit extends Extension {
if(is_a($event, 'AdminBuildingEvent')) {
global $page;
- $page->add_main_block(new Block("Mass Tag Edit", $this->build_mass_tag_edit()));
+ $page->add_block(new Block("Mass Tag Edit", $this->build_mass_tag_edit()));
}
// When an alias is added, oldtag becomes inaccessable
@@ -60,7 +60,7 @@ class TagEdit extends Extension {
if(is_a($event, 'SetupBuildingEvent')) {
$sb = new SetupBlock("Tag Editing");
$sb->add_bool_option("tag_edit_anon", "Allow anonymous editing: ");
- $event->panel->add_main_block($sb);
+ $event->panel->add_block($sb);
}
if(is_a($event, 'ConfigSaveEvent')) {
$event->config->set_bool_from_post("tag_edit_anon");
diff --git a/core/ext/user.ext.php b/core/ext/user.ext.php
index 6408cd45..393f8b67 100644
--- a/core/ext/user.ext.php
+++ b/core/ext/user.ext.php
@@ -30,8 +30,8 @@ class UserPage extends Extension {
else {
$page->set_title("Login");
$page->set_heading("Login");
- $page->add_side_block(new NavBlock());
- $page->add_main_block(new Block("Login There",
+ $page->add_block(new NavBlock());
+ $page->add_block(new Block("Login There",
"There should be a login box to the left"));
}
}
@@ -61,10 +61,10 @@ class UserPage extends Extension {
global $page;
if($user->is_anonymous()) {
- $page->add_side_block(new Block("Login", $this->build_login_block()), 90);
+ $page->add_block(new Block("Login", $this->build_login_block(), "left", 90));
}
else {
- $page->add_side_block(new Block("User Links", $this->build_links_block()), 90);
+ $page->add_block(new Block("User Links", $this->build_links_block(), "left", 90));
}
}
@@ -72,7 +72,7 @@ class UserPage extends Extension {
$sb = new SetupBlock("User Options");
$sb->add_bool_option("login_signup_enabled", "Allow new signups: ");
$sb->add_longtext_option("login_tac", "
Terms & Conditions:
");
- $event->panel->add_main_block($sb);
+ $event->panel->add_block($sb);
}
if(is_a($event, 'ConfigSaveEvent')) {
$event->config->set_bool_from_post("login_signup_enabled");
@@ -81,7 +81,7 @@ class UserPage extends Extension {
if(is_a($event, 'UserBlockBuildingEvent')) {
$event->add_link("User Config", make_link("user"));
- $event->add_link("Log Out", make_link("user/logout"));
+ $event->add_link("Log Out", make_link("user/logout"), 99);
}
}
// }}}
@@ -116,8 +116,8 @@ class UserPage extends Extension {
else {
$page->set_title("Permission Denied");
$page->set_heading("Permission Denied");
- $page->add_side_block(new NavBlock(), 0);
- $page->add_main_block(new Block("Error", "No user with those details was found"));
+ $page->add_block(new NavBlock());
+ $page->add_block(new Block("Error", "No user with those details was found"));
}
}
@@ -129,8 +129,8 @@ class UserPage extends Extension {
if(!$config->get_bool("login_signup_enabled")) {
$page->set_title("Signups Disabled");
$page->set_heading("Signups Disabled");
- $page->add_side_block(new NavBlock());
- $page->add_main_block(new Block("Signups Disabled",
+ $page->add_block(new NavBlock());
+ $page->add_block(new Block("Signups Disabled",
"The board admin has disabled the ability to create new accounts~"));
}
else if(isset($_POST['name']) && isset($_POST['pass1']) && isset($_POST['pass2'])) {
@@ -140,15 +140,15 @@ class UserPage extends Extension {
$page->set_title("Error");
$page->set_heading("Error");
- $page->add_side_block(new NavBlock());
+ $page->add_block(new NavBlock());
if(strlen($name) < 1) {
- $page->add_main_block(new Block("Error", "Username must be at least 1 character"));
+ $page->add_block(new Block("Error", "Username must be at least 1 character"));
}
else if($pass1 != $pass2) {
- $page->add_main_block(new Block("Error", "Passwords don't match"));
+ $page->add_block(new Block("Error", "Passwords don't match"));
}
else if($database->db->GetRow("SELECT * FROM users WHERE name = ?", array($name))) {
- $page->add_main_block(new Block("Error", "That username is already taken"));
+ $page->add_block(new Block("Error", "That username is already taken"));
}
else {
$addr = $_SERVER['REMOTE_ADDR'];
@@ -171,12 +171,12 @@ class UserPage extends Extension {
else {
$page->set_title("Create Account");
$page->set_heading("Create Account");
- $page->add_side_block(new NavBlock());
- $page->add_main_block(new Block("Signup", $this->build_signup_form()));
+ $page->add_block(new NavBlock());
+ $page->add_block(new Block("Signup", $this->build_signup_form()));
}
}
//}}}
-// Things do ne *to* the user {{{
+// Things done *to* the user {{{
private function change_password_wrapper() {
global $user;
global $page;
@@ -184,9 +184,9 @@ class UserPage extends Extension {
$page->set_title("Error");
$page->set_heading("Error");
- $page->add_side_block(new NavBlock());
+ $page->add_block(new NavBlock());
if($user->is_anonymous()) {
- $page->add_main_block(new Block("Error", "You aren't logged in"));
+ $page->add_block(new Block("Error", "You aren't logged in"));
}
else if(isset($_POST['id']) && isset($_POST['name']) &&
isset($_POST['pass1']) && isset($_POST['pass2'])) {
@@ -196,11 +196,11 @@ class UserPage extends Extension {
$pass2 = $_POST['pass2'];
if((!$user->is_admin()) && ($name != $user->name)) {
- $page->add_main_block(new Block("Error",
+ $page->add_block(new Block("Error",
"You need to be an admin to change other people's passwords"));
}
else if($pass1 != $pass2) {
- $page->add_main_block(new Block("Error", "Passwords don't match"));
+ $page->add_block(new Block("Error", "Passwords don't match"));
}
else {
global $config;
@@ -236,12 +236,12 @@ class UserPage extends Extension {
$page->set_title("Error");
$page->set_heading("Error");
- $page->add_side_block(new NavBlock());
+ $page->add_block(new NavBlock());
if(!$user->is_admin()) {
- $page->add_main_block(new Block("Not Admin", "Only admins can edit accounts"));
+ $page->add_block(new Block("Not Admin", "Only admins can edit accounts"));
}
else if(!isset($_POST['id']) || !is_numeric($_POST['id'])) {
- $page->add_main_block(new Block("No ID Specified",
+ $page->add_block(new Block("No ID Specified",
"You need to specify the account number to edit"));
}
else {
@@ -293,24 +293,24 @@ class UserPage extends Extension {
if(!is_null($duser)) {
$page->set_title("{$duser->name}'s Page");
$page->set_heading("{$duser->name}'s Page");
- $page->add_side_block(new NavBlock(), 0);
- $page->add_main_block(new Block("Stats", $this->build_stats($duser)));
+ $page->add_block(new NavBlock());
+ $page->add_block(new Block("Stats", $this->build_stats($duser)));
if(!$user->is_anonymous()) {
if($user->id == $duser->id || $user->is_admin()) {
- $page->add_main_block(new Block("Options", $this->build_options($duser)));
+ $page->add_block(new Block("Options", $this->build_options($duser), "main", 0));
}
if($user->is_admin()) {
- $page->add_main_block(new Block("More Options", $this->build_more_options($duser)));
- $page->add_main_block(new Block("IP List", $this->build_ip_list($duser)));
+ $page->add_block(new Block("More Options", $this->build_more_options($duser)));
+ $page->add_block(new Block("IP List", $this->build_ip_list($duser)));
}
}
}
else {
$page->set_title("No Such User");
$page->set_heading("No Such User");
- $page->add_side_block(new NavBlock(), 0);
- $page->add_main_block(new Block("No User By That ID",
+ $page->add_block(new NavBlock());
+ $page->add_block(new Block("No User By That ID",
"If you typed the ID by hand, try again; if you came from a link on this ".
"site, it might be bug report time..."));
}
@@ -423,6 +423,7 @@ class UserPage extends Extension {
$h_name = html_escape($user->name);
$html = "Logged in as $h_name
";
+ ksort($ubbe->parts);
$html .= join("\n
", $ubbe->parts);
return $html;
diff --git a/core/ext/view.ext.php b/core/ext/view.ext.php
index 41c352dd..3f5b22ca 100644
--- a/core/ext/view.ext.php
+++ b/core/ext/view.ext.php
@@ -16,9 +16,9 @@ class ViewImage extends Extension {
global $page;
$page->set_title("Image not found");
$page->set_heading("Image not found");
- $page->add_side_block(new NavBlock(), 0);
- $page->add_main_block(new Block("Image not found",
- "No image in the database has the ID #$image_id"), 0);
+ $page->add_block(new NavBlock());
+ $page->add_block(new Block("Image not found",
+ "No image in the database has the ID #$image_id"));
}
}
@@ -28,17 +28,18 @@ class ViewImage extends Extension {
global $page;
$page->set_title("Image {$image->id}: ".$image->get_tag_list());
$page->set_heading($image->get_tag_list());
- $page->add_side_block(new Block("Navigation", $this->build_navigation($image->id)), 0);
- $page->add_main_block(new Block("Image", $this->build_image_view($image)), 0);
- $page->add_main_block(new Block(null, $this->build_info($image)), 10);
+ $page->add_block(new Block("Navigation", $this->build_navigation($image->id), "left", 0));
+ $page->add_block(new Block("Image", $this->build_image_view($image), "main", 0));
+ $page->add_block(new Block(null, $this->build_info($image), "main", 10));
}
if(is_a($event, 'SetupBuildingEvent')) {
$sb = new SetupBlock("View Options");
+ $sb->position = 30;
$sb->add_text_option("image_ilink", "Long link ");
$sb->add_text_option("image_slink", "
Short link ");
$sb->add_text_option("image_tlink", "
Thumbnail link ");
- $event->panel->add_main_block($sb, 30);
+ $event->panel->add_block($sb);
}
if(is_a($event, 'ConfigSaveEvent')) {
$event->config->set_string_from_post("image_ilink");
diff --git a/core/navblock.class.php b/core/navblock.class.php
index 38be5693..bc5dca64 100644
--- a/core/navblock.class.php
+++ b/core/navblock.class.php
@@ -1,11 +1,10 @@
header = "Navigation";
$this->body = "Index";
+ $this->section = "left";
+ $this->position = 0;
}
}
?>
diff --git a/core/page.class.php b/core/page.class.php
index 400b3f14..2553e4f0 100644
--- a/core/page.class.php
+++ b/core/page.class.php
@@ -1,5 +1,5 @@
title = $title;
@@ -60,14 +59,8 @@ class Page {
$this->headers[$position] = $line;
}
- public function add_side_block($block, $position=50) {
- while(isset($this->sideblocks[$position])) $position++;
- $this->sideblocks[$position] = $block;
- }
-
- public function add_main_block($block, $position=50) {
- while(isset($this->mainblocks[$position])) $position++;
- $this->mainblocks[$position] = $block;
+ public function add_block($block) {
+ $this->blocks[] = $block;
}
// ==============================================
@@ -80,10 +73,9 @@ class Page {
switch($this->mode) {
case "page":
header("Cache-control: no-cache");
- ksort($this->sideblocks);
- ksort($this->mainblocks);
- $theme = $config->get_string("theme");
- require_once "themes/$theme/default.php";
+ usort($this->blocks, "blockcmp");
+ $layout = new Layout();
+ $layout->display_page($this);
break;
case "data":
print $this->data;
diff --git a/core/paginator.class.php b/core/paginator.class.php
index 1cfdc15d..463f92d1 100644
--- a/core/paginator.class.php
+++ b/core/paginator.class.php
@@ -6,6 +6,8 @@ class Paginator extends Block {
public function Paginator($page, $query, $page_number, $total_pages) {
$this->body = $this->build_paginator($page_number, $total_pages, $page, $query);
+ $this->section = "main";
+ $this->position = 90;
}
private function gen_page_link($base_url, $query, $page, $name) {
diff --git a/core/util.inc.php b/core/util.inc.php
index dafcaaf1..9e1a641f 100644
--- a/core/util.inc.php
+++ b/core/util.inc.php
@@ -216,6 +216,57 @@ function CountExecs($db, $sql, $inputarray) {
$null = null; return $null;
}
+function get_theme_object($file, $class) {
+ global $config;
+ $theme = $config->get_string("theme", "default");
+ if(file_exists("themes/$theme/$file.theme.php")) {
+ require_once "themes/$theme/$file.theme.php";
+ return new $class();
+ }
+ else {
+ require_once "ext/$file/theme.php";
+ return new $class();
+ }
+}
+
+function get_debug_info() {
+ global $config;
+
+ if($config->get_bool('debug_enabled')) {
+ if(function_exists('memory_get_usage')) {
+ $i_mem = sprintf("%5.2f", ((memory_get_usage()+512)/1024)/1024);
+ }
+ else {
+ $i_mem = "???";
+ }
+ if(function_exists('getrusage')) {
+ $ru = getrusage();
+ $i_utime = sprintf("%5.2f", ($ru["ru_utime.tv_sec"]*1e6+$ru["ru_utime.tv_usec"])/1000000);
+ $i_stime = sprintf("%5.2f", ($ru["ru_stime.tv_sec"]*1e6+$ru["ru_stime.tv_usec"])/1000000);
+ }
+ else {
+ $i_utime = "???";
+ $i_stime = "???";
+ }
+ $i_files = count(get_included_files());
+ global $_execs;
+ $debug = "
Took $i_utime + $i_stime seconds and {$i_mem}MB of RAM";
+ $debug .= "; Used $i_files files and $_execs queries";
+ }
+ else {
+ $debug = "";
+ }
+ return $debug;
+}
+
+function blockcmp($a, $b) {
+ if($a->position == $b->position) {
+ return 0;
+ }
+ else {
+ return ($a->position > $b->position);
+ }
+}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
* Things which should be in the core API *
@@ -284,7 +335,7 @@ function _get_query_parts() {
return split('/', $path);
}
-function get_page_request() {
+function get_page_request($page_object) {
global $config;
$args = _get_query_parts();
@@ -301,7 +352,7 @@ function get_page_request() {
$args = array_slice($args, 1);
}
- return new PageRequestEvent($page, $args);
+ return new PageRequestEvent($page, $args, $page_object);
}
function get_user() {
diff --git a/ext/alias_editor/main.php b/ext/alias_editor/main.php
index 33159eab..b6d92c98 100644
--- a/ext/alias_editor/main.php
+++ b/ext/alias_editor/main.php
@@ -11,8 +11,11 @@ class AddAliasEvent extends Event {
}
class AliasEditor extends Extension {
+ var $theme;
// event handler {{{
public function receive_event($event) {
+ if(is_null($this->theme)) $this->theme = get_theme_object("alias_editor", "AliasEditorTheme");
+
if(is_a($event, 'PageRequestEvent') && ($event->page == "alias")) {
global $user;
if($event->get_arg(0) == "add") {
@@ -27,7 +30,7 @@ class AliasEditor extends Extension {
if(isset($_POST['oldtag'])) {
global $database;
$database->Execute("DELETE FROM aliases WHERE oldtag=?", array($_POST['oldtag']));
-
+
global $page;
$page->set_mode("redirect");
$page->set_redirect(make_link("admin"));
@@ -36,10 +39,8 @@ class AliasEditor extends Extension {
}
else if($event->get_arg(0) == "list") {
global $page;
- $page->set_title("Alias List");
- $page->set_heading("Alias List");
- $page->add_side_block(new NavBlock());
- $page->add_main_block(new Block("Aliases", $this->build_aliases()));
+ global $database;
+ $this->theme->display_aliases($page, $database->db->GetAssoc("SELECT oldtag, newtag FROM aliases"), $user->is_admin());
}
else if($event->get_arg(0) == "export") {
global $page;
@@ -65,66 +66,6 @@ class AliasEditor extends Extension {
}
}
// }}}
-// admin page HTML {{{
- private function build_aliases() {
- global $database;
-
- global $user;
- if($user->is_admin()) {
- $action = "
From | To | $action - $h_aliases - $add -
From | To | $action + $h_aliases + $add +
You need to create an account before you can comment
"; - } - } - private function query_to_html($query, $args, $trim=false) { global $database; global $config; @@ -327,7 +296,7 @@ class CommentList extends Extension { $page->set_title("Error"); $page->set_heading("Error"); - $page->add_side_block(new NavBlock()); + $page->add_block(new NavBlock()); if(!$config->get_bool('comment_anon') && $user->is_anonymous()) { $page->add_main_block(new Block("Permission Denied", "Anonymous posting has been disabled")); } diff --git a/ext/comment/theme.php b/ext/comment/theme.php new file mode 100644 index 00000000..cb99aaec --- /dev/null +++ b/ext/comment/theme.php @@ -0,0 +1,52 @@ +set_title("Comments"); + $page->set_heading("Comments"); + $page->add_block(new Block("Navigation", $this->build_navigation($current_page, $total_pages), "left")); + $page->add_block(new Paginator("comment/list", null, $current_page, $total_pages), 90); + } + + private function build_navigation($page_number, $total_pages) { + $prev = $page_number - 1; + $next = $page_number + 1; + + $h_prev = ($page_number <= 1) ? "Prev" : + "Prev"; + $h_index = "Index"; + $h_next = ($page_number >= $total_pages) ? "Next" : + "Next"; + + return "$h_prev | $h_index | $h_next"; + } + + // FIXME: privatise this + public function build_postbox($image_id) { + $i_image_id = int_escape($image_id); + return " + + "; + } + + + public function add_comment_list($page, $image, $comments, $position, $with_postbox) { + $html = "You need to create an account before you can comment