public function __construct(BASE_CLASS_WidgetParameter $param) { parent::__construct(); $this->titleOnly = (bool) $param->customParamList['title_only']; $this->assign('titleOnly', $this->titleOnly); $url = trim($param->customParamList['rss_url']); if (!$url) { return; } $cacheKey = 'rss_widget_cache_' . $url; $cachedState = OW::getCacheService()->get($cacheKey); if ($cachedState === false) { try { $rssLoading = OW::getConfig()->getValue('base', 'rss_loading'); if (!empty($rssLoading) && time() - $rssLoading < 60 * 5) { return; } else { if ($rssLoading === null) { OW::getConfig()->addConfig('base', 'rss_loading', time()); } else { OW::getConfig()->saveConfig('base', 'rss_loading', time()); } } $rssIterator = RssParcer::getIterator($param->customParamList['rss_url'], self::$countInterval[1]); OW::getConfig()->saveConfig('base', 'rss_loading', 0); } catch (Exception $e) { OW::getConfig()->saveConfig('base', 'rss_loading', 0); return; } foreach ($rssIterator as $item) { $item->time = strtotime($item->date); $this->rss[] = (array) $item; } try { OW::getCacheService()->set($cacheKey, json_encode($this->rss), 60 * 60); } catch (Exception $e) { } } else { $this->rss = (array) json_decode($cachedState, true); } $this->count = intval($param->customParamList['item_count']); }