2015-10-26 12:51:02 +00:00
|
|
|
<?php
|
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
class CustomViewImageTheme extends ViewImageTheme
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Build a page showing $image and some info about it
|
|
|
|
*/
|
|
|
|
public function display_page(Image $image, $editor_parts)
|
|
|
|
{
|
|
|
|
global $page;
|
|
|
|
$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(null, $this->build_pin($image), "subtoolbar", 0));
|
|
|
|
$page->add_block(new Block(null, $this->build_info($image, $editor_parts), "left", 20));
|
|
|
|
}
|
2015-10-26 12:51:02 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
public function display_admin_block(Page $page, $parts)
|
|
|
|
{
|
|
|
|
if (count($parts) > 0) {
|
|
|
|
$page->add_block(new Block("Image Controls", join("<br>", $parts), "drawer", 50));
|
|
|
|
}
|
|
|
|
}
|
2015-10-26 12:51:02 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
protected function build_pin(Image $image)
|
|
|
|
{
|
|
|
|
global $database;
|
2015-10-26 12:51:02 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
if (isset($_GET['search'])) {
|
|
|
|
$search_terms = explode(' ', $_GET['search']);
|
|
|
|
$query = "search=".url_escape($_GET['search']);
|
|
|
|
} else {
|
|
|
|
$search_terms = [];
|
|
|
|
$query = null;
|
|
|
|
}
|
2015-10-26 12:51:02 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
$h_prev = '<a id="prevlink" class="mdl-navigation__link mdl-js-ripple-effect" href="'.make_link("post/prev/{$image->id}", $query).'">Prev</a>';
|
|
|
|
$h_index = "<a class='mdl-navigation__link mdl-js-ripple-effect' href='".make_link()."'>Current</a>";
|
|
|
|
$h_next = '<a id="nextlink" class="mdl-navigation__link mdl-js-ripple-effect" href="'.make_link("post/next/{$image->id}", $query).'">Next</a>';
|
2015-10-26 12:51:02 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
return $h_prev.$h_index.$h_next;
|
|
|
|
}
|
2015-10-26 12:51:02 +00:00
|
|
|
|
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
protected function build_info(Image $image, $editor_parts)
|
|
|
|
{
|
|
|
|
global $user;
|
2015-10-26 12:51:02 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
if (count($editor_parts) == 0) {
|
|
|
|
return ($image->is_locked() ? "<br>[Image Locked]" : "");
|
|
|
|
}
|
2015-10-26 12:51:02 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
$html = make_form(make_link("post/set"))."
|
2015-10-26 12:51:02 +00:00
|
|
|
<input type='hidden' name='image_id' value='{$image->id}'>
|
|
|
|
<table style='' class='image_info form'>
|
|
|
|
";
|
2019-05-28 16:59:38 +00:00
|
|
|
foreach ($editor_parts as $part) {
|
|
|
|
$html .= $part;
|
|
|
|
}
|
|
|
|
if (
|
|
|
|
(!$image->is_locked() || $user->can("edit_image_lock")) &&
|
|
|
|
$user->can("edit_image_tag")
|
|
|
|
) {
|
|
|
|
$html .= "
|
2015-10-26 12:51:02 +00:00
|
|
|
<tr><td colspan='4'>
|
|
|
|
<input class='view' type='button' value='Edit' onclick='$(\".view\").hide(); $(\".edit\").show();'>
|
|
|
|
<input class='edit' type='submit' value='Set'>
|
|
|
|
</td></tr>
|
|
|
|
";
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
|
|
|
$html .= "
|
2015-10-26 12:51:02 +00:00
|
|
|
</table>
|
|
|
|
</form>
|
|
|
|
";
|
2019-05-28 16:59:38 +00:00
|
|
|
return $html;
|
|
|
|
}
|
2015-10-26 12:51:02 +00:00
|
|
|
}
|