Beispiel #1
0
 /**
  * ============================================================
  *  GET ACCEPTED USER(S) DATA
  * ============================================================
  *
  * -- CODE: ---------------------------------------------------
  *
  *    echo Guardian::ally('mecha');
  *
  * ------------------------------------------------------------
  *
  *    var_dump(Guardian::ally());
  *
  * ------------------------------------------------------------
  *
  */
 public static function ally($user = null, $fallback = false)
 {
     if ($file = File::exist(LOG . DS . 'users.txt')) {
         $ally = array();
         foreach (explode("\n", file_get_contents($file)) as $str) {
             $s = trim($str);
             // serialized array
             if (strpos($s, 'a:') === 0) {
                 $s = unserialize($s);
                 // encoded JSON array
             } else {
                 if (strpos($s, '{"') === 0) {
                     $s = json_decode($s, true);
                     // Pattern 1: `user: pass (Author Name: status) email@domain.com`
                     // Pattern 2: `user: pass (Author Name $status) email@domain.com`
                 } else {
                     if (preg_match('#^(.*?)\\:\\s*(.*?)\\s+\\((.*?)(?:\\s*\\$|\\:\\s*)(pilot|[a-z0-9_.]+)\\)(?:\\s+(.*?))?$#', $s, $matches)) {
                         $s = array();
                         $s['user'] = $matches[1];
                         $s['pass'] = $matches[2];
                         $s['name'] = $matches[3];
                         $s['status'] = $matches[4];
                         $s['email'] = isset($matches[5]) && !empty($matches[5]) ? $matches[5] : false;
                     } else {
                         self::abort('Broken <code>' . LOG . DS . 'users.txt</code> format.');
                     }
                 }
             }
             foreach ($s as $k => $v) {
                 $v = Converter::strEval($v);
                 $s[$k . '_raw'] = Filter::colon('user:'******'_raw', $v, $s);
                 $s[$k] = Filter::colon('user:'******'user']] = Filter::apply('user', $s, $s['user']);
         }
         $ally = Filter::apply('users', $ally);
         if (is_null($user)) {
             return $ally;
         }
         return isset($ally[$user]) ? $ally[$user] : $fallback;
     } else {
         self::abort('Missing <code>' . LOG . DS . 'users.txt</code> file.');
     }
 }
Beispiel #2
0
function do_facebook_open_graph()
{
    $config = Config::get();
    $T2 = str_repeat(TAB, 2);
    echo O_BEGIN . $T2 . '<!-- Start Facebook Open Graph -->' . NL;
    echo $T2 . '<meta property="og:title" content="' . Text::parse($config->page_title, '->text') . '"' . ES . NL;
    echo $T2 . '<meta property="og:url" content="' . Filter::colon('og:url', $config->url_current) . '"' . ES . NL;
    if (isset($config->{$config->page_type}->description)) {
        $config->description = $config->{$config->page_type}->description;
    }
    echo $T2 . '<meta property="og:description" content="' . Text::parse($config->description, '->text') . '"' . ES . NL;
    if ($config->page_type !== '404' && isset($config->{$config->page_type}->image)) {
        echo $T2 . '<meta property="og:image" content="' . $config->{$config->page_type}->image . '"' . ES . NL;
    } else {
        echo $T2 . '<meta property="og:image" content="' . Filter::colon('favicon:url', $config->url . '/favicon.ico') . '"' . ES . NL;
    }
    echo $T2 . '<meta property="og:site_name" content="' . $config->title . '"' . ES . NL;
    echo $T2 . '<meta property="og:type" content="' . ($config->page_type === 'article' ? 'article' : 'website') . '"' . ES . NL;
    echo $T2 . '<!-- End Facebook Open Graph -->' . O_END;
}
function do_twitter_cards()
{
    $config = Config::get();
    $twitter_cards_config = File::open(__DIR__ . DS . 'states' . DS . 'config.txt')->unserialize();
    $T2 = str_repeat(TAB, 2);
    echo O_BEGIN . $T2 . '<!-- Start Twitter Cards -->' . NL;
    echo $T2 . '<meta name="twitter:card" content="' . (isset($config->{$config->page_type}->image) && $config->{$config->page_type}->image !== Image::placeholder() ? 'summary_large_image' : 'summary') . '"' . ES . NL;
    echo $T2 . '<meta name="twitter:site" content="@' . $twitter_cards_config['twitter_site'] . '"' . ES . NL;
    echo $T2 . '<meta name="twitter:creator" content="@' . $twitter_cards_config['twitter_creator'] . '"' . ES . NL;
    echo $T2 . '<meta name="twitter:title" content="' . Text::parse($config->page_title, '->text') . '"' . ES . NL;
    echo $T2 . '<meta name="twitter:url" content="' . Filter::colon('twitter:url', $config->url_current) . '"' . ES . NL;
    if (isset($config->{$config->page_type}->description)) {
        $config->description = $config->{$config->page_type}->description;
    }
    echo $T2 . '<meta name="twitter:description" content="' . Text::parse($config->description, '->text') . '"' . ES . NL;
    if ($config->page_type !== '404' && isset($config->{$config->page_type}->image)) {
        echo $T2 . '<meta name="twitter:image" content="' . $config->{$config->page_type}->image . '"' . ES . NL;
    } else {
        echo $T2 . '<meta name="twitter:image" content="' . $config->url . '/favicon.ico"' . ES . NL;
    }
    echo $T2 . '<!-- End Twitter Cards -->' . O_END;
}
Beispiel #4
0
function do_meta_3()
{
    $config = Config::get();
    $speak = Config::speak();
    $html = Cell::link(Filter::colon('favicon:url', $config->url . '/favicon.ico'), 'shortcut icon', 'image/x-icon', array(), 2) . NL;
    $html .= Cell::link(Filter::colon('canonical:url', $config->url_current), 'canonical', null, array(), 2) . NL;
    $html .= Cell::link(Filter::colon('sitemap:url', $config->url . '/sitemap'), 'sitemap', null, array(), 2) . NL;
    $html .= Cell::link(Filter::colon('feed:url', $config->url . '/feed/rss'), 'alternate', 'application/rss+xml', array('title' => $speak->feeds . $config->title_separator . $config->title), 2) . O_END;
    echo Filter::apply('meta', $html, 3);
}
Beispiel #5
0
<?php

$bucket = array();
$url_base = $config->url . '/feed/json';
$json_order = strtoupper(Request::get('order', 'DESC'));
$json_filter = Request::get('filter', "");
$json_limit = Request::get('chunk', 25);
if ($pages = Mecha::eat(Get::articles($json_order, $json_filter))->chunk($config->offset, $json_limit)->vomit()) {
    foreach ($pages as $path) {
        $bucket[] = Get::articleHeader($path);
    }
}
$json = array('meta' => array('generator' => 'Mecha ' . MECHA_VERSION, 'title' => $config->title, 'slogan' => $config->slogan, 'url' => array('home' => $config->url, 'previous' => $config->offset > 1 ? Filter::colon('feed:url', $url_base . '/' . ($config->offset - 1)) : null, 'next' => $config->offset < ceil($config->total_articles / $json_limit) ? Filter::colon('feed:url', $url_base . '/' . ($config->offset + 1)) : null), 'description' => $config->description, 'update' => date('c'), 'author' => (array) $config->author, 'offset' => $config->offset, 'total' => $config->total_articles, 'tags' => Get::articleTags()), 'item' => null);
if (!empty($bucket)) {
    $json['item'] = array();
    foreach ($bucket as $i => $item) {
        $json['item'][$i] = array('title' => $item->title, 'url' => $item->url, 'date' => $item->date->W3C, 'update' => Date::format($item->update, 'c'), 'id' => $item->id, 'description' => $item->description, 'kind' => Mecha::A($item->kind));
        Weapon::fire('json_item', array(&$json['item'][$i], $item, $i));
    }
}
Weapon::fire('json_meta', array(&$json['meta']));
echo (isset($_GET['callback']) ? $_GET['callback'] . '(' : "") . json_encode($json) . (isset($_GET['callback']) ? ');' : "");
Beispiel #6
0
 /**
  * ==========================================================================
  *  EXTRACT RESPONSE FILE INTO LIST OF RESPONSE DATA FROM ITS PATH/ID/TIME
  * ==========================================================================
  *
  * -- CODE: -----------------------------------------------------------------
  *
  *    var_dump(Get::response(1399334470));
  *
  * --------------------------------------------------------------------------
  *
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  *  Parameter  | Type   | Description
  *  ---------- | ------ | ---------------------------------------------------
  *  $reference | string | Response path, ID or time
  *  $excludes  | array  | Exclude some field(s) from result(s)
  *  $folder    | string | Folder of response(s) and response(s)' post
  *  $connector | string | Path connector for permalink URL
  *  $FP        | string | Filter prefix for `Text::toPage()`
  *  ---------- | ------ | ---------------------------------------------------
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  *
  */
 public static function response($reference, $excludes = array(), $folder = array(), $connector = '/', $FP = 'response:')
 {
     $config = Config::get();
     $excludes = array_flip($excludes);
     $results = false;
     if (!is_array($reference)) {
         // By time => `2014-06-21-20-05-17` or by ID => `1403355917`
         if (strpos($reference, $folder[0]) !== 0) {
             $reference = self::responsePath($reference, $folder[0]);
         }
         // By path => `lot\responses\$folder[0]\2014-05-24-11-17-06_2014-06-21-20-05-17_0000-00-00-00-00-00.txt`
         $results = self::responseExtract($reference, $FP);
     } else {
         // From `Get::responseExtract()`
         $results = $reference;
     }
     if (!$results || !file_exists($results['path'])) {
         return false;
     }
     $results['date'] = Filter::colon($FP . 'date', Date::extract($results['time']), $results);
     $results = $results + Text::toPage(file_get_contents($results['path']), 'message', $FP, array('url' => '#', 'content_type' => $config->html_parser->active, 'fields' => array(), 'message' => ""), $results);
     if (!isset($excludes['permalink'])) {
         if ($path = self::postPath($results['post'], $folder[1])) {
             $link = self::postAnchor($path, $folder[1], $connector, "")->url . '#' . rtrim($FP, ':') . '-' . $results['id'];
         } else {
             $link = '#';
         }
         $results['permalink'] = Filter::colon($FP . 'permalink', $link, $results);
     }
     if (!isset($excludes['fields'])) {
         self::__fields($results, $FP);
     }
     foreach ($results as $key => $value) {
         if (isset($excludes[$key])) {
             unset($results[$key]);
         }
     }
     return Mecha::O($results);
 }
Beispiel #7
0
echo '<link>' . $config->url . '/</link>';
echo '<description>' . $config->description . '</description>';
echo '<lastBuildDate>' . Date::format(time(), 'r') . '</lastBuildDate>';
echo '<atom:link rel="self" href="' . $config->url_current . '"/>';
echo $config->offset > 1 ? '<atom:link rel="previous" href="' . Filter::colon('feed:url', $url_base . '/' . ($config->offset - 1)) . '"/>' : "";
echo $config->offset < ceil($config->total_articles / $rss_limit) ? '<atom:link rel="next" href="' . Filter::colon('feed:url', $url_base . '/' . ($config->offset + 1)) . '"/>' : "";
Weapon::fire('rss_meta');
if (!empty($bucket)) {
    foreach ($bucket as $i => $item) {
        $title = strip_tags($item->title);
        $description = $item->description;
        $kind = Mecha::A($item->kind);
        echo '<item>';
        echo '<title><![CDATA[' . $title . ']]></title>';
        echo '<link>' . $item->url . '</link>';
        echo '<description><![CDATA[' . $description . ']]></description>';
        echo '<pubDate>' . Date::format($item->time, 'r') . '</pubDate>';
        echo '<guid>' . $item->url . '</guid>';
        if (!empty($kind)) {
            foreach ($kind as $k) {
                $tag = Get::articleTag($k);
                echo '<category domain="' . Filter::colon('tag:url', $config->url . '/' . $config->tag->slug . '/' . $tag->slug) . '">' . $tag->name . '</category>';
            }
        }
        echo '<source url="' . $item->url . '"><![CDATA[' . $config->title . ': ' . $title . ']]></source>';
        Weapon::fire('rss_item', array($item, $i));
        echo '</item>';
    }
}
echo '</channel>';
echo '</rss>';
Beispiel #8
0
        return $results;
    }
    // Include comment(s) data
    $c = array();
    $cc = 0;
    $ccc = '0 ' . $speak->comments;
    if ($comments = Get::comments('ASC', 'post:' . $results->id, Guardian::happy() ? 'txt,hold' : 'txt')) {
        $cc = $comments !== false ? count($comments) : 0;
        $ccc = $cc . ' ' . ($cc === 1 ? $speak->comment : $speak->comments);
        foreach ($comments as $comment) {
            $c[] = Get::comment($comment);
        }
        $results->comments = Filter::colon($FP . 'comments', $c, $results);
    }
    $results->total_comments = Filter::colon($FP . 'total_comments', $cc, $results);
    $results->total_comments_text = Filter::colon($FP . 'total_comments_text', $ccc, $results);
    unset($comments, $c, $cc, $ccc);
    return $results;
});
/**
 * ==========================================================================
 *  GET COMMENT PATH
 * ==========================================================================
 *
 * -- CODE: -----------------------------------------------------------------
 *
 *    var_dump(Get::commentPath(1399334470));
 *
 * --------------------------------------------------------------------------
 *
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Beispiel #9
0
         }
     }
     Menu::add('manager', $menus);
     $html .= Menu::manager('ul', $T1);
 }
 if ($type === 'BAR') {
     $bars = array();
     if ($_bars = Mecha::A(Config::get('manager_bar'))) {
         $_bars = Mecha::eat($_bars)->order('ASC', 'stack', true, 10)->vomit();
         foreach ($_bars as $k => $v) {
             if (is_string($v)) {
                 $bar = $v;
             } else {
                 $t = ' data-tooltip="' . Text::parse(isset($v['description']) ? $v['description'] : $k, '->encoded_html') . '"';
                 if (isset($v['url'])) {
                     $url = Filter::colon('manager:url', Converter::url($v['url']));
                     $c = $config->url_current === $url ? ' ' . Widget::$config['classes']['current'] : "";
                     $bar = '<a class="item' . $c . '" href="' . $url . '"' . $t . '>';
                 } else {
                     $bar = '<span class="item a"' . $t . '>';
                 }
                 $bar .= isset($v['icon']) ? strpos($v['icon'], '<') === false ? Jot::icon($v['icon']) : $v['icon'] : $k;
                 $bar .= ' <span class="label">' . $k . '</span>';
                 if (isset($v['count']) && ($v['count'] === '&infin;' || (double) $v['count'] > 0)) {
                     $bar .= ' <span class="counter">' . $v['count'] . '</span>';
                 }
                 $bar .= isset($v['url']) ? '</a>' : '</span>';
             }
             $bars[] = $bar;
         }
     }
$brush = Text::parse($brush, '->text');
if (is_numeric($brush) && $brush <= 0) {
    $brush = false;
}
$_ = File::D(__DIR__) . DS . 'assets' . DS;
echo '<!DOCTYPE html>' . NL;
echo '<html dir="ltr">' . NL;
echo TAB . '<head>' . NL;
echo str_repeat(TAB, 2) . '<meta charset="' . $config->charset . '">' . NL;
echo str_repeat(TAB, 2) . '<title>' . File::B($snippet) . '</title>' . NL;
echo str_repeat(TAB, 2) . '<link href="' . Filter::colon('favicon:url', $config->url . '/favicon.ico') . '" rel="shortcut icon" type="image/x-icon">' . NL;
echo str_repeat(TAB, 2) . Asset::stylesheet(array($_ . 'shell' . DS . 'page.min.css', $_ . 'shell' . DS . 'brush.min.css'));
echo TAB . '</head>' . NL;
echo TAB . '<body>' . NL;
echo str_repeat(TAB, 2) . '<pre><code' . ($brush !== false ? ' data-language="' . $brush . '"' : "") . '>';
echo Filter::colon('snippet:content_raw', Text::parse($content, '->encoded_html'), $snippet);
echo '</code></pre>' . NL;
echo str_repeat(TAB, 2) . '<div>' . NL;
echo str_repeat(TAB, 3) . '<strong><a href="' . $config->url . '" title="' . $speak->home . '">' . $config->title . '</a></strong>' . NL;
echo str_repeat(TAB, 3) . '<a href="?raw=1" target="_blank">' . $speak->plugin_snippet_share_title_raw . '</a>' . NL;
echo str_repeat(TAB, 3) . '<a href="?file=1">' . $speak->download . '</a>' . NL;
echo str_repeat(TAB, 2) . '</div>' . NL;
echo str_repeat(TAB, 2) . Asset::javascript(array($_ . 'sword' . DS . 'brush.min.js', $_ . 'sword' . DS . 'brush.line.min.js'));
if ($brush !== false) {
    echo str_repeat(TAB, 2) . Asset::javascript($_ . 'sword' . DS . 'brush' . DS . 'generic.min.js');
    if ($brush !== 'generic' && ($f = File::exist($_ . 'sword' . DS . 'brush' . DS . $brush . '.min.js'))) {
        echo str_repeat(TAB, 2) . Asset::javascript($f);
    }
}
echo TAB . '</body>' . NL;
echo '</html>';
Beispiel #11
0
<?php

$bucket = array();
if ($config->total_pages > 0) {
    foreach (Get::pages() as $page) {
        list($time, $kind, $slug) = explode('_', File::N($page), 3);
        $bucket[] = (object) array('url' => Filter::colon('page:url', $config->url . '/' . $slug), 'date' => Filter::colon('page:time', Date::format($time, 'c')), 'changefreq' => 'weekly', 'priority' => (string) '0.5');
    }
}
if ($config->total_articles > 0) {
    foreach (Get::articles() as $article) {
        list($time, $kind, $slug) = explode('_', File::N($article), 3);
        $bucket[] = (object) array('url' => Filter::colon('article:url', $config->url . '/' . $config->index->slug . '/' . $slug), 'date' => Filter::colon('article:time', Date::format($time, 'c')), 'changefreq' => 'weekly', 'priority' => (string) '1.0');
    }
}
echo '<?xml version="1.0" encoding="UTF-8" ?>';
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
if (!empty($bucket)) {
    foreach ($bucket as $i => $item) {
        echo '<url>';
        echo '<loc>' . $item->url . '</loc>';
        echo '<lastmod>' . $item->date . '</lastmod>';
        echo '<changefreq>' . $item->changefreq . '</changefreq>';
        echo '<priority>' . $item->priority . '</priority>';
        Weapon::fire('sitemap_item', array($item, $i));
        echo '</url>';
    }
}
echo '</urlset>';
Beispiel #12
0
 protected static function __doParseHeaders($text, $FP, $data)
 {
     $results = array();
     $headers = explode("\n", trim($text));
     foreach ($headers as $header) {
         $field = explode(S, $header, 2);
         if (!isset($field[1])) {
             $field[1] = 'false';
         }
         $key = Text::parse(trim($field[0]), '->array_key', true);
         $value = Converter::DS(trim($field[1]));
         $value = Filter::colon($FP . $key . '_raw', Converter::strEval($value), $data);
         $results[$key . '_raw'] = $value;
         $value = Filter::colon($FP . $key, $value, $data);
         $results[$key] = $value;
     }
     return $results;
 }
Beispiel #13
0
<?php

if (isset($article->tags)) {
    $tags = array();
    foreach ($article->tags as $tag) {
        if ($tag && $tag->id !== 0) {
            $url = Filter::colon('tag:url', $config->url . '/' . $config->tag->slug . '/' . $tag->slug);
            $tags[] = '<a href="' . $url . '" rel="tag">' . $tag->name . '</a>';
        }
    }
    $s = count($tags) > 1 ? $speak->tags : $speak->tag;
    echo !empty($tags) ? $s . ': ' . implode(', ', $tags) : "";
}
Beispiel #14
0
 public static function merge($path, $name = null, $addon = "", $call = null)
 {
     $the_path = strpos($name, ROOT) === 0 ? File::path($name) : ASSET . DS . File::path($name);
     $the_log = LOG . DS . 'asset.' . str_replace(array(ASSET . DS, DS), array("", '__'), $the_path) . '.log';
     $is_valid = true;
     if (!file_exists($the_log)) {
         $is_valid = false;
     } else {
         $the_time = explode("\n", file_get_contents($the_log));
         if (count($the_time) !== count($path)) {
             $is_valid = false;
         } else {
             foreach ($the_time as $i => $unix) {
                 $p = self::path($path[$i]);
                 if (!file_exists($p) || (int) filemtime($p) !== (int) $unix) {
                     $is_valid = false;
                     break;
                 }
             }
         }
     }
     $unix = "";
     $content = "";
     $e = File::E($name);
     if (!file_exists($the_path) || !$is_valid) {
         if (Text::check($e)->in(array('gif', 'jpeg', 'jpg', 'png'))) {
             foreach ($path as &$p) {
                 $p = Filter::colon('asset:source', $p);
                 if (!self::ignored($p) && ($p = Filter::colon('asset:path', self::path($p, false)))) {
                     $unix .= filemtime($p) . "\n";
                 }
             }
             File::write(trim($unix))->saveTo($the_log);
             Image::take($path)->merge()->saveTo($the_path);
         } else {
             foreach ($path as $p) {
                 $p = Filter::colon('asset:source', $p);
                 if (!self::ignored($p) && ($p = Filter::colon('asset:path', self::path($p, false)))) {
                     $unix .= filemtime($p) . "\n";
                     $c = Filter::apply('asset:input', file_get_contents($p) . "\n", $p);
                     if (strpos(File::B($p), '.min.') === false) {
                         if (strpos(File::B($the_path), '.min.css') !== false) {
                             $c = Converter::detractShell($c);
                         } else {
                             if (strpos(File::B($the_path), '.min.js') !== false) {
                                 $c = Converter::detractSword($c);
                             } else {
                                 $c = $c . "\n";
                             }
                         }
                         $content .= Filter::apply('asset:output', $c, $p);
                     } else {
                         $content .= Filter::apply('asset:output', $c . "\n", $p);
                     }
                 }
             }
             File::write(trim($unix))->saveTo($the_log);
             File::write(trim($content))->saveTo($the_path);
         }
     }
     if (is_null($call)) {
         $call = Mecha::alter($e, array('css' => 'stylesheet', 'js' => 'javascript', 'gif' => 'image', 'jpeg' => 'image', 'jpg' => 'image', 'png' => 'image'));
     }
     return call_user_func('self::' . $call, $the_path, $addon);
 }
Beispiel #15
0
<?php

Weapon::add('meta', function () {
    $config = Config::get();
    $T2 = str_repeat(TAB, 2);
    echo O_BEGIN . $T2 . '<!-- Start Facebook Open Graph -->' . NL;
    echo $T2 . '<meta property="og:title" content="' . Text::parse($config->page_title, '->text') . '"' . ES . NL;
    echo $T2 . '<meta property="og:type" content="' . ($config->page_type === 'article' ? 'article' : 'website') . '"' . ES . NL;
    echo $T2 . '<meta property="og:url" content="' . Filter::colon('og:url', $config->url_current) . '"' . ES . NL;
    if ($config->page_type !== '404' && isset($config->{$config->page_type}->image)) {
        echo $T2 . '<meta property="og:image" content="' . $config->{$config->page_type}->image . '"' . ES . NL;
    }
    echo $T2 . '<meta property="og:site_name" content="' . $config->title . '"' . ES . NL;
    if (isset($config->{$config->page_type}->description)) {
        $config->description = $config->{$config->page_type}->description;
    }
    echo $T2 . '<meta property="og:description" content="' . Text::parse($config->description, '->text') . '"' . ES . NL;
    echo $T2 . '<!-- End Facebook Open Graph -->' . O_END;
}, 11);
Beispiel #16
0
 /**
  * Widget Search Form
  * ------------------
  *
  * [1]. Widget::search();
  * [2]. Widget::search('search query...');
  * [3]. Widget::search('search query...', '<i class="icon icon-search"></i>');
  *
  */
 public static function search($placeholder = null, $submit = null)
 {
     $T1 = TAB;
     $T2 = str_repeat($T1, 2);
     $id = Config::get('widget_search_form_id', 0) + 1;
     $config = Config::get();
     $speak = Config::speak();
     $html = O_BEGIN . '<div class="widget widget-search widget-search-form" id="widget-search-form-' . $id . '">' . NL;
     $html .= $T1 . '<form action="' . Filter::colon('search:url', $config->url . '/' . $config->search->slug) . '" method="post">' . NL;
     $html .= $T2 . '<input type="text" name="q" value="' . $config->search_query . '"' . (!is_null($placeholder) ? ' placeholder="' . $placeholder . '"' : "") . ' autocomplete="off"' . ES . ($submit !== false ? ' <button type="submit">' . (is_null($submit) ? $speak->search : $submit) . '</button>' : "") . NL;
     $html .= $T1 . '</form>' . NL;
     $html .= '</div>' . O_END;
     Config::set('widget_search_form_id', $id);
     return Filter::apply(array('widget:search.form', 'widget:search', 'widget'), $html, $id);
 }
Weapon::add('thumbnail_before', 'do_thumbnail_http_header', 1);
Route::accept('t/(:num)/(:all)', function ($size = 0, $path = "") {
    $path = Filter::colon('thumbnail:path', ASSET . DS . File::path($path));
    $G = array('data' => array('path' => $path, 'lot' => func_get_args()));
    if (!($path = File::exist($path))) {
        HTTP::status(404);
        exit;
    }
    Weapon::fire('thumbnail_before', array($G, $G));
    Image::take($path)->resize($size)->draw();
}, 12);
Route::accept('t/(:num)/(:num)/(:all)', function ($width = 0, $height = 0, $path = "") {
    $path = Filter::colon('thumbnail:path', ASSET . DS . File::path($path));
    $G = array('data' => array('path' => $path, 'lot' => func_get_args()));
    if (!($path = File::exist($path))) {
        HTTP::status(404);
        exit;
    }
    Weapon::fire('thumbnail_before', array($G, $G));
    Image::take($path)->crop($width, $height)->draw();
}, 11);
Route::accept('t/(:num)/(:num)/(:num)/(:num)/(:all)', function ($x = 0, $y = 0, $width = 0, $height = 0, $path = "") {
    $path = Filter::colon('thumbnail:path', ASSET . DS . File::path($path));
    $G = array('data' => array('path' => $path, 'lot' => func_get_args()));
    if (!($path = File::exist($path))) {
        HTTP::status(404);
        exit;
    }
    Weapon::fire('thumbnail_before', array($G, $G));
    Image::take($path)->crop($x, $y, $width, $height)->draw();
}, 10);
Beispiel #18
0
 public static function grow($array = null, $indent = "", $FP = 'tree:')
 {
     return O_BEGIN . Filter::colon($FP . 'trunk', rtrim(self::create($array, $indent, $FP, 0), NL)) . O_END;
 }
Beispiel #19
0
 private static function __fields(&$results, $FP)
 {
     // Initialize custom field(s) with the default value(s) so that
     // user(s) don't have to write `isset()` function multiple time(s)
     // just to prevent error message(s) because of the object key(s)
     // that is not available in the old post(s).
     $fields = self::state_field(null, array(), true, rtrim($FP, ':'));
     foreach ($fields as $k => $v) {
         $s = isset($results['fields'][$k]) && trim($results['fields'][$k]) !== "" ? $results['fields'][$k] : null;
         $s = Filter::colon($FP . 'fields_raw.' . $k, $s, $results);
         $results['fields_raw'][$k] = $s;
         if ($s === null) {
             // For `option` field type, the first option will be used as the default value
             if ($v['type'] === 'option' || $v['type'] === 'o') {
                 $vv = array_keys(Converter::toArray($v['value']));
                 if (isset($v['placeholder']) && trim($v['placeholder']) !== "") {
                     // do nothing ...
                 } else {
                     $s = isset($vv[0]) ? $vv[0] : "";
                 }
                 // For `boolean` field type, empty value is equal to `false`
             } else {
                 if ($v['type'] === 'boolean' || $v['type'] === 'b') {
                     $s = false;
                 }
             }
         } else {
             // For `file` field type, the original custom field value is used to limit the file extension
             // So we have to check the existence of the file first. If it does not exist, then it may be
             // contained with the file extension(s), not with a file name
             if ($v['type'] === 'file' || $v['type'] === 'f') {
                 $e = File::E($s, false);
                 $s = $e !== false ? File::exist(SUBSTANCE . DS . $e . DS . $s, "") : "";
             }
         }
         $results['fields'][$k] = Filter::colon($FP . 'fields.' . $k, $s, $results);
     }
     unset($fields, $s);
 }
Beispiel #20
0
  <label class="grid-group">
    <span class="grid span-2 form-label"><?php 
echo $speak->password;
?>
</span>
    <span class="grid span-4">
    <?php 
echo Form::password('pass', null, null, array('autocomplete' => 'off'));
?>
    </span>
  </label>
  <?php 
$origin = Config::get('url_origin', $config->manager->slug . '/article');
?>
  <?php 
if ($origin !== Filter::colon('manager:url', $config->url . '/' . $config->manager->slug . '/logout')) {
    ?>
  <?php 
    echo Form::hidden('kick', Request::get('kick', $origin));
    ?>
  <?php 
}
?>
  <div class="grid-group">
    <span class="grid span-2"></span>
    <span class="grid span-4">
      <?php 
Weapon::fire('action_before', $hooks);
?>
      <?php 
echo Form::button($speak->login, null, null, null, array('class' => array('btn', 'btn-action')));
Beispiel #21
0
function do_footer_manager_link($content, $path)
{
    global $config, $speak;
    if (File::N($path) === 'block.footer.bar') {
        $s = Guardian::happy() ? '<a href="' . Filter::colon('manager:url', $config->url . '/' . $config->manager->slug . '/logout') . '" rel="nofollow">' . $speak->log_out . '</a>' : '<a href="' . Filter::colon('manager:url', $config->url . '/' . $config->manager->slug . '/login') . '" rel="nofollow">' . $speak->log_in . '</a>';
        return str_replace('<div class="blog-footer-right">', '<div class="blog-footer-right">' . $s, $content);
    }
    return $content;
}
Beispiel #22
0
<?php

if ($posts = call_user_func('Get::' . $segment[1] . 's')) {
    ?>
<div class="grid-group">
  <span class="grid span-1 form-label"><?php 
    echo $speak->to;
    ?>
</span>
  <span class="grid span-5">
  <?php 
    if (count($posts) > 600) {
        // 600+ post(s), fallback to text input for performance reason
        $_post = call_user_func('Get::' . $segment[1] . 'Anchor', $page->post);
        echo Form::text('post', Request::get('post', Guardian::wayback('post', $page->post)), time());
        echo $_post ? ' ' . Jot::btn('action:external-link', "", $_post->url, array('title' => $_post->title, 'target' => '_blank')) : "";
    } else {
        $results = array();
        foreach ($posts as $v) {
            list($_time, $_kind, $_slug) = explode('_', File::N($v), 3);
            $results[Date::format($_time, 'U')] = Filter::colon($segment[1] . ':url', $config->url . '/' . $config->index->slug . '/' . $_slug);
        }
        asort($results);
        echo Form::select('post', $results, Request::get('post', Guardian::wayback('post', $page->post)), array('class' => 'select-block'));
    }
    ?>
  </span>
</div>
<?php 
}