public function add_this() { return zest::add_this($this->get_url(), $this->title); }
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"> </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; }