From 18cd6fbd99a0eb680b67d55fd3a9f52e6d680d16 Mon Sep 17 00:00:00 2001 From: shish Date: Sat, 21 Jul 2007 12:11:41 +0000 Subject: [PATCH] danbooru theme work git-svn-id: file:///home/shish/svn/shimmie2/trunk@348 7f39781d-f577-437e-ae19-be835c7a54ca --- ext/comment/main.php | 7 +- themes/danbooru/comment.theme.php | 109 ++++++++++++++++++++++++++++++ themes/danbooru/layout.class.php | 13 +++- themes/danbooru/page.class.php | 5 +- themes/danbooru/style.css | 20 +++--- themes/danbooru/upload.theme.php | 91 +++++++++++++++++++++++++ themes/danbooru/view.theme.php | 94 ++++++++++++++++++++++++++ 7 files changed, 323 insertions(+), 16 deletions(-) create mode 100644 themes/danbooru/comment.theme.php create mode 100644 themes/danbooru/upload.theme.php create mode 100644 themes/danbooru/view.theme.php diff --git a/ext/comment/main.php b/ext/comment/main.php index f79eccfa..eeb80921 100644 --- a/ext/comment/main.php +++ b/ext/comment/main.php @@ -26,6 +26,7 @@ class Comment { // {{{ $this->comment_id = $row['comment_id']; $this->image_id = $row['image_id']; $this->poster_ip = $row['poster_ip']; + $this->posted = $row['posted']; } } // }}} @@ -170,7 +171,8 @@ class CommentList extends Extension { SELECT users.id as user_id, users.name as user_name, comments.comment as comment, comments.id as comment_id, - comments.image_id as image_id, comments.owner_ip as poster_ip + comments.image_id as image_id, comments.owner_ip as poster_ip, + comments.posted as posted FROM comments LEFT JOIN users ON comments.owner_id=users.id ORDER BY comments.id DESC @@ -191,7 +193,8 @@ class CommentList extends Extension { SELECT users.id as user_id, users.name as user_name, comments.comment as comment, comments.id as comment_id, - comments.image_id as image_id, comments.owner_ip as poster_ip + comments.image_id as image_id, comments.owner_ip as poster_ip, + comments.posted as posted FROM comments LEFT JOIN users ON comments.owner_id=users.id WHERE comments.image_id=? diff --git a/themes/danbooru/comment.theme.php b/themes/danbooru/comment.theme.php new file mode 100644 index 00000000..c90b6260 --- /dev/null +++ b/themes/danbooru/comment.theme.php @@ -0,0 +1,109 @@ +Prev"; + $h_index = "Index"; + $h_next = ($page_number >= $total_pages) ? "Next" : + "Next"; + + $nav = "$h_prev | $h_index | $h_next"; + + $page->set_title("Comments"); + $page->set_heading("Comments"); + $page->add_block(new Block("Navigation", $nav, "left")); + $page->add_block(new Paginator("comment/list", null, $page_number, $total_pages), 90); + $page->disable_left(); + } + + public function display_recent_comments($page, $comments) { + // no recent comments in this theme + //$html = $this->comments_to_html($comments, true); + //$html .= "

Full List"; + //$page->add_block(new Block("Comments", $html, "left")); + } + + public function display_comments($page, $comments, $postbox, $image_id) { + $count = count($comments); + if($postbox) { + $page->add_block(new Block("$count Comments", + $this->comments_to_html($comments). + $this->build_postbox($image_id), "main", 30)); + } + else { + $page->add_block(new Block("$count Comments", + $this->comments_to_html($comments), "main", 30)); + } + } + + + private function comments_to_html($comments, $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; + + $tfe = new TextFormattingEvent($comment->comment); + send_event($tfe); + + $i_uid = int_escape($comment->owner_id); + $h_name = html_escape($comment->owner_name); + $h_poster_ip = html_escape($comment->poster_ip); + $h_comment = ($trim ? substr($tfe->stripped, 0, 50)."..." : $tfe->formatted); + $i_comment_id = int_escape($comment->comment_id); + $i_image_id = int_escape($comment->image_id); + $h_posted = html_escape($comment->posted); + + $h_userlink = "$h_name"; + $h_dellink = $user->is_admin() ? + " ($h_poster_ip, stripped."');\" ". + "href='".make_link("comment/delete/$i_comment_id/$i_image_id")."'>Del)" : ""; + $h_imagelink = $trim ? ">>>\n" : ""; + return "

$h_userlink $h_dellink
Posted on $h_posted
$h_comment

"; + } + + // 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) { + $count = count($comments); + + $html = "
"; + $html .= "
" . build_thumb_html($image) . "
"; + $html .= "
"; + foreach($image->get_tag_array() as $tag) { + $u_tag = url_escape($tag); + $html .= "
".html_escape($tag).""; + } + $html .= "
"; + $html .= "
"; + $html .= "$count Comments
"; + $html .= $this->comments_to_html($comments); + $html .= "
"; + $html .= "
"; + $html .= "
 
"; + + $page->add_block(new Block(null, $html, "main", $position)); + } +} +?> diff --git a/themes/danbooru/layout.class.php b/themes/danbooru/layout.class.php index 2be9b572..d9b23850 100644 --- a/themes/danbooru/layout.class.php +++ b/themes/danbooru/layout.class.php @@ -110,6 +110,15 @@ class Layout { // bzchan: prepare main title link $title_link = "

$site_name

"; + if($page->left_enabled) { + $left = ""; + $withleft = "withleft"; + } + else { + $left = ""; + $withleft = ""; + } + print << @@ -130,8 +139,8 @@ $header_html $subheading - -
$main_block_html
+ $left +
$main_block_html