示例#1
0
 /**
  * @param int $image_id
  * @return string
  */
 protected function build_postbox($image_id)
 {
     return $this->rr(parent::build_postbox($image_id));
 }
示例#2
0
 /**
  * @param int $current_page
  */
 private function build_page($current_page)
 {
     global $database, $user;
     $where = SPEED_HAX ? "WHERE posted > now() - interval '24 hours'" : "";
     $total_pages = $database->cache->get("comment_pages");
     if (empty($total_pages)) {
         $total_pages = (int) ($database->get_one("\n\t\t\t\tSELECT COUNT(c1)\n\t\t\t\tFROM (SELECT COUNT(image_id) AS c1 FROM comments {$where} GROUP BY image_id) AS s1\n\t\t\t") / 10);
         $database->cache->set("comment_pages", $total_pages, 600);
     }
     $total_pages = max($total_pages, 1);
     $current_page = clamp($current_page, 1, $total_pages);
     $threads_per_page = 10;
     $start = $threads_per_page * ($current_page - 1);
     $result = $database->Execute("\n\t\t\tSELECT image_id,MAX(posted) AS latest\n\t\t\tFROM comments\n\t\t\t{$where}\n\t\t\tGROUP BY image_id\n\t\t\tORDER BY latest DESC\n\t\t\tLIMIT :limit OFFSET :offset\n\t\t", array("limit" => $threads_per_page, "offset" => $start));
     $user_ratings = ext_is_live("Ratings") ? Ratings::get_user_privs($user) : "";
     $images = array();
     while ($row = $result->fetch()) {
         $image = Image::by_id($row["image_id"]);
         if (ext_is_live("Ratings") && !is_null($image) && strpos($user_ratings, $image->rating) === FALSE) {
             $image = null;
             // this is "clever", I may live to regret it
         }
         if (!is_null($image)) {
             $comments = $this->get_comments($image->id);
             $images[] = array($image, $comments);
         }
     }
     $this->theme->display_comment_list($images, $current_page, $total_pages, $user->can("create_comment"));
 }