本文整理汇总了PHP中Filter::colon方法的典型用法代码示例。如果您正苦于以下问题:PHP Filter::colon方法的具体用法?PHP Filter::colon怎么用?PHP Filter::colon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Filter
的用法示例。
在下文中一共展示了Filter::colon方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ally
/**
* ============================================================
* 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:' . $k . '_raw', $v, $s);
$s[$k] = Filter::colon('user:' . $k, $v, $s);
}
$ally[$s['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.');
}
}
示例2: do_facebook_open_graph
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;
}
示例3: do_twitter_cards
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;
}
示例4: do_meta_3
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);
}
示例5: array
<?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']) ? ');' : "");
示例6: response
/**
* ==========================================================================
* 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);
}
示例7: ceil
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>';
示例8: array
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));
*
* --------------------------------------------------------------------------
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
示例9: array
}
}
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'] === '∞' || (double) $v['count'] > 0)) {
$bar .= ' <span class="counter">' . $v['count'] . '</span>';
}
$bar .= isset($v['url']) ? '</a>' : '</span>';
}
$bars[] = $bar;
}
}
示例10: str_repeat
$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>';
示例11: array
<?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>';
示例12: __doParseHeaders
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;
}
示例13: array
<?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) : "";
}
示例14: merge
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);
}
示例15: function
<?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);