theme engine'd
git-svn-id: file:///home/shish/svn/shimmie2/trunk@295 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
parent
3084446c2e
commit
086d13ac34
1 changed files with 2 additions and 81 deletions
|
@ -2,7 +2,7 @@
|
|||
|
||||
class ViewImage extends Extension {
|
||||
var $theme;
|
||||
// event handling {{{
|
||||
|
||||
public function receive_event($event) {
|
||||
if(is_null($this->theme)) $this->theme = get_theme_object("view", "ViewTheme");
|
||||
|
||||
|
@ -21,14 +21,7 @@ class ViewImage extends Extension {
|
|||
}
|
||||
|
||||
if(is_a($event, 'DisplayingImageEvent')) {
|
||||
$image = $event->get_image();
|
||||
|
||||
$page = $event->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("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));
|
||||
$this->theme->display_page($event->page, $event->get_image());
|
||||
}
|
||||
|
||||
if(is_a($event, 'SetupBuildingEvent')) {
|
||||
|
@ -40,78 +33,6 @@ class ViewImage extends Extension {
|
|||
$event->panel->add_block($sb);
|
||||
}
|
||||
}
|
||||
// }}}
|
||||
// HTML {{{
|
||||
var $pin = null;
|
||||
|
||||
private function build_pin($image_id) {
|
||||
if(!is_null($this->pin)) {
|
||||
return $this->pin;
|
||||
}
|
||||
|
||||
global $database;
|
||||
|
||||
// $next_img = $database->db->GetOne("SELECT id FROM images WHERE id < ? ORDER BY id DESC", array($image_id));
|
||||
// $prev_img = $database->db->GetOne("SELECT id FROM images WHERE id > ? ORDER BY id ASC ", array($image_id));
|
||||
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) ? "<a href='".make_link("post/view/{$prev->id}", $query)."'>Prev</a>" : "Prev");
|
||||
$h_index = "<a href='".make_link("index")."'>Index</a>";
|
||||
$h_next = (!is_null($next) ? "<a href='".make_link("post/view/{$next->id}", $query)."'>Next</a>" : "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 = "
|
||||
<p><form action='".make_link("index")."' method='GET'>
|
||||
<input id='search_input' name='search' type='text'
|
||||
value='Search' autocomplete='off'>
|
||||
<input type='submit' value='Find' style='display: none;'>
|
||||
</form>
|
||||
<div id='search_completions'></div>";
|
||||
|
||||
return "$h_pin<br>$h_search";
|
||||
}
|
||||
|
||||
private function build_image_view($image) {
|
||||
$ilink = $image->get_image_link();
|
||||
return "<img id='main_image' src='$ilink'>";
|
||||
}
|
||||
|
||||
private function build_info($image) {
|
||||
global $user;
|
||||
$owner = $image->get_owner();
|
||||
$h_owner = html_escape($owner->name);
|
||||
$h_ip = html_escape($image->owner_ip);
|
||||
$i_owner_id = int_escape($owner->id);
|
||||
|
||||
$html = "";
|
||||
if(strlen($image->get_short_link()) > 0) {
|
||||
$slink = $image->get_short_link();
|
||||
$html .= "<p>Link: <input size='50' type='text' value='$slink'>";
|
||||
}
|
||||
$html .= "<p>Uploaded by <a href='".make_link("user/$h_owner")."'>$h_owner</a>";
|
||||
if($user->is_admin()) {
|
||||
$html .= " ($h_ip)";
|
||||
}
|
||||
$html .= "<p>".$this->build_pin($image->id);
|
||||
|
||||
return $html;
|
||||
}
|
||||
// }}}
|
||||
}
|
||||
add_event_listener(new ViewImage());
|
||||
?>
|
||||
|
|
Reference in a new issue