_feed = $feed; $this->_options = $options; } abstract protected function _getCachePath(); protected function _getCache($path) { return file_get_contents($path); } abstract protected function _fetchItems(); abstract protected function _spamFilter($items); abstract protected function _mapItems($content); abstract protected function _sortContent($content); protected function _getItems() { $cacheFile = sprintf($this->_getCachePath(), $this->_feed); $this->_cacheTime = file_exists($cacheFile) ? filemtime($cacheFile) : 0; if ($this->_cacheTime > strtotime('-' . $this->_cacheTimeout)) { return unserialize($this->_getCache($cacheFile)); } else { $content = $this->_fetchItems(); file_put_contents($cacheFile, serialize($content)); $this->_cacheTime = time(); return $content; } } public function get() { $items = $this->_getItems(); if (isset($this->_options['spamfilter'])) { $items = $this->_spamFilter($items); } return $this->_sortContent($this->_mapItems($items)); } public function cacheTime() { return $this->_cacheTime; } abstract public function title(); } ?>