本文整理汇总了PHP中Get::articles方法的典型用法代码示例。如果您正苦于以下问题:PHP Get::articles方法的具体用法?PHP Get::articles怎么用?PHP Get::articles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Get
的用法示例。
在下文中一共展示了Get::articles方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: function
echo O_BEGIN . $page->js . O_END;
}
});
Shield::attach('page-' . $slug);
}, 100);
/**
* Home Page
* ---------
*
* [1]. /
*
*/
Route::accept('/', function () use($config, $excludes) {
Session::kill('search.query');
Session::kill('search.results');
$s = Get::articles();
if ($articles = Mecha::eat($s)->chunk(1, $config->index->per_page)->vomit()) {
$articles = Mecha::walk($articles, function ($path) use($excludes) {
return Get::article($path, $excludes);
});
} else {
$articles = false;
}
Filter::add('pager:url', function ($url) {
return Filter::apply('index:url', $url);
});
Config::set(array('articles' => $articles, 'pagination' => Navigator::extract($s, 1, $config->index->per_page, $config->index->slug)));
Shield::attach('page-home');
}, 110);
/**
* Route Hook: after
示例2: 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']) ? ');' : "");
示例3: 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' => $config->url . '/' . $slug, 'date' => 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' => $config->url . '/' . $config->index->slug . '/' . $slug, 'date' => 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>';
示例4: array
$article = Mecha::O(array('id' => "", 'path' => "", 'state' => 'draft', 'date' => array('W3C' => ""), 'title' => $config->defaults->article_title, 'slug' => "", 'content_raw' => $config->defaults->article_content, 'content_type' => $config->html_parser, 'description' => "", 'kind' => array(), 'author' => Guardian::get('author'), 'css_raw' => $config->defaults->article_custom_css, 'js_raw' => $config->defaults->article_custom_js, 'fields' => array()));
Config::set(array('page_title' => Config::speak('manager.title_new_', $speak->article) . $config->title_separator . $config->manager->title, 'article' => Mecha::A($article)));
}
$G = array('data' => Mecha::A($article));
Config::set('html_parser', $article->content_type);
if ($request = Request::post()) {
Guardian::checkToken($request['token']);
$task_connect = $article;
include DECK . DS . 'workers' . DS . 'task.field.5.php';
$extension = $request['action'] === 'publish' ? '.txt' : '.draft';
$kind = isset($request['kind']) ? $request['kind'] : array(0);
sort($kind);
// Check for duplicate slug, except for the current old slug.
// Allow user(s) to change their post slug, but make sure they
// do not type the slug of another post.
if (trim($slug) !== "" && $slug !== $article->slug && ($files = Get::articles('DESC', "", 'txt,draft,archive'))) {
foreach ($files as $file) {
if (strpos(File::B($file), '_' . $slug . '.') !== false) {
Notify::error(Config::speak('notify_error_slug_exist', $slug));
Guardian::memorize($request);
break;
}
}
unset($files);
}
// Slug must contains at least one letter or one `-`. This validation added
// to prevent user(s) from inputting a page offset instead of article slug.
// Because the URL pattern of article's index page is `article/1` and the
// URL pattern of article's single page is `article/article-slug`
if (!preg_match('#[a-z\\-]#i', $slug)) {
Notify::error($speak->notify_error_slug_missing_letter);
示例5: function
* [1]. /
*
*/
Route::accept('/', function () use($config) {
Session::kill('search_query');
Session::kill('search_results');
if ($files = Mecha::eat(Get::articles())->chunk(1, $config->index->per_page)->vomit()) {
$articles = array();
foreach ($files as $file) {
$articles[] = Get::article($file, array('content', 'tags', 'css', 'js', 'comments'));
}
unset($files);
} else {
$articles = false;
}
Config::set(array('articles' => $articles, 'pagination' => Navigator::extract(Get::articles(), 1, $config->index->per_page, $config->index->slug)));
Shield::attach('page-home');
}, 110);
/**
* Do Routing
* ----------
*/
Route::execute();
/**
* 404 Page
* --------
*
* Fallback to 404 page if nothing matched.
*
*/
Shield::abort();
示例6: relatedPost
/**
* Widget Related Post
* -------------------
*
* [1]. Widget::relatedPost();
* [2]. Widget::relatedPost(5);
*
*/
public static function relatedPost($total = 7)
{
$T1 = TAB;
$T2 = str_repeat($T1, 2);
$config = Config::get();
if ($config->page_type !== 'article') {
return self::randomPost($total);
} else {
if (!($files = Get::articles('DESC', 'kind:' . implode(',', (array) $config->article->kind)))) {
return O_BEGIN . '<div class="widget widget-related widget-related-post">' . Config::speak('notify_empty', strtolower($speak->posts)) . '</div>' . O_END;
}
if (count($files) <= 1) {
return self::randomPost($total);
}
$files = Mecha::eat($files)->shake()->vomit();
$html = O_BEGIN . '<div class="widget widget-related widget-related-post" id="widget-related-post-' . self::$id['related_post'] . '">' . NL;
self::$id['related_post']++;
$html .= $T1 . '<ul>' . NL;
for ($i = 0, $count = count($files); $i < $total; ++$i) {
if ($i === $count) {
break;
}
if ($files[$i] !== $config->article->path) {
$article = Get::articleAnchor($files[$i]);
$html .= $T2 . '<li><a href="' . $article->url . '">' . $article->title . '</a></li>' . NL;
}
}
$html .= $T1 . '</ul>' . NL;
$html .= '</div>' . O_END;
$html = Filter::apply('widget', $html);
return Filter::apply('widget:related.post', Filter::apply('widget:related', $html));
}
}