diff --git a/ext/comment/main.php b/ext/comment/main.php index b09b30e7..98c0a940 100644 --- a/ext/comment/main.php +++ b/ext/comment/main.php @@ -1,14 +1,6 @@ comment = $comment; } } -// }}} -/* CommentDeletionEvent {{{ - * CommentDeletionEvent: - * $comment_id - * + +/** * A comment is being deleted. Maybe used by spam * detectors to get a feel for what should be delted * and what should be kept? @@ -34,10 +23,10 @@ class CommentDeletionEvent extends Event { $this->comment_id = $comment_id; } } -// }}} + class CommentPostingException extends SCoreException {} -class Comment { // {{{ +class Comment { public function Comment($row) { $this->owner_id = $row['user_id']; $this->owner_name = $row['user_name']; @@ -52,29 +41,59 @@ class Comment { // {{{ global $database; return $database->db->GetOne("SELECT COUNT(*) AS count FROM comments WHERE owner_id=?", array($user->id)); } -} // }}} +} -class CommentList implements Extension { - var $theme; -// event handler {{{ - public function receive_event(Event $event) { - global $config, $database, $page, $user; +class CommentList extends SimpleExtension { + public function onInitExt($event) { + global $config, $database; + $config->set_default_bool('comment_anon', true); + $config->set_default_int('comment_window', 5); + $config->set_default_int('comment_limit', 10); + $config->set_default_int('comment_count', 5); - if(is_null($this->theme)) $this->theme = get_theme_object($this); + if($config->get_int("ext_comments_version") < 2) { + // shortcut to latest + if($config->get_int("ext_comments_version") < 1) { + $database->create_table("comments", " + id SCORE_AIPK, + image_id INTEGER NOT NULL, + owner_id INTEGER NOT NULL, + owner_ip SCORE_INET NOT NULL, + posted DATETIME DEFAULT NULL, + comment TEXT NOT NULL, + INDEX (image_id), + INDEX (owner_ip), + INDEX (posted), + FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE, + FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE CASCADE + "); + $config->set_int("ext_comments_version", 2); + } - if($event instanceof InitExtEvent) { - global $config; - $config->set_default_bool('comment_anon', true); - $config->set_default_int('comment_window', 5); - $config->set_default_int('comment_limit', 10); - $config->set_default_int('comment_count', 5); + // === + if($config->get_int("ext_comments_version") < 1) { + $database->Execute("CREATE TABLE comments ( + id {$database->engine->auto_increment}, + image_id INTEGER NOT NULL, + owner_id INTEGER NOT NULL, + owner_ip CHAR(16) NOT NULL, + posted DATETIME DEFAULT NULL, + comment TEXT NOT NULL, + INDEX (image_id) + ) {$database->engine->create_table_extras}"); + $config->set_int("ext_comments_version", 1); + } - if($config->get_int("ext_comments_version") < 2) { - $this->install(); + if($config->get_int("ext_comments_version") == 1) { + $database->Execute("CREATE INDEX comments_owner_ip ON comments(owner_ip)"); + $database->Execute("CREATE INDEX comments_posted ON comments(posted)"); + $config->set_int("ext_comments_version", 2); } } + } - if(($event instanceof PageRequestEvent) && $event->page_matches("comment")) { + public function onPageRequest($event) { + if($event->page_matches("comment")) { if($event->get_arg(0) == "add") { if(isset($_POST['image_id']) && isset($_POST['comment'])) { try { @@ -110,121 +129,84 @@ class CommentList implements Extension { $this->build_page($event->get_arg(1)); } } - - if($event instanceof PostListBuildingEvent) { - $cc = $config->get_int("comment_count"); - if($cc > 0) { - $recent = $this->get_recent_comments($cc); - if(count($recent) > 0) { - $this->theme->display_recent_comments($page, $recent); - } - } - } - - if($event instanceof DisplayingImageEvent) { - $this->theme->display_comments( - $page, - $this->get_comments($event->image->id), - $this->can_comment(), - $event->image); - } - - if($event instanceof ImageDeletionEvent) { - $this->delete_comments($event->image->id); - } - // TODO: split akismet into a separate class, which can veto the event - if($event instanceof CommentPostingEvent) { - $this->add_comment_wrapper($event->image_id, $event->user, $event->comment, $event); - } - if($event instanceof CommentDeletionEvent) { - $this->delete_comment($event->comment_id); - } - - if($event instanceof SetupBuildingEvent) { - $sb = new SetupBlock("Comment Options"); - $sb->add_bool_option("comment_anon", "Allow anonymous comments: "); - $sb->add_label("
Limit to "); - $sb->add_int_option("comment_limit"); - $sb->add_label(" comments per "); - $sb->add_int_option("comment_window"); - $sb->add_label(" minutes"); - $sb->add_label("
Show "); - $sb->add_int_option("comment_count"); - $sb->add_label(" recent comments on the index"); - $sb->add_text_option("comment_wordpress_key", "
Akismet Key "); - $event->panel->add_block($sb); - } - - if(is_a($event, 'SearchTermParseEvent')) { - $matches = array(); - if(preg_match("/comments(<|>|<=|>=|=)(\d+)/", $event->term, $matches)) { - $cmp = $matches[1]; - $comments = $matches[2]; - $event->add_querylet(new Querylet("images.id IN (SELECT DISTINCT image_id FROM comments GROUP BY image_id HAVING count(image_id) $cmp $comments)")); - } - else if(preg_match("/commented_by=(.*)/i", $event->term, $matches)) { - global $database; - $user = User::by_name($matches[1]); - if(!is_null($user)) { - $user_id = $user->id; - } - else { - $user_id = -1; - } - - $event->add_querylet(new Querylet("images.id IN (SELECT image_id FROM comments WHERE owner_id = $user_id)")); - } - else if(preg_match("/commented_by_userid=([0-9]+)/i", $event->term, $matches)) { - $user_id = int_escape($matches[1]); - $event->add_querylet(new Querylet("images.id IN (SELECT image_id FROM comments WHERE owner_id = $user_id)")); - } - } } -// }}} -// installer {{{ - protected function install() { - global $database; + + public function onPostListBuilding($event) { global $config; - - // shortcut to latest - if($config->get_int("ext_comments_version") < 1) { - $database->create_table("comments", " - id SCORE_AIPK, - image_id INTEGER NOT NULL, - owner_id INTEGER NOT NULL, - owner_ip SCORE_INET NOT NULL, - posted DATETIME DEFAULT NULL, - comment TEXT NOT NULL, - INDEX (image_id), - INDEX (owner_ip), - INDEX (posted), - FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE, - FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE CASCADE - "); - $config->set_int("ext_comments_version", 2); - } - - // === - if($config->get_int("ext_comments_version") < 1) { - $database->Execute("CREATE TABLE comments ( - id {$database->engine->auto_increment}, - image_id INTEGER NOT NULL, - owner_id INTEGER NOT NULL, - owner_ip CHAR(16) NOT NULL, - posted DATETIME DEFAULT NULL, - comment TEXT NOT NULL, - INDEX (image_id) - ) {$database->engine->create_table_extras}"); - $config->set_int("ext_comments_version", 1); - } - - if($config->get_int("ext_comments_version") == 1) { - $database->Execute("CREATE INDEX comments_owner_ip ON comments(owner_ip)"); - $database->Execute("CREATE INDEX comments_posted ON comments(posted)"); - $config->set_int("ext_comments_version", 2); + $cc = $config->get_int("comment_count"); + if($cc > 0) { + $recent = $this->get_recent_comments($cc); + if(count($recent) > 0) { + $this->theme->display_recent_comments($recent); + } } } -// }}} + + public function onDisplayingImage($event) { + $this->theme->display_image_comments( + $event->image, + $this->get_comments($event->image->id), + $this->can_comment() + ); + } + + public function onImageDeletion($event) { + global $database; + $database->Execute("DELETE FROM comments WHERE image_id=?", array($image_id)); + log_info("comment", "Deleting all comments for Image #$image_id"); + } + + // TODO: split akismet into a separate class, which can veto the event + public function onCommentPosting($event) { + $this->add_comment_wrapper($event->image_id, $event->user, $event->comment, $event); + } + + public function onCommentDeletion($event) { + global $database; + $database->Execute("DELETE FROM comments WHERE id=?", array($comment_id)); + log_info("comment", "Deleting Comment #$comment_id"); + } + + public function onSetupBuilding($event) { + $sb = new SetupBlock("Comment Options"); + $sb->add_bool_option("comment_anon", "Allow anonymous comments: "); + $sb->add_label("
Limit to "); + $sb->add_int_option("comment_limit"); + $sb->add_label(" comments per "); + $sb->add_int_option("comment_window"); + $sb->add_label(" minutes"); + $sb->add_label("
Show "); + $sb->add_int_option("comment_count"); + $sb->add_label(" recent comments on the index"); + $sb->add_text_option("comment_wordpress_key", "
Akismet Key "); + $event->panel->add_block($sb); + } + + public function onSearchTermParse($event) { + $matches = array(); + if(preg_match("/comments(<|>|<=|>=|=)(\d+)/", $event->term, $matches)) { + $cmp = $matches[1]; + $comments = $matches[2]; + $event->add_querylet(new Querylet("images.id IN (SELECT DISTINCT image_id FROM comments GROUP BY image_id HAVING count(image_id) $cmp $comments)")); + } + else if(preg_match("/commented_by=(.*)/i", $event->term, $matches)) { + global $database; + $user = User::by_name($matches[1]); + if(!is_null($user)) { + $user_id = $user->id; + } + else { + $user_id = -1; + } + + $event->add_querylet(new Querylet("images.id IN (SELECT image_id FROM comments WHERE owner_id = $user_id)")); + } + else if(preg_match("/commented_by_userid=([0-9]+)/i", $event->term, $matches)) { + $user_id = int_escape($matches[1]); + $event->add_querylet(new Querylet("images.id IN (SELECT image_id FROM comments WHERE owner_id = $user_id)")); + } + } + // page building {{{ private function build_page($current_page) { global $page; @@ -250,16 +232,15 @@ class CommentList implements Extension { $total_pages = (int)($database->db->GetOne("SELECT COUNT(image_id) AS count FROM comments GROUP BY image_id") / 10); - $this->theme->display_page_start($page, $current_page, $total_pages); - - $n = 10; + $images = array(); while(!$result->EOF) { $image = Image::by_id($result->fields["image_id"]); $comments = $this->get_comments($image->id); - $this->theme->add_comment_list($page, $image, $comments, $n, $this->can_comment()); - $n += 1; + $images[] = array($image, $comments); $result->MoveNext(); } + + $this->theme->display_comment_list($images, $current_page, $total_pages, $this->can_comment()); } // }}} // get comments {{{ @@ -433,19 +414,6 @@ class CommentList implements Extension { log_info("comment", "Comment #$cid added"); } } - - private function delete_comments($image_id) { - global $database; - $database->Execute("DELETE FROM comments WHERE image_id=?", array($image_id)); - log_info("comment", "Deleting all comments for Image #$image_id"); - } - - private function delete_comment($comment_id) { - global $database; - $database->Execute("DELETE FROM comments WHERE id=?", array($comment_id)); - log_info("comment", "Deleting Comment #$comment_id"); - } // }}} } -add_event_listener(new CommentList()); ?> diff --git a/ext/comment/theme.php b/ext/comment/theme.php index e2b68ba9..f54af86b 100644 --- a/ext/comment/theme.php +++ b/ext/comment/theme.php @@ -1,13 +1,16 @@ set_heading("Comments"); $page->add_block(new Block("Navigation", $nav, "left")); $this->display_paginator($page, "comment/list", null, $page_number, $total_pages); + + // parts for each image + $position = 10; + foreach($images as $pair) { + $image = $pair[0]; + $comments = $pair[1]; + + $thumb_html = $this->build_thumb_html($image); + + $comment_html = ""; + foreach($comments as $comment) { + $comment_html .= $this->comment_to_html($comment); + } + if($can_post) { + $comment_html .= $this->build_postbox($image->id); + } + + $html = " + + + +
$thumb_html$comment_html
+ "; + + $page->add_block(new Block("{$image->id}: ".($image->get_tag_list()), $html, "main", $position++)); + } } - /* + + /** * Add some comments to the page, probably in a sidebar * * $comments = an array of Comment objects to be shown */ - public function display_recent_comments(Page $page, $comments) { - $html = $this->comments_to_html($comments, true); + public function display_recent_comments($comments) { + global $page; + $html = ""; + foreach($comments as $comment) { + $html .= $this->comment_to_html($comment, true); + } $html .= "

Full List"; $page->add_block(new Block("Comments", $html, "left")); } - /* + + /** * Show comments for an image */ - public function display_comments(Page $page, $comments, $postbox, Image $image) { - if($postbox) { - $html = $this->comments_to_html($comments) . $this->build_postbox($image->id); + public function display_image_comments(Image $image, $comments, $postbox) { + global $page; + $html = ""; + foreach($comments as $comment) { + $html .= $this->comment_to_html($comment); } - else { - $html = $this->comments_to_html($comments); + if($postbox) { + $html .= $this->build_postbox($image->id); } $page->add_block(new Block("Comments", $html, "main", 30)); } - /* - * Add a block with thumbnail and comments, as part of the comment - * list page - */ - public function add_comment_list(Page $page, Image $image, $comments, $position, $with_postbox) { - $html = "

"; - $html .= "
" . $this->build_thumb_html($image) . "
"; - $html .= "
" . $this->comments_to_html($comments) . "
"; - $html .= "
"; - if($with_postbox) { - $html .= "
".($this->build_postbox($image->id))."
"; - } - else { - // $html .= "

You need to create an account before you can comment

"; - $html .= "

 

"; - } - - $page->add_block(new Block("{$image->id}: ".($image->get_tag_list()), $html, "main", $position)); - } - - - /* - * Various functions which are only used by this theme - */ - - - protected function comments_to_html($comments, $trim=false) { - $html = "
"; - foreach($comments as $comment) { - $html .= $this->comment_to_html($comment, $trim); - } - $html .= "
"; - return $html; - } protected function comment_to_html($comment, $trim=false) { global $user; @@ -98,14 +101,33 @@ class CommentListTheme extends Themelet { $i_image_id = int_escape($comment->image_id); $h_userlink = "$h_name"; - $stripped_nonl = str_replace("\n", "\\n", $tfe->stripped); + $stripped_nonl = str_replace("\n", "\\n", substr($tfe->stripped, 0, 50)); $stripped_nonl = str_replace("\r", "\\r", $stripped_nonl); $h_dellink = $user->is_admin() ? "
($h_poster_ip, Del)" : ""; - $h_imagelink = $trim ? ">>>\n" : ""; - return "

$h_userlink: $h_comment $h_imagelink $h_dellink

"; + + if($trim) { + return " + $h_userlink: $h_comment + >>> + $h_dellink + "; + } + else { + //$avatar = ""; + //if(!empty($comment->owner->email)) { + // $hash = md5(strtolower($comment->owner->email)); + // $avatar = "
"; + //} + return " +
+ $h_userlink: $h_comment + $h_dellink +
+ "; + } } protected function build_postbox($image_id) { @@ -113,12 +135,12 @@ class CommentListTheme extends Themelet { $hash = CommentList::get_hash(); return "
- - - -
+ + + +
- "; + "; } } ?> diff --git a/themes/danbooru/comment.theme.php b/themes/danbooru/comment.theme.php index 5eb8ea55..0bad0bed 100644 --- a/themes/danbooru/comment.theme.php +++ b/themes/danbooru/comment.theme.php @@ -1,7 +1,12 @@ disable_left(); + + // parts for the whole page $prev = $page_number - 1; $next = $page_number + 1; @@ -12,30 +17,51 @@ class CustomCommentListTheme extends CommentListTheme { "Next"; $nav = "$h_prev | $h_index | $h_next"; - + $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(); + + // parts for each image + $position = 10; + foreach($images as $pair) { + $image = $pair[0]; + $comments = $pair[1]; + + $thumb_html = $this->build_thumb_html($image); + + $s = "   "; + $un = $image->get_owner()->name; + $t = ""; + foreach($image->get_tag_array() as $tag) { + $u_tag = url_escape($tag); + $t .= "".html_escape($tag)." "; + } + $p = autodate($image->posted); + + $comment_html = "Date $p $s User $un
Tags $t

 "; + foreach($comments as $comment) { + $comment_html .= $this->comment_to_html($comment); + } + if($can_post) { + $comment_html .= $this->build_postbox($image->id); + } + + $html = " + + + +
$thumb_html$comment_html
+ "; + + + $page->add_block(new Block(" ", $html, "main", $position++)); + } } - public function display_recent_comments($page, $comments) { + public function display_recent_comments($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 $page, $comments, $postbox, Image $image) { - $count = count($comments); - $cs = $count == 1 ? "Comment" : "Comments"; - if($postbox) { - $html = $this->comments_to_html($comments) . $this->build_postbox($image->id); - } - else { - $html = $this->comments_to_html($comments); - } - $page->add_block(new Block("$count $cs", $html, "main", 30)); } @@ -55,33 +81,21 @@ class CustomCommentListTheme extends CommentListTheme { $h_userlink = "$h_name"; $h_dellink = $user->is_admin() ? - " ($h_poster_ip, ($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

"; - } - - public function add_comment_list(Page $page, Image $image, $comments, $position, $with_postbox) { - $s = "   "; - $un = $image->get_owner()->name; - $t = ""; - foreach($image->get_tag_array() as $tag) { - $u_tag = url_escape($tag); - $t .= "".html_escape($tag)." "; + if($trim) { + return "

$h_userlink $h_dellink
Posted $h_posted
$h_comment

"; + } + else { + return " + + + +
$h_userlink
Posted $h_posted$h_dellink
$h_comment
+ "; } - $p = autodate($image->posted); - - $html = "
"; - $html .= "
" . $this->build_thumb_html($image) . "
"; - $html .= "
"; - $html .= "Date $p $s User $un
Tags $t

 "; - $html .= $this->comments_to_html($comments); - $html .= "

"; - $html .= "
"; - $html .= "
 
"; - - $page->add_block(new Block(" ", $html, "main", $position)); } } ?> diff --git a/themes/danbooru/style.css b/themes/danbooru/style.css index 2813f706..309c9e70 100644 --- a/themes/danbooru/style.css +++ b/themes/danbooru/style.css @@ -39,7 +39,6 @@ THEAD { } TD { vertical-align: top; - text-align: center; } /* bzchan: subtitle black border removed */ #subtitle { @@ -50,7 +49,9 @@ TD { border-top: none; } #body SELECT {width: 150px;} -TD>INPUT {width: 100%;} +TD>INPUT[type="submit"] {width: 100%;} +TD>INPUT[type="text"] {width: 100%;} +TD>INPUT[type="password"] {width: 100%;} TD>SELECT {width: 100%;} #footer { diff --git a/themes/default/comment.theme.php b/themes/default/comment.theme.php index ac41df22..97676e24 100644 --- a/themes/default/comment.theme.php +++ b/themes/default/comment.theme.php @@ -1,51 +1,12 @@ "; - $html .= "
" . $this->build_thumb_html($image) . "
"; - $html .= "
" . $this->comments_to_html($comments) . "
"; - $html .= ""; - if($with_postbox) { - $html .= "
".($this->build_postbox($image->id))."
"; - } - else { - // $html .= "

You need to create an account before you can comment

"; - $html .= "

 

"; - } - - $page->add_block(new Block("{$image->id}: ".($image->get_tag_list()), $html, "main", $position)); + protected function comment_to_html($comment, $trim=false) { + return $this->rr(parent::comment_to_html($comment, $trim)); } - protected 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_userlink = "$h_name"; - $stripped_nonl = str_replace("\n", "\\n", $tfe->stripped); - $stripped_nonl = str_replace("\r", "\\r", $stripped_nonl); - $h_dellink = $user->is_admin() ? - "
($h_poster_ip, Del)" : ""; - $h_imagelink = $trim ? ">>>\n" : ""; - return " -
-
-
-
$h_userlink: $h_comment $h_imagelink $h_dellink
-
-
-
"; + protected function build_postbox($image_id) { + return $this->rr(parent::build_postbox($image_id)); } } ?> diff --git a/themes/default/setup.theme.php b/themes/default/setup.theme.php index 1da9c867..8f7071a2 100644 --- a/themes/default/setup.theme.php +++ b/themes/default/setup.theme.php @@ -3,17 +3,8 @@ * A customised version of the Setup theme */ class CustomSetupTheme extends SetupTheme { - /** - * Turn a SetupBlock into HTML... with rounded corners. - */ protected function sb_to_html(SetupBlock $block) { - return " -
-
-
{$block->header}
{$block->body}
-
-
- "; + return $this->rr(parent::sb_to_html($block)); } } ?> diff --git a/themes/default/style.css b/themes/default/style.css index 16cc31b2..ddacd4af 100644 --- a/themes/default/style.css +++ b/themes/default/style.css @@ -120,6 +120,7 @@ UL { overflow: hidden; } .comment { + margin-bottom: 16px; text-align: left; } @@ -187,7 +188,6 @@ UL { .setupblock { text-align: center; - margin: 16px; width: 350px; } .setupblock TEXTAREA { diff --git a/themes/default/themelet.class.php b/themes/default/themelet.class.php index 49b41d59..71c832fe 100644 --- a/themes/default/themelet.class.php +++ b/themes/default/themelet.class.php @@ -50,6 +50,20 @@ class Themelet { } + /** + * Put something in a rounded rectangle box; specific to the default theme + */ + public function rr($html) { + return " +
+
+
$html
+
+
+ "; + } + + /** * Add a generic paginator */ diff --git a/themes/futaba/comment.theme.php b/themes/futaba/comment.theme.php index 1b6aeda0..b367da94 100644 --- a/themes/futaba/comment.theme.php +++ b/themes/futaba/comment.theme.php @@ -1,29 +1,50 @@ get_string('title'); $page->set_title($page_title); $page->set_heading($page_title); $page->disable_left(); $page->add_block(new Block(null, $this->build_upload_box(), "main", 0)); -// $page->add_block(new Block(null, "
", "main", 2)); -// $this->display_paginator($page, "comment/list", null, $page_number, $total_pages, 5); $page->add_block(new Block(null, "
", "main", 80)); $this->display_paginator($page, "comment/list", null, $page_number, $total_pages, 90); + + // parts for each image + $position = 10; + foreach($images as $pair) { + $image = $pair[0]; + $comments = $pair[1]; + + $h_filename = html_escape($image->filename); + $h_filesize = to_shorthand_int($image->filesize); + $w = $image->width; + $h = $image->height; + + $comment_html = ""; + $comment_id = 0; + foreach($comments as $comment) { + $comment_html .= $this->comment_to_html($comment, false, $comment_id++); + } + + $html = "

 


"; + $html .= "File: id}")."\">$h_filename - ($h_filesize, {$w}x{$h}) - "; + $html .= html_escape($image->get_tag_list()); + $html .= "
"; + $html .= "
" . $this->build_thumb_html($image) . "
"; + $html .= "
$comment_html
"; + $html .= "
"; + + $page->add_block(new Block(null, $html, "main", $position++)); + } } - public function display_recent_comments(Page $page, $comments) { + public function display_recent_comments($comments) { // sidebar fails in this theme } @@ -31,35 +52,6 @@ class CustomCommentListTheme extends CommentListTheme { return "[[ insert upload-and-comment extension here ]]"; } - /* - * Add a block with thumbnail and comments, as part of the comment - * list page - */ - public function add_comment_list(Page $page, Image $image, $comments, $position, $with_postbox) { - $h_filename = html_escape($image->filename); - $h_filesize = to_shorthand_int($image->filesize); - $w = $image->width; - $h = $image->height; - - $html = "
"; - $html .= "File: id}")."\">$h_filename - ($h_filesize, {$w}x{$h}) - "; - $html .= html_escape($image->get_tag_list()); - $html .= "
"; - $html .= "
" . $this->build_thumb_html($image) . "
"; - $html .= "
" . $this->comments_to_html($comments) . "
"; - $html .= "
"; - - $page->add_block(new Block(null, $html, "main", $position)); - } - - protected function comments_to_html($comments, $trim=false) { - $html = ""; - $inner_id = 0; - foreach($comments as $comment) { - $html .= $this->comment_to_html($comment, $trim, $inner_id++); - } - return $html; - } protected function comment_to_html(Comment $comment, $trim=false, $inner_id=0) { global $user; @@ -80,27 +72,16 @@ class CustomCommentListTheme extends CommentListTheme { " ($h_poster_ip, stripped."');\" ". "href='".make_link("comment/delete/$i_comment_id/$i_image_id")."'>Del)" : ""; - $h_imagelink = $trim ? ">>>\n" : ""; + $h_reply = "[Reply]"; if($inner_id == 0) { - return "
$h_userlink$h_dellink $h_date No.$i_comment_id [Reply]

$h_comment

"; + return "
$h_userlink$h_dellink $h_date No.$i_comment_id $h_reply

$h_comment

"; } else { return "
>>". - "
$h_userlink$h_dellink $h_date No.$i_comment_id [Reply]

$h_comment

" . + "
$h_userlink$h_dellink $h_date No.$i_comment_id $h_reply

$h_comment

" . "
"; } } - - protected function build_postbox($image_id) { - $i_image_id = int_escape($image_id); - return " -
- - -
-
- "; - } } ?> diff --git a/themes/futaba/style.css b/themes/futaba/style.css index e8bf74ab..d6aba334 100644 --- a/themes/futaba/style.css +++ b/themes/futaba/style.css @@ -106,7 +106,5 @@ TD { padding: 5px; } .thumb { - width: 220px; - display: inline-block; - margin-bottom: 16px; + margin: 16px; } diff --git a/themes/warm/comment.theme.php b/themes/warm/comment.theme.php index d54ac46d..40c93637 100644 --- a/themes/warm/comment.theme.php +++ b/themes/warm/comment.theme.php @@ -1,51 +1,12 @@ "; - $html .= "
" . $this->build_thumb_html($image) . "
"; - $html .= "
" . $this->comments_to_html($comments) . "
"; - $html .= ""; - if($with_postbox) { - $html .= "
".($this->build_postbox($image->id))."
"; - } - else { - // $html .= "

You need to create an account before you can comment

"; - $html .= "

 

"; - } - - $page->add_block(new Block("{$image->id}: ".($image->get_tag_list()), $html, "main", $position)); + protected function comment_to_html($comment, $trim=false) { + return $this->box(parent::comment_to_html($comment, $trim)); } - protected function comment_to_html(Comment $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_userlink = "$h_name"; - $stripped_nonl = str_replace("\n", "\\n", $tfe->stripped); - $stripped_nonl = str_replace("\r", "\\r", $stripped_nonl); - $h_dellink = $user->is_admin() ? - "
($h_poster_ip, Del)" : ""; - $h_imagelink = $trim ? ">>>\n" : ""; - return " -
-
-
-
$h_userlink: $h_comment $h_imagelink $h_dellink
-
-
-
"; + protected function build_postbox($image_id) { + return $this->box(parent::build_postbox($image_id)); } } ?> diff --git a/themes/warm/setup.theme.php b/themes/warm/setup.theme.php index 1da9c867..3932ab6a 100644 --- a/themes/warm/setup.theme.php +++ b/themes/warm/setup.theme.php @@ -3,17 +3,8 @@ * A customised version of the Setup theme */ class CustomSetupTheme extends SetupTheme { - /** - * Turn a SetupBlock into HTML... with rounded corners. - */ protected function sb_to_html(SetupBlock $block) { - return " -
-
-
{$block->header}
{$block->body}
-
-
- "; + return $this->box(parent::sb_to_html($block)); } } ?> diff --git a/themes/warm/style.css b/themes/warm/style.css index 20822739..236d8a49 100644 --- a/themes/warm/style.css +++ b/themes/warm/style.css @@ -186,7 +186,6 @@ UL { .setupblock { text-align: center; - margin: 16px; width: 350px; } .setupblock TEXTAREA { diff --git a/themes/warm/themelet.class.php b/themes/warm/themelet.class.php index 3a2a2db4..1c160108 100644 --- a/themes/warm/themelet.class.php +++ b/themes/warm/themelet.class.php @@ -51,6 +51,20 @@ class Themelet { } + /** + * Put something in a box; specific to the default theme + */ + public function box($html) { + return " +
+
+
$html
+
+
+ "; + } + + /** * Add a generic paginator */