theme engine 2.1

git-svn-id: file:///home/shish/svn/shimmie2/trunk@466 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
shish 2007-08-23 11:14:03 +00:00
parent 619238308f
commit 862e647365
13 changed files with 36 additions and 33 deletions

View file

@ -33,7 +33,7 @@ class LinkImageTheme extends Themelet {
50));
}
private function url ($url,$content,$type) {
protected function url ($url,$content,$type) {
if ($content == NULL) {$content=$url;}
switch ($type) {
@ -49,7 +49,7 @@ class LinkImageTheme extends Themelet {
return $text;
}
private function img ($src,$type) {
protected function img ($src,$type) {
switch ($type) {
case "html":
$text = "<img src=\"$src\" />";
@ -63,7 +63,7 @@ class LinkImageTheme extends Themelet {
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".
"<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)));
}
private function can_edit($user, $page) {
protected function can_edit($user, $page) {
global $config;
if(!is_null($page) && $page->is_locked() && !$user->is_admin()) return false;
@ -46,7 +46,7 @@ class WikiTheme {
return false;
}
private function create_edit_html($page) {
protected function create_edit_html($page) {
$h_title = html_escape($page->title);
$u_title = url_escape($page->title);
$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();
$tfe = new TextFormattingEvent($page->body);

View file

@ -167,12 +167,11 @@ function _count_execs($db, $sql, $inputarray) {
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";
if(class_exists("Custom$class")) {
$class = "Custom$class";
return new $class();
}
else {
require_once "ext/$file/theme.php";
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 = "";
foreach($comments as $comment) {
$html .= $this->comment_to_html($comment, $trim);
@ -83,7 +83,7 @@ class CommentListTheme extends Themelet {
return $html;
}
private function comment_to_html($comment, $trim=false) {
protected function comment_to_html($comment, $trim=false) {
global $user;
$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>";
}
private function build_postbox($image_id) {
protected function build_postbox($image_id) {
$i_image_id = int_escape($image_id);
return "
<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)));
}
private function build_data_form($info) {
protected function build_data_form($info) {
$data = <<<EOD
Optional:
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;
$next = $page_number + 1;
@ -71,7 +71,7 @@ class IndexTheme extends Themelet {
return "$h_prev | $h_index | $h_next<br>$h_search";
}
private function build_table($images, $query) {
protected function build_table($images, $query) {
global $config;
$width = $config->get_int('index_width');

View file

@ -52,14 +52,14 @@ class SetupTheme extends Themelet {
$page->add_block(new Block("Setup", $table));
}
private function build_navigation() {
protected function build_navigation() {
return "
<a href='".make_link()."'>Index</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";
}
}

View file

@ -115,7 +115,7 @@ class TagListTheme extends Themelet {
$page->add_block(new Block("Refine Search", $html, "left", 60));
}
private function ars($tag, $tags) {
protected function ars($tag, $tags) {
$html = "";
$html .= " <span class='ars'>(";
$html .= $this->get_add_link($tags, $tag);
@ -125,7 +125,7 @@ class TagListTheme extends Themelet {
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)) {
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)) {
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)) {
return "";
}
@ -158,7 +158,7 @@ class TagListTheme extends Themelet {
}
}
private function tag_link($tag) {
protected function tag_link($tag) {
$u_tag = url_escape($tag);
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) {
if($ok) {
$page->set_mode("redirect");
$page->set_redirect(make_link("post/list"));
$page->set_redirect(make_link());
}
else {
$page->set_title("Upload Status");
@ -64,7 +64,7 @@ class UploadTheme extends Themelet {
$page->add_block(new Block($title, $message));
}
private function build_upload_block() {
protected function build_upload_block() {
global $config;
$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 $config;
@ -130,7 +130,7 @@ class UserPageTheme extends Themelet {
";
}
private function build_options($duser) {
protected function build_options($duser) {
global $database;
global $config;
@ -150,7 +150,7 @@ class UserPageTheme extends Themelet {
return $html;
}
private function build_more_options($duser) {
protected function build_more_options($duser) {
global $database;
global $config;

View file

@ -15,7 +15,7 @@ class ViewTheme extends Themelet {
var $pin = null;
private function build_pin($image_id) {
protected function build_pin($image_id) {
if(!is_null($this->pin)) {
return $this->pin;
}
@ -35,14 +35,14 @@ class ViewTheme extends Themelet {
$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("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");
$this->pin = "$h_prev | $h_index | $h_next";
return $this->pin;
}
private function build_navigation($image_id) {
protected function build_navigation($image_id) {
$h_pin = $this->build_pin($image_id);
$h_search = "
<p><form action='".make_link()."' method='GET'>
@ -55,12 +55,12 @@ class ViewTheme extends Themelet {
return "$h_pin<br>$h_search";
}
private function build_image_view($image) {
protected function build_image_view($image) {
$ilink = $image->get_image_link();
return "<img id='main_image' src='$ilink'>";
}
private function build_info($image) {
protected function build_info($image) {
global $user;
$owner = $image->get_owner();
$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)));
}
private function make_zoomer($image_width, $zoom_by_default) {
protected function make_zoomer($image_width, $zoom_by_default) {
global $config;
$default = $zoom_by_default ? "scale(img);" : "";
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/layout.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();
$user = _get_user();
send_event(new InitExtEvent());