• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP HabariDateTime类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中HabariDateTime的典型用法代码示例。如果您正苦于以下问题:PHP HabariDateTime类的具体用法?PHP HabariDateTime怎么用?PHP HabariDateTime使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了HabariDateTime类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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'=>'[email protected]',
				'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' => '[email protected]',
			'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 );
	}
开发者ID:rynodivino,项目名称:tests,代码行数:40,代码来源:test_comment.php


示例2: 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);
     }
 }
开发者ID:habari-extras,项目名称:autopinger,代码行数:12,代码来源:autopinger.plugin.php


示例3: check_posts

 public static function check_posts($nolimit = false)
 {
     $autoclosed = array();
     $age_in_days = Options::get('autoclose__age_in_days');
     if (is_null($age_in_days)) {
         return;
     }
     $age_in_days = abs(intval($age_in_days));
     $search = array('content_type' => 'entry', 'before' => HabariDateTime::date_create()->modify('-' . $age_in_days . ' days'), 'nolimit' => true, 'status' => 'published');
     if (!$nolimit) {
         $search['after'] = HabariDateTime::date_create()->modify('-' . ($age_in_days + 30) . ' days');
     }
     $posts = Posts::get($search);
     foreach ($posts as $post) {
         if (!$post->info->comments_disabled && !$post->info->comments_autoclosed) {
             $post->info->comments_disabled = true;
             $post->info->comments_autoclosed = true;
             $post->info->commit();
             $autoclosed[] = sprintf('<a href="%s">%s</a>', $post->permalink, htmlspecialchars($post->title));
         }
     }
     if (count($autoclosed)) {
         if (count($autoclosed) > 5) {
             Session::notice(sprintf(_t('Comments autoclosed for: %s and %d other posts', 'autoclose'), implode(', ', array_slice($autoclosed, 0, 5)), count($autoclosed) - 5));
         } else {
             Session::notice(sprintf(_t('Comments autoclosed for: %s', 'autoclose'), implode(', ', $autoclosed)));
         }
     } else {
         Session::notice(sprintf(_t('Found no posts older than %d days with comments enabled.', 'autoclose'), $age_in_days));
     }
     return true;
 }
开发者ID:habari-extras,项目名称:autoclose,代码行数:32,代码来源:autoclose.plugin.php


示例4: 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');
 }
开发者ID:ringmaster,项目名称:system,代码行数:29,代码来源:admindashboardhandler.php


示例5: setUp

 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @access protected
  */
 protected function setUp()
 {
     $this->post_id = Post::get()->id;
     $this->paramarray = array('id' => 'foofoo', 'post_id' => $this->post_id, 'name' => 'test', 'email' => '[email protected]', '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 = new Comment($this->paramarray);
     $this->comment->insert();
 }
开发者ID:psaintlaurent,项目名称:Habari,代码行数:13,代码来源:commentTest.php


示例6: 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);
 }
开发者ID:habari-extras,项目名称:naturalpower,代码行数:26,代码来源:theme.php


示例7: 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();
 }
开发者ID:habari-extras,项目名称:addon_catalog,代码行数:32,代码来源:beaconhandler.php


示例8: filter_post_field_load

 public function filter_post_field_load($value, $key)
 {
     switch ($key) {
         case 'event_start':
         case 'event_end':
             return HabariDateTime::date_create($value)->text_format('{M} {j}, {Y} {g}:{i}{a}');
     }
     return $value;
 }
开发者ID:ringmaster,项目名称:elks853,代码行数:9,代码来源:eventone.plugin.php


示例9: action_plugin_activation

 public function action_plugin_activation($file = '')
 {
     if (Plugins::id_from_file($file) == Plugins::id_from_file(__FILE__)) {
         if (Options::get('database_optimizer__frequency') == null) {
             Options::set('database_optimizer__frequency', 'weekly');
         }
         // add a cronjob to kick off next and optimize our db now
         CronTab::add_single_cron('optimize database tables initial', 'optimize_database', HabariDateTime::date_create(time()), 'Optimizes database tables.');
         $this->create_cron();
     }
 }
开发者ID:habari-extras,项目名称:database_optimizer,代码行数:11,代码来源:database_optimizer.plugin.php


示例10: post_options

 /**
  * Handles POST requests from the options admin page
  */
 public function post_options()
 {
     $option_items = array();
     $timezones = DateTimeZone::listIdentifiers();
     $timezones = array_merge(array('' => ''), array_combine(array_values($timezones), array_values($timezones)));
     $option_items[_t('Name & Tagline')] = array('title' => array('label' => _t('Site Name'), 'type' => 'text', 'helptext' => ''), 'tagline' => array('label' => _t('Site Tagline'), 'type' => 'text', 'helptext' => ''), 'about' => array('label' => _t('About'), 'type' => 'textarea', 'helptext' => ''));
     $option_items[_t('Publishing')] = array('pagination' => array('label' => _t('Items per Page'), 'type' => 'text', 'helptext' => ''), 'atom_entries' => array('label' => _t('Entries to show in Atom feed'), 'type' => 'text', 'helptext' => ''), 'comments_require_id' => array('label' => _t('Require Comment Author Info'), 'type' => 'checkbox', 'helptext' => ''), 'spam_percentage' => array('label' => _t('Comment SPAM Threshold'), 'type' => 'text', 'helptext' => _t('The likelihood a comment is considered SPAM, in percent.')));
     $option_items[_t('Time & Date')] = array('timezone' => array('label' => _t('Time Zone'), 'type' => 'select', 'selectarray' => $timezones, 'helptext' => _t('Current Date Time: %s', array(HabariDateTime::date_create()->format()))), 'dateformat' => array('label' => _t('Date Format'), 'type' => 'text', 'helptext' => _t('Current Date: %s', array(HabariDateTime::date_create()->date))), 'timeformat' => array('label' => _t('Time Format'), 'type' => 'text', 'helptext' => _t('Current Time: %s', array(HabariDateTime::date_create()->time))));
     $option_items[_t('Language')] = array('locale' => array('label' => _t('Locale'), 'type' => 'select', 'selectarray' => array_merge(array('' => 'default'), array_combine(HabariLocale::list_all(), HabariLocale::list_all())), 'helptext' => _t('International language code')), 'system_locale' => array('label' => _t('System Locale'), 'type' => 'text', 'helptext' => _t('The appropriate locale code for your server')));
     $option_items[_t('Troubleshooting')] = array('log_min_severity' => array('label' => _t('Minimum Severity'), 'type' => 'select', 'selectarray' => LogEntry::list_severities(), 'helptext' => _t('Only log entries with a this or higher severity.')), 'log_backtraces' => array('label' => _t('Log Backtraces'), 'type' => 'checkbox', 'helptext' => _t('Logs error backtraces to the log table\'s data column. Can drastically increase log size!')));
     /*$option_items[_t('Presentation')] = array(
     		'encoding' => array(
     			'label' => _t('Encoding'),
     			'type' => 'select',
     			'selectarray' => array(
     				'UTF-8' => 'UTF-8'
     				),
     			'helptext' => '',
     			),
     		);*/
     $option_items = Plugins::filter('admin_option_items', $option_items);
     $form = new FormUI('Admin Options');
     $tab_index = 3;
     foreach ($option_items as $name => $option_fields) {
         $fieldset = $form->append('wrapper', Utils::slugify(_u($name)), $name);
         $fieldset->class = 'container settings';
         $fieldset->append('static', $name, '<h2>' . htmlentities($name, ENT_COMPAT, 'UTF-8') . '</h2>');
         foreach ($option_fields as $option_name => $option) {
             $field = $fieldset->append($option['type'], $option_name, $option_name, $option['label']);
             $field->template = 'optionscontrol_' . $option['type'];
             $field->class = 'item clear';
             if ($option['type'] == 'select' && isset($option['selectarray'])) {
                 $field->options = $option['selectarray'];
             }
             $field->tabindex = $tab_index;
             $tab_index++;
             if (isset($option['helptext'])) {
                 $field->helptext = $option['helptext'];
             } else {
                 $field->helptext = '';
             }
         }
     }
     /* @todo: filter for additional options from plugins
      * We could either use existing config forms and simply extract
      * the form controls, or we could create something different
      */
     $submit = $form->append('submit', 'apply', _t('Apply'), 'admincontrol_submit');
     $submit->tabindex = $tab_index;
     $form->on_success(array($this, 'form_options_success'));
     $this->theme->form = $form->get();
     $this->theme->option_names = array_keys($option_items);
     $this->theme->display('options');
 }
开发者ID:ringmaster,项目名称:system,代码行数:57,代码来源:adminoptionshandler.php


示例11: action_atom_add_post

 public function action_atom_add_post($xml, $post)
 {
     $link = $xml->addChild('link');
     $link->addAttribute('rel', 'replies');
     //type="application/atom+xml" is default, could be omitted
     //$link->addAttribute('type', 'application/atom+xml');
     $link->addAttribute('href', URL::get('atom_feed_entry_comments', array('slug' => $post->slug)));
     $link->addAttribute('thr:count', $post->comments->approved->count, 'http://purl.org/syndication/thread/1.0');
     if ($post->comments->approved->count > 0) {
         $link->addAttribute('thr:updated', HabariDateTime::date_create(end($post->comments->approved)->date)->get(HabariDateTime::ATOM), 'http://purl.org/syndication/thread/1.0');
     }
     $xml->addChild('thr:total', $post->comments->approved->count, 'http://purl.org/syndication/thread/1.0');
 }
开发者ID:habari-extras,项目名称:atomthreading,代码行数:13,代码来源:atomthreading.plugin.php


示例12: test_create_post

 public function test_create_post()
 {
     $tags = array('one', 'two', 'THREE');
     $params = array('title' => 'A post title', 'content' => 'Some great content. Really.', 'user_id' => $this->user->id, 'status' => Post::status('published'), 'content_type' => Post::type('entry'), 'tags' => 'one, two, THREE', 'pubdate' => HabariDateTime::date_create(time()));
     $post = Post::create($params);
     $this->assertType('Post', $post, 'Post should be created.');
     // Check the post's id is set.
     $this->assertGreaterThan(0, (int) $post->id, 'The Post id should be greater than zero');
     // Check the post's tags are usable.
     $this->assertEquals(count($post->tags), count($tags), 'All tags should have been created.');
     foreach ($post->tags as $tag_slug => $tag_text) {
         $this->assertEquals($tag_slug, Utils::slugify($tag_text), 'Tags key should be slugified tag.');
     }
 }
开发者ID:psaintlaurent,项目名称:Habari,代码行数:14,代码来源:postTest.php


示例13: setUp

 protected function setUp()
 {
     set_time_limit(0);
     $this->posts = array();
     $user = User::get_by_name('posts_test');
     if (!$user) {
         $user = User::create(array('username' => 'posts_test', 'email' => '[email protected]', 'password' => md5('q' . rand(0, 65535))));
     }
     $time = time() - 160;
     $this->tag_sets = array(array('one'), array('two'), array('one', 'two'), array('three'));
     foreach ($this->tag_sets as $tags) {
         $time = $time - rand(3600, 3600 * 36);
         $this->posts[] = Post::create(array('title' => $this->get_title(), 'content' => $this->get_content(1, 3, 'some', array('ol' => 1, 'ul' => 1), 'cat'), 'user_id' => $user->id, 'status' => Post::status('published'), 'content_type' => Post::type('entry'), 'tags' => $tags, 'pubdate' => HabariDateTime::date_create($time)));
     }
 }
开发者ID:psaintlaurent,项目名称:Habari,代码行数:15,代码来源:postsTagsTest.php


示例14: fetch_backtype

 protected static function fetch_backtype($url)
 {
     $backtype = array();
     $cacheName = "backtype-{$url}";
     if (Cache::has($cacheName)) {
         foreach (Cache::get($cacheName) as $cachedBacktype) {
             $cachedBacktype->date = HabariDateTime::date_create($cachedBacktype->date);
             $backtype[] = $cachedBacktype;
         }
         return $backtype;
     }
     $connectData = json_decode(file_get_contents("http://api.backtype.com/comments/connect.json?url={$url}&key=key&itemsperpage=10000"));
     if (isset($connectData->comments)) {
         foreach ($connectData->comments as $dat) {
             $comment = new StdClass();
             switch ($dat->entry_type) {
                 case 'tweet':
                     $comment->id = 'backtype-twitter-' . $dat->tweet_id;
                     $comment->url = 'http://twitter.com/' . $dat->tweet_from_user . '/status/' . $dat->tweet_id;
                     $comment->name = '@' . $dat->tweet_from_user . ' (via Backtype: Twitter)';
                     $comment->content_out = InputFilter::filter($dat->tweet_text);
                     $comment->date = $dat->tweet_created_at;
                     break;
                 case 'comment':
                     $comment->id = 'backtype-comment-' . $dat->comment->id;
                     $comment->url = $dat->comment->url;
                     $comment->name = $dat->author->name . ' (via Backtype: ' . InputFilter::filter($dat->blog->title) . ')';
                     $comment->content_out = InputFilter::filter($dat->comment->content);
                     $comment->date = $dat->comment->date;
                     break;
             }
             if (!$comment) {
                 continue;
             }
             $comment->status = Comment::STATUS_APPROVED;
             $comment->type = Comment::TRACKBACK;
             $comment->email = null;
             $backtype[] = $comment;
         }
     }
     Cache::set($cacheName, $backtype);
     return $backtype;
 }
开发者ID:habari-extras,项目名称:backtype,代码行数:43,代码来源:backtype.plugin.php


示例15: the_title

 /**
  * Return the title for the page
  * @return String the title.
  */
 public function the_title($head = false)
 {
     $title = '';
     //check against the matched rule
     switch ($this->matched_rule->name) {
         case 'display_404':
             $title = 'Error 404';
             break;
         case 'display_entry':
             $title .= $this->post->title;
             break;
         case 'display_page':
             $title .= $this->post->title;
             break;
         case 'display_search':
             $title .= 'Search for ' . ucfirst($this->criteria);
             break;
         case 'display_entries_by_tag':
             $title .= ucfirst($this->tag) . ' Tag';
             break;
         case 'display_entries_by_date':
             $title .= 'Archive for ';
             $archive_date = new HabariDateTime();
             if (empty($date_array['day'])) {
                 if (empty($date_array['month'])) {
                     //Year only
                     $archive_date->set_date($this->year, 1, 1);
                     $title .= $archive_date->format('Y');
                     break;
                 }
                 //year and month only
                 $archive_date->set_date($this->year, $this->month, 1);
                 $title .= $archive_date->format('F Y');
                 break;
             }
             $archive_date->set_date($this->year, $this->month, $this->day);
             $title .= $archive_date->format('F jS, Y');
             break;
         case 'display_home':
             return Options::get('title');
             break;
     }
     return $title;
 }
开发者ID:habari-extras,项目名称:fun-with-photos,代码行数:48,代码来源:theme.php


示例16: test_delete_content_type

	public function test_delete_content_type()
	{
		Post::add_new_type( 'test_type' );

		$params = array(
			'title' => 'A post title',
			'content' => 'Some great content. Really.',
			'user_id' => $this->user->id,
			'status' => Post::status('published'),
			'content_type' => Post::type('test_type'),
			'pubdate' => HabariDateTime::date_create( time() ),
		);
		$post = Post::create($params);

		$this->assert_true( 'test_type' == $post->typename, "Post content type should be 'test_type'." );
		$this->assert_false( Post::delete_post_type( 'test_type' ), "Post still exists with the content type 'test_type'" );

		$post->delete();
		$this->assert_true( Post::delete_post_type( 'test_type' ), "No posts exist with the content type 'test_type'" );

	}
开发者ID:rynodivino,项目名称:tests,代码行数:21,代码来源:test_post.php


示例17: act_poll_cron

 /**
  * Handles asyncronous cron calls.
  *
  * @todo next_cron should be the actual next run time and update it when new
  * crons are added instead of just maxing out at one day..
  */
 function act_poll_cron()
 {
     Utils::check_request_method(array('GET', 'HEAD', 'POST'));
     $time = doubleval($this->handler_vars['time']);
     if ($time != Options::get('cron_running')) {
         return;
     }
     // allow script to run for 10 minutes
     set_time_limit(600);
     $time = HabariDateTime::date_create();
     $crons = DB::get_results('SELECT * FROM {crontab} WHERE start_time <= ? AND next_run <= ?', array($time->sql, $time->sql), 'CronJob');
     if ($crons) {
         foreach ($crons as $cron) {
             $cron->execute();
         }
     }
     // set the next run time to the lowest next_run OR a max of one day.
     $next_cron = DB::get_value('SELECT next_run FROM {crontab} ORDER BY next_run ASC LIMIT 1', array());
     Options::set('next_cron', min(intval($next_cron), $time->modify('+1 day')->int));
     Options::set('cron_running', false);
 }
开发者ID:anupom,项目名称:my-blog,代码行数:27,代码来源:crontab.php


示例18: update_tweetbacks

 private function update_tweetbacks(Post $post)
 {
     // Get the lastest tweetback in database
     $tweetbacks = $post->comments->tweetbacks;
     if ($tweetbacks->count > 0) {
         $tweet_url = explode('/', $tweetbacks[0]->url);
         $since_id = end($tweet_url);
     } else {
         $since_id = 0;
     }
     // Get short urls
     $aliases = array_filter((array) ShortURL::get($post));
     //$aliases[] = $post->permalink; // Do not include original permalink, because Twitter Search has character limit, too.
     // Construct request URL
     $url = 'http://search.twitter.com/search.json?';
     $url .= http_build_query(array('ors' => implode(' ', $aliases), 'rpp' => 50, 'since_id' => $since_id), '', '&');
     // Get JSON content
     $call = new RemoteRequest($url);
     $call->set_timeout(5);
     $result = $call->execute();
     if (Error::is_error($result)) {
         throw Error::raise(_t('Unable to contact Twitter.', $this->class_name));
     }
     $response = $call->get_response_body();
     // Decode JSON
     $obj = json_decode($response);
     if (isset($obj->results) && is_array($obj->results)) {
         $obj = $obj->results;
     } else {
         throw Error::raise(_t('Response is not correct, Twitter server may be down or API is changed.', $this->class_name));
     }
     // Store new tweetbacks into database
     foreach ($obj as $tweet) {
         Comment::create(array('post_id' => $post->id, 'name' => $tweet->from_user, 'url' => sprintf('http://twitter.com/%1$s/status/%2$d', $tweet->from_user, $tweet->id), 'content' => $tweet->text, 'status' => Comment::STATUS_APPROVED, 'date' => HabariDateTime::date_create($tweet->created_at), 'type' => Comment::TWEETBACK));
     }
 }
开发者ID:habari-extras,项目名称:tweetsuite,代码行数:36,代码来源:tweetsuite.plugin.php


示例19: 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 = HabariDateTime::date_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(Comment::STATUS_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(Comment::STATUS_UNAPPROVED, false) : Comments::count_by_author(User::identify()->id, Comment::STATUS_UNAPPROVED), 'spam_comment_count' => $user->can('manage_all_comments') ? Comments::count_total(Comment::STATUS_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();
     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->get_additem_form();
     $this->display('dashboard');
 }
开发者ID:wwxgitcat,项目名称:habari,代码行数:28,代码来源:admindashboardhandler.php


示例20: update_scheduled_posts_cronjob

 /**
  * function update_scheduled_posts_cronjob
  *
  * Creates or recreates the cronjob to publish
  * scheduled posts. It is called whenever a post
  * is updated or created
  *
  */
 public static function update_scheduled_posts_cronjob()
 {
     $min_time = DB::get_value('SELECT MIN(pubdate) FROM {posts} WHERE status = ?', array(Post::status('scheduled')));
     CronTab::delete_cronjob('publish_scheduled_posts');
     if ($min_time) {
         CronTab::add_single_cron('publish_scheduled_posts', array('Posts', 'publish_scheduled_posts'), $min_time, 'Next run: ' . HabariDateTime::date_create($min_time)->get('c'));
     }
 }
开发者ID:psaintlaurent,项目名称:Habari,代码行数:16,代码来源:posts.php



注:本文中的HabariDateTime类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Handler类代码示例发布时间:2022-05-23
下一篇:
PHP Haanga类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap