From 1cacc2d24725d3756b82335cb1e32353a14163d3 Mon Sep 17 00:00:00 2001 From: shish Date: Fri, 26 Oct 2007 01:35:53 +0000 Subject: [PATCH] make build_thumb_html be part of the themelet class git-svn-id: file:///home/shish/svn/shimmie2/trunk@570 7f39781d-f577-437e-ae19-be835c7a54ca --- core/util.inc.php | 10 ---------- ext/comment/theme.php | 2 +- ext/image/main.php | 2 +- ext/index/theme.php | 2 +- ext/regen_thumb/theme.php | 2 +- ext/rss_images/main.php | 2 +- themes/danbooru/comment.theme.php | 2 +- themes/danbooru/index.theme.php | 2 +- themes/danbooru/themelet.class.php | 11 +++++++++++ themes/default/themelet.class.php | 21 +++++++++++++++++++++ 10 files changed, 39 insertions(+), 17 deletions(-) diff --git a/core/util.inc.php b/core/util.inc.php index 605f3a7d..1e231149 100644 --- a/core/util.inc.php +++ b/core/util.inc.php @@ -112,16 +112,6 @@ function make_link($page=null, $query=null) { } } -function build_thumb_html($image, $query=null) { - global $config; - $h_view_link = make_link("post/view/{$image->id}", $query); - $h_tip = html_escape($image->get_tooltip()); - $h_thumb_link = $image->get_thumb_link(); - $tsize = get_thumbnail_size($image->width, $image->height); - return "$h_tip"; -} - /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\ * Misc * diff --git a/ext/comment/theme.php b/ext/comment/theme.php index d91a0276..6a518510 100644 --- a/ext/comment/theme.php +++ b/ext/comment/theme.php @@ -56,7 +56,7 @@ class CommentListTheme extends Themelet { */ public function add_comment_list($page, $image, $comments, $position, $with_postbox) { $html = "
"; - $html .= "
" . build_thumb_html($image) . "
"; + $html .= "
" . $this->build_thumb_html($image) . "
"; $html .= $this->comments_to_html($comments); $html .= "
"; if($with_postbox) { diff --git a/ext/image/main.php b/ext/image/main.php index a888f357..6ca4fa42 100644 --- a/ext/image/main.php +++ b/ext/image/main.php @@ -183,7 +183,7 @@ class ImageIO extends Extension { $existing = $database->get_image_by_hash($image->hash); if(!is_null($existing)) { $error = "Image {$existing->id} ". - "already has hash {$image->hash}:

".build_thumb_html($existing); + "already has hash {$image->hash}:

".Themelet::build_thumb_html($existing); return $error; } diff --git a/ext/index/theme.php b/ext/index/theme.php index aee24a6d..997c6b26 100644 --- a/ext/index/theme.php +++ b/ext/index/theme.php @@ -83,7 +83,7 @@ class IndexTheme extends Themelet { for($j=0; $j<$width; $j++) { $image = isset($images[$i*$width+$j]) ? $images[$i*$width+$j] : null; if(!is_null($image)) { - $table .= "\t" . build_thumb_html($image, $query) . "\n"; + $table .= "\t" . $this->build_thumb_html($image, $query) . "\n"; } else { $table .= "\t \n"; diff --git a/ext/regen_thumb/theme.php b/ext/regen_thumb/theme.php index 4e3ad357..a479cfd8 100644 --- a/ext/regen_thumb/theme.php +++ b/ext/regen_thumb/theme.php @@ -27,7 +27,7 @@ class RegenThumbTheme extends Themelet { $page->set_heading("Thumbnail Regenerated"); $page->add_header(""); $page->add_block(new NavBlock()); - $page->add_block(new Block("Thumbnail", build_thumb_html($image))); + $page->add_block(new Block("Thumbnail", $this->build_thumb_html($image))); } } ?> diff --git a/ext/rss_images/main.php b/ext/rss_images/main.php index 4b2d0778..34d8c63a 100644 --- a/ext/rss_images/main.php +++ b/ext/rss_images/main.php @@ -33,7 +33,7 @@ class RSS_Images extends Extension { $owner = $image->get_owner(); $posted = strftime("%a, %d %b %Y %T %Z", $image->posted_timestamp); $content = html_escape( - "

" . build_thumb_html($image) . "

" . + "

" . Themelet::build_thumb_html($image) . "

" . "

Uploaded by " . $owner->name . "

" ); diff --git a/themes/danbooru/comment.theme.php b/themes/danbooru/comment.theme.php index 67e2a89a..d97afc97 100644 --- a/themes/danbooru/comment.theme.php +++ b/themes/danbooru/comment.theme.php @@ -67,7 +67,7 @@ class CustomCommentListTheme extends CommentListTheme { $count = count($comments); $html = "
"; - $html .= "
" . build_thumb_html($image) . "
"; + $html .= "
" . $this->build_thumb_html($image) . "
"; $html .= "
"; foreach($image->get_tag_array() as $tag) { $u_tag = url_escape($tag); diff --git a/themes/danbooru/index.theme.php b/themes/danbooru/index.theme.php index 15e0bbf2..74b2bd09 100644 --- a/themes/danbooru/index.theme.php +++ b/themes/danbooru/index.theme.php @@ -51,7 +51,7 @@ class CustomIndexTheme extends IndexTheme { protected function build_table($images, $query) { $table = ""; foreach($images as $image) { - $table .= "\t" . build_thumb_html($image, $query) . "\n"; + $table .= "\t" . $this->build_thumb_html($image, $query) . "\n"; } return $table; } diff --git a/themes/danbooru/themelet.class.php b/themes/danbooru/themelet.class.php index 1f9860ab..ca18e4df 100644 --- a/themes/danbooru/themelet.class.php +++ b/themes/danbooru/themelet.class.php @@ -9,6 +9,17 @@ class Themelet { } + public function build_thumb_html($image, $query=null) { + global $config; + $h_view_link = make_link("post/view/{$image->id}", $query); + $h_tip = html_escape($image->get_tooltip()); + $h_thumb_link = $image->get_thumb_link(); + $tsize = get_thumbnail_size($image->width, $image->height); + return "$h_tip"; + } + + public function display_paginator($page, $base, $query, $page_number, $total_pages) { if($total_pages == 0) $total_pages = 1; $body = $this->build_paginator($page_number, $total_pages, $base, $query); diff --git a/themes/default/themelet.class.php b/themes/default/themelet.class.php index 6fe3f348..02cca80b 100644 --- a/themes/default/themelet.class.php +++ b/themes/default/themelet.class.php @@ -1,6 +1,9 @@ set_title($title); $page->set_heading($title); @@ -9,6 +12,24 @@ class Themelet { } + /** + * Generic thumbnail code; returns HTML rather than adding + * a block since thumbs tend to go inside blocks... + */ + public function build_thumb_html($image, $query=null) { + global $config; + $h_view_link = make_link("post/view/{$image->id}", $query); + $h_tip = html_escape($image->get_tooltip()); + $h_thumb_link = $image->get_thumb_link(); + $tsize = get_thumbnail_size($image->width, $image->height); + return "$h_tip"; + } + + + /** + * Add a generic paginator + */ public function display_paginator($page, $base, $query, $page_number, $total_pages) { if($total_pages == 0) $total_pages = 1; $body = $this->build_paginator($page_number, $total_pages, $base, $query);