Пример #1
0
 public function display_mass_tagger(Page $page, Event $event, $config)
 {
     $data_href = get_base_href();
     $body = "\n\t\t\t<form action='" . make_link("mass_tagger/tag") . "' method='POST'>\n\t\t\t\t<input id='mass_tagger_activate' type='button' onclick='activate_mass_tagger(\"{$data_href}\");' value='Activate'/>\n\t\t\t\t<div id='mass_tagger_controls' style='display: none;'>\n\t\t\t\t\tClick on images to mark them. Use the 'Index Options' in the Board Config to increase the amount of shown images.\n\t\t\t\t\t<br />\n\t\t\t\t\t<input type='hidden' name='ids' id='mass_tagger_ids' />\n\t\t\t\t\tSet instead of add? <input type='checkbox' name='setadd' value='set' />\n\t\t\t\t\t<label>Tags: <input type='text' name='tag' /></label>\n\n\t\t\t\t\t<input type='submit' value='Tag Marked Images' />\n\t\t\t\t</div>\n\t\t\t</form>\n\t\t";
     $block = new Block("Mass Tagger", $body, "left", 50);
     $page->add_block($block);
 }
Пример #2
0
 private function get_body()
 {
     // returns just the contents of the body
     global $database;
     global $config;
     $base_href = $config->get_string('base_href');
     $data_href = get_base_href();
     $sitename = $config->get_string('title');
     $contact_link = $config->get_string('contact_link');
     $counter_dir = $config->get_string('home_counter', 'default');
     $total = ceil($database->db->GetOne("SELECT COUNT(*) FROM images"));
     $strtotal = "{$total}";
     $num_comma = number_format($total);
     $counter_text = "";
     for ($n = 0; $n < strlen($strtotal); $n++) {
         $cur = $strtotal[$n];
         $counter_text .= " <img alt='{$cur}' src='{$data_href}/ext/home/counters/{$counter_dir}/{$cur}.gif' />  ";
     }
     // get the homelinks and process them
     $main_links = $config->get_string('home_links');
     $main_links = str_replace('$base', $base_href, $main_links);
     $main_links = str_replace('[', "<a href='", $main_links);
     $main_links = str_replace('|', "'>", $main_links);
     $main_links = str_replace(']', "</a>", $main_links);
     $main_text = $config->get_string('home_text');
     return $this->theme->build_body($sitename, $main_links, $main_text, $contact_link, $num_comma, $counter_text);
 }
Пример #3
0
 private function get_body()
 {
     // returns just the contents of the body
     global $database;
     global $config;
     $base_href = $config->get_string('base_href');
     $data_href = get_base_href();
     $sitename = $config->get_string('title');
     $contact_link = $config->get_string('contact_link');
     $counter_dir = $config->get_string('home_counter', 'default');
     $total = Image::count_images();
     $strtotal = "{$total}";
     $num_comma = number_format($total);
     $counter_text = "";
     for ($n = 0; $n < strlen($strtotal); $n++) {
         $cur = $strtotal[$n];
         $counter_text .= " <img alt='{$cur}' src='{$data_href}/ext/home/counters/{$counter_dir}/{$cur}.gif' />  ";
     }
     // get the homelinks and process them
     $main_links = $config->get_string('home_links');
     $main_links = str_replace('$base', $base_href, $main_links);
     $main_links = preg_replace('#\\[(.*?)\\|(.*?)\\]#', "<a href='\\1'>\\2</a>", $main_links);
     $main_links = str_replace('//', "/", $main_links);
     $main_text = $config->get_string('home_text');
     return $this->theme->build_body($sitename, $main_links, $main_text, $contact_link, $num_comma, $counter_text);
 }
Пример #4
0
 public function display_image(Page $page, Image $image)
 {
     $data_href = get_base_href();
     $ilink = $image->get_image_link();
     $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}' 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", 0));
 }
Пример #5
0
 private function get_body()
 {
     // returns just the contents of the body
     global $config;
     $base_href = get_base_href();
     $sitename = $config->get_string('title');
     $contact_link = $config->get_string('contact_link');
     $counter_dir = $config->get_string('home_counter', 'default');
     $total = Image::count_images();
     $strtotal = "{$total}";
     $num_comma = number_format($total);
     $counter_text = "";
     $length = strlen($strtotal);
     for ($n = 0; $n < $length; $n++) {
         $cur = $strtotal[$n];
         $counter_text .= " <img alt='{$cur}' src='{$base_href}/ext/home/counters/{$counter_dir}/{$cur}.gif' />  ";
     }
     // get the homelinks and process them
     if (strlen($config->get_string('home_links', '')) > 0) {
         $main_links = $config->get_string('home_links');
     } else {
         $main_links = '[url=site://post/list]Posts[/url] [url=site://comment/list]Comments[/url] [url=site://tags]Tags[/url]';
         if (class_exists("Pools")) {
             $main_links .= ' [url=site://pool]Pools[/url]';
         }
         if (class_exists("Wiki")) {
             $main_links .= ' [url=site://wiki]Wiki[/url]';
         }
         $main_links .= ' [url=site://ext_doc]Documentation[/url]';
     }
     $main_links = format_text($main_links);
     $main_text = $config->get_string('home_text');
     return $this->theme->build_body($sitename, $main_links, $main_text, $contact_link, $num_comma, $counter_text);
 }
Пример #6
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);
 }
Пример #7
0
 function __construct($main)
 {
     $matches = array();
     $lines = file($main);
     $number_of_lines = count($lines);
     preg_match("#ext/(.*)/main.php#", $main, $matches);
     $this->ext_name = $matches[1];
     $this->name = $this->ext_name;
     $this->enabled = $this->is_enabled($this->ext_name);
     for ($i = 0; $i < $number_of_lines; $i++) {
         $line = $lines[$i];
         if (preg_match("/Name: (.*)/", $line, $matches)) {
             $this->name = $matches[1];
         }
         if (preg_match("/Visibility: (.*)/", $line, $matches)) {
             $this->visibility = $matches[1];
         }
         if (preg_match("/Link: (.*)/", $line, $matches)) {
             $this->link = $matches[1];
             if ($this->link[0] == "/") {
                 $this->link = make_link(substr($this->link, 1));
             }
         }
         if (preg_match("/Version: (.*)/", $line, $matches)) {
             $this->version = $matches[1];
         }
         if (preg_match("/Author: (.*) [<\\(](.*@.*)[>\\)]/", $line, $matches)) {
             $this->author = $matches[1];
             $this->email = $matches[2];
         } else {
             if (preg_match("/Author: (.*)/", $line, $matches)) {
                 $this->author = $matches[1];
             }
         }
         if (preg_match("/(.*)Description: ?(.*)/", $line, $matches)) {
             $this->description = $matches[2];
             $start = $matches[1] . " ";
             $start_len = strlen($start);
             while (substr($lines[$i + 1], 0, $start_len) == $start) {
                 $this->description .= " " . substr($lines[$i + 1], $start_len);
                 $i++;
             }
         }
         if (preg_match("/(.*)Documentation: ?(.*)/", $line, $matches)) {
             $this->documentation = $matches[2];
             $start = $matches[1] . " ";
             $start_len = strlen($start);
             while (substr($lines[$i + 1], 0, $start_len) == $start) {
                 $this->documentation .= " " . substr($lines[$i + 1], $start_len);
                 $i++;
             }
             $this->documentation = str_replace('$site', make_http(get_base_href()), $this->documentation);
         }
         if (preg_match("/\\*\\//", $line, $matches)) {
             break;
         }
     }
 }
Пример #8
0
 public function build_tagger(Page $page, $event)
 {
     // Initialization code
     $base_href = get_base_href();
     // TODO: AJAX test and fallback.
     $page->add_html_header("<script src='{$base_href}/ext/tagger/webtoolkit.drag.js' type='text/javascript'></script>");
     $page->add_block(new Block(null, "<script type='text/javascript'>\n\t\t\t\t\$( document ).ready(function() {\n\t\t\t\t\tTagger.initialize(" . $event->get_image()->id . ");\n\t\t\t\t});\n\t\t\t</script>", "main", 1000));
     // Tagger block
     $page->add_block(new Block(null, $this->html($event->get_image()), "main"));
 }
Пример #9
0
 public function onPageRequest(PageRequestEvent $event)
 {
     global $page, $user;
     // Adds header to enable chatbox
     $root = get_base_href();
     $yPath = make_http($root . "/ext/chatbox/");
     $page->add_html_header("\n\t\t\t\t<script src=\"http://code.jquery.com/jquery-migrate-1.2.1.js\" type=\"text/javascript\"></script>\n\t\t\t\t<script src=\"{$root}/ext/chatbox/js/yshout.js\" type=\"text/javascript\"></script>\n\n\t\t\t\t<link rel=\"stylesheet\" href=\"{$root}/ext/chatbox/css/dark.yshout.css\" />\n\n\t\t\t\t<script type=\"text/javascript\">\n\t\t\t\t\tnickname = '{$user->name}';\n\t\t\t\t\tnew YShout({ yPath: '{$yPath}' });\n\t\t\t\t</script>\n\t\t", 500);
     // loads the chatbox at the set location
     $html = "<div id=\"yshout\"></div>";
     $chatblock = new Block("Chatbox", $html, "main", 97);
     $page->add_block($chatblock);
 }
Пример #10
0
/**
 * @return   Smarty  Locally-usable Smarty instance.
 */
function get_smarty_instance()
{
    $s = new Smarty();
    $s->compile_dir = join(DIRECTORY_SEPARATOR, array(dirname(__FILE__), '..', 'templates', 'cache'));
    $s->cache_dir = join(DIRECTORY_SEPARATOR, array(dirname(__FILE__), '..', 'templates', 'cache'));
    $s->template_dir = join(DIRECTORY_SEPARATOR, array(dirname(__FILE__), '..', 'templates'));
    $s->config_dir = join(DIRECTORY_SEPARATOR, array(dirname(__FILE__), '..', 'templates'));
    $s->assign('domain', get_domain_name());
    $s->assign('base_dir', get_base_dir());
    $s->assign('base_href', get_base_href());
    $s->assign('constants', get_defined_constants());
    $s->assign('request', array('get' => $_GET));
    return $s;
}
Пример #11
0
 public function display_holiday($date)
 {
     global $page;
     if ($date) {
         $csssheet = "<link rel='stylesheet' href='" . get_base_href() . "/contrib/holiday/stylesheets/";
         // April Fools
         // Flips the entire page upside down!
         // TODO: Make it possible for the user to turn this off!
         if (date('d/m') == '01/04') {
             $csssheet .= "aprilfools.css";
         }
         $csssheet .= "' type='text/css'>";
         $page->add_html_header("{$csssheet}");
     }
 }
Пример #12
0
    /**
     * Display $message and exit
     *
     * @param string $message
     */
    public function display_message($message)
    {
        global $config, $user, $page;
        $theme_name = $config->get_string('theme');
        $data_href = get_base_href();
        $login_link = make_link("user_admin/login");
        $auth = $user->get_auth_html();
        $page->set_mode('data');
        $page->set_code(503);
        $page->set_data(<<<EOD
<html>
\t<head>
\t\t<title>Downtime</title>
\t\t<link rel="stylesheet" href="{$data_href}/themes/{$theme_name}/style.css" type="text/css">
\t</head>
\t<body>
\t\t<div id="downtime">
\t\t\t<section>
\t\t\t\t<h1><center>Down for Maintenance</center></h1>
\t\t\t\t<div id="message" class="blockbody">
\t\t\t\t\t{$message}
\t\t\t\t</div>
\t\t\t</section>
\t\t\t<section>
\t\t\t\t<h3>Admin Login</h3>
\t\t\t\t<div id="login" class="blockbody">
\t\t\t\t\t<form action="{$login_link}" method="POST">
\t\t\t\t\t\t{$auth}
\t\t\t\t\t\t<table id="login_table" summary="Login Form">
\t\t\t\t\t\t\t<tr>
\t\t\t\t\t\t\t\t<td width="70"><label for="user">Name</label></td>
\t\t\t\t\t\t\t\t<td width="70"><input id="user" type="text" name="user"></td>
\t\t\t\t\t\t\t</tr>
\t\t\t\t\t\t\t<tr>
\t\t\t\t\t\t\t\t<td><label for="pass">Password</label></td>
\t\t\t\t\t\t\t\t<td><input id="pass" type="password" name="pass"></td>
\t\t\t\t\t\t\t</tr>
\t\t\t\t\t\t\t<tr><td colspan="2"><input type="submit" value="Log In"></td></tr>
\t\t\t\t\t\t</table>
\t\t\t\t\t</form>
\t\t\t\t</div>
\t\t\t</section>
\t\t</div>
\t</body>
</html>
EOD
);
    }
Пример #13
0
/**
 * @return   Smarty  Locally-usable Smarty instance.
 */
function get_smarty_instance()
{
    $s = new Smarty();
    $s->compile_dir = join(DIRECTORY_SEPARATOR, array(dirname(__FILE__), '..', 'templates', 'cache'));
    $s->cache_dir = join(DIRECTORY_SEPARATOR, array(dirname(__FILE__), '..', 'templates', 'cache'));
    $s->template_dir = join(DIRECTORY_SEPARATOR, array(dirname(__FILE__), '..', 'templates'));
    $s->config_dir = join(DIRECTORY_SEPARATOR, array(dirname(__FILE__), '..', 'templates'));
    $s->register_modifier('url_domain', 'get_url_domain');
    $s->register_modifier('nice_relative_time', 'get_relative_time');
    $s->assign('domain', get_domain_name());
    $s->assign('base_dir', get_base_dir());
    $s->assign('base_href', get_base_href());
    $s->assign('logo', '<img src="' . LOGO . '" />');
    $s->assign('site_title', SITE_TITLE);
    //	    $s->clear_all_cache();
    return $s;
}
Пример #14
0
 public function display_page()
 {
     global $config, $page;
     $base_href = get_base_href();
     $oekW = $config->get_int("oekaki_width", 400);
     $oekH = $config->get_int("oekaki_height", 400);
     if (isset($_POST['oekW']) && isset($_POST['oekH'])) {
         $oekW = int_escape($_POST['oekW']);
         $oekH = int_escape($_POST['oekH']);
     }
     $html = "\n    <applet archive='{$base_href}/ext/oekaki/chibipaint.jar' code='chibipaint.ChibiPaint.class' width='800' height='600'>\n      <param name='canvasWidth' value='" . $oekW . "' />\n      <param name='canvasHeight' value='" . $oekH . "' />\n      <param name='postUrl' value='" . make_http(make_link("oekaki/upload")) . "' />\n      <param name='exitUrl' value='" . make_http(make_link("oekaki/claim")) . "' />\n      <param name='exitUrlTarget' value='_self' />\n      JAVA NOT INSTALLED :(<!-- alternative content for users who don't have Java installed -->\n    </applet>\n\t\t";
     #      <param name='loadImage' value='http://yourserver/oekaki/pictures/168.png' />
     #      <param name='loadChibiFile' value='http://yourserver/oekaki/pictures/168.chi' />
     // FIXME: prevent oekaki block from collapsing on click in cerctain themes. This causes canvas reset
     $page->set_title("Oekaki");
     $page->set_heading("Oekaki");
     $page->add_block(new NavBlock());
     $page->add_block(new Block("Oekaki", $html, "main", 20));
 }
Пример #15
0
 /**
  * Collect the information and return it in a keyed array.
  */
 private function get_info()
 {
     global $config, $database;
     global $_event_listeners;
     // yay for using secret globals \o/
     $info = array();
     $info['site_title'] = $config->get_string("title");
     $info['site_theme'] = $config->get_string("theme");
     $info['site_url'] = "http://" . $_SERVER["HTTP_HOST"] . get_base_href();
     $info['sys_shimmie'] = VERSION;
     $info['sys_schema'] = $config->get_string("db_version");
     $info['sys_php'] = phpversion();
     $info['sys_db'] = $database->get_driver_name();
     $info['sys_os'] = php_uname();
     $info['sys_disk'] = to_shorthand_int(disk_total_space("./") - disk_free_space("./")) . " / " . to_shorthand_int(disk_total_space("./"));
     $info['sys_server'] = $_SERVER["SERVER_SOFTWARE"];
     $info['thumb_engine'] = $config->get_string("thumb_engine");
     $info['thumb_quality'] = $config->get_int('thumb_quality');
     $info['thumb_width'] = $config->get_int('thumb_width');
     $info['thumb_height'] = $config->get_int('thumb_height');
     $info['thumb_mem'] = $config->get_int("thumb_mem_limit");
     $info['stat_images'] = $database->get_one("SELECT COUNT(*) FROM images");
     $info['stat_comments'] = $database->get_one("SELECT COUNT(*) FROM comments");
     $info['stat_users'] = $database->get_one("SELECT COUNT(*) FROM users");
     $info['stat_tags'] = $database->get_one("SELECT COUNT(*) FROM tags");
     $info['stat_image_tags'] = $database->get_one("SELECT COUNT(*) FROM image_tags");
     $els = array();
     foreach (get_declared_classes() as $class) {
         $rclass = new ReflectionClass($class);
         if ($rclass->isAbstract()) {
             // don't do anything
         } elseif (is_subclass_of($class, "Extension")) {
             $els[] = $class;
         }
     }
     $info['sys_extensions'] = join(', ', $els);
     //$cfs = array();
     //foreach($database->get_all("SELECT name, value FROM config") as $pair) {
     //	$cfs[] = $pair['name']."=".$pair['value'];
     //}
     //$info[''] = "Config: ".join(", ", $cfs);
     return $info;
 }
Пример #16
0
    /**
     * Display $message and exit
     */
    public function display_message($message)
    {
        global $config, $user;
        $theme_name = $config->get_string('theme');
        $data_href = get_base_href();
        $login_link = make_link("user_admin/login");
        header("HTTP/1.0 503 Service Temporarily Unavailable");
        $auth = $user->get_auth_html();
        print <<<EOD
<html>
\t<head>
\t\t<title>Downtime</title>
\t\t<link rel="stylesheet" href="{$data_href}/themes/{$theme_name}/style.css" type="text/css">
\t</head>
\t<body>
\t\t<div id="downtime">
\t\t\t<h1>Down for Maintenance</h1>
\t\t\t<div id="message">
\t\t\t\t{$message}
\t\t\t</div>
\t\t\t<h3>Admin Login</h3>
\t\t\t<div id="login">
\t\t\t\t<form action="{$login_link}" method="POST">
\t\t\t\t\t{$auth}
\t\t\t\t\t<table id="login_table" summary="Login Form">
\t\t\t\t\t\t<tr>
\t\t\t\t\t\t\t<td width="70"><label for="user">Name</label></td>
\t\t\t\t\t\t\t<td width="70"><input id="user" type="text" name="user"></td>
\t\t\t\t\t\t</tr>
\t\t\t\t\t\t<tr>
\t\t\t\t\t\t\t<td><label for="pass">Password</label></td>
\t\t\t\t\t\t\t<td><input id="pass" type="password" name="pass"></td>
\t\t\t\t\t\t</tr>
\t\t\t\t\t\t<tr><td colspan="2"><input type="submit" value="Log In"></td></tr>
\t\t\t\t\t</table>
\t\t\t\t</form>
\t\t\t</div>
\t\t</div>
\t</body>
</html>
EOD;
    }
Пример #17
0
 public function display_emotes($list)
 {
     global $page;
     $data_href = get_base_href();
     $html = "<html><head><title>Emoticon list</title></head><body>";
     $html .= "<table><tr>";
     $n = 1;
     foreach ($list as $item) {
         $pathinfo = pathinfo($item);
         $name = $pathinfo["filename"];
         $html .= "<td><img src='{$data_href}/{$item}'> :{$name}:</td>";
         if ($n++ % 3 == 0) {
             $html .= "</tr><tr>";
         }
     }
     $html .= "</tr></table>";
     $html .= "</body></html>";
     $page->set_mode("data");
     $page->set_data($html);
 }
Пример #18
0
/**
 * @return   Smarty  Locally-usable Smarty instance.
 */
function get_smarty_instance($user)
{
    $s = new Smarty();
    $s->compile_dir = join(DIRECTORY_SEPARATOR, array(dirname(__FILE__), '..', 'templates', 'cache'));
    $s->cache_dir = join(DIRECTORY_SEPARATOR, array(dirname(__FILE__), '..', 'templates', 'cache'));
    $s->template_dir = join(DIRECTORY_SEPARATOR, array(dirname(__FILE__), '..', 'templates'));
    $s->config_dir = join(DIRECTORY_SEPARATOR, array(dirname(__FILE__), '..', 'templates'));
    $s->assign('domain', get_domain_name());
    $s->assign('base_dir', get_base_dir());
    $s->assign('base_href', get_base_href());
    $s->assign('constants', get_defined_constants());
    $s->assign('providers', get_map_providers());
    $s->assign('request', array('get' => $_GET, 'post' => $_POST, 'uri' => $_SERVER['REQUEST_URI'], 'query' => $_SERVER['QUERY_STRING'], 'authenticated' => isset($user), 'user' => $user));
    $s->register_modifier('nice_placename', 'nice_placename');
    $s->register_modifier('nice_domainname', 'nice_domainname');
    $s->register_modifier('nice_relativetime', 'nice_relativetime');
    $s->register_modifier('nice_datetime', 'nice_datetime');
    $s->register_modifier('nice_degree', 'nice_degree');
    $s->register_modifier('decode_utf8', 'decode_utf8');
    return $s;
}
Пример #19
0
 private function get_info()
 {
     global $config, $database;
     global $_event_listeners;
     // yay for using secret globals \o/
     $info = array();
     $info['site_title'] = $config->get_string("title");
     $info['site_theme'] = $config->get_string("theme");
     $info['site_url'] = "http://" . $_SERVER["HTTP_HOST"] . get_base_href();
     $info['sys_shimmie'] = VERSION;
     $info['sys_schema'] = $config->get_string("db_version");
     $info['sys_php'] = phpversion();
     $info['sys_os'] = php_uname();
     $info['sys_disk'] = to_shorthand_int(disk_total_space("./") - disk_free_space("./")) . " / " . to_shorthand_int(disk_total_space("./"));
     $info['sys_server'] = $_SERVER["SERVER_SOFTWARE"];
     include "config.php";
     // more magical hax
     $proto = preg_replace("#(.*)://.*#", "\$1", $database_dsn);
     $db = $database->db->ServerInfo();
     $info['sys_db'] = "{$proto} / {$db['version']}";
     $info['stat_images'] = $database->db->GetOne("SELECT COUNT(*) FROM images");
     $info['stat_comments'] = $database->db->GetOne("SELECT COUNT(*) FROM comments");
     $info['stat_users'] = $database->db->GetOne("SELECT COUNT(*) FROM users");
     $info['stat_tags'] = $database->db->GetOne("SELECT COUNT(*) FROM tags");
     $info['stat_image_tags'] = $database->db->GetOne("SELECT COUNT(*) FROM image_tags");
     $els = array();
     foreach ($_event_listeners as $el) {
         $els[] = get_class($el);
     }
     $info['sys_extensions'] = join(', ', $els);
     //$cfs = array();
     //foreach($database->get_all("SELECT name, value FROM config") as $pair) {
     //	$cfs[] = $pair['name']."=".$pair['value'];
     //}
     //$info[''] = "Config: ".join(", ", $cfs);
     return $info;
 }
Пример #20
0
    public function onPageRequest(PageRequestEvent $event)
    {
        global $config, $database, $page;
        if ($event->page_matches("rss/comments")) {
            $page->set_mode("data");
            $page->set_type("application/rss+xml");
            $comments = $database->get_all("\n\t\t\t\tSELECT\n\t\t\t\t\tusers.id as user_id, users.name as user_name,\n\t\t\t\t\tcomments.comment as comment, comments.id as comment_id,\n\t\t\t\t\tcomments.image_id as image_id, comments.owner_ip as poster_ip,\n\t\t\t\t\tcomments.posted as posted\n\t\t\t\tFROM comments\n\t\t\t\tLEFT JOIN users ON comments.owner_id=users.id\n\t\t\t  \tORDER BY comments.id DESC\n\t\t  \t\tLIMIT 10\n\t\t\t");
            $data = "";
            foreach ($comments as $comment) {
                $image_id = $comment['image_id'];
                $comment_id = $comment['comment_id'];
                $link = make_http(make_link("post/view/{$image_id}"));
                $owner = html_escape($comment['user_name']);
                $posted = date(DATE_RSS, strtotime($comment['posted']));
                $comment = html_escape($comment['comment']);
                $content = html_escape("{$owner}: {$comment}");
                $data .= "\n\t\t\t\t\t<item>\n\t\t\t\t\t\t<title>{$owner} comments on {$image_id}</title>\n\t\t\t\t\t\t<link>{$link}</link>\n\t\t\t\t\t\t<guid isPermaLink=\"false\">{$comment_id}</guid>\n\t\t\t\t\t\t<pubDate>{$posted}</pubDate>\n\t\t\t\t\t\t<description>{$content}</description>\n\t\t\t\t\t</item>\n\t\t\t\t";
            }
            $title = $config->get_string('title');
            $base_href = make_http(get_base_href());
            $version = $config->get_string('version');
            $xml = <<<EOD
<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0">
\t<channel>
\t\t<title>{$title}</title>
\t\t<description>The latest comments on the image board</description>
\t\t<link>{$base_href}</link>
\t\t<generator>{$version}</generator>
\t\t<copyright>(c) 2007 Shish</copyright>
\t\t{$data}
\t</channel>
</rss>
EOD;
            $page->set_data($xml);
        }
    }
Пример #21
0
/**
 * @return string
 */
function captcha_get_html()
{
    global $config, $user;
    if (DEBUG && ip_in_range($_SERVER['REMOTE_ADDR'], "127.0.0.0/8")) {
        return "";
    }
    $captcha = "";
    if ($user->is_anonymous() && $config->get_bool("comment_captcha")) {
        $r_publickey = $config->get_string("api_recaptcha_pubkey");
        if (!empty($r_publickey)) {
            $captcha = recaptcha_get_html($r_publickey);
        } else {
            session_start();
            //$securimg = new Securimage();
            $base = get_base_href();
            $captcha = "<br/><img src='{$base}/lib/securimage/securimage_show.php?sid=" . md5(uniqid(time())) . "'>" . "<br/>CAPTCHA: <input type='text' name='code' value='' />";
        }
    }
    return $captcha;
}
Пример #22
0
 /**
  * This function grabs all the CSS and JavaScript files sprinkled throughout Shimmie's folders,
  * concatenates them together into two large files (one for CSS and one for JS) and then stores
  * them in the /cache/ directory for serving to the user.
  * 
  * Why do this? Two reasons:
  *  1. Reduces the number of files the user's browser needs to download.
  *  2. Allows these cached files to be compressed/minified by the admin.
  * 
  * TODO: This should really be configurable somehow...
  */
 protected function add_auto_html_headers()
 {
     global $config;
     $data_href = get_base_href();
     $theme_name = $config->get_string('theme', 'default');
     $this->add_html_header("<script type='text/javascript'>base_href = '{$data_href}';</script>", 40);
     # 404/static handler will map these to themes/foo/bar.ico or lib/static/bar.ico
     $this->add_html_header("<link rel='icon' type='image/x-icon' href='{$data_href}/favicon.ico'>", 41);
     $this->add_html_header("<link rel='apple-touch-icon' href='{$data_href}/apple-touch-icon.png'>", 42);
     $css_files = array();
     $css_latest = 0;
     foreach (array_merge(zglob("lib/*.css"), zglob("ext/*/style.css"), zglob("themes/{$theme_name}/style.css")) as $css) {
         $css_files[] = $css;
         $css_latest = max($css_latest, filemtime($css));
     }
     $css_cache_file = data_path("cache/style.{$theme_name}.{$css_latest}.css");
     if (!file_exists($css_cache_file)) {
         $css_data = "";
         foreach ($css_files as $file) {
             $file_data = file_get_contents($file);
             $pattern = '/url[\\s]*\\([\\s]*["\']?([^"\'\\)]+)["\']?[\\s]*\\)/';
             $replace = 'url("../../' . dirname($file) . '/$1")';
             $file_data = preg_replace($pattern, $replace, $file_data);
             $css_data .= $file_data . "\n";
         }
         file_put_contents($css_cache_file, $css_data);
     }
     $this->add_html_header("<link rel='stylesheet' href='{$data_href}/{$css_cache_file}' type='text/css'>", 43);
     $js_files = array();
     $js_latest = 0;
     foreach (array_merge(zglob("lib/*.js"), zglob("ext/*/script.js"), zglob("themes/{$theme_name}/script.js")) as $js) {
         $js_files[] = $js;
         $js_latest = max($js_latest, filemtime($js));
     }
     $js_cache_file = data_path("cache/script.{$theme_name}.{$js_latest}.js");
     if (!file_exists($js_cache_file)) {
         $js_data = "";
         foreach ($js_files as $file) {
             $js_data .= file_get_contents($file) . "\n";
         }
         file_put_contents($js_cache_file, $js_data);
     }
     $this->add_html_header("<script src='{$data_href}/{$js_cache_file}' type='text/javascript'></script>", 44);
 }
Пример #23
0
    /**
     * turns the Page into HTML
     */
    public 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->headers);
        foreach ($page->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 .= $this->block_to_html($block, true, "left");
                    break;
                case "main":
                    $main_block_html .= $this->block_to_html($block, false, "main");
                    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;
            }
        }
        $debug = get_debug_info();
        $contact = empty($contact_link) ? "" : "<br><a href='{$contact_link}'>Contact</a>";
        $wrapper = "";
        if (strlen($page->heading) > 100) {
            $wrapper = ' style="height: 3em; overflow: auto;"';
        }
        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</head>

\t<body>
\t\t<h1{$wrapper}>{$page->heading}</h1>

\t\t{$sub_block_html}

\t\t<div id="nav">{$left_block_html}</div>
\t\t<div id="body">{$main_block_html}</div>

\t\t<div id="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; Co 2007-2010,
\t\t\tbased on the Danbooru concept.
\t\t\t{$debug}
\t\t\t{$contact}
\t\t</div>
\t</body>
</html>
EOD;
    }
Пример #24
0
/**
 * Returns a pagination object to be used for setting display options
 * on the front end
 */
function create_pagination_display_obj($pagination_results, $count, $filter_args = array())
{
    $pagination_results['total'] = intval($count['count']);
    $pagination_results['more'] = $pagination_results['offset'] + $pagination_results['perpage'] < $pagination_results['total'] ? true : false;
    $pagination_results['total_fmt'] = number_format($count['count']);
    if ($pagination_results['total'] <= $pagination_results['perpage']) {
        $pagination_results['hide'] = true;
    }
    // create query string from any filter args passed in, ie. time, place...
    $filter_query = http_build_query($filter_args);
    // set pagination links
    if ($pagination_results['more']) {
        $pagination_results['next_link'] = get_base_href() . '?page=' . ($pagination_results['page'] + 1);
        if (!empty($filter_query)) {
            $pagination_results['next_link'] .= '&' . $filter_query;
        }
    }
    if ($pagination_results['page'] > 1) {
        $pagination_results['prev_link'] = get_base_href() . '?page=' . ($pagination_results['page'] - 1);
        if (!empty($filter_query)) {
            $pagination_results['prev_link'] .= '&' . $filter_query;
        }
    }
    return $pagination_results;
}
Пример #25
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;
    }
Пример #26
0
    /**
     * @return string
     */
    protected function h_bookmarklets()
    {
        global $config;
        $link = make_http(make_link("upload"));
        $main_page = make_http(make_link());
        $title = $config->get_string('title');
        $max_size = $config->get_int('upload_size');
        $max_kb = to_shorthand_int($max_size);
        $delimiter = $config->get_bool('nice_urls') ? '?' : '&amp;';
        $html = '';
        $js = 'javascript:(
			function() {
				if(typeof window=="undefined" || !window.location || window.location.href=="about:blank") {
					window.location = "' . $main_page . '";
				}
				else if(typeof document=="undefined" || !document.body) {
					window.location = "' . $main_page . '?url="+encodeURIComponent(window.location.href);
				}
				else if(window.location.href.match("\\/\\/' . $_SERVER["HTTP_HOST"] . '.*")) {
					alert("You are already at ' . $title . '!");
				}
				else {
					var tags = prompt("Please enter tags", "tagme");
					if(tags != "" && tags != null) {
						var link = "' . $link . $delimiter . 'url="+location.href+"&tags="+tags;
						var w = window.open(link, "_blank");
					}
				}
			}
		)();';
        $html .= '<a href=\'' . $js . '\'>Upload to ' . $title . '</a>';
        $html .= ' (Drag &amp; drop onto your bookmarks toolbar, then click when looking at an image)';
        // Bookmarklet checks if shimmie supports ext. If not, won't upload to site/shows alert saying not supported.
        $supported_ext = "jpg jpeg gif png";
        if (class_exists("FlashFileHandler")) {
            $supported_ext .= " swf";
        }
        if (class_exists("ICOFileHandler")) {
            $supported_ext .= " ico ani cur";
        }
        if (class_exists("MP3FileHandler")) {
            $supported_ext .= " mp3";
        }
        if (class_exists("SVGFileHandler")) {
            $supported_ext .= " svg";
        }
        if (class_exists("VideoFileHandler")) {
            $supported_ext .= " flv mp4 ogv webm m4v";
        }
        $title = "Booru to " . $config->get_string('title');
        // CA=0: Ask to use current or new tags | CA=1: Always use current tags | CA=2: Always use new tags
        $html .= '<p><a href="javascript:
			var ste=&quot;' . $link . $delimiter . 'url=&quot;;
			var supext=&quot;' . $supported_ext . '&quot;;
			var maxsize=&quot;' . $max_kb . '&quot;;
			var CA=0;
			void(document.body.appendChild(document.createElement(&quot;script&quot;)).src=&quot;' . make_http(get_base_href()) . "/ext/upload/bookmarklet.js" . '&quot;)
		">' . $title . '</a> (Click when looking at an image page. Works on sites running Shimmie / Danbooru / Gelbooru. (This also grabs the tags / rating / source!))';
        return $html;
    }
Пример #27
0
 private function getAll()
 {
     global $database;
     $data_href = get_base_href();
     $url = $data_href . "/ext/tips/images/";
     $tips = $database->get_all("SELECT * FROM tips ORDER BY id ASC");
     $this->theme->showAll($url, $tips);
 }
Пример #28
0
    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 = get_prefixed_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>";
            set_prefixed_cookie("flash_message", "", -1, "/");
        }
        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;
    }
Пример #29
0
 protected function add_auto_headers()
 {
     $data_href = get_base_href();
     foreach (glob("lib/*.js") as $js) {
         $this->add_header("<script src='{$data_href}/{$js}' type='text/javascript'></script>");
     }
     foreach (glob("lib/*.css") as $css) {
         $this->add_header("<link rel='stylesheet' href='{$data_href}/{$css}' type='text/css'>");
     }
     $css_files = glob("ext/*/style.css");
     if ($css_files) {
         foreach ($css_files as $css_file) {
             $this->add_header("<link rel='stylesheet' href='{$data_href}/{$css_file}' type='text/css'>");
         }
     }
     $js_files = glob("ext/*/script.js");
     if ($js_files) {
         foreach ($js_files as $js_file) {
             $this->add_header("<script src='{$data_href}/{$js_file}' type='text/javascript'></script>");
         }
     }
 }
Пример #30
0
    /**
     * turns the Page into HTML
     */
    public function display_page(Page $page)
    {
        global $config;
        $theme_name = $config->get_string('theme', 'material');
        $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');
        $site_link = make_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 = "";
        $drawer_block_html = "";
        //use exampled in user.theme.php & view.theme.php
        $toolbar_block_html = "";
        // not used at this point
        $subtoolbar_block_html = "";
        // use exampled in user.theme.php
        $navigation = "";
        $h_search = "\n      <div class='mdl-textfield mdl-js-textfield mdl-textfield--expandable\n                  mdl-textfield--floating-label mdl-textfield--align-right'>\n        <form action='" . make_link() . "' method='GET'>\n          <label class='mdl-button mdl-js-button mdl-button--icon'\n                 for='waterfall-exp'>\n            <i class='material-icons'>search</i>\n          </label>\n          <div class='mdl-textfield__expandable-holder'>\n            <input id='waterfall-exp' class='autocomplete_tags mdl-textfield__input' name='search' type='text' placeholder='Search' value='' />\n            <input type='hidden' name='q' value='/post/list'>\n            <input type='submit' value='Find' style='display: none;' />\n          </div>\n        </form>\n      </div>\n    ";
        foreach ($page->blocks as $block) {
            switch ($block->section) {
                case "toolbar":
                    $toolbar_block_html .= $this->get_html($block, "toolbar");
                    break;
                case "subtoolbar":
                    $subtoolbar_block_html .= $this->get_html($block, "subtoolbar");
                    break;
                case "left":
                    if ($block->header == "Navigation") {
                        $subtoolbar_block_html = $this->rework_navigation($block);
                        break;
                    }
                    // $left_block_html .= $block->get_html(true);
                    $left_block_html .= $this->get_html($block, "full", true, "left-blocks nav-card mdl-cell--4-col-tablet");
                    break;
                case "head":
                    $head_block_html .= $this->get_html($block, "third", true, "nav-card head-blocks");
                    break;
                case "drawer":
                    $drawer_block_html .= $this->get_html($block, "full", true, "nav-card drawer-blocks");
                    break;
                case "main":
                    // $main_block_html .= $block->get_html(false);
                    $main_block_html .= $this->get_html($block, "main", true, "");
                    break;
                case "subheading":
                    // $sub_block_html .= $block->body; // $this->block_to_html($block, true);
                    $sub_block_html .= $this->get_html($block, "third", true, "nav-card");
                    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 = get_prefixed_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>";
            set_prefixed_cookie("flash_message", "", -1, "/");
        }
        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>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
\t\t<title>{$page->title}</title>
    <link rel="stylesheet" href="//fonts.googleapis.com/css?family=Roboto:regular,bold,italic,thin,light,bolditalic,black,medium&amp;lang=en">
    <link rel="stylesheet" href="//fonts.googleapis.com/icon?family=Material+Icons"  rel="stylesheet">
    <link rel="stylesheet" href="{$data_href}/themes/{$theme_name}/material.min.css?v1.0.5"  rel="stylesheet">
    {$header_html}
\t\t<script type="text/javascript" src="{$data_href}/themes/{$theme_name}/material.min.js?v1.0.5"></script>
\t\t<script type="text/javascript" src="{$data_href}/themes/{$theme_name}/script0.js?v1"></script>
    <!-- having conflicts this ensures the screens will not remain hidden \\while the layout is adjusted -->
\t</head>

\t<body>

    <div class="mdl-layout mdl-js-layout mdl-layout--fixed-header">
      <header class="mdl-layout__header mdl-layout__header--waterfall">
        <!-- Top row, always visible -->
        <div class="mdl-layout__header-row ">
          <!-- Title -->
          <span class="mdl-layout-title">
            <a class="mdl-logo" href="{$site_link}">{$site_name}</a>
          </span>
          <div class="mdl-layout-spacer"></div>
          {$h_search}
          {$toolbar_block_html}
          <button id="menu-left-col-menu"
                  class="mdl-button mdl-js-button mdl-button--icon">
            <i class="material-icons">more_vert</i>
          </button>
        </div>
        <!-- Bottom row, not visible on scroll -->
        <div class="mdl-layout__header-row">
          <div class="mdl-layout-spacer"></div>
          <!-- Navigation -->
          {$subtoolbar_block_html}
        </div>
      </header>
      <div class="mdl-layout__drawer">
        <span class="mdl-layout-title">Drawer</span>
          <div class="mdl-grid">
            {$drawer_block_html}
          </div>
        <nav class="mdl-navigation">
          <a class="mdl-navigation__link" href="http://code.shishnet.org/shimmie2/">Shimmie  &copy;</a>
        </nav>
      </div>
      <main class="mdl-layout__content">
        <div class="mdl-grid">
          <div class="mdl-cell mdl-cell--12-col mdl-grid ">
            {$head_block_html}
            {$sub_block_html}
          </div>
        </div>
        <div id="main-grid" class="mdl-grid">
          <div id="left-block" class="mdl-cell mdl-cell--4-col mdl-cell--8-col-tablet mdl-cell--4-col-phone mdl-color--grey-200">
            <script>
              document.getElementById("left-block").style.display="none";
            </script>
            <div id="left-blk-content" class="mdl-cell mdl-cell--12-col mdl-grid">
              <!-- Start Left Block -->
              {$left_block_html}
            </div>
          </div>
          <div id="main-block" class="mdl-cell mdl-shadow--2dp mdl-cell--8-col mdl-cell--8-col-tablet mdl-color--grey-200 mdl-grid">
              <script>
                document.getElementById("main-block").style.display="none";
              </script>
              <!-- Start art Block -->
              <article class="mdl-cell mdl-cell--12-col mdl-cell--top">
              {$flash_html}
              {$main_block_html}
              </article>
          </div>
        </div>
          <footer class="mdl-mini-footer">
              {$debug}
              {$contact}
          </footer>
      </main>
    </div>

    <ul class="mdl-menu mdl-menu--bottom-right mdl-js-menu mdl-js-ripple-effect"
        for="menu-left-col-menu">
      <li id="layout-top" class="mdl-menu__item">Layout Top</li>
      <li id="layout-right" class="mdl-menu__item">Layout Right</li>
      <li id="layout-bottom" class="mdl-menu__item">Layout Bottom</li>
      <li id="layout-left" class="mdl-menu__item">Layout Left</li>
    </ul>
\t</body>
</html>
EOD;
    }