Example #1
0
$Module = $Params['Module'];
if (!isset($Params['RSSFeed'])) {
    eZDebug::writeError('No RSS feed specified');
    return $Module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
}
$feedName = $Params['RSSFeed'];
$RSSExport = eZRSSExport::fetchByName($feedName);
// Get and check if RSS Feed exists
if (!$RSSExport) {
    eZDebug::writeError('Could not find RSSExport : ' . $Params['RSSFeed']);
    return $Module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
}
$config = eZINI::instance('site.ini');
$cacheTime = intval($config->variable('RSSSettings', 'CacheTime'));
$lastModified = gmdate('D, d M Y H:i:s', time()) . ' GMT';
eZURI::setTransformURIMode('full');
if ($cacheTime <= 0) {
    $xmlDoc = $RSSExport->attribute('rss-xml-content');
    $rssContent = $xmlDoc;
} else {
    $cacheDir = eZSys::cacheDirectory();
    $currentSiteAccessName = $GLOBALS['eZCurrentAccess']['name'];
    $cacheFilePath = $cacheDir . '/rss/' . md5($currentSiteAccessName . $feedName) . '.xml';
    if (!is_dir(dirname($cacheFilePath))) {
        eZDir::mkdir(dirname($cacheFilePath), false, true);
    }
    $cacheFile = eZClusterFileHandler::instance($cacheFilePath);
    if (!$cacheFile->exists() or time() - $cacheFile->mtime() > $cacheTime) {
        $xmlDoc = $RSSExport->attribute('rss-xml-content');
        // Get current charset
        $charset = eZTextCodec::internalCharset();