Example #1
0
 /**
  * Returns the formatted html
  *
  * html example
  * e.g <h1>{TITLE}</h1><h2>{DATE}</h2><h3>by {AUTHOR}</h3>{IMAGE}{TEXT}<div class="spacer">&nbsp;</div>
  *
  * @param   array	$options	Options for the rendering array('count', 'date_format','image' = array($width,$height), 'word_count', 'html')
  * @return	string	$html		Formatted HTML
  */
 public function render_summary($options = null, $feedpost_options = null)
 {
     $array = array('per_page' => 5, 'pagination' => 'classic', 'template' => 'feed', 'html' => '{FEEDPOSTS}{PAGINATION}');
     if (!$options) {
         $config = Kohana::config_load('zest');
         $options = $config['feed.summary'];
     }
     $array = arr::overwrite($array, $options);
     $uri = uri::instance();
     $page = $uri->segment('page', 1);
     $feedposts = "";
     $posts = $this->get_posts($array['per_page'], ($page - 1) * $array['per_page']);
     foreach ($posts as $post) {
         $feedposts .= $post->render_summary($feedpost_options);
     }
     $pagination = new Pagination(array('uri_segment' => 'page', 'total_items' => count($this->get_posts()), 'items_per_page' => $array['per_page'], 'style' => $array['pagination']));
     if ($array['template'] != '') {
         $html = zest::template_to_html('snippets/' . $array['template']);
     } else {
         $html = $array['html'];
     }
     $html = str_replace("{RSS_LINK}", $this->get_rss(), $html);
     $html = str_replace("{FEEDPOSTS}", $feedposts, $html);
     $html = str_replace("{PAGINATION}", $pagination, $html);
     $html = str_replace("{FEED_LINK}", $this->get_url(), $html);
     return $html;
 }
Example #2
0
 public static function get_by_url()
 {
     static $instance;
     if (empty($instance)) {
         $uri = uri::instance();
         $page = $uri->segment(1);
         $page = ORM::factory('page')->where(array('seoURL' => $page, 'status_id' => 2))->find();
         if ($page->id > 0) {
             $instance = $page;
         } else {
             $instance = null;
         }
     }
     return $instance;
 }
Example #3
0
 /**
  * Returns a feedpost from the current url
  *
  * $param	bool	$unpublished	Return unpublished posts too?
  * @return	object|bool	$post		The feedpost generated by the url, or null if no feedpost found
  */
 public static function get_by_url($unpublished = false)
 {
     $uri = uri::instance();
     $feed = Feed_Model::get_by_url();
     if ($feed && $feed->id > 0) {
         $post_id = $uri->segment(2);
         $post = ORM::factory('feedpost', $post_id);
         if (!$unpublished) {
             if ($post->status_id == 2) {
                 return $post;
             }
         } else {
             return $post;
         }
     }
     return null;
 }