/** * Returns each result article's content * */ public static function content(FTL_Binding $tag) { // paragraph limit ? $paragraph = isset($tag->attr['paragraph']) ? (int) self::get_attribute($tag, 'paragraph') : FALSE; $content = $tag->locals->result['content']; // Limit to x paragraph if the attribute is set if ($paragraph !== FALSE) { $content = tag_limiter($content, 'p', $paragraph); } return self::wrap($tag, $content); }
/** * Prepare the articles array * * @param FTL_Binding $tag * @param Array $articles * * @return Array Articles * */ private static function prepare_articles(FTL_Binding $tag, $articles) { // Articles index starts at 1. $index = 1; // view $view = $tag->getAttribute('view'); // paragraph limit ? $paragraph = $tag->getAttribute('paragraph'); // auto_link // Removed because of double execution // (also done by the Tagmanager) // $auto_link = $tag->getAttribute('auto_link', TRUE); // Last part of the URI $uri_last_part = array_pop(explode('/', uri_string())); $count = count($articles); foreach ($articles as $key => $article) { // Force the view if the "view" attribute is defined if (!is_null($view)) { $articles[$key]['view'] = $view; } $articles[$key]['active_class'] = ''; $article_url = array_pop(explode('/', $article['url'])); $articles[$key]['is_active'] = $uri_last_part == $article_url; if (!is_null($tag->getAttribute('active_class'))) { if ($uri_last_part == $article_url) { $articles[$key]['active_class'] = $tag->attr['active_class']; } } // Limit to x paragraph if the attribute is set if (!is_null($paragraph)) { $articles[$key]['content'] = tag_limiter($article['content'], 'p', intval($paragraph)); } // Autolink the content // if ($auto_link) // $articles[$key]['content'] = auto_link($articles[$key]['content'], 'both', TRUE); // Article's index $articles[$key]['index'] = $index++; // Article's count $articles[$key]['count'] = $count; // Article's ID $articles[$key]['id'] = $articles[$key]['id_article']; } return $articles; }
/** * Processes one string by adding text helper attributes * * @param FTL_Binding $tag * @param String $value * * @usage <ion:content /> * */ public function process_string(FTL_Binding $tag, $value) { // paragraph & words limit ? $paragraph = $tag->getAttribute('paragraph'); $words = $tag->getAttribute('words'); $chars = $tag->getAttribute('characters'); $ellipsize = $tag->getAttribute('ellipsize'); // Limit to x paragraph if the attribute is set if (!is_null($paragraph)) { $value = tag_limiter($value, 'p', intval($paragraph)); } // Limit to x words if (!is_null($words)) { $value = word_limiter($value, $words); } // Limit to x characters if (!is_null($chars)) { $value = character_limiter($value, $chars); } // Ellipsize the text // See : http://codeigniter.com/user_guide/helpers/text_helper.html if (!is_null($ellipsize)) { $ellipsize = explode(',', $ellipsize); if (!isset($ellipsize[0])) { $ellipsize[0] = 32; } if (!isset($ellipsize[1])) { $ellipsize[1] = 0.5; } if (floatval($ellipsize[1]) > 0.99) { $ellipsize[1] = 0.99; } $value = ellipsize($value, intval($ellipsize[0]), floatval($ellipsize[1])); } return $value; }
<item> <title><?php echo xml_convert($article['title']); ?> </title> <link><?php echo $article['url']; ?> </link> <guid><?php echo $article['url']; ?> </guid> <description><![CDATA[<?php echo strip_tags(tag_limiter($article['content'], 'p', 1)); ?> ]]></description> <?php $unix_date = strtotime($article['date'] . " GMT"); ?> <pubDate><?php echo date('r', $unix_date); ?> </pubDate> </item> <?php } ?> </channel>