<span class="help-block">You can define multiple feeds URLs separated by coma.</span>
                    <span class="help-block">Shortcuts:
                        <ul>
                            <li><a href="#" onclick="updateForm('feed_url', 'http://feeds.cyberciti.biz/Nixcraft-LinuxFreebsdSolarisTipsTricks');">http://feeds.cyberciti.biz/Nixcraft-LinuxFreebsdSolarisTipsTricks</a></li>
                            <li><a href="#" onclick="updateForm('feed_url', 'http://www.digitaltrends.com/feed/');">http://www.digitaltrends.com/feed/</a></li>
                        </ul>
                    </span>

                    <button type="submit" class="btn btn-primary">Submit</button>

                </form>
            </div>
            <article>

<?php 
\WebSyndication\Helper::setOptions($options);
$feeds = null;
if (!empty($feed_urls)) {
    $feeds = new \WebSyndication\FeedsCollection($feed_urls);
    $feeds->read();
    //var_export($feeds);
    $categories = $feeds->getItemsCategories();
    if (empty($category)) {
        $items = $feeds->getItems();
    } else {
        $items = $feeds->getItemsCollectionByCategorie($category);
    }
    $pagination = new \Library\Tool\Pagination($items, $page_max, $page_max * ($current_page - 1));
    echo '<div class="page-header"><h1>';
    foreach ($feeds->getFeedsRegistry() as $i => $feed) {
        echo $feed->getFeedUrl() . ' (' . $feed->getProtocol() . ' ' . $feed->getVersion() . ') ';
 public static function parseTag($xml, $tag_name, array $tag_specifications, array $global_specifications, $is_attribute = false)
 {
     if (self::$_debug) {
         echo '<hr /><br />tag name : "' . $tag_name . '" with specs ' . var_export($tag_specifications, 1);
     }
     //.' on value '.var_export($xml,1);
     // type of the field
     if (isset($tag_specifications['type'])) {
         $field_type = $tag_specifications['type'];
     } else {
         throw new \LogicException(sprintf('Type not defined for tag_name "%s"!', $tag_name));
     }
     // the field settings
     $field_settings = isset($tag_specifications['settings']) ? explode(',', $tag_specifications['settings']) : null;
     // the field value
     $value = null;
     if (false === $is_attribute && isset($xml->{$tag_name})) {
         if ($field_type === 'list') {
             $value = array();
             for ($i = 0; $i < count($xml->{$tag_name}); $i++) {
                 $value[] = $xml->{$tag_name}[$i];
             }
         } else {
             $value = $xml->{$tag_name};
         }
     } elseif (true === $is_attribute) {
         $value = \WebSyndication\Helper::getAttribute($xml, $tag_name);
     } elseif (isset($tag_specifications['default'])) {
         $value = $tag_specifications['default'];
     }
     // parsing
     if ($value) {
         // other specification for this field type ?
         if (isset($global_specifications[$field_type])) {
             $field = new \WebSyndication\Abstracts\StdClass();
             //                $field->type = $type;
             $field->type = $field_type;
             foreach ($global_specifications[$field_type] as $f_name => $f_specs) {
                 if ($f_name === 'content' && !isset($value->content)) {
                     $f_name = $tag_name;
                     $value = $xml;
                 }
                 $tag = self::parseTag($value, $f_name, $f_specs, $global_specifications, isset($f_specs['attribute']) && $f_specs['attribute'] === '1');
                 if (!is_null($tag)) {
                     $field->{$f_name} = $tag;
                 }
             }
             if (self::$_debug) {
                 echo '<br />=> special object : ' . var_export($field, 1);
             }
         } else {
             if ($field_type === 'list' && isset($tag_specifications['listitem_type'])) {
                 $field_settings['listitem_type'] = $tag_specifications['listitem_type'];
             }
             if (isset($tag_specifications['rename'])) {
                 $tag_name = $tag_specifications['rename'];
             }
             $field = new \WebSyndication\Item($field_type, $value, $tag_name, $field_settings);
             if (self::$_debug) {
                 echo '<br />=> object : ' . var_export($field, 1);
             }
         }
         return $field;
     } elseif (isset($tag_specifications['required']) && $tag_specifications['required'] === '1' && self::$_debug) {
         throw new \RuntimeException(sprintf('Required field "%s" is empty!', $tag_name));
     }
     return null;
 }
 public function getTagItem($tag_name)
 {
     return Helper::findTagByCommonName($this, $tag_name);
 }
 public function parse()
 {
     if ($this->getProtocol() === 'RSS') {
         // channel
         $parser = new Parser($this->xml->channel, $this, 'channel');
         $channel = $parser->getData();
         $channel->protocol = strtolower($this->getProtocol());
         $this->setData($channel);
         // items
         $this->items = new XMLObjectsCollection($this->xml->channel);
         foreach ($this->items as $i => $item) {
             $parser = new Parser($item, $this, 'item');
             $item = $parser->getData();
             $item->protocol = strtolower($this->getProtocol());
             $item->id = $this->id . '_' . Helper::encodeStringToId($item->title->content);
             $this->items->addData($i, $item);
         }
     } elseif ($this->getProtocol() === 'ATOM') {
         // entry
         $parser = new Parser($this->xml, $this, 'feed');
         $channel = $parser->getData();
         $channel->protocol = strtolower($this->getProtocol());
         $this->setData($channel);
         // entry
         $this->items = new XMLObjectsCollection($this->xml);
         foreach ($this->items as $i => $item) {
             $parser = new Parser($item, $this, 'feed');
             $item = $parser->getData();
             $item->protocol = strtolower($this->getProtocol());
             $item->id = $this->id . '_' . Helper::encodeStringToId($item->title->content);
             $this->items->addData($i, $item);
         }
     }
 }
 public function getHtml()
 {
     if (!$this->exists()) {
         return '';
     }
     switch ($this->type) {
         case 'datetime':
             $html = '<abbr title="' . $this->content->format('c') . '">' . (class_exists('WebSyndication\\Helper') ? \WebSyndication\Helper::getLocalizedDateString($this->content) : $this->content->format('D j m Y H:i:s')) . '</abbr>';
             break;
         case 'time':
             $html = $this->content->format('H:i:s');
             break;
         case 'email':
             $html = '<a href="mailto:' . $this->content . '" title="Contact this email">' . $this->content . '</a>';
             break;
         case 'url':
             $html = '<a href="' . $this->content . '" title="See online">' . $this->content . '</a>';
             break;
         case 'text':
             $html = $this->xml_value;
             break;
         case 'lang':
             $html = '<abbr title="ISO : ' . $this->xml_value . '">' . $this->content . '</abbr>';
             break;
         case 'list':
             $html = '';
             foreach ($this->content as $_ctt) {
                 $html .= (strlen($html) ? ', ' : '') . $_ctt->content;
             }
             break;
         default:
             $html = $this->content;
             break;
     }
     return $html;
 }
 /**
  * Test if an item is already cached and if its cache is still valid
  *
  * This may check if a cache exists for the item and if it seems always valid ; validity
  * may be tested for a static duration time (a `max_cache_time`) and could be checked
  * comparing the creation time of the cache entry and the last modification time of the
  * source if it is possible.
  *
  * @return bool
  */
 public function isCached()
 {
     $cache_lifetime = Helper::getOption('cache_lifetime', 0);
     if ($cache_lifetime > 0) {
         return @file_exists($this->getCacheKey()) && filemtime($this->getCacheKey()) + $cache_lifetime > time();
     } else {
         return @file_exists($this->getCacheKey());
     }
 }
 /**
  * Get a template file path
  */
 public function getTemplate($name)
 {
     return Helper::getTemplate($name);
 }
 public function forceRefresh($feed_url)
 {
     $cachable = Helper::getOption('use_cache', false);
     $index = $this->getFeedItemIndex($feed_url);
     if ($index) {
         $this->feeds_registry[$i] = $cachable ? new FeedCachable($this->offsetGet($index), $index) : new Feed($this->offsetGet($index), $index);
     }
 }