public function getContent() { $url = $this->getConfigVar('feed_url'); if ($url == '') { return 'Enter a RSS Feed in this Widget configuration.'; } // Cache File path $cacheFile = PATH_site . 'typo3temp/mydashboard' . substr(md5($url . $this->getConfigVar('feed_title')), 0, 15) . '.cache'; // Update rules $updateRSS = isset($_POST['ajax']) && isset($_POST['action']) && $_POST['action'] == 'refresh'; // Load a Cache File if (file_exists($cacheFile) && !$updateRSS) { $fileinfo = fileatime($cacheFile); if ($fileinfo > time() - (int) $this->getConfigVar('cache_time_h')) { $data = $this->loadRSSData($cacheFile); return $this->renderRSSArray($data); } # if } # if // Load the rss2array class and fetch the RSS Feed require_once \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('mydashboard', 'widgets/helper/rss2array.php'); $rss_array = rss2array($url); // Safe the Feed in a Cache File $this->safeRSSData($cacheFile, $rss_array); return $this->renderRSSArray($rss_array); }
$aRSSArray = KTrss::getInternalFeed($user); } else { // If it is a url, it is an external feed // However, sometimes internal documents get added as external feeds // Check that the url isn't an internal one. global $default; $rootUrl = $default->rootUrl; $bSSL = $default->sslEnabled; $sProtocol = $bSSL ? 'https' : 'http'; $sBaseUrl = $sProtocol . '://' . $_SERVER['HTTP_HOST'] . $rootUrl; $sInternal = $sBaseUrl . '/rss.php'; if (!(strpos($feed, $sInternal) === FALSE)) { // Feed is internal $aRSSArray = KTrss::getExternalInternalFeed($feed, $user); } else { $aRSSArray = rss2array($feed); } } if (is_array($aRSSArray[errors])) { foreach ($aRSSArray[errors] as $errorItem) { $response .= $errorItem . '<br>'; echo '<br>' . $response . '<br>'; return; } } // Prepare response data to be passed back to page $response = "<h3>" . $aRSSArray[channel][title] . "</h3>" . "<div class='outerContainer' id='outerContainer'>" . "<table width='90%'>"; for ($i = 0; $i < count($aRSSArray[items]); $i++) { $response .= "<tr>\n\t\t\t\t<td colspan='2'><strong><a href='" . $aRSSArray[items][$i][link] . "' target='_blank'>" . $aRSSArray[items][$i][title] . "</a><strong></td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>" . $aRSSArray[items][$i][description] . "</td>\n\t\t\t</tr>\n\t\t\t<tr><td colspan='2'><br></td></tr>"; } $response .= "</table></div><br>";
function rsscache_download_feeds_by_category($c) { global $rsscache_sql_db; $c = trim($c); $category = config_xml_by_category($c); // DEBUG // echo '<pre><tt>'; // print_r ($category); //exit; if ($category == NULL) { return; } if (!rsscache_item_has_feed($category)) { return; } $table_suffix = isset($category['rsscache:table_suffix']) ? $category['rsscache:table_suffix'] : NULL; for ($j = 0; rsscache_item_has_feed($category, $j); $j++) { $exec = isset($category['rsscache:feed_' . $j . '_exec']) ? $category['rsscache:feed_' . $j . '_exec'] : ''; $link = isset($category['rsscache:feed_' . $j . '_link']) ? '"' . $category['rsscache:feed_' . $j . '_link'] . '"' : ''; $p = ''; $p .= 'category: ' . $c . "\n" . 'exec: ' . $exec . "\n" . 'link: ' . $link . "\n" . 'table_suffix: ' . ($table_suffix ? $table_suffix : '(none)') . "\n"; echo $p; // get feed $p = $exec . ' ' . $link; // DEBUG // echo $p; // exit; exec($p, $a); $p = implode("\n", $a); // DEBUG // echo $p; // exit; $rss = simplexml_load_string($p, 'SimpleXMLElement', LIBXML_NOCDATA); // DEBUG print_r($rss); exit; $a = rss2array($rss); // DEBUG print_r($a); exit; // download thumbnails // $a = rsscache_download_thumbnails ($a); $sql_queries_s = rsstool_write_ansisql($a, $c, $table_suffix, $rsscache_sql_db->conn); rsscache_sql_queries($sql_queries_s); } }