Exemplo n.º 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;
 }
Exemplo n.º 2
0
 public function render($options = null)
 {
     if (!$options) {
         $config = Kohana::config_load('zest');
         $options = $config['comment'];
     }
     $array = array("date_format" => 'D jS M Y', "image" => array(50, 50), "html" => '{AVATAR}{DATE} by {AUTHOR}<br/><p>{TEXT}</p><a href="{DELETE_LINK}" title="delete comment"></a><div class="spacer">&nbsp;</div>', "default_image" => 'http://' . $_SERVER['HTTP_HOST'] . '/zest/images/user_icon.gif', "template" => '');
     $array = arr::overwrite($array, $options);
     if (isset($array['template']) && $array['template'] != "") {
         $html = zest::template_to_html('snippets/' . $array['template']);
     } else {
         $html = $array['html'];
     }
     $html = str_replace('{DATE}', date($array['date_format'], strtotime($this->date)), $html);
     $html = str_replace('{AVATAR}', gravatar::render($this->email, $array['image'][0], $array['default_image']), $html);
     if ($this->fl_deleted == 1) {
         $html = str_replace('{TEXT}', '<i>This comment has been deleted.</i>', $html);
     } else {
         $html = str_replace('{TEXT}', $this->title, $html);
     }
     $html = str_replace('{AUTHOR}', $this->display_name, $html);
     if ($this->can_modify()) {
         $html = str_replace('{DELETE_LINK}', $this->delete_url(), $html);
     }
     return $html;
 }
Exemplo n.º 3
0
 public function get_template()
 {
     if (file_exists(DOCROOT . THEME_PATH . $this->template . '.html')) {
         $template = THEME_PATH . $this->template . '.html';
     } else {
         $template = DEFAULT_THEME_PATH . $this->template . '.html';
     }
     return zest::template_to_html($template);
 }
Exemplo n.º 4
0
 public function edit($url)
 {
     $display_name = ucwords(str_replace('_', ' ', $url));
     $this->__set_heading("Editing Theme file - " . $display_name);
     $view = new View('zest/content');
     $content = form::open('admin/snippets/save/' . $url);
     $html = zest::template_to_html(THEME_PATH . $url);
     $content .= form::label('content', 'Code');
     $content .= '<p><small>This is only for advanced users. To edit <a onclick="$(\'#content\').toggle();return false;" href="#">click here</a></small></p>';
     $content .= form::textarea('content', $html, 'id="content" class="fullWidth no-editor hside"');
     $content .= form::submit('submit', 'Save', 'class="submit"');
     $content .= form::close();
     $view->content = $content;
     $this->__set_content($view);
 }
Exemplo n.º 5
0
 public function render($options = null)
 {
     if (!$options) {
         $config = Kohana::config_load('zest');
         $options = $config['feedpost.full'];
     }
     $array = array("date_format" => 'D jS M Y', "image" => array(250, 250), "image_class" => "", "html" => '<h1>{TITLE}</h1><h2>{DATE}</h2><h3>by {AUTHOR}</h3>{IMAGE}{TEXT}<div class="spacer">&nbsp;</div>', "template" => '', "word_limit" => 0);
     $array = arr::overwrite($array, $options);
     if (isset($array['template']) && $array['template'] != "") {
         $html = zest::template_to_html('snippets/' . $array['template']);
     } else {
         $html = $array['html'];
     }
     $html = str_replace('{TITLE}', $this->title, $html);
     $html = str_replace('{DATE}', date($array['date_format'], strtotime($this->date)), $html);
     if ($this->media_id > 0) {
         $html = str_replace('{IMAGE}', $this->media->render_cropped($array['image'][0], $array['image'][1], $array['image_class']), $html);
     } else {
         $html = str_replace('{IMAGE}', '', $html);
     }
     if (isset($array['word_limit']) && $array['word_limit'] > 0) {
         $html = str_replace('{TEXT}', text::limit_words(strip_tags($this->text), $array['word_limit']), $html);
     } else {
         $html = str_replace('{TEXT}', $this->text, $html);
         $html = str_replace('{ADD_THIS}', zest::add_this($this->get_url(), $this->title), $html);
     }
     $html = str_replace('{LINK}', $this->get_url(), $html);
     $html = str_replace('{FEED_LINK}', $this->feed->get_url(), $html);
     $html = str_replace('{FEED_TITLE}', $this->feed->title, $html);
     $html = str_replace('{AUTHOR}', $this->user->username, $html);
     if ($this->feed->has_comments()) {
         $html = str_replace('{COMMENT_FORM}', $this->comment_form(), $html);
         $comments = $this->get_comments();
         $comments_html = "<a name='comments'></a>";
         foreach ($comments as $c) {
             $comments_html .= $c->render();
         }
         if ($comments_html == "") {
             $comments_html = "<p>No comments have yet been posted. Be the first!</p>";
         }
         $html = str_replace('{COMMENTS}', $comments_html, $html);
         $com_count = count($comments);
         switch ($com_count) {
             case 0:
                 $str = '0 comments';
                 break;
             case 1:
                 $str = '1 comment';
                 break;
             default:
                 $str = $com_count . ' comments';
                 break;
         }
         $html = str_replace('{COMMENT_COUNT}', $str, $html);
     } else {
         $html = str_replace('{COMMENT_FORM}', '', $html);
         $html = str_replace('{COMMENTS}', '', $html);
         $html = str_replace('{COMMENT_COUNT}', '', $html);
     }
     return $html;
 }