Theme engine 2.1 ported to branch_2.1

git-svn-id: file:///home/shish/svn/shimmie2/branches/branch_2.1@468 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
shish 2007-08-23 11:51:24 +00:00
parent 2d4294115c
commit 09acf33f72
21 changed files with 55 additions and 464 deletions

View File

@ -49,14 +49,14 @@ class Home extends Extension {
$counter_dir = $config->get_string('home_counter', 'default'); $counter_dir = $config->get_string('home_counter', 'default');
$total = ceil($database->db->GetOne("SELECT COUNT(*) FROM images")); $total = ceil($database->db->GetOne("SELECT COUNT(*) FROM images"));
$strtotal = "$total";
$numbers = array();
$numbers = str_split($total);
$num_comma = number_format($total); $num_comma = number_format($total);
$counter_text = ""; $counter_text = "";
foreach ($numbers as $cur) for($n=0; $n<strlen($strtotal); $n++)
{ {
$cur = $strtotal[$n];
$counter_text .= " <img alt='$cur' src='$data_href/ext/home/counters/$counter_dir/$cur.gif' /> "; $counter_text .= " <img alt='$cur' src='$data_href/ext/home/counters/$counter_dir/$cur.gif' /> ";
} }

View File

@ -33,7 +33,7 @@ class LinkImageTheme extends Themelet {
50)); 50));
} }
private function url ($url,$content,$type) { protected function url ($url,$content,$type) {
if ($content == NULL) {$content=$url;} if ($content == NULL) {$content=$url;}
switch ($type) { switch ($type) {
@ -49,7 +49,7 @@ class LinkImageTheme extends Themelet {
return $text; return $text;
} }
private function img ($src,$type) { protected function img ($src,$type) {
switch ($type) { switch ($type) {
case "html": case "html":
$text = "<img src=\"$src\" />"; $text = "<img src=\"$src\" />";
@ -63,7 +63,7 @@ class LinkImageTheme extends Themelet {
return $text; return $text;
} }
private function link_code($label,$content,$id=NULL) { protected function link_code($label,$content,$id=NULL) {
return "<label for='".$id."' title='Click to select the textbox'>$label</label>\n". return "<label for='".$id."' title='Click to select the textbox'>$label</label>\n".
"<input type='text' readonly='readonly' id='".$id."' name='".$id."' value='".html_escape($content)."' onfocus='this.select();'></input>\n<br/>\n"; "<input type='text' readonly='readonly' id='".$id."' name='".$id."' value='".html_escape($content)."' onfocus='this.select();'></input>\n<br/>\n";
} }

View File

@ -36,7 +36,7 @@ class WikiTheme {
$page->add_block(new Block("Editor", $this->create_edit_html($wiki_page))); $page->add_block(new Block("Editor", $this->create_edit_html($wiki_page)));
} }
private function can_edit($user, $page) { protected function can_edit($user, $page) {
global $config; global $config;
if(!is_null($page) && $page->is_locked() && !$user->is_admin()) return false; if(!is_null($page) && $page->is_locked() && !$user->is_admin()) return false;
@ -46,7 +46,7 @@ class WikiTheme {
return false; return false;
} }
private function create_edit_html($page) { protected function create_edit_html($page) {
$h_title = html_escape($page->title); $h_title = html_escape($page->title);
$u_title = url_escape($page->title); $u_title = url_escape($page->title);
$i_revision = int_escape($page->revision) + 1; $i_revision = int_escape($page->revision) + 1;
@ -70,7 +70,7 @@ class WikiTheme {
"; ";
} }
private function create_display_html($page) { protected function create_display_html($page) {
$owner = $page->get_owner(); $owner = $page->get_owner();
$tfe = new TextFormattingEvent($page->body); $tfe = new TextFormattingEvent($page->body);

View File

@ -167,12 +167,11 @@ function _count_execs($db, $sql, $inputarray) {
function get_theme_object($file, $class) { function get_theme_object($file, $class) {
global $config; global $config;
$theme = $config->get_string("theme", "default"); $theme = $config->get_string("theme", "default");
if(file_exists("themes/$theme/$file.theme.php")) { if(class_exists("Custom$class")) {
require_once "themes/$theme/$file.theme.php"; $class = "Custom$class";
return new $class(); return new $class();
} }
else { else {
require_once "ext/$file/theme.php";
return new $class(); return new $class();
} }
} }

View File

@ -75,7 +75,7 @@ class CommentListTheme extends Themelet {
*/ */
private function comments_to_html($comments, $trim=false) { protected function comments_to_html($comments, $trim=false) {
$html = ""; $html = "";
foreach($comments as $comment) { foreach($comments as $comment) {
$html .= $this->comment_to_html($comment, $trim); $html .= $this->comment_to_html($comment, $trim);
@ -83,7 +83,7 @@ class CommentListTheme extends Themelet {
return $html; return $html;
} }
private function comment_to_html($comment, $trim=false) { protected function comment_to_html($comment, $trim=false) {
global $user; global $user;
$tfe = new TextFormattingEvent($comment->comment); $tfe = new TextFormattingEvent($comment->comment);
@ -105,7 +105,7 @@ class CommentListTheme extends Themelet {
return "<p class='comment'>$h_userlink: $h_comment $h_imagelink $h_dellink</p>"; return "<p class='comment'>$h_userlink: $h_comment $h_imagelink $h_dellink</p>";
} }
private function build_postbox($image_id) { protected function build_postbox($image_id) {
$i_image_id = int_escape($image_id); $i_image_id = int_escape($image_id);
return " return "
<form action='".make_link("comment/add")."' method='POST'> <form action='".make_link("comment/add")."' method='POST'>

View File

@ -13,7 +13,7 @@ class ETTheme extends Themelet {
$page->add_block(new Block("Data which is to be sent:", $this->build_data_form($info))); $page->add_block(new Block("Data which is to be sent:", $this->build_data_form($info)));
} }
private function build_data_form($info) { protected function build_data_form($info) {
$data = <<<EOD $data = <<<EOD
Optional: Optional:
Add this site to the public shimmie users list: No Add this site to the public shimmie users list: No

View File

@ -46,7 +46,7 @@ class IndexTheme extends Themelet {
} }
private function build_navigation($page_number, $total_pages, $search_terms) { protected function build_navigation($page_number, $total_pages, $search_terms) {
$prev = $page_number - 1; $prev = $page_number - 1;
$next = $page_number + 1; $next = $page_number + 1;
@ -71,7 +71,7 @@ class IndexTheme extends Themelet {
return "$h_prev | $h_index | $h_next<br>$h_search"; return "$h_prev | $h_index | $h_next<br>$h_search";
} }
private function build_table($images, $query) { protected function build_table($images, $query) {
global $config; global $config;
$width = $config->get_int('index_width'); $width = $config->get_int('index_width');

View File

@ -52,14 +52,14 @@ class SetupTheme extends Themelet {
$page->add_block(new Block("Setup", $table)); $page->add_block(new Block("Setup", $table));
} }
private function build_navigation() { protected function build_navigation() {
return " return "
<a href='".make_link()."'>Index</a> <a href='".make_link()."'>Index</a>
<br><a href='http://trac.shishnet.org/shimmie2/wiki/Settings'>Help</a> <br><a href='http://trac.shishnet.org/shimmie2/wiki/Settings'>Help</a>
"; ";
} }
private function sb_to_html($block) { protected function sb_to_html($block) {
return "<div class='setupblock'><b>{$block->header}</b><br>{$block->body}</div>\n"; return "<div class='setupblock'><b>{$block->header}</b><br>{$block->body}</div>\n";
} }
} }

View File

@ -115,7 +115,7 @@ class TagListTheme extends Themelet {
$page->add_block(new Block("Refine Search", $html, "left", 60)); $page->add_block(new Block("Refine Search", $html, "left", 60));
} }
private function ars($tag, $tags) { protected function ars($tag, $tags) {
$html = ""; $html = "";
$html .= " <span class='ars'>("; $html .= " <span class='ars'>(";
$html .= $this->get_add_link($tags, $tag); $html .= $this->get_add_link($tags, $tag);
@ -125,7 +125,7 @@ class TagListTheme extends Themelet {
return $html; return $html;
} }
private function get_remove_link($tags, $tag) { protected function get_remove_link($tags, $tag) {
if(!in_array($tag, $tags) && !in_array("-$tag", $tags)) { if(!in_array($tag, $tags) && !in_array("-$tag", $tags)) {
return ""; return "";
} }
@ -136,7 +136,7 @@ class TagListTheme extends Themelet {
} }
} }
private function get_add_link($tags, $tag) { protected function get_add_link($tags, $tag) {
if(in_array($tag, $tags)) { if(in_array($tag, $tags)) {
return ""; return "";
} }
@ -147,7 +147,7 @@ class TagListTheme extends Themelet {
} }
} }
private function get_subtract_link($tags, $tag) { protected function get_subtract_link($tags, $tag) {
if(in_array("-$tag", $tags)) { if(in_array("-$tag", $tags)) {
return ""; return "";
} }
@ -158,7 +158,7 @@ class TagListTheme extends Themelet {
} }
} }
private function tag_link($tag) { protected function tag_link($tag) {
$u_tag = url_escape($tag); $u_tag = url_escape($tag);
return make_link("post/list/$u_tag/1"); return make_link("post/list/$u_tag/1");
} }

View File

@ -51,7 +51,7 @@ class UploadTheme extends Themelet {
public function display_upload_status($page, $ok) { public function display_upload_status($page, $ok) {
if($ok) { if($ok) {
$page->set_mode("redirect"); $page->set_mode("redirect");
$page->set_redirect(make_link("post/list")); $page->set_redirect(make_link());
} }
else { else {
$page->set_title("Upload Status"); $page->set_title("Upload Status");
@ -64,7 +64,7 @@ class UploadTheme extends Themelet {
$page->add_block(new Block($title, $message)); $page->add_block(new Block($title, $message));
} }
private function build_upload_block() { protected function build_upload_block() {
global $config; global $config;
$upload_list = ""; $upload_list = "";

View File

@ -106,7 +106,7 @@ class UserPageTheme extends Themelet {
} }
} }
private function build_stats($duser) { protected function build_stats($duser) {
global $database; global $database;
global $config; global $config;
@ -130,7 +130,7 @@ class UserPageTheme extends Themelet {
"; ";
} }
private function build_options($duser) { protected function build_options($duser) {
global $database; global $database;
global $config; global $config;
@ -150,7 +150,7 @@ class UserPageTheme extends Themelet {
return $html; return $html;
} }
private function build_more_options($duser) { protected function build_more_options($duser) {
global $database; global $database;
global $config; global $config;

View File

@ -15,7 +15,7 @@ class ViewTheme extends Themelet {
var $pin = null; var $pin = null;
private function build_pin($image_id) { protected function build_pin($image_id) {
if(!is_null($this->pin)) { if(!is_null($this->pin)) {
return $this->pin; return $this->pin;
} }
@ -35,14 +35,14 @@ class ViewTheme extends Themelet {
$prev = $database->get_prev_image($image_id, $search_terms); $prev = $database->get_prev_image($image_id, $search_terms);
$h_prev = (!is_null($prev) ? "<a href='".make_link("post/view/{$prev->id}", $query)."'>Prev</a>" : "Prev"); $h_prev = (!is_null($prev) ? "<a href='".make_link("post/view/{$prev->id}", $query)."'>Prev</a>" : "Prev");
$h_index = "<a href='".make_link("post/list")."'>Index</a>"; $h_index = "<a href='".make_link()."'>Index</a>";
$h_next = (!is_null($next) ? "<a href='".make_link("post/view/{$next->id}", $query)."'>Next</a>" : "Next"); $h_next = (!is_null($next) ? "<a href='".make_link("post/view/{$next->id}", $query)."'>Next</a>" : "Next");
$this->pin = "$h_prev | $h_index | $h_next"; $this->pin = "$h_prev | $h_index | $h_next";
return $this->pin; return $this->pin;
} }
private function build_navigation($image_id) { protected function build_navigation($image_id) {
$h_pin = $this->build_pin($image_id); $h_pin = $this->build_pin($image_id);
$h_search = " $h_search = "
<p><form action='".make_link()."' method='GET'> <p><form action='".make_link()."' method='GET'>
@ -55,12 +55,12 @@ class ViewTheme extends Themelet {
return "$h_pin<br>$h_search"; return "$h_pin<br>$h_search";
} }
private function build_image_view($image) { protected function build_image_view($image) {
$ilink = $image->get_image_link(); $ilink = $image->get_image_link();
return "<img id='main_image' src='$ilink'>"; return "<img id='main_image' src='$ilink'>";
} }
private function build_info($image) { protected function build_info($image) {
global $user; global $user;
$owner = $image->get_owner(); $owner = $image->get_owner();
$h_owner = html_escape($owner->name); $h_owner = html_escape($owner->name);

View File

@ -5,7 +5,7 @@ class ZoomTheme extends Themelet {
$page->add_block(new Block(null, $this->make_zoomer($image->width, $zoom_by_default))); $page->add_block(new Block(null, $this->make_zoomer($image->width, $zoom_by_default)));
} }
private function make_zoomer($image_width, $zoom_by_default) { protected function make_zoomer($image_width, $zoom_by_default) {
global $config; global $config;
$default = $zoom_by_default ? "scale(img);" : ""; $default = $zoom_by_default ? "scale(img);" : "";
return <<<EOD return <<<EOD

View File

@ -38,6 +38,10 @@ $_theme = $config->get_string("theme", "default");
require_once "themes/$_theme/page.class.php"; require_once "themes/$_theme/page.class.php";
require_once "themes/$_theme/layout.class.php"; require_once "themes/$_theme/layout.class.php";
require_once "themes/$_theme/themelet.class.php"; require_once "themes/$_theme/themelet.class.php";
$themelets = array_merge(glob("ext/*/theme.php"), glob("themes/$_theme/*.theme.php"));
foreach($themelets as $filename) {
require_once $filename;
}
$page = new Page(); $page = new Page();
$user = _get_user(); $user = _get_user();
send_event(new InitExtEvent()); send_event(new InitExtEvent());

View File

@ -1,6 +1,6 @@
<?php <?php
class CommentListTheme extends Themelet { class CustomCommentListTheme extends CommentListTheme {
public function display_page_start($page, $page_number, $total_pages) { public function display_page_start($page, $page_number, $total_pages) {
$prev = $page_number - 1; $prev = $page_number - 1;
$next = $page_number + 1; $next = $page_number + 1;
@ -40,15 +40,7 @@ class CommentListTheme extends Themelet {
} }
private function comments_to_html($comments, $trim=false) { protected function comment_to_html($comment, $trim=false) {
$html = "";
foreach($comments as $comment) {
$html .= $this->comment_to_html($comment, $trim);
}
return $html;
}
private function comment_to_html($comment, $trim=false) {
global $user; global $user;
$tfe = new TextFormattingEvent($comment->comment); $tfe = new TextFormattingEvent($comment->comment);
@ -71,19 +63,6 @@ class CommentListTheme extends Themelet {
return "<p class='comment'>$h_userlink $h_dellink<br/><b>Posted on $h_posted</b><br/>$h_comment</p>"; return "<p class='comment'>$h_userlink $h_dellink<br/><b>Posted on $h_posted</b><br/>$h_comment</p>";
} }
// FIXME: privatise this
public function build_postbox($image_id) {
$i_image_id = int_escape($image_id);
return "
<form action='".make_link("comment/add")."' method='POST'>
<input type='hidden' name='image_id' value='$i_image_id' />
<textarea name='comment' rows='5' cols='50'></textarea>
<br><input type='submit' value='Post' />
</form>
";
}
public function add_comment_list($page, $image, $comments, $position, $with_postbox) { public function add_comment_list($page, $image, $comments, $position, $with_postbox) {
$count = count($comments); $count = count($comments);

View File

@ -1,12 +1,6 @@
<?php <?php
class IndexTheme extends Themelet { class CustomIndexTheme extends IndexTheme {
public function set_page($page_number, $total_pages, $search_terms) {
$this->page_number = $page_number;
$this->total_pages = $total_pages;
$this->search_terms = $search_terms;
}
public function display_page($page, $images) { public function display_page($page, $images) {
global $config; global $config;
@ -40,7 +34,7 @@ class IndexTheme extends Themelet {
} }
private function build_navigation($page_number, $total_pages, $search_terms) { protected function build_navigation($page_number, $total_pages, $search_terms) {
$h_search_string = count($search_terms) == 0 ? "" : html_escape(implode(" ", $search_terms)); $h_search_string = count($search_terms) == 0 ? "" : html_escape(implode(" ", $search_terms));
$h_search_link = make_link(); $h_search_link = make_link();
$h_search = " $h_search = "
@ -53,30 +47,5 @@ class IndexTheme extends Themelet {
return $h_search; return $h_search;
} }
private function build_table($images, $query) {
global $config;
$width = $config->get_int('index_width');
$height = $config->get_int('index_height');
$table = "<table>\n";
for($i=0; $i<$height; $i++) {
$table .= "<tr>\n";
for($j=0; $j<$width; $j++) {
$image = isset($images[$i*$width+$j]) ? $images[$i*$width+$j] : null;
if(!is_null($image)) {
$table .= "\t<td>" . build_thumb_html($image, $query) . "</td>\n";
}
else {
$table .= "\t<td>&nbsp;</td>\n";
}
}
$table .= "</tr>\n";
}
$table .= "</table>\n";
return $table;
}
} }
?> ?>

View File

@ -156,6 +156,9 @@ A:hover {text-decoration: underline;}
padding: 8px 4px 8px 4px; padding: 8px 4px 8px 4px;
} }
#large_upload_form {
width: 600px;
}
.setupblock { .setupblock {
border: 1px solid #AAA; border: 1px solid #AAA;
padding: 8px; padding: 8px;

View File

@ -1,21 +1,9 @@
<?php <?php
class TagListTheme extends Themelet { class CustomTagListTheme extends TagListTheme {
var $heading = ""; var $heading = "";
var $list = ""; var $list = "";
public function set_heading($text) {
$this->heading = $text;
}
public function set_tag_list($list) {
$this->list = $list;
}
public function set_navigation($nav) {
$this->navigation = $nav;
}
public function display_page($page) { public function display_page($page) {
$page->disable_left(); $page->disable_left();
$page->set_title("Tag List"); $page->set_title("Tag List");
@ -23,145 +11,5 @@ class TagListTheme extends Themelet {
$page->add_block(new Block("Navigation", str_replace("<br>", ", ", $this->navigation), "main", 0)); $page->add_block(new Block("Navigation", str_replace("<br>", ", ", $this->navigation), "main", 0));
$page->add_block(new Block("&nbsp;", $this->list)); $page->add_block(new Block("&nbsp;", $this->list));
} }
// =======================================================================
/*
* $tag_infos = array(
* array('tag' => $tag, 'count' => $number_of_uses),
* ...
* )
*/
public function display_related_block($page, $tag_infos) {
global $config;
$html = "";
$n = 0;
foreach($tag_infos as $row) {
$tag = $row['tag'];
$h_tag = html_escape($tag);
$h_tag_no_underscores = str_replace("_", " ", $h_tag);
$count = $row['count'];
if($n++) $html .= "\n<br/>";
if(!is_null($config->get_string('info_link'))) {
$link = str_replace('$tag', $tag, $config->get_string('info_link'));
$html .= " <a class='tag_info_link' href='$link'>?</a>";
}
$link = $this->tag_link($row['tag']);
$html .= " <a class='tag_name' href='$link'>$h_tag_no_underscores</a>";
}
$page->add_block(new Block("Related", $html, "left"));
}
/*
* $tag_infos = array(
* array('tag' => $tag, 'count' => $number_of_uses),
* ...
* )
*/
public function display_popular_block($page, $tag_infos) {
global $config;
$html = "";
$n = 0;
foreach($tag_infos as $row) {
$tag = $row['tag'];
$h_tag = html_escape($tag);
$h_tag_no_underscores = str_replace("_", " ", $h_tag);
$count = $row['count'];
if($n++) $html .= "\n<br/>";
if(!is_null($config->get_string('info_link'))) {
$link = str_replace('$tag', $tag, $config->get_string('info_link'));
$html .= " <a class='tag_info_link' href='$link'>?</a>";
}
$link = $this->tag_link($row['tag']);
$html .= " <a class='tag_name' href='$link'>$h_tag_no_underscores</a>";
if($config->get_bool("tag_list_numbers")) {
$html .= " <span class='tag_count'>$count</span>";
}
}
$html .= "<p><a class='more' href='".make_link("tags")."'>Full List</a>\n";
$page->add_block(new Block("Popular Tags", $html, "left", 60));
}
/*
* $tag_infos = array(
* array('tag' => $tag),
* ...
* )
* $search = the current array of tags being searched for
*/
public function display_refine_block($page, $tag_infos, $search) {
global $config;
$html = "";
$n = 0;
foreach($tag_infos as $row) {
$tag = $row['tag'];
$h_tag = html_escape($tag);
$h_tag_no_underscores = str_replace("_", " ", $h_tag);
if($n++) $html .= "\n<br/>";
if(!is_null($config->get_string('info_link'))) {
$link = str_replace('$tag', $tag, $config->get_string('info_link'));
$html .= " <a class='tag_info_link' href='$link'>?</a>";
}
$link = $this->tag_link($row['tag']);
$html .= " <a class='tag_name' href='$link'>$h_tag_no_underscores</a>";
$html .= $this->ars($tag, $search);
}
$page->add_block(new Block("Refine Search", $html, "left", 60));
}
private function ars($tag, $tags) {
$html = "";
$html .= " <span class='ars'>(";
$html .= $this->get_add_link($tags, $tag);
$html .= $this->get_remove_link($tags, $tag);
$html .= $this->get_subtract_link($tags, $tag);
$html .= ")</span>";
return $html;
}
private function get_remove_link($tags, $tag) {
if(!in_array($tag, $tags) && !in_array("-$tag", $tags)) {
return "";
}
else {
$tags = array_remove($tags, $tag);
$tags = array_remove($tags, "-$tag");
return "<a href='".$this->tag_link(join(' ', $tags))."' title='Remove' rel='nofollow'>R</a>";
}
}
private function get_add_link($tags, $tag) {
if(in_array($tag, $tags)) {
return "";
}
else {
$tags = array_remove($tags, "-$tag");
$tags = array_add($tags, $tag);
return "<a href='".$this->tag_link(join(' ', $tags))."' title='Add' rel='nofollow'>A</a>";
}
}
private function get_subtract_link($tags, $tag) {
if(in_array("-$tag", $tags)) {
return "";
}
else {
$tags = array_remove($tags, $tag);
$tags = array_add($tags, "-$tag");
return "<a href='".$this->tag_link(join(' ', $tags))."' title='Subtract' rel='nofollow'>S</a>";
}
}
private function tag_link($tag) {
$u_tag = url_escape($tag);
return make_link("post/list/$u_tag/1");
}
} }
?> ?>

View File

@ -1,6 +1,6 @@
<?php <?php
class UploadTheme extends Themelet { class CustomUploadTheme extends UploadTheme {
public function display_block($page) { public function display_block($page) {
// this theme links to /upload // this theme links to /upload
// $page->add_block(new Block("Upload", $this->build_upload_block(), "left", 20)); // $page->add_block(new Block("Upload", $this->build_upload_block(), "left", 20));
@ -8,86 +8,7 @@ class UploadTheme extends Themelet {
public function display_page($page) { public function display_page($page) {
$page->disable_left(); $page->disable_left();
parent::display_page($page);
global $config;
$tl_enabled = ($config->get_string("transload_engine", "none") != "none");
$upload_list = "";
for($i=0; $i<$config->get_int('upload_count'); $i++) {
$n = $i + 1;
$width = $tl_enabled ? "35%" : "80%";
$upload_list .= "
<tr>
<td>File $n</td>
<td style='width: $width;'><input accept='image/jpeg,image/png,image/gif' id='data$i' name='data$i' type='file'></td>
";
if($tl_enabled) {
$upload_list .= "
<td>URL $n</td>
<td><input id='url$i' name='url$i' type='text'></td>
";
}
$upload_list .= "
</tr>
";
}
$max_size = $config->get_int('upload_size');
$max_kb = to_shorthand_int($max_size);
$html = "
<form enctype='multipart/form-data' action='".make_link("upload")."' method='POST'>
<table id='large_upload_form'>
$upload_list
<tr><td>Tags</td><td colspan='3'><input id='tagBox' name='tags' type='text' value='tagme' autocomplete='off'></td></tr>
<tr><td>Source</td><td colspan='3'><input name='source' type='text'></td></tr>
<tr><td colspan='4'><input type='submit' value='Post'></td></tr>
</table>
</form>
<div id='upload_completions' style='clear: both;'><small>(Max file size is $max_kb)</small></div>
";
$page->set_title("Upload");
$page->set_heading("Upload");
$page->add_block(new NavBlock());
$page->add_block(new Block("Upload", $html, "main", 20));
}
public function display_upload_status($page, $ok) {
if($ok) {
$page->set_mode("redirect");
$page->set_redirect(make_link());
}
else {
$page->set_title("Upload Status");
$page->set_heading("Upload Status");
$page->add_block(new NavBlock());
}
}
public function display_upload_error($page, $title, $message) {
$page->add_block(new Block($title, $message));
}
private function build_upload_block() {
global $config;
$upload_list = "";
for($i=0; $i<$config->get_int('upload_count'); $i++) {
if($i == 0) $style = ""; // "style='display:visible'";
else $style = "style='display:none'";
$upload_list .= "<input accept='image/jpeg,image/png,image/gif' size='10' ".
"id='data$i' name='data$i' $style onchange=\"showUp('data".($i+1)."')\" type='file'>\n";
}
$max_size = $config->get_int('upload_size');
$max_kb = to_shorthand_int($max_size);
// <input type='hidden' name='max_file_size' value='$max_size' />
return "
<form enctype='multipart/form-data' action='".make_link("upload")."' method='POST'>
$upload_list
<input id='tagBox' name='tags' type='text' value='tagme' autocomplete='off'>
<input type='submit' value='Post'>
</form>
<div id='upload_completions' style='clear: both;'><small>(Max file size is $max_kb)</small></div>
";
} }
} }
?> ?>

View File

@ -1,6 +1,6 @@
<?php <?php
class UserPageTheme extends Themelet { class CustomUserPageTheme extends UserPageTheme {
public function display_login_page($page) { public function display_login_page($page) {
$page->set_title("Login"); $page->set_title("Login");
$page->set_heading("Login"); $page->set_heading("Login");
@ -49,31 +49,6 @@ class UserPageTheme extends Themelet {
$page->add_block(new Block("Signup", $html)); $page->add_block(new Block("Signup", $html));
} }
public function display_signups_disabled($page) {
$page->set_title("Signups Disabled");
$page->set_heading("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~"));
}
public function display_login_block($page) {
global $config;
$html = "
<form action='".make_link("user_admin/login")."' method='POST'>
<table border='1' summary='Login Form'>
<tr><td width='70'>Name</td><td width='70'><input type='text' name='user'></td></tr>
<tr><td>Password</td><td><input type='password' name='pass'></td></tr>
<tr><td colspan='2'><input type='submit' name='gobu' value='Log In'></td></tr>
</table>
</form>
";
if($config->get_bool("login_signup_enabled")) {
$html .= "<small><a href='".make_link("user_admin/create")."'>Create Account</a></small>";
}
$page->add_block(new Block("Login", $html, "left", 90));
}
public function display_ip_list($page, $uploads, $comments) { public function display_ip_list($page, $uploads, $comments) {
$html = "<table id='ip-history' style='width: 400px;'>"; $html = "<table id='ip-history' style='width: 400px;'>";
$html .= "<tr><td>Uploaded from: "; $html .= "<tr><td>Uploaded from: ";
@ -91,47 +66,11 @@ class UserPageTheme extends Themelet {
} }
public function display_user_page($page, $duser, $user) { public function display_user_page($page, $duser, $user) {
$page->set_title("{$duser->name}'s Page");
$page->set_heading("{$duser->name}'s Page");
$page->add_block(new NavBlock());
$page->add_block(new Block("Stats", $this->build_stats($duser)));
$page->disable_left(); $page->disable_left();
parent::display_user_page($page, $duser, $user);
if(!$user->is_anonymous()) {
if($user->id == $duser->id || $user->is_admin()) {
$page->add_block(new Block("Options", $this->build_options($duser), "main", 20));
}
if($user->is_admin()) {
$page->add_block(new Block("More Options", $this->build_more_options($duser)));
}
}
} }
private function build_stats($duser) { protected function build_options($duser) {
global $database;
global $config;
$i_days_old = int_escape($duser->get_days_old());
$h_join_date = html_escape($duser->join_date);
$i_image_count = int_escape($duser->get_image_count());
$i_comment_count = int_escape($duser->get_comment_count());
$i_days_old2 = ($i_days_old == 0) ? 1 : $i_days_old;
$h_image_rate = sprintf("%3.1f", ($i_image_count / $i_days_old2));
$h_comment_rate = sprintf("%3.1f", ($i_comment_count / $i_days_old2));
$u_name = url_escape($duser->name);
$images_link = make_link("post/list/user=$u_name/1");
return "
Join date: $h_join_date ($i_days_old days old)
<br><a href='$images_link'>Images uploaded</a>: $i_image_count ($h_image_rate / day)
<br>Comments made: $i_comment_count ($h_comment_rate / day)
";
}
private function build_options($duser) {
global $database; global $database;
global $config; global $config;
@ -150,25 +89,6 @@ class UserPageTheme extends Themelet {
"; ";
return $html; return $html;
} }
private function build_more_options($duser) {
global $database;
global $config;
$i_user_id = int_escape($duser->id);
$h_is_admin = $duser->is_admin() ? " checked" : "";
$h_is_enabled = $duser->is_enabled() ? " checked" : "";
$html = "
<form action='".make_link("user_admin/set_more")."' method='POST'>
<input type='hidden' name='id' value='$i_user_id'>
Admin: <input name='admin' type='checkbox'$h_is_admin>
<br>Enabled: <input name='enabled' type='checkbox'$h_is_enabled>
<p><input type='submit' value='Set'>
</form>
";
return $html;
}
// }}} // }}}
} }
?> ?>

View File

@ -1,6 +1,6 @@
<?php <?php
class ViewTheme extends Themelet { class CustomViewTheme extends ViewTheme {
public function display_image_not_found($page, $image_id) { public function display_image_not_found($page, $image_id) {
$page->set_title("Image not found"); $page->set_title("Image not found");
$page->set_heading("Image not found"); $page->set_heading("Image not found");
@ -9,64 +9,12 @@ class ViewTheme extends Themelet {
"No image in the database has the ID #$image_id")); "No image in the database has the ID #$image_id"));
} }
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()));
$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));
}
var $pin = null; var $pin = null;
private function build_pin($image_id) { protected function build_info($image) {
if(!is_null($this->pin)) {
return $this->pin;
}
global $database;
if(isset($_GET['search'])) {
$search_terms = explode(' ', $_GET['search']);
$query = "search=".url_escape($_GET['search']);
}
else {
$search_terms = array();
$query = null;
}
$next = $database->get_next_image($image_id, $search_terms);
$prev = $database->get_prev_image($image_id, $search_terms);
$h_prev = (!is_null($prev) ? "<a href='".make_link("post/view/{$prev->id}", $query)."'>Prev</a>" : "Prev");
$h_index = "<a href='".make_link()."'>Index</a>";
$h_next = (!is_null($next) ? "<a href='".make_link("post/view/{$next->id}", $query)."'>Next</a>" : "Next");
$this->pin = "$h_prev | $h_index | $h_next";
return $this->pin;
}
private function build_navigation($image_id) {
$h_pin = $this->build_pin($image_id);
$h_search = "
<p><form action='".make_link()."' method='GET'>
<input id='search_input' name='search' type='text'
value='Search' autocomplete='off'>
<input type='submit' value='Find' style='display: none;'>
</form>
<div id='search_completions'></div>";
return "$h_pin<br>$h_search";
}
private function build_image_view($image) {
$ilink = $image->get_image_link();
return "<img id='main_image' src='$ilink'>";
}
private function build_info($image) {
global $user; global $user;
$owner = $image->get_owner(); $owner = $image->get_owner();
$h_owner = html_escape($owner->name); $h_owner = html_escape($owner->name);
@ -112,7 +60,7 @@ class ViewTheme extends Themelet {
</div> </div>
"; ";
} }
return $html; return $html;
} }
} }