From 38a8df40ae7352c67ca3e195d3fad034c8da3c1b Mon Sep 17 00:00:00 2001 From: shish Date: Sun, 29 Apr 2007 02:43:41 +0000 Subject: [PATCH] early bbcode support for comments, and comments page uses standard thumb html generator git-svn-id: file:///home/shish/svn/shimmie2/trunk@36 7f39781d-f577-437e-ae19-be835c7a54ca --- ext/comment.ext.php | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/ext/comment.ext.php b/ext/comment.ext.php index eff09947..a9ac96f8 100644 --- a/ext/comment.ext.php +++ b/ext/comment.ext.php @@ -28,20 +28,20 @@ class Comment { // {{{ $this->poster_ip = $row['poster_ip']; } - public function to_html($link_to_image = false) { + public function to_html($trim=false) { global $user; $i_uid = int_escape($this->owner_id); $h_name = html_escape($this->owner_name); $h_poster_ip = html_escape($this->poster_ip); - $h_comment = bbcode2html($this->comment); + $h_comment = ($trim ? substr(bbcode_to_text($this->comment), 0, 50)."..." : bbcode_to_html($this->comment)); $i_comment_id = int_escape($this->comment_id); $i_image_id = int_escape($this->image_id); $h_userlink = "$h_name"; $h_dellink = $user->is_admin() ? "
($h_poster_ip, Del)" : ""; - $h_imagelink = $link_to_image ? ">>>\n" : ""; + $h_imagelink = $trim ? ">>>\n" : ""; return "

$h_userlink: $h_comment $h_imagelink $h_dellink

"; } } // }}} @@ -87,7 +87,6 @@ class CommentList extends Extension { global $config; if($config->get_int("comment_count") > 0) { $page->add_side_block(new Block("Comments", $this->build_recent_comments()), 50); - // $page->add_quicknav("Comments", make_link("comments/list")); } } @@ -190,10 +189,9 @@ class CommentList extends Extension { while(!$result->EOF) { $image = $database->get_image($result->fields["image_id"]); - $html = "
"; - $html .= ""; - $html .= ""; - $html .= $this->build_image_comments($image->id); + $html = "
"; + $html .= "
" . build_thumb_html($image) . "
"; + $html .= $this->build_image_comments($image->id); $html .= "
"; $html .= "
".($this->build_postbox($image->id))."
"; @@ -230,7 +228,7 @@ class CommentList extends Extension { LEFT JOIN users ON comments.owner_id=users.id WHERE comments.image_id=? ORDER BY comments.id ASC - ", array($i_image_id)); + ", array($i_image_id), false); $html .= "
"; return $html; } @@ -240,12 +238,7 @@ class CommentList extends Extension { $html = $this->query_to_html(" SELECT users.id as user_id, users.name as user_name, - if( - length(comments.comment) > 50, - concat(substring(comments.comment, 1, 50), ' ...'), - comments.comment - ) as comment, - comments.id as comment_id, + comments.comment as comment, comments.id as comment_id, comments.image_id as image_id, comments.owner_ip as poster_ip FROM comments LEFT JOIN users ON comments.owner_id=users.id @@ -272,7 +265,7 @@ class CommentList extends Extension { } } - private function query_to_html($query, $args, $link_to_image=false) { + private function query_to_html($query, $args, $trim=false) { global $database; global $config; @@ -280,7 +273,7 @@ class CommentList extends Extension { $result = $database->db->Execute($query, $args); while(!$result->EOF) { $comment = new Comment($result->fields); - $html .= $comment->to_html($link_to_image); + $html .= $comment->to_html($trim); $result->MoveNext(); } return $html;