Esempio n. 1
0
 /**
  * Show a page of aliases.
  *
  * Note: $can_manage = whether things like "add new alias" should be shown
  *
  * @param array $aliases An array of ($old_tag => $new_tag)
  * @param int $pageNumber
  * @param int $totalPages
  */
 public function display_aliases($aliases, $pageNumber, $totalPages)
 {
     global $page, $user;
     $can_manage = $user->can("manage_alias_list");
     if ($can_manage) {
         $h_action = "<th width='10%'>Action</th>";
         $h_add = "\n\t\t\t\t<tr>\n\t\t\t\t\t" . make_form(make_link("alias/add")) . "\n\t\t\t\t\t\t<td><input type='text' name='oldtag'></td>\n\t\t\t\t\t\t<td><input type='text' name='newtag'></td>\n\t\t\t\t\t\t<td><input type='submit' value='Add'></td>\n\t\t\t\t\t</form>\n\t\t\t\t</tr>\n\t\t\t";
     } else {
         $h_action = "";
         $h_add = "";
     }
     $h_aliases = "";
     foreach ($aliases as $old => $new) {
         $h_old = html_escape($old);
         $h_new = "<a href='" . make_link("post/list/" . url_escape($new) . "/1") . "'>" . html_escape($new) . "</a>";
         $h_aliases .= "<tr><td>{$h_old}</td><td>{$h_new}</td>";
         if ($can_manage) {
             $h_aliases .= "\n\t\t\t\t\t<td>\n\t\t\t\t\t\t" . make_form(make_link("alias/remove")) . "\n\t\t\t\t\t\t\t<input type='hidden' name='oldtag' value='{$h_old}'>\n\t\t\t\t\t\t\t<input type='submit' value='Remove'>\n\t\t\t\t\t\t</form>\n\t\t\t\t\t</td>\n\t\t\t\t";
         }
         $h_aliases .= "</tr>";
     }
     $html = "\n\t\t\t<table id='aliases' class='sortable zebra'>\n\t\t\t\t<thead><tr><th>From</th><th>To</th>{$h_action}</tr></thead>\n\t\t\t\t<tbody>{$h_aliases}</tbody>\n\t\t\t\t<tfoot>{$h_add}</tfoot>\n\t\t\t</table>\n\t\t\t<p><a href='" . make_link("alias/export/aliases.csv") . "'>Download as CSV</a></p>\n\t\t";
     $bulk_html = "\n\t\t\t" . make_form(make_link("alias/import"), 'post', true) . "\n\t\t\t\t<input type='file' name='alias_file'>\n\t\t\t\t<input type='submit' value='Upload List'>\n\t\t\t</form>\n\t\t";
     $page->set_title("Alias List");
     $page->set_heading("Alias List");
     $page->add_block(new NavBlock());
     $page->add_block(new Block("Aliases", $html));
     if ($can_manage) {
         $page->add_block(new Block("Bulk Upload", $bulk_html, "main", 51));
     }
     $this->display_paginator($page, "alias/list", null, $pageNumber, $totalPages);
 }
Esempio n. 2
0
 public function display_table(Page $page, $extensions, $editable)
 {
     $h_en = $editable ? "<th>Enabled</th>" : "";
     $html = "\n\t\t\t" . make_form(make_link("ext_manager/set")) . "\n\t\t\t\t<script type='text/javascript'>\n\t\t\t\t\$(document).ready(function() {\n\t\t\t\t\t\$(\"#extensions\").tablesorter();\n\t\t\t\t});\n\t\t\t\t</script>\n\t\t\t\t<table id='extensions' class='zebra'>\n\t\t\t\t\t<thead>\n\t\t\t\t\t\t<tr>{$h_en}<th>Name</th><th>Description</th></tr>\n\t\t\t\t\t</thead>\n\t\t\t\t\t<tbody>\n\t\t";
     foreach ($extensions as $extension) {
         if (!$editable && $extension->visibility == "admin") {
             continue;
         }
         $h_name = html_escape(empty($extension->name) ? $extension->ext_name : $extension->name);
         $h_description = html_escape($extension->description);
         if ($extension->enabled === TRUE) {
             $h_enabled = " checked='checked'";
         } else {
             if ($extension->enabled === FALSE) {
                 $h_enabled = "";
             } else {
                 $h_enabled = " disabled checked='checked'";
             }
         }
         $h_link = make_link("ext_doc/" . url_escape($extension->ext_name));
         $h_en = $editable ? "<td><input type='checkbox' name='ext_" . html_escape($extension->ext_name) . "'{$h_enabled}></td>" : "";
         $html .= "\n\t\t\t\t<tr>\n\t\t\t\t\t{$h_en}\n\t\t\t\t\t<td><a href='{$h_link}'>{$h_name}</a></td>\n\t\t\t\t\t<td style='text-align: left;'>{$h_description}</td>\n\t\t\t\t</tr>";
     }
     $h_set = $editable ? "<tfoot><tr><td colspan='5'><input type='submit' value='Set Extensions'></td></tr></tfoot>" : "";
     $html .= "\n\t\t\t\t\t</tbody>\n\t\t\t\t\t{$h_set}\n\t\t\t\t</table>\n\t\t\t</form>\n\t\t";
     $page->set_title("Extensions");
     $page->set_heading("Extensions");
     $page->add_block(new NavBlock());
     $page->add_block(new Block("Extension Manager", $html));
 }
Esempio n. 3
0
 /**
  * @param array $images
  * @param array $search_terms
  * @param int $page_number
  */
 private function do_rss($images, $search_terms, $page_number)
 {
     global $page;
     global $config;
     $page->set_mode("data");
     $page->set_type("application/rss+xml");
     $data = "";
     foreach ($images as $image) {
         $data .= $this->thumb($image);
     }
     $title = $config->get_string('title');
     $base_href = make_http(get_base_href());
     $search = "";
     if (count($search_terms) > 0) {
         $search = url_escape(implode(" ", $search_terms)) . "/";
     }
     if ($page_number > 1) {
         $prev_url = make_link("rss/images/{$search}" . ($page_number - 1));
         $prev_link = "<atom:link rel=\"previous\" href=\"{$prev_url}\" />";
     } else {
         $prev_link = "";
     }
     $next_url = make_link("rss/images/{$search}" . ($page_number + 1));
     $next_link = "<atom:link rel=\"next\" href=\"{$next_url}\" />";
     // no end...
     $version = VERSION;
     $xml = "<" . "?xml version=\"1.0\" encoding=\"utf-8\" ?" . ">\n<rss version=\"2.0\" xmlns:media=\"http://search.yahoo.com/mrss\" xmlns:atom=\"http://www.w3.org/2005/Atom\">\n    <channel>\n        <title>{$title}</title>\n        <description>The latest uploads to the image board</description>\n\t\t<link>{$base_href}</link>\n\t\t<generator>Shimmie-{$version}</generator>\n\t\t<copyright>(c) 2007 Shish</copyright>\n\t\t{$prev_link}\n\t\t{$next_link}\n\t\t{$data}\n\t</channel>\n</rss>";
     $page->set_data($xml);
 }
Esempio n. 4
0
 public function display_aliases(Page $page, $aliases, $is_admin, $pageNumber, $totalPages)
 {
     if ($is_admin) {
         $action = "<th width='10%'>Action</th>";
         $add = "\n\t\t\t\t<tr>\n\t\t\t\t\t<form action='" . make_link("alias/add") . "' method='POST'>\n\t\t\t\t\t\t<td><input type='text' name='oldtag'></td>\n\t\t\t\t\t\t<td><input type='text' name='newtag'></td>\n\t\t\t\t\t\t<td><input type='submit' value='Add'></td>\n\t\t\t\t\t</form>\n\t\t\t\t</tr>\n\t\t\t";
     } else {
         $action = "";
         $add = "";
     }
     $h_aliases = "";
     $n = 0;
     foreach ($aliases as $old => $new) {
         $h_old = html_escape($old);
         $h_new = "<a href='" . make_link("post/list/" . url_escape($new) . "/1") . "'>" . html_escape($new) . "</a>";
         $oe = $n++ % 2 == 0 ? "even" : "odd";
         $h_aliases .= "<tr class='{$oe}'><td>{$h_old}</td><td>{$h_new}</td>";
         if ($is_admin) {
             $h_aliases .= "\n\t\t\t\t\t<td>\n\t\t\t\t\t\t<form action='" . make_link("alias/remove") . "' method='POST'>\n\t\t\t\t\t\t\t<input type='hidden' name='oldtag' value='{$h_old}'>\n\t\t\t\t\t\t\t<input type='submit' value='Remove'>\n\t\t\t\t\t\t</form>\n\t\t\t\t\t</td>\n\t\t\t\t";
         }
         $h_aliases .= "</tr>";
     }
     $html = "\n\t\t\t<script>\n\t\t\t\$(document).ready(function() {\n\t\t\t\t\$(\"#aliases\").tablesorter();\n\t\t\t});\n\t\t\t</script>\n\t\t\t<table id='aliases' class='zebra'>\n\t\t\t\t<thead><tr><th>From</th><th>To</th>{$action}</tr></thead>\n\t\t\t\t<tbody>{$h_aliases}</tbody>\n\t\t\t\t<tfoot>{$add}</tfoot>\n\t\t\t</table>\n\t\t\t<p><a href='" . make_link("alias/export/aliases.csv") . "'>Download as CSV</a></p>\n\t\t";
     $bulk_html = "\n\t\t\t<form enctype='multipart/form-data' action='" . make_link("alias/import") . "' method='POST'>\n\t\t\t\t<input type='file' name='alias_file'>\n\t\t\t\t<input type='submit' value='Upload List'>\n\t\t\t</form>\n\t\t";
     $page->set_title("Alias List");
     $page->set_heading("Alias List");
     $page->add_block(new NavBlock());
     $page->add_block(new Block("Aliases", $html));
     if ($is_admin) {
         $page->add_block(new Block("Bulk Upload", $bulk_html, "main", 51));
     }
     $this->display_paginator($page, "alias/list", null, $pageNumber, $totalPages);
 }
Esempio n. 5
0
 /**
  * Returns info about the current page number.
  *
  * @param PageRequestEvent $event
  * @return array
  */
 private function get_list_pageinfo(PageRequestEvent $event)
 {
     global $config, $database;
     // get the amount of images per page
     $images_per_page = $config->get_int('index_images');
     // if there are no tags, use default
     if (is_null($event->get_arg(1))) {
         $prefix = "";
         $page_number = int_escape($event->get_arg(0));
         $total_pages = ceil($database->get_one("SELECT COUNT(*) FROM images") / $images_per_page);
     } else {
         // if there are tags, use pages with tags
         $prefix = url_escape($event->get_arg(0)) . "/";
         $page_number = int_escape($event->get_arg(1));
         $total_pages = ceil($database->get_one("SELECT count FROM tags WHERE tag=:tag", array("tag" => $event->get_arg(0))) / $images_per_page);
     }
     // creates previous & next values
     // When previous first page, go to last page
     if ($page_number <= 1) {
         $prev = $total_pages;
     } else {
         $prev = $page_number - 1;
     }
     if ($page_number >= $total_pages) {
         $next = 1;
     } else {
         $next = $page_number + 1;
     }
     // Create return array
     $pageinfo = array("prev" => $prefix . $prev, "next" => $prefix . $next);
     return $pageinfo;
 }
Esempio n. 6
0
 /**
  * @param Page $page
  * @param Image[] $images
  */
 public function display_page(Page $page, $images)
 {
     global $config;
     if (count($this->search_terms) == 0) {
         $query = null;
         $page_title = $config->get_string('title');
     } else {
         $search_string = implode(' ', $this->search_terms);
         $query = url_escape($search_string);
         $page_title = html_escape($search_string);
     }
     $nav = $this->build_navigation($this->page_number, $this->total_pages, $this->search_terms);
     $page->set_title($page_title);
     $page->set_heading($page_title);
     $page->add_block(new Block("Search", $nav, "left", 0));
     if (count($images) > 0) {
         if ($query) {
             $page->add_block(new Block("Images", $this->build_table($images, "search={$query}"), "main", 10));
             $this->display_paginator($page, "post/list/{$query}", null, $this->page_number, $this->total_pages);
         } else {
             $page->add_block(new Block("Images", $this->build_table($images, null), "main", 10));
             $this->display_paginator($page, "post/list", null, $this->page_number, $this->total_pages);
         }
     } else {
         $page->add_block(new Block("No Images Found", "No images were found to match the search criteria"));
     }
 }
Esempio n. 7
0
    /**
     * @param Page $page
     * @param array $history
     * @param int $page_number
     */
    public function display_global_page(Page $page, $history, $page_number)
    {
        $start_string = "\n\t\t\t<div style='text-align: left'>\n\t\t\t\t" . make_form(make_link("tag_history/revert")) . "\n\t\t\t\t\t<ul style='list-style-type:none;'>\n\t\t";
        $end_string = "\n\t\t\t\t\t</ul>\n\t\t\t\t\t<input type='submit' value='Revert To'>\n\t\t\t\t</form>\n\t\t\t</div>\n\t\t";
        global $user;
        $history_list = "";
        foreach ($history as $fields) {
            $current_id = $fields['id'];
            $image_id = $fields['image_id'];
            $current_tags = html_escape($fields['tags']);
            $name = $fields['name'];
            $h_ip = $user->can("view_ip") ? " " . show_ip($fields['user_ip'], "Tagging Image #{$image_id} as '{$current_tags}'") : "";
            $setter = "<a href='" . make_link("user/" . url_escape($name)) . "'>" . html_escape($name) . "</a>{$h_ip}";
            $history_list .= '
				<li>
					<input type="radio" name="revert" value="' . $current_id . '">
					<a href="' . make_link('post/view/' . $image_id) . '">' . $image_id . '</a>:
					' . $current_tags . ' (Set by ' . $setter . ')
				</li>
			';
        }
        $history_html = $start_string . $history_list . $end_string;
        $page->set_title("Global Tag History");
        $page->set_heading("Global Tag History");
        $page->add_block(new Block("Tag History", $history_html, "main", 10));
        $h_prev = $page_number <= 1 ? "Prev" : '<a href="' . make_link('tag_history/all/' . ($page_number - 1)) . '">Prev</a>';
        $h_index = "<a href='" . make_link() . "'>Index</a>";
        $h_next = '<a href="' . make_link('tag_history/all/' . ($page_number + 1)) . '">Next</a>';
        $nav = $h_prev . ' | ' . $h_index . ' | ' . $h_next;
        $page->add_block(new Block("Navigation", $nav, "left"));
    }
Esempio n. 8
0
 public function display_pms(Page $page, $pms)
 {
     global $user;
     $html = "\n\t\t\t<script type='text/javascript'>\n\t\t\t\$(document).ready(function() {\n\t\t\t\t\$(\"#pms\").tablesorter();\n\t\t\t});\n\t\t\t</script>\n\t\t\t<table id='pms' class='zebra'>\n\t\t\t\t<thead><tr><th>Subject</th><th>From</th><th>Date</th><th>Action</th></tr></thead>\n\t\t\t\t<tbody>";
     $n = 0;
     foreach ($pms as $pm) {
         $oe = $n++ % 2 == 0 ? "even" : "odd";
         $h_subject = html_escape($pm->subject);
         if (strlen(trim($h_subject)) == 0) {
             $h_subject = "(No subject)";
         }
         $from_name = User::by_id($pm->from_id)->name;
         $h_from = html_escape($from_name);
         $from_url = make_link("user/" . url_escape($from_name));
         $pm_url = make_link("pm/read/" . $pm->id);
         $del_url = make_link("pm/delete");
         $h_date = html_escape($pm->sent_date);
         if ($pm->is_read) {
             $h_subject = "<b>{$h_subject}</b>";
         }
         $html .= "<tr class='{$oe}'><td><a href='{$pm_url}'>{$h_subject}</a></td>\n\t\t\t<td><a href='{$from_url}'>{$h_from}</a></td><td>{$h_date}</td>\n\t\t\t<td><form action='{$del_url}' method='POST'>\n\t\t\t\t<input type='hidden' name='pm_id' value='{$pm->id}'>\n\t\t\t\t" . $user->get_auth_html() . "\n\t\t\t\t<input type='submit' value='Delete'>\n\t\t\t</form></td></tr>";
     }
     $html .= "\n\t\t\t\t</tbody>\n\t\t\t</table>\n\t\t";
     $page->add_block(new Block("Private Messages", $html, "main", 10));
 }
Esempio n. 9
0
 public function display_events($events)
 {
     $table = "\n<style>\n.sizedinputs TD INPUT {\n\twidth: 100%;\n}\n</style>\n<table class='zebra'>\n\t<thead>\n\t\t<tr><th>Time</th><th>Module</th><th>User</th><th>Message</th></tr>\n\t\t<form action='" . make_link("log/view") . "' method='GET'>\n\t\t\t<tr class='sizedinputs'>\n\t\t\t\t<td><input type='text' name='time' value='" . $this->heie("time") . "'></td>\n\t\t\t\t<td><input type='text' name='module' value='" . $this->heie("module") . "'></td>\n\t\t\t\t<td><input type='text' name='user' value='" . $this->heie("user") . "'></td>\n\t\t\t\t<td>\n\t\t\t\t\t<select name='priority'>\n\t\t\t\t\t\t<option value='" . SCORE_LOG_DEBUG . "'>Debug</option>\n\t\t\t\t\t\t<option value='" . SCORE_LOG_INFO . "' selected>Info</option>\n\t\t\t\t\t\t<option value='" . SCORE_LOG_WARNING . "'>Warning</option>\n\t\t\t\t\t\t<option value='" . SCORE_LOG_ERROR . "'>Error</option>\n\t\t\t\t\t\t<option value='" . SCORE_LOG_CRITICAL . "'>Critical</option>\n\t\t\t\t\t</select>\n\t\t\t\t\t<input type='submit' value='Search' style='width: 20%'>\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t</form>\n\t</thead>\n\t<tbody>\n";
     $n = 0;
     foreach ($events as $event) {
         $oe = $n++ % 2 == 0 ? "even" : "odd";
         $c = $this->pri_to_col($event['priority']);
         $table .= "<tr style='color: {$c}' class='{$oe}'>";
         $table .= "<td>" . str_replace(" ", "&nbsp;", $event['date_sent']) . "</td>";
         $table .= "<td>" . $event['section'] . "</td>";
         if ($event['username'] == "Anonymous") {
             $table .= "<td>" . $event['address'] . "</td>";
         } else {
             $table .= "<td><span title='" . $event['address'] . "'>" . "<a href='" . make_link("user/" . url_escape($event['username'])) . "'>" . html_escape($event['username']) . "</a>" . "</span></td>";
         }
         $table .= "<td>" . $this->scan_entities(html_escape($event['message'])) . "</td>";
         $table .= "</tr>\n";
     }
     $table .= "</tbody></table>";
     global $page;
     $page->set_title("Event Log");
     $page->set_heading("Event Log");
     $page->add_block(new NavBlock());
     $page->add_block(new Block("Events", $table));
 }
Esempio n. 10
0
 public function display_pms(Page $page, $pms)
 {
     global $user;
     $html = "\n\t\t\t<table id='pms' class='zebra sortable'>\n\t\t\t\t<thead><tr><th>R?</th><th>Subject</th><th>From</th><th>Date</th><th>Action</th></tr></thead>\n\t\t\t\t<tbody>";
     foreach ($pms as $pm) {
         $h_subject = html_escape($pm->subject);
         if (strlen(trim($h_subject)) == 0) {
             $h_subject = "(No subject)";
         }
         $from = User::by_id($pm->from_id);
         $from_name = $from->name;
         $h_from = html_escape($from_name);
         $from_url = make_link("user/" . url_escape($from_name));
         $pm_url = make_link("pm/read/" . $pm->id);
         $del_url = make_link("pm/delete");
         $h_date = html_escape($pm->sent_date);
         $readYN = "Y";
         if (!$pm->is_read) {
             $h_subject = "<b>{$h_subject}</b>";
             $readYN = "N";
         }
         $hb = $from->can("hellbanned") ? "hb" : "";
         $html .= "<tr class='{$hb}'>\n\t\t\t<td>{$readYN}</td>\n\t\t\t<td><a href='{$pm_url}'>{$h_subject}</a></td>\n\t\t\t<td><a href='{$from_url}'>{$h_from}</a></td><td>{$h_date}</td>\n\t\t\t<td><form action='{$del_url}' method='POST'>\n\t\t\t\t<input type='hidden' name='pm_id' value='{$pm->id}'>\n\t\t\t\t" . $user->get_auth_html() . "\n\t\t\t\t<input type='submit' value='Delete'>\n\t\t\t</form></td>\n\t\t\t</tr>";
     }
     $html .= "\n\t\t\t\t</tbody>\n\t\t\t</table>\n\t\t";
     $page->add_block(new Block("Private Messages", $html, "main", 40, "private-messages"));
 }
Esempio n. 11
0
 public function display_image(Page $page, Image $image)
 {
     $data_href = get_base_href();
     $ilink = $image->get_image_link();
     $fname = url_escape($image->filename);
     //Most of the time this will be the title/artist of the song.
     $html = "\n\t\t\t<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'\n\t\t\t        codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0'\n\t\t\t\t\twidth='400' height='15'>\n\t\t\t\t<param name='movie' value='{$data_href}/ext/handle_mp3/xspf_player_slim.swf?song_url={$ilink}'/>\n\t\t\t\t<param name='quality' value='high' />\n\t\t\t\t<embed src='{$data_href}/ext/handle_mp3/xspf_player_slim.swf?song_url={$ilink}&song_title={$fname}' quality='high'\n\t\t\t\t\tpluginspage='http://www.macromedia.com/go/getflashplayer'\n\t\t\t\t\twidth='400' height='15'\n\t\t\t\t\ttype='application/x-shockwave-flash'></embed>\n\t\t\t</object>\n\t\t\t<p><a href='{$ilink}'>Download</a>";
     $page->add_block(new Block("Music", $html, "main", 10));
 }
Esempio n. 12
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++));
     }
 }
Esempio n. 13
0
 public function receive_event(Event $event)
 {
     global $config, $database, $page, $user;
     if (is_null($this->theme)) {
         $this->theme = get_theme_object($this);
     }
     if (is_a($event, 'PageRequestEvent') && ($event->page_matches("post/prev") || $event->page_matches("post/next"))) {
         $image_id = int_escape($event->get_arg(0));
         if (isset($_GET['search'])) {
             $search_terms = explode(' ', $_GET['search']);
             $query = "search=" . url_escape($_GET['search']);
         } else {
             $search_terms = array();
             $query = null;
         }
         $image = Image::by_id($image_id);
         if ($event->page_matches("post/next")) {
             $image = $image->get_next($search_terms);
         } else {
             $image = $image->get_prev($search_terms);
         }
         if (!is_null($image)) {
             $page->set_mode("redirect");
             $page->set_redirect(make_link("post/view/{$image->id}", $query));
         } else {
             $this->theme->display_error($page, "Image not found", "No more images");
         }
     }
     if ($event instanceof PageRequestEvent && $event->page_matches("post/view")) {
         $image_id = int_escape($event->get_arg(0));
         $image = Image::by_id($image_id);
         if (!is_null($image)) {
             send_event(new DisplayingImageEvent($image));
             $iabbe = new ImageAdminBlockBuildingEvent($image, $user);
             send_event($iabbe);
             ksort($iabbe->parts);
             $this->theme->display_admin_block($page, $iabbe->parts);
         } else {
             $this->theme->display_error($page, "Image not found", "No image in the database has the ID #{$image_id}");
         }
     }
     if ($event instanceof PageRequestEvent && $event->page_matches("post/set")) {
         $image_id = int_escape($_POST['image_id']);
         send_event(new ImageInfoSetEvent(Image::by_id($image_id)));
         $query = $_POST['query'];
         $page->set_mode("redirect");
         $page->set_redirect(make_link("post/view/{$image_id}", $query));
     }
     if ($event instanceof DisplayingImageEvent) {
         $iibbe = new ImageInfoBoxBuildingEvent($event->get_image(), $user);
         send_event($iibbe);
         ksort($iibbe->parts);
         $this->theme->display_page($page, $event->get_image(), $iibbe->parts);
     }
 }
Esempio n. 14
0
 protected function display_page_images(Page $page, $images)
 {
     if (count($this->search_terms) > 0) {
         $query = url_escape(implode(' ', $this->search_terms));
         $page->add_block(new Block("Images", $this->build_table($images, "#search={$query}"), "main", 10, "image-list"));
         $this->display_paginator($page, "post/list/{$query}", null, $this->page_number, $this->total_pages);
     } else {
         $page->add_block(new Block("Images", $this->build_table($images, null), "main", 10, "image-list"));
         $this->display_paginator($page, "post/list", null, $this->page_number, $this->total_pages);
     }
 }
Esempio n. 15
0
 protected function create_edit_html(WikiPage $page)
 {
     $h_title = html_escape($page->title);
     $u_title = url_escape($page->title);
     $i_revision = int_escape($page->revision) + 1;
     global $user;
     if ($user->is_admin()) {
         $val = $page->is_locked() ? " checked" : "";
         $lock = "<br>Lock page: <input type='checkbox' name='lock'{$val}>";
     } else {
         $lock = "";
     }
     return "\n\t\t\t" . make_form(make_link("wiki_admin/save")) . "\n\t\t\t\t<input type='hidden' name='title' value='{$h_title}'>\n\t\t\t\t<input type='hidden' name='revision' value='{$i_revision}'>\n\t\t\t\t<textarea name='body' style='width: 100%' rows='20'>" . html_escape($page->body) . "</textarea>\n\t\t\t\t{$lock}\n\t\t\t\t<br><input type='submit' value='Save'>\n\t\t\t</form>\n\t\t";
 }
Esempio n. 16
0
 public function get_tag_editor_html(Image $image)
 {
     global $user;
     $tag_links = array();
     foreach ($image->get_tag_array() as $tag) {
         $h_tag = html_escape($tag);
         $u_tag = url_escape($tag);
         $h_link = make_link("post/list/{$u_tag}/1");
         $tag_links[] = "<a href='{$h_link}'>{$h_tag}</a>";
     }
     $h_tag_links = implode(" ", $tag_links);
     $h_tags = html_escape($image->get_tag_list());
     return "\n\t\t\t<tr>\n\t\t\t\t<th width='50px'>Tags</th>\n\t\t\t\t<td>\n\t\t" . ($user->can("edit_image_tag") ? "\n\t\t\t\t\t<span class='view'>{$h_tag_links}</span>\n\t\t\t\t\t<input class='edit autocomplete_tags' type='text' name='tag_edit__tags' value='{$h_tags}' id='tag_editor' autocomplete='off'>\n\t\t" : "\n\t\t\t\t\t{$h_tag_links}\n\t\t") . "\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t";
 }
Esempio n. 17
0
 protected function build_navigation($page_number, $total_pages, $search_terms)
 {
     $prev = $page_number - 1;
     $next = $page_number + 1;
     $u_tags = url_escape(implode(" ", $search_terms));
     $query = empty($u_tags) ? "" : "/{$u_tags}";
     $h_prev = $page_number <= 1 ? "Prev" : "<a href='" . make_link("post/list{$query}/{$prev}") . "'>Prev</a>";
     $h_index = "<a href='" . make_link() . "'>Index</a>";
     $h_next = $page_number >= $total_pages ? "Next" : "<a href='" . make_link("post/list{$query}/{$next}") . "'>Next</a>";
     $h_search_string = html_escape(implode(" ", $search_terms));
     $h_search_link = make_link();
     $h_search = "\n\t\t\t<script><!--\n\t\t\t\$(document).ready(function() {\n\t\t\t\t\$(\"#search_input\").DefaultValue(\"Search\");\n\t\t\t});\n\t\t\t//--></script>\n\t\t\t<p><form action='{$h_search_link}' method='GET'>\n\t\t\t\t<input id='search_input' name='search' type='text'\n\t\t\t\t\t\tvalue='{$h_search_string}' autocomplete='off' />\n\t\t\t\t<input type='hidden' name='q' value='/post/list'>\n\t\t\t\t<input type='submit' value='Find' style='display: none;' />\n\t\t\t</form>\n\t\t\t<div id='search_completions'></div>";
     return "{$h_prev} | {$h_index} | {$h_next}<br>{$h_search}";
 }
Esempio n. 18
0
 protected function build_pin(Image $image)
 {
     if (isset($_GET['search'])) {
         $search_terms = explode(' ', $_GET['search']);
         $query = "search=" . url_escape($_GET['search']);
     } else {
         $search_terms = array();
         $query = null;
     }
     $h_prev = "<a id='prevlink' href='" . make_link("post/prev/{$image->id}", $query) . "'>Prev</a>";
     $h_index = "<a href='" . make_link() . "'>Index</a>";
     $h_next = "<a id='nextlink' href='" . make_link("post/next/{$image->id}", $query) . "'>Next</a>";
     return "{$h_prev} | {$h_index} | {$h_next}";
 }
Esempio n. 19
0
 protected function build_navigation($page_number, $total_pages, $search_terms)
 {
     $prev = $page_number - 1;
     $next = $page_number + 1;
     $u_tags = url_escape(implode(" ", $search_terms));
     $query = empty($u_tags) ? "" : "/{$u_tags}";
     $h_prev = $page_number <= 1 ? "Prev" : "<a href='" . make_link("post/list{$query}/{$prev}") . "'>Prev</a>";
     $h_index = "<a href='" . make_link() . "'>Index</a>";
     $h_next = $page_number >= $total_pages ? "Next" : "<a href='" . make_link("post/list{$query}/{$next}") . "'>Next</a>";
     $h_search_string = html_escape(implode(" ", $search_terms));
     $h_search_link = make_link();
     $h_search = "\n\t\t\t<script><!--\n\t\t\t\$(document).ready(function() {\n\t\t\t\t\$('#search_input').DefaultValue('Search');\n\t\t\t\t\$('#search_input').autocomplete('" . make_link("api/internal/tag_list/complete") . "', {\n\t\t\t\t\twidth: 320,\n\t\t\t\t\tmax: 15,\n\t\t\t\t\thighlight: false,\n\t\t\t\t\tmultiple: true,\n\t\t\t\t\tmultipleSeparator: ' ',\n\t\t\t\t\tscroll: true,\n\t\t\t\t\tscrollHeight: 300,\n\t\t\t\t\tselectFirst: false\n\t\t\t\t});\n\t\t\t});\n\t\t\t//--></script>\n\t\t\t<p><form action='{$h_search_link}' method='GET'>\n\t\t\t\t<input id='search_input' name='search' type='text'\n\t\t\t\t\t\tvalue='{$h_search_string}' autocomplete='off' />\n\t\t\t\t<input type='hidden' name='q' value='/post/list'>\n\t\t\t\t<input type='submit' value='Find' style='display: none;' />\n\t\t\t</form>\n\t\t\t<div id='search_completions'></div>";
     return "{$h_prev} | {$h_index} | {$h_next}<br>{$h_search}";
 }
Esempio n. 20
0
 protected function build_pin(Image $image)
 {
     global $database;
     if (isset($_GET['search'])) {
         $search_terms = explode(' ', $_GET['search']);
         $query = "search=" . url_escape($_GET['search']);
     } else {
         $search_terms = array();
         $query = null;
     }
     $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>';
     return $h_prev . $h_index . $h_next;
 }
Esempio n. 21
0
 public function display_user_list(Page $page, $users, User $user)
 {
     $page->set_title("User List");
     $page->set_heading("User List");
     $page->add_block(new NavBlock());
     $html = "<table>";
     $html .= "<tr><td>Name</td></tr>";
     foreach ($users as $duser) {
         $html .= "<tr>";
         $html .= "<td><a href='" . make_link("user/" . url_escape($duser->name)) . "'>" . html_escape($duser->name) . "</a></td>";
         $html .= "</tr>";
     }
     $html .= "</table>";
     $page->add_block(new Block("Users", $html));
 }
Esempio n. 22
0
 protected function build_image_editor(Image $image, $editor_parts)
 {
     if (count($editor_parts) == 0) {
         return $image->is_locked() ? "<br>[Image Locked]" : "";
     }
     if (isset($_GET['search'])) {
         $h_query = "search=" . url_escape($_GET['search']);
     } else {
         $h_query = "";
     }
     $html = " (<a href=\"javascript: toggle('imgdata')\">edit info</a>)";
     $html .= "\n\t\t\t<div id='imgdata'>\n\t\t\t\t<form action='" . make_link("post/set") . "' method='POST'>\n\t\t\t\t\t<input type='hidden' name='image_id' value='{$image->id}'>\n\t\t\t\t\t<input type='hidden' name='query' value='{$h_query}'>\n\t\t\t\t\t<table style='width: 500px;'>\n\t\t";
     foreach ($editor_parts as $part) {
         $html .= $part;
     }
     $html .= "\n\t\t\t\t\t\t<tr><td colspan='2'><input type='submit' value='Set'></td></tr>\n\t\t\t\t\t</table>\n\t\t\t\t</form>\n\t\t\t\t<br>\n\t\t\t</div>\n\t\t";
     return $html;
 }
Esempio n. 23
0
 public function display_events($events, $page_num, $page_total)
 {
     $table = "\n<style>\n.sizedinputs TD INPUT {\n\twidth: 100%;\n}\n</style>\n<table class='zebra'>\n\t<thead>\n\t\t<tr><th>Time</th><th>Module</th><th>User</th><th colspan='2'>Message</th></tr>\n\t\t<form action='" . make_link("log/view") . "' method='GET'>\n\t\t\t<tr class='sizedinputs'>\n\t\t\t\t<td><input type='time' name='time' value='" . $this->heie("time") . "'></td>\n\t\t\t\t<td><input type='text' name='module' value='" . $this->heie("module") . "'></td>\n\t\t\t\t<td><input type='text' name='user' value='" . $this->heie("user") . "'></td>\n\t\t\t\t<td>\n\t\t\t\t\t<select name='priority'>\n\t\t\t\t\t\t<option value='" . SCORE_LOG_DEBUG . "'>Debug</option>\n\t\t\t\t\t\t<option value='" . SCORE_LOG_INFO . "' selected>Info</option>\n\t\t\t\t\t\t<option value='" . SCORE_LOG_WARNING . "'>Warning</option>\n\t\t\t\t\t\t<option value='" . SCORE_LOG_ERROR . "'>Error</option>\n\t\t\t\t\t\t<option value='" . SCORE_LOG_CRITICAL . "'>Critical</option>\n\t\t\t\t\t</select>\n\t\t\t\t</td>\n\t\t\t\t<td><input type='submit' value='Search'></td>\n\t\t\t</tr>\n\t\t</form>\n\t</thead>\n\t<tbody>\n";
     reset($events);
     // rewind to first element in array.
     foreach ($events as $event) {
         $c = $this->pri_to_col($event['priority']);
         $table .= "<tr style='color: {$c}'>";
         $table .= "<td>" . str_replace(" ", "&nbsp;", substr($event['date_sent'], 0, 19)) . "</td>";
         $table .= "<td>" . $event['section'] . "</td>";
         if ($event['username'] == "Anonymous") {
             $table .= "<td>" . $event['address'] . "</td>";
         } else {
             $table .= "<td><span title='" . $event['address'] . "'>" . "<a href='" . make_link("user/" . url_escape($event['username'])) . "'>" . html_escape($event['username']) . "</a>" . "</span></td>";
         }
         $table .= "<td colspan='2'>" . $this->scan_entities(html_escape($event['message'])) . "</td>";
         $table .= "</tr>\n";
     }
     $table .= "</tbody></table>";
     global $page;
     $page->set_title("Event Log");
     $page->set_heading("Event Log");
     $page->add_block(new NavBlock());
     $page->add_block(new Block("Events", $table));
     $args = "";
     // Check if each arg is actually empty and skip it if so
     if (strlen($this->ueie("time"))) {
         $args .= $this->ueie("time") . "&";
     }
     if (strlen($this->ueie("module"))) {
         $args .= $this->ueie("module") . "&";
     }
     if (strlen($this->ueie("user"))) {
         $args .= $this->ueie("user") . "&";
     }
     if (strlen($this->ueie("priority"))) {
         $args .= $this->ueie("priority");
     }
     // If there are no args at all, set $args to null to prevent an unnecessary ? at the end of the paginator url
     if (strlen($args) == 0) {
         $args = null;
     }
     $this->display_paginator($page, "log/view", $args, $page_num, $page_total);
 }
Esempio n. 24
0
 public function display_global_page(Page $page, $history)
 {
     $start_string = "\n\t\t\t<div style='text-align: left'>\n\t\t\t\t<form enctype='multipart/form-data' action='" . make_link("tag_history/revert") . "' method='POST'>\n\t\t\t\t\t<ul style='list-style-type:none;'>\n\t\t";
     $end_string = "\n\t\t\t\t\t</ul>\n\t\t\t\t\t<input type='submit' value='Revert'>\n\t\t\t\t</form>\n\t\t\t</div>\n\t\t";
     global $user;
     $history_list = "";
     foreach ($history as $fields) {
         $current_id = $fields['id'];
         $image_id = $fields['image_id'];
         $current_tags = html_escape($fields['tags']);
         $name = $fields['name'];
         $setter = "<a href='" . make_link("user/" . url_escape($name)) . "'>" . html_escape($name) . "</a>";
         if ($user->is_admin()) {
             $setter .= " / " . $fields['user_ip'];
         }
         $history_list .= "\n\t\t\t\t<li>\n\t\t\t\t\t<input type='radio' name='revert' value='{$current_id}'>\n\t\t\t\t\t<a href='" . make_link("post/view/{$image_id}") . "'>{$image_id}</a>:\n\t\t\t\t\t{$current_tags} (Set by {$setter})\n\t\t\t\t</li>\n\t\t\t";
     }
     $history_html = $start_string . $history_list . $end_string;
     $page->set_title("Global Tag History");
     $page->set_heading("Global Tag History");
     $page->add_block(new NavBlock());
     $page->add_block(new Block("Tag History", $history_html, "main", 10));
 }
Esempio n. 25
0
    private function html(Image $image)
    {
        global $config;
        $i_image_id = int_escape($image->id);
        $h_source = html_escape($image->source);
        $h_query = isset($_GET['search']) ? $h_query = "search=" . url_escape($_GET['search']) : "";
        $delay = $config->get_string("ext_tagger_search_delay", "250");
        $url_form = make_link("tag_edit/set");
        // TODO: option for initial Tagger window placement.
        $html = <<<EOD
<div id="tagger_parent" style="display:none; top:25px; right:25px;">
\t<div id="tagger_titlebar">Tagger</div>

\t<div id="tagger_toolbar">
\t\t<input type="text" value="" id="tagger_filter" onkeyup="Tagger.tag.search(this.value, {$delay});"></input>
\t\t<input type="button" value="Add" onclick="Tagger.tag.create(byId('tagger_filter').value);"></input>
\t\t<form action="{$url_form}" method="POST" onsubmit="Tagger.tag.submit();">
\t\t\t<input type='hidden' name='image_id' value='{$i_image_id}' id="image_id"></input>
\t\t\t<input type='hidden' name='query' value='{$h_query}'></input>
\t\t\t<input type='hidden' name='source' value='{$h_source}'></input>
\t\t\t<input type="hidden" name="tags" value="" id="tagger_tags"></input>

\t\t\t<input type="submit" value="Set"></input>
\t\t</form>
\t\t<!--<ul id="tagger_p-menu"></ul>
\t\t<br style="clear:both;"/>-->
\t</div>

\t<div id="tagger_body">
\t\t<div id="tagger_p-search" name="Searched Tags"></div>
\t\t<div id="tagger_p-applied" name="Applied Tags"></div>
\t</div>
\t<div id="tagger_statusbar"></div>
</div>
EOD;
        return $html;
    }
Esempio n. 26
0
 private function do_rss($images, $search_terms, $page_number)
 {
     global $page;
     global $config;
     $page->set_mode("data");
     $page->set_type("application/rss+xml");
     $data = "";
     foreach ($images as $image) {
         $link = make_http(make_link("post/view/{$image->id}"));
         $tags = html_escape($image->get_tag_list());
         $owner = $image->get_owner();
         $thumb_url = $image->get_thumb_link();
         $image_url = $image->get_image_link();
         $posted = date(DATE_RSS, $image->posted_timestamp);
         $content = html_escape("<p>" . Themelet::build_thumb_html($image) . "</p>" . "<p>Uploaded by " . html_escape($owner->name) . "</p>");
         $data .= "\n\t\t<item>\n\t\t\t<title>{$image->id} - {$tags}</title>\n\t\t\t<link>{$link}</link>\n\t\t\t<guid isPermaLink=\"true\">{$link}</guid>\n\t\t\t<pubDate>{$posted}</pubDate>\n\t\t\t<description>{$content}</description>\n\t\t\t<media:thumbnail url=\"{$thumb_url}\"/>\n\t\t\t<media:content url=\"{$image_url}\"/>\n\t\t</item>\n\t\t\t";
     }
     $title = $config->get_string('title');
     $base_href = make_http($config->get_string('base_href'));
     $search = "";
     if (count($search_terms) > 0) {
         $search = url_escape(implode(" ", $search_terms)) . "/";
     }
     if ($page_number > 1) {
         $prev_url = make_link("rss/images/{$search}" . ($page_number - 1));
         $prev_link = "<atom:link rel=\"previous\" href=\"{$prev_url}\" />";
     } else {
         $prev_link = "";
     }
     $next_url = make_link("rss/images/{$search}" . ($page_number + 1));
     $next_link = "<atom:link rel=\"next\" href=\"{$next_url}\" />";
     // no end...
     $version = VERSION;
     $xml = "<" . "?xml version=\"1.0\" encoding=\"utf-8\" ?" . ">\n<rss version=\"2.0\" xmlns:media=\"http://search.yahoo.com/mrss\" xmlns:atom=\"http://www.w3.org/2005/Atom\">\n    <channel>\n        <title>{$title}</title>\n        <description>The latest uploads to the image board</description>\n\t\t<link>{$base_href}</link>\n\t\t<generator>Shimmie-{$version}</generator>\n\t\t<copyright>(c) 2007 Shish</copyright>\n\t\t{$prev_link}\n\t\t{$next_link}\n\t\t{$data}\n\t</channel>\n</rss>";
     $page->set_data($xml);
 }
Esempio n. 27
0
 /**
  * @param string $tag
  * @return string
  */
 private function tag_link($tag)
 {
     $u_tag = url_escape($tag);
     return make_link("post/list/{$u_tag}/1");
 }
Esempio n. 28
0
 public function show_history($histories, $pageNumber, $totalPages)
 {
     global $page;
     $html = "<table id='poolsList' class='zebra'>" . "<thead><tr>" . "<th>Pool</th>" . "<th>Post Count</th>" . "<th>Changes</th>" . "<th>Updater</th>" . "<th>Date</th>" . "<th>Action</th>" . "</tr></thead>";
     $n = 0;
     foreach ($histories as $history) {
         $oe = $n++ % 2 == 0 ? "even" : "odd";
         $pool_link = "<a href='" . make_link("pool/view/" . $history['pool_id']) . "'>" . html_escape($history['title']) . "</a>";
         $user_link = "<a href='" . make_link("user/" . url_escape($history['user_name'])) . "'>" . html_escape($history['user_name']) . "</a>";
         $revert_link = "<a href='" . make_link("pool/revert/" . $history['id']) . "'>Revert</a>";
         if ($history['action'] == 1) {
             $prefix = "+";
         } elseif ($history['action'] == 0) {
             $prefix = "-";
         }
         $images = trim($history['images']);
         $images = explode(" ", $images);
         $image_link = "";
         foreach ($images as $image) {
             $image_link .= "<a href='" . make_link("post/view/" . $image) . "'>" . $prefix . $image . " </a>";
         }
         $html .= "<tr class='{$oe}'>" . "<td class='left'>" . $pool_link . "</td>" . "<td>" . $history['count'] . "</td>" . "<td>" . $image_link . "</td>" . "<td>" . $user_link . "</td>" . "<td>" . $history['date'] . "</td>" . "<td>" . $revert_link . "</td>" . "</tr>";
     }
     $html .= "</tbody></table>";
     $page->set_title("Recent Changes");
     $page->set_heading("Recent Changes");
     $page->add_block(new Block("Recent Changes", $html, "main", 10));
     $this->display_paginator($page, "pool/updated", null, $pageNumber, $totalPages);
 }
Esempio n. 29
0
    public function display_page($page)
    {
        global $config, $user;
        $theme_name = $config->get_string('theme');
        $base_href = $config->get_string('base_href');
        $data_href = get_base_href();
        $contact_link = $config->get_string('contact_link');
        $header_html = "";
        ksort($page->headers);
        foreach ($page->headers as $line) {
            $header_html .= "\t\t{$line}\n";
        }
        $left_block_html = "";
        $user_block_html = "";
        $main_block_html = "";
        $sub_block_html = "";
        foreach ($page->blocks as $block) {
            switch ($block->section) {
                case "left":
                    $left_block_html .= $this->block_to_html($block, true);
                    break;
                case "user":
                    $user_block_html .= $block->body;
                    // $this->block_to_html($block, true);
                    break;
                case "subheading":
                    $sub_block_html .= $block->body;
                    // $this->block_to_html($block, true);
                    break;
                case "main":
                    if ($block->header == "Images") {
                        $block->header = "&nbsp;";
                    }
                    $main_block_html .= $this->block_to_html($block, false);
                    break;
                default:
                    print "<p>error: {$block->header} using an unknown section ({$block->section})";
                    break;
            }
        }
        $debug = get_debug_info();
        $contact = empty($contact_link) ? "" : "<br><a href='{$contact_link}'>Contact</a>";
        if (empty($this->subheading)) {
            $subheading = "";
        } else {
            $subheading = "<div id='subtitle'>{$this->subheading}</div>";
        }
        $site_name = $config->get_string('title');
        // bzchan: change from normal default to get title for top of page
        $main_page = $config->get_string('main_page');
        // bzchan: change from normal default to get main page for top of page
        // bzchan: CUSTOM LINKS are prepared here, change these to whatever you like
        $custom_links = "";
        if ($user->is_anonymous()) {
            $custom_links .= $this->navlinks(make_link('user_admin/login'), "My Account", array("user", "user_admin", "setup", "admin"));
        } else {
            $custom_links .= $this->navlinks(make_link('user'), "My Account", array("user", "user_admin", "setup", "admin"));
        }
        $custom_links .= $this->navlinks(make_link('post/list'), "Posts", array("post"));
        $custom_links .= $this->navlinks(make_link('comment/list'), "Comments", array("comment"));
        $custom_links .= $this->navlinks(make_link('tags'), "Tags", array("tags"));
        if (class_exists("Pools")) {
            $custom_links .= $this->navlinks(make_link('pool/list'), "Pools", array("pool"));
        }
        $custom_links .= $this->navlinks(make_link('upload'), "Upload", array("upload"));
        if (class_exists("Wiki")) {
            $custom_links .= $this->navlinks(make_link('wiki'), "Wiki", array("wiki"));
            $custom_links .= $this->navlinks(make_link('wiki/more'), "More &raquo;", array("wiki/more"));
        }
        $custom_sublinks = "";
        // hack
        global $user;
        $username = url_escape($user->name);
        // hack
        $qp = _get_query_parts();
        $hw = class_exists("Wiki");
        // php sucks
        switch ($qp[0]) {
            default:
                $custom_sublinks .= $user_block_html;
                break;
            case "":
                # FIXME: this assumes that the front page is
                # post/list; in 99% of case it will either be
                # post/list or home, and in the latter case
                # the subnav links aren't shown, but it would
                # be nice to be correct
            # FIXME: this assumes that the front page is
            # post/list; in 99% of case it will either be
            # post/list or home, and in the latter case
            # the subnav links aren't shown, but it would
            # be nice to be correct
            case "post":
            case "upload":
                $custom_sublinks .= "<li><a href='" . make_link('post/list') . "'>All</a></li>";
                $custom_sublinks .= "<li><a href='" . make_link("post/list/favorited_by={$username}/1") . "'>My Favorites</a></li>";
                $custom_sublinks .= "<li><a href='" . make_link("ext_doc/index") . "'>Help</a></li>";
                break;
            case "comment":
                $custom_sublinks .= "<li><a href='" . make_link('comment/list') . "'>All</a></li>";
                $custom_sublinks .= "<li><a href='" . make_link("ext_doc/comment") . "'>Help</a></li>";
                break;
            case "pool":
                $custom_sublinks .= "<li><a href='" . make_link('pool/list') . "'>List</a></li>";
                $custom_sublinks .= "<li><a href='" . make_link("pool/new") . "'>Create</a></li>";
                $custom_sublinks .= "<li><a href='" . make_link("pool/updated") . "'>Changes</a></li>";
                $custom_sublinks .= "<li><a href='" . make_link("ext_doc/pools") . "'>Help</a></li>";
                break;
            case "wiki":
                $custom_sublinks .= "<li><a href='" . make_link('wiki') . "'>Index</a></li>";
                $custom_sublinks .= "<li><a href='" . make_link("wiki/rules") . "'>Rules</a></li>";
                $custom_sublinks .= "<li><a href='" . make_link("ext_doc/wiki") . "'>Help</a></li>";
                break;
            case "tags":
            case "alias":
                $custom_sublinks .= "<li><a href='" . make_link('tags/map') . "'>Map</a></li>";
                $custom_sublinks .= "<li><a href='" . make_link('tags/alphabetic') . "'>Alphabetic</a></li>";
                $custom_sublinks .= "<li><a href='" . make_link('tags/popularity') . "'>Popularity</a></li>";
                $custom_sublinks .= "<li><a href='" . make_link('tags/categories') . "'>Categories</a></li>";
                $custom_sublinks .= "<li><a href='" . make_link('alias/list') . "'>Aliases</a></li>";
                $custom_sublinks .= "<li><a href='" . make_link("ext_doc/tag_edit") . "'>Help</a></li>";
                break;
        }
        // bzchan: failed attempt to add heading after title_link (failure was it looked bad)
        //if($this->heading==$site_name)$this->heading = '';
        //$title_link = "<h1><a href='".make_link($main_page)."'>$site_name</a>/$this->heading</h1>";
        // bzchan: prepare main title link
        $title_link = "<h1 id='site-title'><a href='" . make_link($main_page) . "'>{$site_name}</a></h1>";
        if ($page->left_enabled) {
            $left = "<div id='nav'>{$left_block_html}</div>";
            $withleft = "withleft";
        } else {
            $left = "";
            $withleft = "noleft";
        }
        print <<<EOD
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
\t<head>
\t\t<title>{$page->title}</title>
\t\t<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
\t\t<link rel="stylesheet" href="{$data_href}/themes/{$theme_name}/style.css" type="text/css">
{$header_html}
\t\t<script src='{$data_href}/themes/{$theme_name}/sidebar.js' type='text/javascript'></script>
\t\t<script src='{$data_href}/themes/{$theme_name}/script.js' type='text/javascript'></script>
\t</head>

\t<body>
\t\t<div id="header">
\t\t{$title_link}
\t\t<ul id="navbar" class="flat-list">
\t\t\t{$custom_links}
\t\t</ul>
\t\t<ul id="subnavbar" class="flat-list">
\t\t\t{$custom_sublinks}
\t\t</ul>
\t\t</div>
\t\t{$subheading}
\t\t{$sub_block_html}
\t\t
\t\t{$left}
\t\t<div id="body" class="{$withleft}">{$main_block_html}</div>

\t\t<div id="footer">
        <em>
\t\t\tImages &copy; their respective owners,
\t\t\t<a href="http://code.shishnet.org/shimmie2/">Shimmie</a> &copy;
\t\t\t<a href="http://www.shishnet.org/">Shish</a> &amp; Co 2007-2010,
\t\t\tbased on the Danbooru concept.
\t\t\t{$debug}
\t\t\t{$contact}
        </em>
\t\t</div>
\t</body>
</html>
EOD;
    }
Esempio n. 30
0
 public function onPageRequest($event)
 {
     global $config, $database, $page, $user;
     if ($event->page_matches("post/list")) {
         if (isset($_GET['search'])) {
             $search = url_escape(trim($_GET['search']));
             if (empty($search)) {
                 $page->set_mode("redirect");
                 $page->set_redirect(make_link("post/list/1"));
             } else {
                 $page->set_mode("redirect");
                 $page->set_redirect(make_link("post/list/{$search}/1"));
             }
             return;
         }
         $search_terms = $event->get_search_terms();
         $page_number = $event->get_page_number();
         $page_size = $event->get_page_size();
         try {
             $total_pages = Image::count_pages($search_terms);
             $images = Image::find_images(($page_number - 1) * $page_size, $page_size, $search_terms);
         } catch (SearchTermParseException $stpe) {
             // FIXME: display the error somewhere
             $total_pages = 0;
             $images = array();
         }
         if (count($search_terms) == 0 && count($images) == 0 && $page_number == 1) {
             $this->theme->display_intro($page);
             send_event(new PostListBuildingEvent($search_terms));
         } else {
             if (count($search_terms) > 0 && count($images) == 1 && $page_number == 1) {
                 $page->set_mode("redirect");
                 $page->set_redirect(make_link("post/view/{$images[0]->id}"));
             } else {
                 send_event(new PostListBuildingEvent($search_terms));
                 $this->theme->set_page($page_number, $total_pages, $search_terms);
                 $this->theme->display_page($page, $images);
             }
         }
     }
 }