Example #1
0
	/**
	 * 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'=>'*****@*****.**',
				'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' => '*****@*****.**',
			'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 );
	}
Example #2
0
 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();
 }
 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();
 }
 /**
  * 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);
     }
 }
 /**
  * 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));
     }
 }
Example #6
0
 /**
  * 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();
 }
Example #7
0
 /**
  * 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();
 }
Example #8
0
 /**
  * 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')));
 }
 /**
  * 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');
 }
Example #10
0
 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);
 }
Example #11
0
 /**
  * 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');
 }
Example #12
0
 /**
  * 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;
 }
Example #13
0
	/**
	 * 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 );
	}
Example #14
0
 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;
 }
 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;
 }
Example #16
0
 public function add_template_vars()
 {
     //Theme Options
     $this->assign('show_author', true);
     //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)));
     }
     parent::add_template_vars();
 }
Example #17
0
 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' => DateTime::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'");
 }
Example #18
0
 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);
     $this->recent_comments = Comments::get(array('limit' => 5, 'status' => Comment::STATUS_APPROVED, 'orderby' => 'date DESC'));
     $this->recent_posts = Posts::get(array('limit' => 5, 'orderby' => 'pubdate DESC', 'content_type' => Post::type('entry'), 'status' => Post::status('published')));
     if (!$this->template_engine->assigned('pages')) {
         $this->pages = Posts::get(array('content_type' => 'page', 'status' => Post::status('published'), 'nolimit' => 1));
     }
     parent::add_template_vars();
 }
 /**
  * Update the where filters for querying a post if the sharedraft key is set
  *
  * @param array $filters The array of pre-existing filters
  * @return array The modified array, if the key is set
  */
 function filter_posts_get_paramarray($filters)
 {
     if (isset($_GET['sharedraft']) && isset($filters['slug'])) {
         $slug = $filters['slug'];
         $key = $_GET['sharedraft'];
         if ($key == md5($slug . Options::get('guid'))) {
             $filters['status'] = Post::status('any');
             $filters['ignore_permissions'] = true;
         }
     }
     return $filters;
 }
Example #20
0
 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)));
     }
     // Comment form
     $this->add_template('formcontrol_text', dirname(__FILE__) . '/forms/formcontrol_text.php', true);
     $this->add_template('formcontrol_textarea', dirname(__FILE__) . '/forms/formcontrol_textarea.php', true);
     $this->add_template('formcontrol_submit', dirname(__FILE__) . '/forms/formcontrol_submit.php', true);
     // Display author
     $this->assign('show_author', true);
     parent::add_template_vars();
 }
Example #21
0
 public function action_post_insert_after($post)
 {
     if (Post::status('published') != $post->status) {
         return;
     }
     try {
         $bitly = new BitlyAPI(Options::get('bitly__login'), Options::get('bitly__api_key'));
         $result = $bitly->shorten($post->permalink);
         $post->info->short_url = $result->data->url;
     } catch (Exception $e) {
         Session::error('Could not communicate with bit.ly API.', 'Bit.ly API');
     }
 }
Example #22
0
 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.');
     }
 }
 /**
  * React to the update of a post status to 'published'
  * @param Post $post The post object with the status change
  * @param int $oldvalue The old status value
  * @param int $newvalue The new status value
  **/
 public function action_post_update_status($post, $oldvalue, $newvalue)
 {
     if (is_null($oldvalue)) {
         return;
     }
     if ($newvalue == Post::status('published') && $post->content_type == Post::type('entry') && $newvalue != $oldvalue) {
         $user = User::get_by_id($post->user_id);
         if (!empty($user->info->statusnet_name) && !empty($user->info->statusnet_pass)) {
             $name = $user->info->statusnet_name;
             $pw = $user->info->statusnet_pass;
             $svcurl = 'https://' . $user->info->statusnet_svc . '/api/statuses/update.xml';
             $this->post_status($svcurl, $user->info->statusnet_prefix . $post->title . ' ' . $post->permalink, $name, $pw);
         }
     }
 }
Example #24
0
 public function action_block_content_eventone_upcoming($block, $theme)
 {
     $criteria = array('status' => Post::status('published'));
     $criteria['content_type'] = Post::type('event');
     if ($block->limit != '') {
         $criteria['limit'] = $block->limit;
     }
     $criteria['has:info'] = array('event_start', 'event_end');
     $criteria['orderby'] = 'info_event_start_value ASC';
     $criteria['on_query_built'] = function (Query $query) {
         $query->where()->add("date(hipi1.value, 'unixepoch') > date('now')");
     };
     $block->posts = Posts::get($criteria);
     $block->criteria = $criteria;
 }
Example #25
0
 public function add_template_vars()
 {
     if (!$this->template_engine->assigned('pages')) {
         $this->assign('pages', Posts::get(array('content_type' => 'page', 'status' => Post::status('published'))));
     }
     if (!$this->template_engine->assigned('user')) {
         $this->assign('user', User::identify());
     }
     if (!$this->template_engine->assigned('page')) {
         $this->assign('page', isset($page) ? $page : 1);
     }
     //for recent comments loop in sidebar.php
     $this->assign('recent_comments', Comments::get(array('limit' => 8, 'status' => Comment::STATUS_APPROVED, 'orderby' => 'date DESC')));
     parent::add_template_vars();
 }
 public function action_add_template_vars($theme, $handler_vars)
 {
     $items = array();
     if (isset($theme->request->display_home) && $theme->request->display_home) {
         $posts = Posts::get(array('content_type' => Post::type('entry'), 'status' => Post::status('published'), 'nolimit' => true, 'orderby' => 'pubdate ASC'));
         foreach ($posts as $post) {
             $item = array();
             $item['url'] = $post->permalink;
             $item['title'] = $post->title;
             $item['time'] = strtotime($post->pubdate);
             $items[] = $item;
         }
     }
     $theme->timeline_items = $items;
 }
Example #27
0
 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' => '*****@*****.**', '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)));
     }
 }
Example #28
0
 public function add_template_vars()
 {
     $this->assign('home_tab', 'Blog');
     //Set to whatever you want your first tab text to be.
     if (!$this->assigned('pages')) {
         $this->assign('pages', Posts::get(array('content_type' => 'page', 'status' => Post::status('published'), 'nolimit' => 1)));
     }
     if (!$this->assigned('user')) {
         $this->assign('user', User::identify());
     }
     if (!$this->assigned('recent_entries')) {
         $this->assign('recent_entries', Posts::get(array('limit' => 10, 'content_type' => 'entry', 'status' => Post::status('published'), 'orderby' => 'pubdate DESC')));
     }
     $this->add_template('binadamu_submit', dirname(__FILE__) . '/formcontrol_submit.php');
     parent::add_template_vars();
 }
 public function action_block_content_postblock($block, $theme)
 {
     $criteria = array('status' => Post::status('published'));
     if ($block->content_type != '') {
         $ctypes = array_flip(Post::list_active_post_types());
         $criteria['content_type'] = $ctypes[$block->content_type];
     }
     if ($block->limit != '') {
         $criteria['limit'] = $block->limit;
     }
     if ($block->tag != '') {
         $criteria['tag'] = $block->tag;
     }
     $block->posts = Posts::get($criteria);
     $block->criteria = $criteria;
 }
Example #30
0
 /**
  * Check if a tag exists on a published post, to see if we should match this rewrite rule.
  *
  * @return Boolean Whether the tag exists on a published post.
  */
 public static function rewrite_tag_exists($rule, $slug, $parameters)
 {
     $tags = explode(' ', $rule->named_arg_values['tag']);
     $tags = array_map('trim', $tags, array_fill(0, count($tags), '-'));
     $tags = array_map(array('Tags', 'get_one'), $tags);
     $initial_tag_count = count($tags);
     $tags = array_filter($tags);
     // Are all of the tags we asked for actual tags on this site?
     if (count($tags) != $initial_tag_count) {
         return false;
     }
     $tag_params = array();
     foreach ($tags as $tag) {
         $tag_params[] = $tag->term_display;
     }
     return $tag instanceof Term && Posts::count_by_tag($tag_params, Post::status('published')) > 0;
 }