From e171fc98ded876bca0e55fbe5cef0acb2927b3d3 Mon Sep 17 00:00:00 2001 From: shish Date: Wed, 1 Aug 2007 17:24:34 +0000 Subject: [PATCH] danbooru theme tweaks git-svn-id: file:///home/shish/svn/shimmie2/trunk@414 7f39781d-f577-437e-ae19-be835c7a54ca --- themes/danbooru/comment.theme.php | 3 +- themes/danbooru/layout.class.php | 6 +- themes/danbooru/tag_list.theme.php | 167 +++++++++++++++++++++++++++++ themes/danbooru/upload.theme.php | 2 + 4 files changed, 172 insertions(+), 6 deletions(-) create mode 100644 themes/danbooru/tag_list.theme.php diff --git a/themes/danbooru/comment.theme.php b/themes/danbooru/comment.theme.php index 74ba0ba5..0fcbd0a3 100644 --- a/themes/danbooru/comment.theme.php +++ b/themes/danbooru/comment.theme.php @@ -15,7 +15,6 @@ class CommentListTheme extends Themelet { $page->set_title("Comments"); $page->set_heading("Comments"); - $page->add_block(new Block("Navigation", $nav, "left")); $this->display_paginator($page, "comment/list", null, $page_number, $total_pages); $page->disable_left(); } @@ -103,7 +102,7 @@ class CommentListTheme extends Themelet { $html .= ""; $html .= "
 
"; - $page->add_block(new Block(null, $html, "main", $position)); + $page->add_block(new Block(" ", $html, "main", $position)); } } ?> diff --git a/themes/danbooru/layout.class.php b/themes/danbooru/layout.class.php index 2ece0795..96fb30ab 100644 --- a/themes/danbooru/layout.class.php +++ b/themes/danbooru/layout.class.php @@ -59,15 +59,13 @@ class Layout { $left_block_html = ""; $main_block_html = ""; - $firstmain = true; foreach($page->blocks as $block) { switch($block->section) { case "left": $left_block_html .= $this->block_to_html($block, true); break; case "main": - if($firstmain) { - $firstmain = false; + if($block->header == "Images") { $block->header = " "; } $main_block_html .= $this->block_to_html($block, false); @@ -168,7 +166,7 @@ EOD; else { $i = str_replace(' ', '_', $h); if(!is_null($h)) $html .= "\n

$h

\n"; - if(!is_null($b)) $html .= "
$b
\n"; + if(!is_null($b)) $html .= "
$b
\n"; } return $html; } diff --git a/themes/danbooru/tag_list.theme.php b/themes/danbooru/tag_list.theme.php new file mode 100644 index 00000000..f7605f24 --- /dev/null +++ b/themes/danbooru/tag_list.theme.php @@ -0,0 +1,167 @@ +heading = $text; + } + + public function set_tag_list($list) { + $this->list = $list; + } + + public function set_navigation($nav) { + $this->navigation = $nav; + } + + public function display_page($page) { + $page->disable_left(); + $page->set_title("Tag List"); + $page->set_heading($this->heading); + $page->add_block(new Block("Navigation", str_replace("
", " ", $this->navigation), "main", 0)); + $page->add_block(new Block(" ", $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
"; + if(!is_null($config->get_string('info_link'))) { + $link = str_replace('$tag', $tag, $config->get_string('info_link')); + $html .= " ?"; + } + $link = $this->tag_link($row['tag']); + $html .= " $h_tag_no_underscores"; + } + + $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
"; + if(!is_null($config->get_string('info_link'))) { + $link = str_replace('$tag', $tag, $config->get_string('info_link')); + $html .= " ?"; + } + $link = $this->tag_link($row['tag']); + $html .= " $h_tag_no_underscores"; + if($config->get_bool("tag_list_numbers")) { + $html .= " $count"; + } + } + + $html .= "

Full List\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
"; + if(!is_null($config->get_string('info_link'))) { + $link = str_replace('$tag', $tag, $config->get_string('info_link')); + $html .= " ?"; + } + $link = $this->tag_link($row['tag']); + $html .= " $h_tag_no_underscores"; + $html .= $this->ars($tag, $search); + } + + $page->add_block(new Block("Refine Search", $html, "left", 60)); + } + + private function ars($tag, $tags) { + $html = ""; + $html .= " ("; + $html .= $this->get_add_link($tags, $tag); + $html .= $this->get_remove_link($tags, $tag); + $html .= $this->get_subtract_link($tags, $tag); + $html .= ")"; + 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 "R"; + } + } + + 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"; + } + } + + 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 "S"; + } + } + + private function tag_link($tag) { + $u_tag = url_escape($tag); + return make_link("post/list/$u_tag/1"); + } +} +?> diff --git a/themes/danbooru/upload.theme.php b/themes/danbooru/upload.theme.php index fbf0e366..2d18dff9 100644 --- a/themes/danbooru/upload.theme.php +++ b/themes/danbooru/upload.theme.php @@ -7,6 +7,8 @@ class UploadTheme extends Themelet { } public function display_page($page) { + $page->disable_left(); + global $config; $tl_enabled = ($config->get_string("transload_engine", "none") != "none");