From 2a85e6b17ce0f9885b294db69f8d57a091b426e2 Mon Sep 17 00:00:00 2001 From: shish Date: Mon, 16 Jul 2007 14:36:29 +0000 Subject: [PATCH] actually theme'd, and image source git-svn-id: file:///home/shish/svn/shimmie2/trunk@296 7f39781d-f577-437e-ae19-be835c7a54ca --- core/image.class.php | 2 + ext/view/theme.php | 99 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 ext/view/theme.php diff --git a/core/image.class.php b/core/image.class.php index 37b8068c..31e7426e 100644 --- a/core/image.class.php +++ b/core/image.class.php @@ -7,6 +7,7 @@ class Image { var $filename, $ext; var $owner_ip; var $posted; + var $source; public function Image($a=false, $b=false, $c=false) { if($b == false && $c == false) { @@ -29,6 +30,7 @@ class Image { $this->height = $row['height']; $this->posted = $row['posted']; $this->posted_timestamp = $row['posted_timestamp']; + $this->source = $row['source']; } private function mime_to_ext($mime) { diff --git a/ext/view/theme.php b/ext/view/theme.php new file mode 100644 index 00000000..82cc5d3e --- /dev/null +++ b/ext/view/theme.php @@ -0,0 +1,99 @@ +set_title("Image not found"); + $page->set_heading("Image not found"); + $page->add_block(new NavBlock()); + $page->add_block(new Block("Image not found", + "No image in the database has the ID #$image_id")); + } + + public function display_page($page, $image) { + $page->set_title("Image {$image->id}: ".html_escape($image->get_tag_list())); + $page->set_heading(html_escape($image->get_tag_list())); + $page->add_block(new Block("Navigation", $this->build_navigation($image->id), "left", 0)); + $page->add_block(new Block("Image", $this->build_image_view($image), "main", 0)); + $page->add_block(new Block(null, $this->build_info($image), "main", 10)); + } + + + + var $pin = null; + + private function build_pin($image_id) { + if(!is_null($this->pin)) { + return $this->pin; + } + + global $database; + + if(isset($_GET['search'])) { + $search_terms = explode(' ', $_GET['search']); + $query = "search=".url_escape($_GET['search']); + } + else { + $search_terms = array(); + $query = null; + } + + $next = $database->get_next_image($image_id, $search_terms); + $prev = $database->get_prev_image($image_id, $search_terms); + + $h_prev = (!is_null($prev) ? "Prev" : "Prev"); + $h_index = "Index"; + $h_next = (!is_null($next) ? "Next" : "Next"); + + $this->pin = "$h_prev | $h_index | $h_next"; + return $this->pin; + } + + private function build_navigation($image_id) { + $h_pin = $this->build_pin($image_id); + $h_search = " +

+ + +
+
"; + + return "$h_pin
$h_search"; + } + + private function build_image_view($image) { + $ilink = $image->get_image_link(); + return ""; + } + + private function build_info($image) { + global $user; + $owner = $image->get_owner(); + $h_owner = html_escape($owner->name); + $h_ip = html_escape($image->owner_ip); + $h_source = html_escape($image->source); + $i_owner_id = int_escape($owner->id); + + $html = ""; + if(strlen($image->get_short_link()) > 0) { + $slink = $image->get_short_link(); + $html .= "

Link: "; + } + $html .= "

Uploaded by $h_owner"; + if($user->is_admin()) { + $html .= " ($h_ip)"; + } + if(!is_null($image->source)) { + if(substr($image->source, 0, 7) == "http://") { + $html .= " (source)"; + } + else { + $html .= " (source)"; + } + } + $html .= "

".$this->build_pin($image->id); + + return $html; + } +} +?>