本文整理汇总了PHP中Post::status方法的典型用法代码示例。如果您正苦于以下问题:PHP Post::status方法的具体用法?PHP Post::status怎么用?PHP Post::status使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Post
的用法示例。
在下文中一共展示了Post::status方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: module_setup
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*
* @access protected
*/
protected function module_setup()
{
$user = User::get_by_name( 'posts_test' );
if ( !$user ) {
$user = User::create( array (
'username'=>'posts_test',
'email'=>'posts_test@example.com',
'password'=>md5('q' . rand( 0,65535 ) ),
) );
}
$this->user = $user;
$post = Post::create( array(
'title' => 'Test Post',
'content' => 'These tests expect there to be at least one post.',
'user_id' => $user->id,
'status' => Post::status( 'published' ),
'content_type' => Post::type( 'entry' ),
) );
$this->post_id = $post->id;
$this->paramarray = array(
'id' => 'foofoo',
'post_id' => $this->post_id,
'name' => 'test',
'email' => 'test@example.org',
'url' => 'http://example.org',
'ip' => ip2long('127.0.0.1'),
'content' => 'test content',
'status' => Comment::STATUS_UNAPPROVED,
'date' => HabariDateTime::date_create(),
'type' => Comment::COMMENT
);
$this->comment = Comment::create( $this->paramarray );
}
示例2: 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();
}
示例3: act_request
public function act_request()
{
// @todo limit this to GUIDs POST'd
$plugins = Posts::get(array('content_type' => 'addon', 'nolimit' => true, 'status' => Post::status('published')));
$xml = new SimpleXMLElement('<updates></updates>');
foreach ($plugins as $plugin) {
// if we don't have any versions, skip this plugin
if (empty($plugin->info->versions)) {
//continue;
}
// create the beacon's node
$beacon = $xml->addChild('beacon');
$beacon['id'] = $plugin->info->guid;
$beacon['name'] = $plugin->title;
$beacon['url'] = $plugin->permalink;
$beacon['type'] = $plugin->info->type;
foreach ($plugin->info->versions as $version) {
// @todo limit this to only versions older than the one POST'd
$update = $beacon->addChild('update', $version['description']);
$update['severity'] = $version['severity'];
$update['version'] = $version['version'];
$update['habari_version'] = $version['habari_version'];
$update['url'] = $version['url'];
$update['date'] = HabariDateTime::date_create($version->date)->format('c');
}
}
// spit out the xml
ob_clean();
// clean the output buffer
header('Content-type: application/xml');
echo $xml->asXML();
}
示例4: action_post_status_published
/**
* When a post is published, add a cron entry to do pinging
*
* @param Post $post A post object whose status has been set to published
*/
public function action_post_status_published($post)
{
if ($post->status == Post::status('published') && $post->pubdate <= HabariDateTime::date_create()) {
CronTab::add_single_cron('ping update sites', array('Autopinger', 'ping_sites'), HabariDateTime::date_create()->int, 'Ping update sites.');
EventLog::log('Crontab added', 'info', 'default', null, null);
}
}
示例5: 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));
}
}
示例6: 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();
}
示例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()
{
$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();
}
示例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()
{
//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')));
}
示例9: 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');
}
示例10: add_template_vars
public function add_template_vars()
{
//Theme Options
$this->assign('header_text', 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt.');
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()->loggedin);
}
/* if( !$this->template_engine->assigned( 'page' ) ) {
$this->assign('page', isset( $page ) ? $page : 1 );
}*/
if (!$this->template_engine->assigned('all_tags')) {
// List of all the tags
$tags = Tags::get();
$this->assign('all_tags', $tags);
}
//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)));
parent::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);
}
示例11: 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');
}
示例12: action_block_content_recent_comments
/**
* Recent Comments
*
* Handle recent comment block output
*
* @param Block $block The block instance to be configured
* @param Theme $theme The active theme
*/
public function action_block_content_recent_comments($block, $theme)
{
if (!($limit = $block->quantity)) {
$limit = 5;
}
$offset = 0;
$published_posts = 0;
$valid_comments = array();
// prevent endless looping if there are fewer comments than $limit
$comments_remain = true;
while ($published_posts < $limit && $comments_remain) {
$comments = Comments::get(array('limit' => $limit - $published_posts, 'status' => Comment::STATUS_APPROVED, 'type' => Comment::COMMENT, 'offset' => $offset, 'orderby' => 'date DESC'));
// check the posts
foreach ($comments as $key => $comment) {
if ($comment->post->status == Post::status('published')) {
$valid_comments[] = $comments[$key];
++$published_posts;
}
++$offset;
}
// stop looping if out of comments
if (count($comments) === 0) {
$comments_remain = false;
}
}
$block->recent_comments = $valid_comments;
}
示例13: action_post_update_after
/**
* Pingback mentioned links when a post is updated.
* @param Post $post The post is updated
* We invoke this function regardless of what might have been updated
* in the post because:
* - this will only execute if the post is published
* - the pingback_all_links function keeps track of links its
* already pinged, so if the content hasnt changed no
* pings will be sent`
*/
public function action_post_update_after( $post )
{
// only execute if this is a published post
if ( Post::status( 'published' ) != $post->status) {
return;
}
$this->pingback_all_links( $post->content, $post->permalink, $post );
}
示例14: filter_post_update_change
public function filter_post_update_change($new_fields, Post $post, $orig_fields)
{
if ($orig_fields['status'] == Post::status('draft') || $new_fields['status'] == Post::status('draft') || Options::get('slugsync__draftupdates', '') != 1) {
if ($new_fields['title'] != $orig_fields['title'] && $new_fields['slug'] == $orig_fields['slug']) {
$new_fields['slug'] = $new_fields['title'];
}
}
return $new_fields;
}
示例15: get_params
private function get_params($user_filters = array())
{
$default_filters = array('content_type' => Post::type('entry'), 'status' => Post::status('published'), 'limit' => Options::get($this->handler_vars['class_name'] . '__posts_per_page'), 'page' => 1, 'orderby' => Options::get($this->handler_vars['class_name'] . '__show_newest_first') ? 'pubdate DESC' : 'pubdate ASC');
$paramarray = new SuperGlobal($default_filters);
$paramarray = $paramarray->merge($user_filters, $this->handler_vars);
unset($paramarray['entire_match']);
unset($paramarray['class_name']);
return $paramarray;
}