/** * Method to create an RSS feed object * * @param mixed $options * @param int $limit * @throws Exception * @return \Pop\Feed\Format\Rss */ public function __construct($options, $limit = 0) { parent::__construct($options, $limit); // Create the SimpleXMLElement if (null === $this->obj) { if (!($this->obj = simplexml_load_string($this->source, 'SimpleXMLElement', LIBXML_NOWARNING))) { throw new Exception('That feed URL cannot be read at this time. Please try again later.'); } } // Check for the date if (isset($this->obj->channel->lastBuildDate)) { $date = (string) $this->obj->channel->lastBuildDate; } else { if (isset($this->obj->channel->pubDate)) { $date = (string) $this->obj->channel->pubDate; } else { $date = null; } } // Get the main header info of the feed $feed = array(); $feed['title'] = isset($this->obj->channel->title) ? (string) $this->obj->channel->title : null; $feed['url'] = isset($this->obj->channel->link) ? (string) (string) $this->obj->channel->link : null; $feed['description'] = isset($this->obj->channel->description) ? (string) $this->obj->channel->description : null; $feed['date'] = $date; $feed['generator'] = isset($this->obj->channel->generator) ? (string) $this->obj->channel->generator : null; $feed['author'] = isset($this->obj->channel->managingEditor) ? (string) $this->obj->channel->managingEditor : null; $feed['items'] = array(); $this->feed = new \ArrayObject($feed, \ArrayObject::ARRAY_AS_PROPS); }
/** * Method to create a PHP feed object * * @param mixed $options * @param int $limit * @throws Exception * @return \Pop\Feed\Format\Php */ public function __construct($options, $limit = 0) { parent::__construct($options, $limit); // Create the PHP data object from the serialized PHP string source if (null === $this->obj) { if (!($this->obj = unserialize($this->source))) { throw new Exception('That feed URL cannot be read at this time. Please try again later.'); } } }
/** * Constructor method to create an Atom feed object * * @param mixed $options * @param int $limit * @throws Exception * @return Atom */ public function __construct($options, $limit = 0) { parent::__construct($options, $limit); // Create the SimpleXMLElement if (null === $this->obj) { if (!($this->obj = simplexml_load_string($this->source, 'SimpleXMLElement', LIBXML_NOWARNING))) { throw new Exception('That feed URL cannot be read at this time. Please try again later.'); } } // Get the main header info of the feed $feed = []; $feed['title'] = isset($this->obj->title) ? (string) $this->obj->title : null; $feed['url'] = isset($this->obj->link->attributes()->href) ? (string) $this->obj->link->attributes()->href : null; $feed['description'] = isset($this->obj->subtitle) ? (string) $this->obj->subtitle : null; $feed['date'] = isset($this->obj->updated) ? (string) $this->obj->updated : null; $feed['generator'] = isset($this->obj->generator) ? (string) $this->obj->generator : null; $feed['author'] = isset($this->obj->author->name) ? (string) $this->obj->author->name : null; $feed['items'] = []; $this->feed = new \ArrayObject($feed, \ArrayObject::ARRAY_AS_PROPS); }
/** * Method to create a JSON feed object * * @param mixed $options * @param int $limit * @throws Exception * @return \Pop\Feed\Format\Json */ public function __construct($options, $limit = 0) { parent::__construct($options, $limit); // Create the PHP data array from JSON if (null === $this->obj) { if (!($this->obj = json_decode($this->source, true))) { throw new Exception('That feed URL cannot be read at this time. Please try again later.'); } } // Get the main header info of the feed $objs = isset($this->obj['feed']) ? $this->obj['feed'] : $this->obj; $feed = array(); $feed['title'] = isset($objs['title']) ? $objs['title'] : null; $feed['url'] = isset($objs['link']) ? $objs['link'] : null; $feed['description'] = isset($objs['description']) ? $objs['description'] : null; $feed['date'] = isset($objs['updated']) ? $objs['updated'] : null; $feed['generator'] = isset($objs['generator']) ? $objs['generator'] : null; $feed['author'] = isset($objs['author']) ? $objs['author'] : null; $this->feed = new \ArrayObject($feed, \ArrayObject::ARRAY_AS_PROPS); }