Example #1
0
 /**
  * HERE WE GET THE LIST OF POOLS.
  *
  * @param \Page $page
  * @param int $pageNumber
  */
 private function list_pools(Page $page, $pageNumber)
 {
     global $config, $database;
     $pageNumber = clamp($pageNumber, 1, null) - 1;
     $poolsPerPage = $config->get_int("poolsListsPerPage");
     $order_by = "";
     $order = $page->get_cookie("ui-order-pool");
     if ($order == "created" || is_null($order)) {
         $order_by = "ORDER BY p.date DESC";
     } elseif ($order == "updated") {
         $order_by = "ORDER BY p.lastupdated DESC";
     } elseif ($order == "name") {
         $order_by = "ORDER BY p.title ASC";
     } elseif ($order == "count") {
         $order_by = "ORDER BY p.posts DESC";
     }
     $pools = $database->get_all("\n\t\t\tSELECT p.id, p.user_id, p.public, p.title, p.description,\n\t\t\t       p.posts, u.name as user_name\n\t\t\tFROM pools AS p\n\t\t\tINNER JOIN users AS u\n\t\t\tON p.user_id = u.id\n\t\t\t{$order_by}\n\t\t\tLIMIT :l OFFSET :o\n\t\t", array("l" => $poolsPerPage, "o" => $pageNumber * $poolsPerPage));
     $totalPages = ceil($database->get_one("SELECT COUNT(*) FROM pools") / $poolsPerPage);
     $this->theme->list_pools($page, $pools, $pageNumber + 1, $totalPages);
 }
    /**
     * turns the Page into HTML
     *
     * @param Page $page
     */
    public function display_page(Page $page)
    {
        global $config;
        //$theme_name = $config->get_string('theme', 'default');
        $site_name = $config->get_string('title');
        $data_href = get_base_href();
        $main_page = $config->get_string('main_page');
        $contact_link = $config->get_string('contact_link');
        $header_html = "";
        ksort($page->html_headers);
        foreach ($page->html_headers as $line) {
            $header_html .= "\t\t{$line}\n";
        }
        $left_block_html = "";
        $main_block_html = "";
        $head_block_html = "";
        $sub_block_html = "";
        foreach ($page->blocks as $block) {
            switch ($block->section) {
                case "left":
                    $left_block_html .= $block->get_html(true);
                    break;
                case "head":
                    $head_block_html .= "<td width='250'><small>" . $block->get_html(false) . "</small></td>";
                    break;
                case "main":
                    $main_block_html .= $block->get_html(false);
                    break;
                case "subheading":
                    $sub_block_html .= $block->body;
                    // $this->block_to_html($block, true);
                    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='mailto:{$contact_link}'>Contact</a>";
        /*$subheading = empty($page->subheading) ? "" : "<div id='subtitle'>{$page->subheading}</div>";
        
        		$wrapper = "";
        		if(strlen($page->heading) > 100) {
        			$wrapper = ' style="height: 3em; overflow: auto;"';
        		}
        		*/
        $flash = $page->get_cookie("flash_message");
        $flash_html = "";
        if ($flash) {
            $flash_html = "<b id='flash'>" . nl2br(html_escape($flash)) . " <a href='#' onclick=\"\$('#flash').hide(); return false;\">[X]</a></b>";
        }
        print <<<EOD
<!doctype html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]>    <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]>    <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
\t<head>
\t\t<title>{$page->title}</title>
{$header_html}
\t</head>

\t<body>
\t\t<header>
\t\t\t<table id="header" class="bgtop" width="100%" height="113px">
\t\t\t\t<tr>
\t\t\t\t\t<td><center>
\t\t\t\t\t\t<h1><a href="{$data_href}/{$main_page}">{$site_name}</a></h1>
\t\t\t\t\t\t<p>[Navigation links go here]
\t\t\t\t\t</center></td>
\t\t\t\t\t{$head_block_html}
\t\t\t\t</tr>
\t\t\t</table>
\t\t\t{$sub_block_html}
\t\t</header>
\t\t<nav>
\t\t\t{$left_block_html}
\t\t</nav>
\t\t<article>
\t\t\t{$flash_html}
\t\t\t{$main_block_html}
\t\t</article>
\t\t<footer>
\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;
\t\t\t<a href="https://github.com/shish/shimmie2/graphs/contributors">The Team</a>
\t\t\t2007-2014,
\t\t\tbased on the Danbooru concept.
\t\t\t{$debug}
\t\t\t{$contact}
\t\t</footer>
\t</body>
</html>
EOD;
    }
    function display_page(Page $page)
    {
        global $config;
        $theme_name = $config->get_string('theme', 'default');
        $data_href = get_base_href();
        $contact_link = $config->get_string('contact_link');
        $header_html = "";
        ksort($page->html_headers);
        foreach ($page->html_headers as $line) {
            $header_html .= "\t\t{$line}\n";
        }
        $left_block_html = "";
        $main_block_html = "";
        $sub_block_html = "";
        foreach ($page->blocks as $block) {
            switch ($block->section) {
                case "left":
                    $left_block_html .= $block->get_html(true);
                    break;
                case "main":
                    $main_block_html .= $block->get_html(false);
                    break;
                case "subheading":
                    $sub_block_html .= $block->body;
                    // $this->block_to_html($block, true);
                    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='mailto:{$contact_link}'>Contact</a>";
        if (empty($page->subheading)) {
            $subheading = "";
        } else {
            $subheading = "<div id='subtitle'>{$page->subheading}</div>";
        }
        if ($page->left_enabled) {
            $left = "<nav>{$left_block_html}</nav>";
            $withleft = "withleft";
        } else {
            $left = "";
            $withleft = "";
        }
        $flash = $page->get_cookie("flash_message");
        $flash_html = "";
        if ($flash) {
            $flash_html = "<b id='flash'>" . nl2br(html_escape($flash)) . " <a href='#' onclick=\"\$('#flash').hide(); return false;\">[X]</a></b>";
        }
        print <<<EOD
<!doctype html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]>    <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]>    <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
\t<head>
\t\t<title>{$page->title}</title>
{$header_html}
\t\t<script src='{$data_href}/themes/{$theme_name}/script.js' type='text/javascript'></script>
\t</head>

\t<body>
\t\t<header>
\t\t\t<h1>{$page->heading}</h1>
\t\t\t{$subheading}
\t\t\t{$sub_block_html}
\t\t</header>
\t\t{$left}
\t\t<article class="{$withleft}">
\t\t\t{$flash_html}
\t\t\t{$main_block_html}
\t\t</article>
\t\t<footer>
\t\t\t<hr>
\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;
\t\t\t<a href="https://github.com/shish/shimmie2/graphs/contributors">The Team</a>
\t\t\t2007-2014,
\t\t\tbased on the Danbooru concept.
\t\t\t<br>Futaba theme based on 4chan's layout and CSS :3
\t\t\t{$debug}
\t\t\t{$contact}
\t\t</footer>
\t</body>
</html>
EOD;
    }
    /**
     * turns the Page into HTML.
     *
     * @param Page $page
     */
    public function display_page(Page $page)
    {
        global $config, $user;
        $theme_name = $config->get_string('theme', 'lite');
        $site_name = $config->get_string('title');
        $data_href = get_base_href();
        $contact_link = $config->get_string('contact_link');
        $header_html = "";
        ksort($page->html_headers);
        foreach ($page->html_headers as $line) {
            $header_html .= "\t\t{$line}\n";
        }
        $menu = "<div class='menu'>\n\t\t\t<script type='text/javascript' src='{$data_href}/themes/{$theme_name}/wz_tooltip.js'></script>\n\t\t\t<a href='" . make_link() . "' onmouseover='Tip(&#39;Home&#39;, BGCOLOR, &#39;#C3D2E0&#39;, FADEIN, 100)' onmouseout='UnTip()'><img src='{$data_href}/favicon.ico' style='position: relative; top: 3px;'></a>\n\t\t\t<b>{$site_name}</b> ";
        // Custom links: These appear on the menu.
        $custom_links = "";
        if ($user->is_anonymous()) {
            $custom_links .= $this->navlinks(make_link('user_admin/login'), "Account", array("user", "user_admin", "setup", "admin", "profile"));
        } else {
            $custom_links .= $this->navlinks(make_link('user'), "Account", array("user", "setup", "user_admin", "admin", "profile"));
        }
        $custom_links .= $this->navlinks(make_link('post/list'), "Posts", array("post", "view"));
        $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/rules'), "Rules", array("wiki/rules"));
            $custom_links .= $this->navlinks(make_link('wiki'), "Wiki", array("wiki"));
        }
        $menu .= "{$custom_links}</div>";
        $left_block_html = "";
        $main_block_html = "";
        $sub_block_html = "";
        $user_block_html = "";
        foreach ($page->blocks as $block) {
            switch ($block->section) {
                case "left":
                    $left_block_html .= $this->block_to_html($block, true, "left");
                    break;
                case "main":
                    $main_block_html .= $this->block_to_html($block, false, "main");
                    break;
                case "user":
                    $user_block_html .= $block->body;
                    break;
                case "subheading":
                    $sub_block_html .= $this->block_to_html($block, false, "main");
                    break;
                default:
                    print "<p>error: {$block->header} using an unknown section ({$block->section})";
                    break;
            }
        }
        $custom_sublinks = "<div class='sbar'>";
        // hack
        $username = url_escape($user->name);
        // hack
        $qp = explode("/", ltrim(_get_query(), "/"));
        $cs = "";
        // php sucks
        switch ($qp[0]) {
            default:
                $cs = $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":
                if (class_exists("NumericScore")) {
                    $cs .= "<b>Popular by </b><a href='" . make_link('popular_by_day') . "'>Day</a><b>/</b><a href='" . make_link('popular_by_month') . "'>Month</a><b>/</b><a href='" . make_link('popular_by_year') . "'>Year</a> ";
                }
                $cs .= "<a class='tab' href='" . make_link('post/list') . "'>All</a>";
                if (class_exists("Favorites")) {
                    $cs .= "<a class='tab' href='" . make_link("post/list/favorited_by={$username}/1") . "'>My Favorites</a>";
                }
                if (class_exists("RSS_Images")) {
                    $cs .= "<a class='tab' href='" . make_link('rss/images') . "'>Feed</a>";
                }
                if (class_exists("Random_Image")) {
                    $cs .= "<a class='tab' href='" . make_link("random_image/view") . "'>Random Image</a>";
                }
                if (class_exists("Wiki")) {
                    $cs .= "<a class='tab' href='" . make_link("wiki/posts") . "'>Help</a>";
                } else {
                    $cs .= "<a class='tab' href='" . make_link("ext_doc/index") . "'>Help</a>";
                }
                break;
            case "comment":
                $cs .= "<a class='tab' href='" . make_link('comment/list') . "'>All</a>";
                $cs .= "<a class='tab' href='" . make_link('rss/comments') . "'>Feed</a>";
                $cs .= "<a class='tab' href='" . make_link("ext_doc/comment") . "'>Help</a>";
                break;
            case "pool":
                $cs .= "<a class='tab' href='" . make_link('pool/list') . "'>List</a>";
                $cs .= "<a class='tab' href='" . make_link("pool/new") . "'>Create</a>";
                $cs .= "<a class='tab' href='" . make_link("pool/updated") . "'>Changes</a>";
                $cs .= "<a class='tab' href='" . make_link("ext_doc/pools") . "'>Help</a>";
                break;
            case "wiki":
                $cs .= "<a class='tab' href='" . make_link('wiki') . "'>Index</a>";
                $cs .= "<a class='tab' href='" . make_link("wiki/rules") . "'>Rules</a>";
                $cs .= "<a class='tab' href='" . make_link("ext_doc/wiki") . "'>Help</a>";
                break;
            case "tags":
            case "alias":
                $cs .= "<a class='tab' href='" . make_link('tags/map') . "'>Map</a>";
                $cs .= "<a class='tab' href='" . make_link('tags/alphabetic') . "'>Alphabetic</a>";
                $cs .= "<a class='tab' href='" . make_link('tags/popularity') . "'>Popularity</a>";
                $cs .= "<a class='tab' href='" . make_link('tags/categories') . "'>Categories</a>";
                $cs .= "<a class='tab' href='" . make_link('alias/list') . "'>Aliases</a>";
                $cs .= "<a class='tab' href='" . make_link("ext_doc/tag_edit") . "'>Help</a>";
                break;
            case "upload":
                if (class_exists("Wiki")) {
                    $cs .= "<a class='tab' href='" . make_link("wiki/upload_guidelines") . "'>Guidelines</a>";
                }
                break;
            case "random":
                $cs .= "<a class='tab' href='" . make_link('random/view') . "'>Shuffle</a>";
                $cs .= "<a class='tab' href='" . make_link('random/download') . "'>Download</a>";
                break;
            case "featured":
                $cs .= "<a class='tab' href='" . make_link('featured/download') . "'>Download</a>";
                break;
        }
        if ($cs == "") {
            $custom_sublinks = "";
        } else {
            $custom_sublinks .= "{$cs}</div>";
        }
        $debug = get_debug_info();
        $contact = empty($contact_link) ? "" : "<br><a href='mailto:{$contact_link}'>Contact</a>";
        //$subheading = empty($page->subheading) ? "" : "<div id='subtitle'>{$page->subheading}</div>";
        /*$wrapper = "";
        		if(strlen($page->heading) > 100) {
        			$wrapper = ' style="height: 3em; overflow: auto;"';
        		}*/
        if ($page->left_enabled == false) {
            $left_block_html = "";
            $main_block_html = "<article id='body_noleft'>{$main_block_html}</article>";
        } else {
            $left_block_html = "<nav>{$left_block_html}</nav>";
            $main_block_html = "<article>{$main_block_html}</article>";
        }
        $flash = $page->get_cookie("flash_message");
        $flash_html = "";
        if ($flash) {
            $flash_html = "<b id='flash'>" . nl2br(html_escape($flash)) . " <a href='#' onclick=\"\$('#flash').hide(); return false;\">[X]</a></b>";
        }
        print <<<EOD
<!doctype html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]>    <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]>    <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
\t<head>
\t\t<title>{$page->title}</title>
\t\t{$header_html}
\t</head>

\t<body>
\t\t<header>
\t\t\t{$menu}
\t\t\t{$custom_sublinks}
\t\t\t{$sub_block_html}
\t\t</header>
\t\t{$left_block_html}
\t\t{$flash_html}
\t\t{$main_block_html}
\t\t<footer>
\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;
\t\t\t<a href="https://github.com/shish/shimmie2/graphs/contributors">The Team</a>
\t\t\t2007-2014,
\t\t\tbased on the Danbooru concept.<br />
\t\t\tLite Theme by <a href="http://seemslegit.com">Zach</a>
\t\t\t{$debug}
\t\t\t{$contact}
\t\t</footer>
\t</body>
</html>
EOD;
    }