Pop\Feed\Format\Rss::__construct PHP Метод

__construct() публичный Метод

Method to create an RSS feed object
public __construct ( mixed $options, integer $limit ) : Rss
$options mixed
$limit integer
Результат 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);
    }

Usage Example

Пример #1
0
 /**
  * Method to create a Flickr RSS feed object
  *
  * @param  mixed  $options
  * @param  int    $limit
  * @return \Pop\Feed\Format\Rss\Flickr
  */
 public function __construct($options, $limit = 0)
 {
     // Attempt to get the correct URL to parse
     if (is_array($options)) {
         if (isset($options['id'])) {
             $this->url = str_replace('[{id}]', $options['id'], $this->urls['id']);
         }
     }
     parent::__construct($options, $limit);
 }
All Usage Examples Of Pop\Feed\Format\Rss::__construct