2007-07-16 14:36:29 +00:00
|
|
|
<?php
|
|
|
|
|
2008-09-06 17:11:57 +00:00
|
|
|
class ViewImageTheme extends Themelet {
|
2007-07-28 20:30:01 +00:00
|
|
|
/*
|
|
|
|
* Build a page showing $image and some info about it
|
|
|
|
*/
|
2010-05-28 01:07:33 +00:00
|
|
|
public function display_page(Image $image, $editor_parts) {
|
|
|
|
global $page;
|
|
|
|
|
2009-08-24 05:49:40 +00:00
|
|
|
$metatags = str_replace(" ", ", ", html_escape($image->get_tag_list()));
|
|
|
|
|
2007-07-16 14:36:29 +00:00
|
|
|
$page->set_title("Image {$image->id}: ".html_escape($image->get_tag_list()));
|
2009-08-24 05:49:40 +00:00
|
|
|
$page->add_header("<meta name=\"keywords\" content=\"$metatags\">");
|
2011-03-07 23:57:56 +00:00
|
|
|
$page->add_header("<meta property=\"og:title\" content=\"$metatags\">");
|
|
|
|
$page->add_header("<meta property=\"og:type\" content=\"article\">");
|
|
|
|
$page->add_header("<meta property=\"og:image\" content=\"".make_http($image->get_thumb_link())."\">");
|
|
|
|
$page->add_header("<meta property=\"og:url\" content=\"".make_http(make_link("post/view/{$image->id}"))."\">");
|
2007-07-16 14:36:29 +00:00
|
|
|
$page->set_heading(html_escape($image->get_tag_list()));
|
2008-10-09 03:23:12 +00:00
|
|
|
$page->add_block(new Block("Navigation", $this->build_navigation($image), "left", 0));
|
2007-11-14 10:11:56 +00:00
|
|
|
$page->add_block(new Block(null, $this->build_info($image, $editor_parts), "main", 10));
|
2009-07-06 15:51:34 +00:00
|
|
|
//$page->add_block(new Block(null, $this->build_pin($image), "main", 11));
|
2007-07-16 14:36:29 +00:00
|
|
|
}
|
|
|
|
|
2009-01-04 19:54:16 +00:00
|
|
|
public function display_admin_block(Page $page, $parts) {
|
2008-06-14 11:36:19 +00:00
|
|
|
if(count($parts) > 0) {
|
2009-07-28 10:18:09 +00:00
|
|
|
$page->add_block(new Block("Image Controls", join("<br>", $parts), "left", 50));
|
2008-06-14 11:36:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-16 14:36:29 +00:00
|
|
|
|
2009-01-04 19:54:16 +00:00
|
|
|
protected function build_pin(Image $image) {
|
2007-07-16 14:36:29 +00:00
|
|
|
global $database;
|
|
|
|
|
|
|
|
if(isset($_GET['search'])) {
|
|
|
|
$search_terms = explode(' ', $_GET['search']);
|
|
|
|
$query = "search=".url_escape($_GET['search']);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$search_terms = array();
|
|
|
|
$query = null;
|
|
|
|
}
|
2009-01-04 19:18:37 +00:00
|
|
|
|
2010-02-09 10:04:20 +00:00
|
|
|
$h_prev = "<a id='prevlink' href='".make_link("post/prev/{$image->id}", $query)."'>Prev</a>";
|
2007-08-23 11:14:03 +00:00
|
|
|
$h_index = "<a href='".make_link()."'>Index</a>";
|
2010-02-09 10:04:20 +00:00
|
|
|
$h_next = "<a id='nextlink' href='".make_link("post/next/{$image->id}", $query)."'>Next</a>";
|
|
|
|
$script = "
|
2011-08-13 01:40:51 +00:00
|
|
|
<script type='text/javascript'><!--
|
2010-02-09 10:04:20 +00:00
|
|
|
$(document).ready(function() {
|
|
|
|
if(document.location.hash.length > 3) {
|
|
|
|
query = document.location.hash.substring(1);
|
|
|
|
a = document.getElementById(\"prevlink\");
|
|
|
|
a.href = a.href + '?' + query;
|
|
|
|
a = document.getElementById(\"nextlink\");
|
|
|
|
a.href = a.href + '?' + query;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
//--></script>
|
|
|
|
";
|
2007-07-16 14:36:29 +00:00
|
|
|
|
2010-02-09 10:04:20 +00:00
|
|
|
return "$h_prev | $h_index | $h_next$script";
|
2007-07-16 14:36:29 +00:00
|
|
|
}
|
|
|
|
|
2009-01-04 19:54:16 +00:00
|
|
|
protected function build_navigation(Image $image) {
|
2008-10-09 03:23:12 +00:00
|
|
|
$h_pin = $this->build_pin($image);
|
2007-07-16 14:36:29 +00:00
|
|
|
$h_search = "
|
2011-08-13 01:40:51 +00:00
|
|
|
<script type='text/javascript'><!--
|
2009-08-02 07:33:20 +00:00
|
|
|
$(document).ready(function() {
|
|
|
|
$(\"#search_input\").DefaultValue(\"Search\");
|
|
|
|
});
|
|
|
|
//--></script>
|
2007-07-26 13:19:39 +00:00
|
|
|
<p><form action='".make_link()."' method='GET'>
|
2010-07-26 10:18:07 +00:00
|
|
|
<input type='hidden' name='q' value='/post/list'>
|
2009-08-02 07:33:20 +00:00
|
|
|
<input id='search_input' name='search' type='text'>
|
2007-07-16 14:36:29 +00:00
|
|
|
<input type='submit' value='Find' style='display: none;'>
|
|
|
|
</form>
|
|
|
|
<div id='search_completions'></div>";
|
|
|
|
|
|
|
|
return "$h_pin<br>$h_search";
|
|
|
|
}
|
|
|
|
|
2009-01-04 19:54:16 +00:00
|
|
|
protected function build_info(Image $image, $editor_parts) {
|
2007-07-16 14:36:29 +00:00
|
|
|
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);
|
2009-07-28 22:56:46 +00:00
|
|
|
$h_date = autodate($image->posted);
|
2007-07-16 14:36:29 +00:00
|
|
|
|
|
|
|
$html = "";
|
2009-07-28 22:56:46 +00:00
|
|
|
$html .= "<p>Uploaded by <a href='".make_link("user/$h_owner")."'>$h_owner</a> $h_date";
|
2007-11-14 10:11:56 +00:00
|
|
|
|
2007-07-16 14:36:29 +00:00
|
|
|
if($user->is_admin()) {
|
|
|
|
$html .= " ($h_ip)";
|
|
|
|
}
|
|
|
|
if(!is_null($image->source)) {
|
|
|
|
if(substr($image->source, 0, 7) == "http://") {
|
|
|
|
$html .= " (<a href='$h_source'>source</a>)";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$html .= " (<a href='http://$h_source'>source</a>)";
|
|
|
|
}
|
|
|
|
}
|
2007-08-01 16:58:50 +00:00
|
|
|
|
2008-02-17 02:39:43 +00:00
|
|
|
$html .= $this->build_image_editor($image, $editor_parts);
|
2007-08-01 16:58:50 +00:00
|
|
|
|
2008-02-17 02:39:43 +00:00
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
|
2009-01-04 19:54:16 +00:00
|
|
|
protected function build_image_editor(Image $image, $editor_parts) {
|
2010-02-17 14:16:20 +00:00
|
|
|
if(count($editor_parts) == 0) return ($image->is_locked() ? "<br>[Image Locked]" : "");
|
2008-12-16 05:29:48 +00:00
|
|
|
|
2007-11-14 10:11:56 +00:00
|
|
|
if(isset($_GET['search'])) {$h_query = "search=".url_escape($_GET['search']);}
|
|
|
|
else {$h_query = "";}
|
2007-10-28 17:59:56 +00:00
|
|
|
|
2008-02-17 02:39:43 +00:00
|
|
|
$html = " (<a href=\"javascript: toggle('imgdata')\">edit info</a>)";
|
2007-11-14 10:11:56 +00:00
|
|
|
$html .= "
|
|
|
|
<div id='imgdata'>
|
2010-09-22 11:56:19 +00:00
|
|
|
".make_form(make_link("post/set"))."
|
2007-11-14 10:11:56 +00:00
|
|
|
<input type='hidden' name='image_id' value='{$image->id}'>
|
|
|
|
<input type='hidden' name='query' value='$h_query'>
|
2008-04-08 16:54:13 +00:00
|
|
|
<table style='width: 500px;'>
|
2007-11-14 10:11:56 +00:00
|
|
|
";
|
|
|
|
foreach($editor_parts as $part) {
|
|
|
|
$html .= $part;
|
2007-08-01 16:58:50 +00:00
|
|
|
}
|
2007-11-14 10:11:56 +00:00
|
|
|
$html .= "
|
2008-04-08 16:54:13 +00:00
|
|
|
<tr><td colspan='2'><input type='submit' value='Set'></td></tr>
|
|
|
|
</table>
|
2008-03-24 04:05:42 +00:00
|
|
|
</form>
|
|
|
|
<br>
|
|
|
|
</div>
|
2007-11-14 10:11:56 +00:00
|
|
|
";
|
2007-07-16 14:36:29 +00:00
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|