本文整理汇总了PHP中Posts::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Posts::get方法的具体用法?PHP Posts::get怎么用?PHP Posts::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Posts
的用法示例。
在下文中一共展示了Posts::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: theme_monthly_archives_links_list
public function theme_monthly_archives_links_list($theme, $full_names = TRUE, $show_counts = TRUE, $type = 'entry', $status = 'published')
{
$results = Posts::get(array('content_type' => $type, 'status' => $status, 'month_cts' => 1));
$archives[] = '';
foreach ($results as $result) {
// add leading zeros
$result->month = str_pad($result->month, 2, 0, STR_PAD_LEFT);
// what format do we want to show the month in?
if ($full_names) {
$display_month = HabariDateTime::date_create()->set_date($result->year, $result->month, 1)->get('F');
} else {
$display_month = HabariDateTime::date_create()->set_date($result->year, $result->month, 1)->get('M');
}
// do we want to show the count of posts?
if ($show_counts) {
$count = ' (' . $result->ct . ')';
} else {
$count = '';
}
$archives[] = '<li>';
$archives[] = '<a href="' . URL::get('display_entries_by_date', array('year' => $result->year, 'month' => $result->month)) . '" title="View entries in ' . $display_month . '/' . $result->year . '">' . $display_month . ' ' . $result->year . ' ' . $count . '</a>';
$archives[] = '</li>';
}
$archives[] = '';
return implode("\n", $archives);
}
示例2: add_template_vars
/**
* Add some variables to the template output
*/
public function add_template_vars()
{
// Use theme options to set values that can be used directly in the templates
// Don't check for constant values in the template code itself
$this->assign('show_title_image', self::SHOW_TITLE_IMAGE);
$this->assign('home_label', self::HOME_LABEL);
$this->assign('show_powered', self::SHOW_POWERED);
$this->assign('display_login', self::DISPLAY_LOGIN);
$this->assign('tags_in_multiple', self::TAGS_IN_MULTIPLE);
$this->assign('post_class', 'post' . (!self::SHOW_ENTRY_PAPERCLIP ? ' alt' : ''));
$this->assign('page_class', 'post' . (!self::SHOW_PAGE_PAPERCLIP ? ' alt' : ''));
$this->assign('show_post_nav', self::SHOW_POST_NAV);
$locale = Options::get('locale');
if (file_exists(Site::get_dir('theme', true) . $locale . '.css')) {
$this->assign('localized_css', $locale . '.css');
} else {
$this->assign('localized_css', false);
}
if (!$this->template_engine->assigned('pages')) {
$this->assign('pages', Posts::get(array('content_type' => 'page', 'status' => Post::status('published'), 'nolimit' => 1)));
}
$this->assign('post_id', isset($this->post) && $this->post->content_type == Post::type('page') ? $this->post->id : 0);
// Add FormUI template placing the input before the label
$this->add_template('charcoal_text', dirname(__FILE__) . '/formcontrol_text.php');
parent::add_template_vars();
}
示例3: get_dashboard
/**
* Handles get requests for the dashboard
* @todo update check should probably be cron'd and cached, not re-checked every load
*/
public function get_dashboard()
{
// Not sure how best to determine this yet, maybe set an option on install, maybe do this:
$firstpostdate = DB::get_value('SELECT min(pubdate) FROM {posts} WHERE status = ?', array(Post::status('published')));
if ($firstpostdate) {
$this->theme->active_time = DateTime::create($firstpostdate);
}
// check to see if we have updates to display
$this->theme->updates = Options::get('updates_available', array());
// collect all the stats we display on the dashboard
$user = User::identify();
$this->theme->stats = array('author_count' => Users::get(array('count' => 1)), 'post_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('any'), 'status' => Post::status('published'))), 'comment_count' => Comments::count_total('approved', false), 'tag_count' => Tags::vocabulary()->count_total(), 'user_draft_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('any'), 'status' => Post::status('draft'), 'user_id' => $user->id)), 'unapproved_comment_count' => User::identify()->can('manage_all_comments') ? Comments::count_total('unapproved', false) : Comments::count_by_author(User::identify()->id, Comment::status('unapproved')), 'spam_comment_count' => $user->can('manage_all_comments') ? Comments::count_total('spam', false) : Comments::count_by_author($user->id, Comment::status('spam')), 'user_scheduled_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('any'), 'status' => Post::status('scheduled'), 'user_id' => $user->id)));
// check for first run
$u = User::identify();
$uinfo = $u->info;
if (!isset($uinfo->experience_level)) {
$this->theme->first_run = true;
$u->info->experience_level = 'user';
$u->info->commit();
} else {
$this->theme->first_run = false;
}
$this->get_additem_form();
Stack::add('admin_header_javascript', 'dashboard-js');
$this->display('dashboard');
}
示例4: add_template_vars
public function add_template_vars()
{
//TODO: Fully support localization;
//theme configuration
$this->assign('da_feedtext', $this->options['darkautumn__feedtext']);
$this->assign('da_maintenancetitle', $this->options['darkautumn__maintenancetitle']);
$this->assign('da_blurbtext', $this->options['darkautumn__blurbtext']);
$this->assign('da_sidenotes_tag', $this->options['darkautumn__sidenotestag']);
$this->base_url = Site::get_url('habari');
//TODO: use assign instead
$this->theme_url = Site::get_url('theme');
//TODO: use assign instead
if (!$this->posts) {
$this->posts = Posts::get(array('content_type' => 'entry', 'status' => Post::status('published')));
}
if (!$this->pages) {
$this->assign('pages', Posts::get(array('content_type' => 'page', 'status' => Post::status('published'), 'nolimit' => 1)));
}
if (!$this->sidenotes) {
$this->assign('sidenotes', Posts::get(array('tag' => $this->options['darkautumn__sidenotestag'], 'limit' => 5)));
}
if (!$this->page) {
$this->page = isset($page) ? $page : 1;
//TODO: use assign instead
}
$this->assign('post_id', isset($this->post) && $this->post->content_type == Post::type('page') ? $this->post->id : 0);
parent::add_template_vars();
}
示例5: add_template_vars
/**
* Add additional template variables to the template output.
*
* You can assign additional output values in the template here, instead of
* having the PHP execute directly in the template. The advantage is that
* you would easily be able to switch between template types (RawPHP/Smarty)
* without having to port code from one to the other.
*
* You could use this area to provide "recent comments" data to the template,
* for instance.
*
* Note that the variables added here should possibly *always* be added,
* especially 'user'.
*
* Also, this function gets executed *after* regular data is assigned to the
* template. So the values here, unless checked, will overwrite any existing
* values.
*/
public function add_template_vars()
{
//Theme Options
$this->assign('home_tab', 'Home');
//Set to whatever you want your first tab text to be.
$this->assign('show_author', false);
//Display author in posts
if (!$this->template_engine->assigned('pages')) {
$this->assign('pages', Posts::get(array('content_type' => 'page', 'status' => Post::status('published'), 'nolimit' => 1)));
}
if (!$this->template_engine->assigned('page')) {
$page = Controller::get_var('page');
$this->assign('page', isset($page) ? $page : 1);
}
parent::add_template_vars();
//from mzingi
//visiting page/2, /3 will offset to the next page of posts in the sidebar
$page = Controller::get_var('page');
$pagination = Options::get('pagination');
if ($page == '') {
$page = 1;
}
$this->assign('more_posts', Posts::get(array('status' => 'published', 'content_type' => 'entry', 'offset' => $pagination * $page, 'limit' => 5)));
//from mzingi
//for recent comments loop in sidebar.php
$this->assign('recent_comments', Comments::get(array('limit' => 5, 'status' => Comment::STATUS_APPROVED, 'orderby' => 'date DESC')));
}
示例6: get_dashboard
/**
* Handles get requests for the dashboard
* @todo update check should probably be cron'd and cached, not re-checked every load
*/
public function get_dashboard()
{
// Not sure how best to determine this yet, maybe set an option on install, maybe do this:
$firstpostdate = DB::get_value('SELECT min(pubdate) FROM {posts} WHERE status = ?', array(Post::status('published')));
$this->theme->active_time = HabariDateTime::date_create($firstpostdate);
// get the active theme, so we can check it
// @todo this should be worked into the main Update::check() code for registering beacons
$active_theme = Themes::get_active();
$active_theme = $active_theme->name . ':' . $active_theme->version;
// check to see if we have updates to display
$this->theme->updates = Options::get('updates_available', array());
// collect all the stats we display on the dashboard
$this->theme->stats = array('author_count' => Users::get(array('count' => 1)), 'page_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('page'), 'status' => Post::status('published'))), 'entry_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('entry'), 'status' => Post::status('published'))), 'comment_count' => Comments::count_total(Comment::STATUS_APPROVED, false), 'tag_count' => Tags::vocabulary()->count_total(), 'page_draft_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('page'), 'status' => Post::status('draft'), 'user_id' => User::identify()->id)), 'entry_draft_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('entry'), 'status' => Post::status('draft'), 'user_id' => User::identify()->id)), 'unapproved_comment_count' => User::identify()->can('manage_all_comments') ? Comments::count_total(Comment::STATUS_UNAPPROVED, false) : Comments::count_by_author(User::identify()->id, Comment::STATUS_UNAPPROVED), 'spam_comment_count' => User::identify()->can('manage_all_comments') ? Comments::count_total(Comment::STATUS_SPAM, false) : Comments::count_by_author(User::identify()->id, Comment::STATUS_SPAM), 'user_entry_scheduled_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('any'), 'status' => Post::status('scheduled'), 'user_id' => User::identify()->id)));
$this->fetch_dashboard_modules();
// check for first run
$u = User::identify();
if (!isset($u->info->experience_level)) {
$this->theme->first_run = true;
$u->info->experience_level = 'user';
$u->info->commit();
} else {
$this->theme->first_run = false;
}
$this->display('dashboard');
}
示例7: add_template_vars
/**
* Add additional template variables to the template output.
*
* You can assign additional output values in the template here, instead of
* having the PHP execute directly in the template. The advantage is that
* you would easily be able to switch between template types (RawPHP/Smarty)
* without having to port code from one to the other.
*
* You could use this area to provide "recent comments" data to the template,
* for instance.
*
* Note that the variables added here should possibly *always* be added,
* especially 'user'.
*
* Also, this function gets executed *after* regular data is assigned to the
* template. So the values here, unless checked, will overwrite any existing
* values.
*/
public function add_template_vars()
{
if (!$this->template_engine->assigned('pages')) {
$this->assign('pages', Posts::get(array('content_type' => 'page', 'status' => Post::status('published'), 'nolimit' => 1)));
}
if (!$this->template_engine->assigned('user')) {
$this->assign('user', User::identify());
}
if (!$this->template_engine->assigned('tags')) {
$this->assign('tags', Tags::get());
}
if (!$this->template_engine->assigned('page')) {
$this->assign('page', isset($page) ? $page : 1);
}
if (!$this->template_engine->assigned('feed_alternate')) {
$matched_rule = URL::get_matched_rule();
switch ($matched_rule->name) {
case 'display_entry':
case 'display_page':
$feed_alternate = URL::get('atom_entry', array('slug' => Controller::get_var('slug')));
break;
case 'display_entries_by_tag':
$feed_alternate = URL::get('atom_feed_tag', array('tag' => Controller::get_var('tag')));
break;
case 'display_home':
default:
$feed_alternate = URL::get('atom_feed', array('index' => '1'));
}
$this->assign('feed_alternate', $feed_alternate);
}
// Specify pages you want in your navigation here
$this->assign('nav_pages', Posts::get(array('content_type' => 'page', 'status' => 'published', 'nolimit' => 1)));
parent::add_template_vars();
}
示例8: add_template_vars
/**
* Add additional template variables to the template output.
*
* You can assign additional output values in the template here, instead of
* having the PHP execute directly in the template. The advantage is that
* you would easily be able to switch between template types (RawPHP/Smarty)
* without having to port code from one to the other.
*
* You could use this area to provide "recent comments" data to the template,
* for instance.
*
* Note that the variables added here should possibly *always* be added,
* especially 'user'.
*
* Also, this function gets executed *after* regular data is assigned to the
* template. So the values here, unless checked, will overwrite any existing
* values.
*/
public function add_template_vars()
{
$this->add_template('formcontrol_text', dirname(__FILE__) . '/forms/formcontrol_text.php', true);
$this->add_template('formcontrol_textarea', dirname(__FILE__) . '/forms/formcontrol_textarea.php', true);
if (!$this->template_engine->assigned('pages')) {
$this->assign('pages', Posts::get(array('content_type' => 'page', 'status' => Post::status('published'), 'nolimit' => 1)));
}
if (!$this->template_engine->assigned('user')) {
$this->assign('user', User::identify());
}
if (!$this->template_engine->assigned('page')) {
$this->assign('page', isset($page) ? $page : 1);
}
if (!$this->template_engine->assigned('feed_alternate')) {
$matched_rule = URL::get_matched_rule();
switch ($matched_rule->name) {
case 'display_entry':
case 'display_page':
$feed_alternate = URL::get('entry', array('slug' => Controller::get_var('slug')));
break;
case 'display_entries_by_tag':
$feed_alternate = URL::get('tag_collection', array('tag' => Controller::get_var('tag')));
break;
case 'index_page':
default:
$feed_alternate = URL::get('collection', array('index' => '1'));
}
$this->assign('feed_alternate', $feed_alternate);
}
parent::add_template_vars();
}
示例9: action_block_content_draft_posts
/**
* Produce the content for the latest drafts block
* @param Block $block The block object
* @param Theme $theme The theme that the block will be output with
*/
public function action_block_content_draft_posts($block, $theme)
{
$block->recent_posts = Posts::get(array('status' => 'draft', 'limit' => 8, 'user_id' => User::identify()->id));
if (User::identify()->can('manage_entries')) {
$block->link = URL::get('admin', array('page' => 'posts', 'status' => Post::status('draft'), 'user_id' => User::identify()->id));
}
}
示例10: add_template_vars
/**
* Add some variables to the template output
*/
public function add_template_vars()
{
if (!$this->template_engine->assigned('pages')) {
$this->assign('pages', Posts::get(array('content_type' => 'page', 'status' => Post::status('published'), 'nolimit' => 1)));
}
$page = Controller::get_var('page');
$page = isset($page) ? $page : 1;
if (!$this->template_engine->assigned('page')) {
$this->assign('page', $page);
}
$this->assign('show_previously', false);
$this->assign('show_latest', false);
$action = Controller::get_action();
if ($action == 'display_home' || $action == 'display_entries') {
$offset = (int) (($page + 1 - 1) * Options::get('pagination'));
$this->assign('previously', Posts::get(array('status' => 'published', 'content_type' => 'entry', 'offset' => $offset, 'limit' => self::PREVIOUSLY_ITEMS)));
$this->assign('show_previously', true);
}
if ($action != 'display_home') {
$this->assign('latest', Posts::get(array('status' => 'published', 'content_type' => 'entry', 'offset' => 0, 'limit' => self::LATEST_ITEMS)));
$this->assign('show_latest', true);
}
$this->assign('controller_action', $action);
parent::add_template_vars();
}
示例11: SitemapBuild
public function SitemapBuild()
{
//return cached sitemap if exsist
if (Cache::has('sitemap')) {
$xml = Cache::get('sitemap');
} else {
$types = Options::get_group(__CLASS__);
//..or generate a new one
$xml = '<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="' . $this->get_url() . '/sitemap.xsl"?><urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"></urlset>';
$xml = new SimpleXMLElement($xml);
if (array_key_exists('any', $types) && $types['any'] || empty($types)) {
// Retrieve all published content, regardless of the type
$content['any'] = Posts::get(array('content_type' => 'any', 'status' => 'published', 'nolimit' => 1));
} else {
// Retreive all published content for select content types
$content['posts'] = Posts::get(array('content_type' => array_keys($types, 1), 'status' => 'published', 'nolimit' => 1));
}
// Add the index page first
$url = $xml->addChild('url');
$url_loc = $url->addChild('loc', Site::get_url('habari'));
// Generate the `<url>`, `<loc>`, `<lastmod>` markup for each post and page.
foreach ($content as $entries) {
foreach ($entries as $entry) {
$url = $xml->addChild('url');
$url_loc = $url->addChild('loc', $entry->permalink);
$url_lastmod = $url->addChild('lastmod', $entry->updated->get('c'));
}
}
$xml = $xml->asXML();
Cache::set('sitemap', $xml);
}
return $xml;
}
示例12: add_template_vars
public function add_template_vars()
{
//Theme Options
$this->assign('show_author', true);
//Display author in posts
// How many months should be displayed by the RN Archives plugin
$this->assign('rn_archives_months', 2);
// Links list
$this->assign('links_list', array('Follow me on Twitter' => 'http://twitter.com/sebastianp'));
if (!$this->template_engine->assigned('pages')) {
$this->assign('pages', Posts::get(array('content_type' => 'page', 'status' => Post::status('published'), 'nolimit' => 1)));
}
// Fetch the last 5 posts, for displaying in the quickbar
if (!$this->template_engine->assigned('latest_posts')) {
$this->assign('latest_posts', Posts::get(array('content_type' => 'entry', 'status' => Post::status('published'), 'limit' => 5)));
}
// Fetch the last 5 comments, for displaying in the quickbar
if (!$this->template_engine->assigned('latest_comments')) {
$this->assign('latest_comments', Comments::get(array('status' => Comment::STATUS_APPROVED)));
}
if (!$this->template_engine->assigned('taglist')) {
$this->assign('taglist', $this->theme_show_tags());
}
// Fetch all the posts
if (!$this->template_engine->assigned('archives')) {
$this->assign('archives', Posts::get(array('content_type' => 'entry', 'status' => Post::status('published'))));
}
parent::add_template_vars();
}
示例13: act_packages
public function act_packages()
{
$packages = Posts::get(array('content_type' => 'plugin', 'nolimit' => true));
$xml = new SimpleXMLElement('<packages/>');
foreach ($packages as $package) {
if (!$package->info->guid) {
continue;
}
$package_node = $xml->addChild('package');
$package_node->addChild('description', utf8_encode(Format::summarize(strip_tags($package->content))));
$package_node->addAttribute('guid', $package->info->guid);
$package_node->addAttribute('name', $package->title);
if ($package->info->author) {
$package_node->addAttribute('author', $package->info->author);
}
if ($package->info->author_url) {
$package_node->addAttribute('author_url', $package->info->author_url);
}
$package_node->addAttribute('type', 'plugin');
$package_node->addAttribute('tags', implode(',', (array) $package->tags));
$versions_node = $package_node->addChild('versions');
foreach ($package->versions as $version) {
if ($version->habari_version) {
$version_node = $versions_node->addChild('version', $version->description);
$version_node->addAttribute('version', $version->version);
$version_node->addAttribute('archive_md5', $version->md5);
$version_node->addAttribute('archive_url', $version->url);
$version_node->addAttribute('habari_version', $version->habari_version);
}
}
}
ob_clean();
header('Content-Type: application/xml');
echo $xml->asXml();
}
示例14: action_block_content_popular_posts
/**
* Populate a block with the popular entries
**/
public function action_block_content_popular_posts($block, $theme)
{
if (!($limit = $block->quantity)) {
$limit = 5;
}
$block->popular_posts = Posts::get(array('content_type' => 'entry', 'has:info' => 'views', 'orderby' => 'CAST(hipi1.value as UNSIGNED) DESC', 'limit' => $limit));
}
示例15: action_plugin_act_plaintext
/**
* Respond to the URL that was created
* Determine the post that was supposed to be displayed, and show it in raw
* @params array $handlervars An array of values passed in from the URL requested
*/
function action_plugin_act_plaintext($handlervars)
{
$activetheme = Themes::create();
$user_filters = array('fetch_fn' => 'get_row', 'limit' => 1);
$page_key = array_search('page', $activetheme->valid_filters);
unset($activetheme->valid_filters[$page_key]);
$user_filters = Plugins::filter('template_user_filters', $user_filters);
$user_filters = array_intersect_key($user_filters, array_flip($activetheme->valid_filters));
$where_filters = Controller::get_handler()->handler_vars->filter_keys($activetheme->valid_filters);
$where_filters = $where_filters->merge($user_filters);
$where_filters = Plugins::filter('template_where_filters', $where_filters);
$post = Posts::get($where_filters);
$current_url = URL::get();
$created_at = $post->pubdate->get();
header('Content-type: text/plain; charset=utf-8');
echo <<<HERE
# {$post->title}
By {$post->author->displayname}
<{$current_url}>
{$created_at}
\t
{$post->content}
HERE;
exit;
}