ct)) { $this->ct = hsl_rainbow(); } if(!array_key_exists($ip, $this->anon_map)) { $this->anon_map[$ip] = $this->ct[$this->anon_cid++ % count($this->ct)]; } return $this->anon_map[$ip]; } /** * Display a page with a list of images, and for each image, * the image's comments */ public function display_comment_list($images, $page_number, $total_pages, $can_post) { global $config, $page, $user; // aaaaaaargh php assert(is_array($images)); assert(is_numeric($page_number)); assert(is_numeric($total_pages)); assert(is_bool($can_post)); // parts for the whole page $prev = $page_number - 1; $next = $page_number + 1; $h_prev = ($page_number <= 1) ? "Prev" : '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")); $this->display_paginator($page, "comment/list", null, $page_number, $total_pages); // parts for each image $position = 10; $comment_limit = $config->get_int("comment_list_count", 10); $comment_captcha = $config->get_bool('comment_captcha'); foreach($images as $pair) { $image = $pair[0]; $comments = $pair[1]; $thumb_html = $this->build_thumb_html($image); $comment_html = ""; $comment_count = count($comments); if($comment_limit > 0 && $comment_count > $comment_limit) { $hidden = $comment_count - $comment_limit; $comment_html .= '
showing '.$comment_limit.' of '.$comment_count.' comments
'; $comments = array_slice($comments, -$comment_limit); $this->show_anon_id = false; } else { $this->show_anon_id = true; } $this->anon_id = 1; foreach($comments as $comment) { $comment_html .= $this->comment_to_html($comment); } if(!$user->is_anonymous()) { if($can_post) { $comment_html .= $this->build_postbox($image->id); } } else { if ($can_post) { if(!$comment_captcha) { $comment_html .= $this->build_postbox($image->id); } else { $comment_html .= "Add Comment"; } } } $html = ''.$thumb_html.' | '.$comment_html.' |
IP Address | |
---|---|
No comments by this user.
'; } else { $html .= ""; } $page->add_block(new Block("Comments", $html, "left", 70, "comment-list-user")); } public function display_all_user_comments($comments, $page_number, $total_pages, $user) { global $page; assert(is_numeric($page_number)); assert(is_numeric($total_pages)); $html = ""; foreach($comments as $comment) { $html .= $this->comment_to_html($comment, true); } if(empty($html)) { $html = 'No comments by this user.
'; } $page->add_block(new Block("Comments", $html, "main", 70, "comment-list-user")); $prev = $page_number - 1; $next = $page_number + 1; //$search_terms = array('I','have','no','idea','what','this','does!'); //$u_tags = url_escape(implode(" ", $search_terms)); //$query = empty($u_tags) ? "" : '/'.$u_tags; $h_prev = ($page_number <= 1) ? "Prev" : "Prev"; $h_index = "Index"; $h_next = ($page_number >= $total_pages) ? "Next" : "Next"; $page->set_title($user->name."'s comments"); $page->add_block(new Block("Navigation", $h_prev.' | '.$h_index.' | '.$h_next, "left", 0)); $this->display_paginator($page, "comment/beta-search/{$user->name}", null, $page_number, $total_pages); } protected function comment_to_html($comment, $trim=false) { global $config, $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_timestamp = autodate($comment->posted); $h_comment = ($trim ? truncate($tfe->stripped, 50) : $tfe->formatted); $i_comment_id = int_escape($comment->comment_id); $i_image_id = int_escape($comment->image_id); if($i_uid == $config->get_int("anon_id")) { $anoncode = ""; $anoncode2 = ""; if($this->show_anon_id) { $anoncode = ''.$this->anon_id.''; if(!array_key_exists($comment->poster_ip, $this->anon_map)) { $this->anon_map[$comment->poster_ip] = $this->anon_id; } #if($user->can("view_ip")) { #$style = " style='color: ".$this->get_anon_colour($comment->poster_ip).";'"; if($user->can("view_ip") || $config->get_bool("comment_samefags_public", false)) { if($this->anon_map[$comment->poster_ip] != $this->anon_id) { $anoncode2 = '('.$this->anon_map[$comment->poster_ip].')'; } } } $h_userlink = "" . $h_name . $anoncode . $anoncode2 . ""; $this->anon_id++; } else { $h_userlink = ''.$h_name.''; } $stripped_nonl = str_replace("\n", "\\n", substr($tfe->stripped, 0, 50)); $stripped_nonl = str_replace("\r", "\\r", $stripped_nonl); if($trim) { return '