Exemple #1
0
 private function build_stats(Image $image)
 {
     $h_owner = html_escape($image->get_owner()->name);
     $h_ownerlink = "<a href='" . make_link("user/{$h_owner}") . "'>{$h_owner}</a>";
     $h_ip = html_escape($image->owner_ip);
     $h_date = autodate($image->posted);
     $h_filesize = to_shorthand_int($image->filesize);
     global $user;
     if ($user->can("view_ip")) {
         $h_ownerlink .= " ({$h_ip})";
     }
     $html = "\n\t\tId: {$image->id}\n\t\t<br>Posted: {$h_date} by {$h_ownerlink}\n\t\t<br>Size: {$image->width}x{$image->height}\n\t\t<br>Filesize: {$h_filesize}\n\t\t";
     if (!is_null($image->source)) {
         $h_source = html_escape($image->source);
         if (substr($image->source, 0, 7) != "http://" && substr($image->source, 0, 8) != "https://") {
             $h_source = "http://" . $h_source;
         }
         $html .= "<br>Source: <a href='{$h_source}'>link</a>";
     }
     if (class_exists("Ratings")) {
         if ($image->rating == null || $image->rating == "u") {
             $image->rating = "u";
         }
         $h_rating = Ratings::rating_to_human($image->rating);
         $html .= "<br>Rating: {$h_rating}";
     }
     return $html;
 }
Exemple #2
0
 /**
  * @param array $images
  * @param int $page_number
  * @param int $total_pages
  * @param bool $can_post
  */
 public function display_comment_list($images, $page_number, $total_pages, $can_post)
 {
     global $config, $page, $user;
     $page->disable_left();
     // parts for the whole page
     $prev = $page_number - 1;
     $next = $page_number + 1;
     $h_prev = $page_number <= 1 ? "Prev" : "<a href='" . make_link("comment/list/{$prev}") . "'>Prev</a>";
     $h_index = "<a href='" . make_link() . "'>Index</a>";
     $h_next = $page_number >= $total_pages ? "Next" : "<a href='" . make_link("comment/list/{$next}") . "'>Next</a>";
     $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_captcha = $config->get_bool('comment_captcha');
     $comment_limit = $config->get_int("comment_list_count", 10);
     foreach ($images as $pair) {
         $image = $pair[0];
         $comments = $pair[1];
         $thumb_html = $this->build_thumb_html($image);
         $s = "&nbsp;&nbsp;&nbsp;";
         $un = $image->get_owner()->name;
         $t = "";
         foreach ($image->get_tag_array() as $tag) {
             $u_tag = url_escape($tag);
             $t .= "<a href='" . make_link("post/list/{$u_tag}/1") . "'>" . html_escape($tag) . "</a> ";
         }
         $p = autodate($image->posted);
         $r = class_exists("Ratings") ? "<b>Rating</b> " . Ratings::rating_to_human($image->rating) : "";
         $comment_html = "<b>Date</b> {$p} {$s} <b>User</b> {$un} {$s} {$r}<br><b>Tags</b> {$t}<p>&nbsp;";
         $comment_count = count($comments);
         if ($comment_limit > 0 && $comment_count > $comment_limit) {
             //$hidden = $comment_count - $comment_limit;
             $comment_html .= "<p>showing {$comment_limit} of {$comment_count} comments</p>";
             $comments = array_slice($comments, -$comment_limit);
         }
         foreach ($comments as $comment) {
             $comment_html .= $this->comment_to_html($comment);
         }
         if ($can_post) {
             if (!$user->is_anonymous()) {
                 $comment_html .= $this->build_postbox($image->id);
             } else {
                 if (!$comment_captcha) {
                     $comment_html .= $this->build_postbox($image->id);
                 } else {
                     $comment_html .= "<a href='" . make_link("post/view/" . $image->id) . "'>Add Comment</a>";
                 }
             }
         }
         $html = "\n\t\t\t\t<table><tr>\n\t\t\t\t\t<td style='width: 220px;'>{$thumb_html}</td>\n\t\t\t\t\t<td style='text-align: left;'>{$comment_html}</td>\n\t\t\t\t</tr></table>\n\t\t\t";
         $page->add_block(new Block("&nbsp;", $html, "main", $position++));
     }
 }