Ejemplo n.º 1
0
 /**
  * Set a feed param
  *
  * @param \SimpleXMLElement        $element
  * @param \Nekland\Bundle\FeedBundle\Feed $feed
  * @return void
  */
 protected function setParam(\SimpleXMLElement $element, Feed $feed)
 {
     if (count($element) === 0) {
         $feed->set($element->getName(), (string) $element);
     } else {
         $feed->set($element->getName(), $this->extractParam($element));
     }
 }
Ejemplo n.º 2
0
 public function subscribeFeed($feedlink, $options = array())
 {
     if ($this->countSubscriptions() >= SUBSCRUBE_LIMIT) {
         $msg = sprintf('SUBSCRIBE LIMIT: %s(%s) %s', $this->data['Member']['username'], $this->id, $feedlink);
         CakeLog::write(LOG_WARNING, $msg);
         return false;
     }
     $Feed = new Feed();
     $feed = $Feed->findByFeedlink($feedlink);
     if ($feed) {
         // subscribed..
         $Feed->set($feed);
     } elseif (isset($options['quick'])) {
         $data = array('feedlink' => $feedlink, 'link' => $feedlink, 'title' => $options['title'], 'description' => '');
         $Feed->set($data);
         $Feed->save();
         $Feed->createCrawlStatus();
     } else {
         $feeddata = FeedUtils::getFeed($feedlink);
         if (!$feeddata) {
             return false;
         }
         $data = array('subscribers_count' => 0, 'feedlink' => $feedlink, 'link' => $feeddata->get_permalink() ? $feeddata->get_permalink() : '', 'title' => $feeddata->get_title() ? $feeddata->get_title() : '');
         $Feed->set($data);
         $Feed->save();
         $Feed->createCrawlStatus();
     }
     unset($options['quick']);
     unset($options['title']);
     $conditions = array();
     $conditions[] = es('Subscription.member_id = %s', $this->id);
     $conditions[] = es('Subscription.feed_id = %s', $Feed->id);
     $sub = $this->Subscription->find($conditions);
     if ($sub) {
         return $sub;
     }
     $data = array('member_id' => $this->id, 'feed_id' => $Feed->id, 'has_unread' => true);
     $data = array_merge($data, $options);
     $this->Subscription->create($data);
     return $this->Subscription->save();
 }