当前位置: 首页>>代码示例>>PHP>>正文


PHP HabariDateTime::date_create方法代码示例

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


在下文中一共展示了HabariDateTime::date_create方法的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 );
	}
开发者ID:rynodivino,项目名称:tests,代码行数:40,代码来源:test_comment.php

示例2: 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

示例3: 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

示例4: 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' => '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 = new Comment($this->paramarray);
     $this->comment->insert();
 }
开发者ID:psaintlaurent,项目名称:Habari,代码行数:13,代码来源:commentTest.php

示例5: 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

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

示例7: 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

示例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: 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

示例10: 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

示例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' => 'posts_test@example.com', '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: 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


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