diff options
author | Fernando García <striptm@yahoo.com> | 2014-03-04 01:40:10 +0100 |
---|---|---|
committer | Fernando García <striptm@yahoo.com> | 2014-03-04 01:40:10 +0100 |
commit | 5ce4dd4d15c9f59155edd7bd7c18b142494cec79 (patch) | |
tree | 747ccce6e9083c3422e5d1a275ce3cb994b70296 /app/classes | |
parent | 3b6675fa5482368fef6d9d162627fde57c2a9e6b (diff) | |
download | planet-5ce4dd4d15c9f59155edd7bd7c18b142494cec79.tar planet-5ce4dd4d15c9f59155edd7bd7c18b142494cec79.tar.gz planet-5ce4dd4d15c9f59155edd7bd7c18b142494cec79.tar.bz2 planet-5ce4dd4d15c9f59155edd7bd7c18b142494cec79.tar.xz planet-5ce4dd4d15c9f59155edd7bd7c18b142494cec79.zip |
Control width blacklisting feed are down, cron.php manage the status of this feeds
Diffstat (limited to 'app/classes')
-rw-r--r-- | app/classes/Planet.class.php | 26 | ||||
-rw-r--r-- | app/classes/PlanetFeed.php | 9 |
2 files changed, 28 insertions, 7 deletions
diff --git a/app/classes/Planet.class.php b/app/classes/Planet.class.php index 81a71fe..3c76378 100644 --- a/app/classes/Planet.class.php +++ b/app/classes/Planet.class.php @@ -97,7 +97,8 @@ class Planet new PlanetFeed( $opml_person['name'], $opml_person['feed'], - $opml_person['website'] + $opml_person['website'], + $opml_person['isDown'] ) ); } @@ -110,11 +111,14 @@ class Planet public function loadFeeds() { foreach ($this->people as $feed) { - $feed->set_timeout(-1); - $feed->init(); - $this->items = array_merge($this->items, $feed->get_items()); - } + //Is down it's filled by cron.php, $Planet->download(1.0) proccess + if (!$feed->isDown) { + $feed->set_timeout(-1); + $feed->init(); + $this->items = array_merge($this->items, $feed->get_items()); + } + } $this->sort(); } @@ -124,8 +128,8 @@ class Planet */ public function download($max_load=0.1) { - $max_load_feeds = ceil(count($this->people) * $max_load); + $opml = OpmlManager::load(dirname(__FILE__).'/../../custom/people.opml'); foreach ($this->people as $feed) { //Avoid mass loading with variable cache duration @@ -140,6 +144,7 @@ class Planet //Load feed $feed->init(); + $isDown = ''; // http://simplepie.org/wiki/reference/simplepie/merge_items ? //Add items to index @@ -148,8 +153,17 @@ class Planet $this->items = array_merge($this->items, $items); } else { $this->errors[] = new PlanetError(1, 'No items : '.$feed->getFeed()); + $isDown = '1'; + } + + //Mark if the feed is temporary unavailable + foreach ($opml->entries as $key => $entrie) { + if ($feed->getFeed() === $entrie['feed']) { + $opml->entries[$key]['isDown'] = $isDown; + } } } + OpmlManager::save($opml, dirname(__FILE__).'/../../custom/people.opml'); } public function sort() diff --git a/app/classes/PlanetFeed.php b/app/classes/PlanetFeed.php index a6c7aab..7c79471 100644 --- a/app/classes/PlanetFeed.php +++ b/app/classes/PlanetFeed.php @@ -9,12 +9,14 @@ class PlanetFeed extends SimplePie public $name; public $feed; public $website; + public $isDown; - public function __construct($name, $feed, $website) + public function __construct($name, $feed, $website, $isDown) { $this->name = $name; $this->feed = $feed; $this->website = $website; + $this->isDown = $isDown; parent::__construct(); $this->set_item_class('PlanetItem'); $this->set_cache_location(dirname(__FILE__).'/../../cache'); @@ -39,6 +41,11 @@ class PlanetFeed extends SimplePie return $this->website; } + public function getIsDown() + { + return $this->isDown; + } + public function compare($person1, $person2) { return strcasecmp($person1->name, $person2->name); |