Exemple #1
0
function buildRssFeedCache($rssurl)
{
    $snoopy = new Snoopy();
    $cnt = 0;
    foreach ($rssurl as $url) {
        if ($snoopy->fetch($url)) {
            $rssdata = $snoopy->results;
            $rss2parser = new XoopsXmlRss2Parser($rssdata);
            if (false != $rss2parser->parse()) {
                $_items = $rss2parser->getItems();
                $count = count($_items);
                for ($i = 0; $i < $count; $i++) {
                    $_items[$i]['title'] = XoopsLocale::convert_encoding($_items[$i]['title'], XoopsLocale::getCharset(), 'UTF-8');
                    $_items[$i]['description'] = XoopsLocale::convert_encoding($_items[$i]['description'], XoopsLocale::getCharset(), 'UTF-8');
                    $items[(string) strtotime($_items[$i]['pubdate']) . "-" . (string) ++$cnt] = $_items[$i];
                }
            } else {
                echo $rss2parser->getErrors();
            }
        }
    }
    krsort($items);
    return $items;
}
Exemple #2
0
 if ($URLs = (include $GLOBALS['xoops']->path('language/' . xoops_getConfigOption('language') . '/backend.php'))) {
     $rssurl = array_unique(array_merge($rssurl, $URLs));
 }
 $rssfile = 'adminnews-' . xoops_getConfigOption('language');
 xoops_load('XoopsCache');
 $items = array();
 if (!($items = XoopsCache::read($rssfile))) {
     require_once $GLOBALS['xoops']->path('class/snoopy.php');
     include_once $GLOBALS['xoops']->path('class/xml/rss/xmlrss2parser.php');
     xoops_load('XoopsLocal');
     $snoopy = new Snoopy();
     $cnt = 0;
     foreach ($rssurl as $url) {
         if ($snoopy->fetch($url)) {
             $rssdata = $snoopy->results;
             $rss2parser = new XoopsXmlRss2Parser($rssdata);
             if (false != $rss2parser->parse()) {
                 $_items = $rss2parser->getItems();
                 $count = count($_items);
                 for ($i = 0; $i < $count; $i++) {
                     $_items[$i]['title'] = XoopsLocal::convert_encoding($_items[$i]['title'], _CHARSET, 'UTF-8');
                     $_items[$i]['description'] = XoopsLocal::convert_encoding($_items[$i]['description'], _CHARSET, 'UTF-8');
                     $items[strval(strtotime($_items[$i]['pubdate'])) . "-" . strval(++$cnt)] = $_items[$i];
                 }
             } else {
                 echo $rss2parser->getErrors();
             }
         }
     }
     krsort($items);
     XoopsCache::write($rssfile, $items, 86400);
Exemple #3
0
 /**
  * @param XoopsXmlRss2Parser $parser
  * @param array $data
  * @return void
  */
 public function handleCharacterData(&$parser, &$data)
 {
     if ($parser->getParentTag() === 'item') {
         $parser->setTempArr('source', $data);
     }
 }