예제 #1
0
 private function createItem($enclosureType = null)
 {
     $this->expectItem('getUrl', $this->permalink);
     $this->expectItem('getTitle', $this->title);
     $this->expectItem('getId', $this->guid);
     $this->expectItem('getContent', $this->body);
     $item = new Item();
     date_default_timezone_set('America/Los_Angeles');
     $date = new \DateTime();
     $date->setTimestamp($this->pub);
     $this->expectItem('getDate', $date);
     $item->setPubDate($this->pub);
     $item->setStatus(0);
     $item->setUnread();
     $item->setUrl($this->permalink);
     $item->setTitle('my<\' title');
     $item->setGuid($this->guid);
     $item->setGuidHash($this->guid);
     $item->setBody($this->body);
     $item->setLastModified($this->time);
     $item->generateSearchIndex();
     $item->setRtl(false);
     $this->expectItem('getAuthor', $this->author);
     $item->setAuthor(html_entity_decode($this->author));
     if ($enclosureType === 'audio/ogg' || $enclosureType === 'video/ogg') {
         $this->expectItem('getEnclosureUrl', $this->enclosureLink);
         $this->expectItem('getEnclosureType', $enclosureType);
         $item->setEnclosureMime($enclosureType);
         $item->setEnclosureLink($this->enclosureLink);
     }
     return $item;
 }
예제 #2
0
 protected function buildItem($parsedItem, $parsedFeed)
 {
     $item = new Item();
     $item->setUnread();
     $item->setUrl($parsedItem->getUrl());
     $item->setGuid($parsedItem->getId());
     $item->setGuidHash($item->getGuid());
     $item->setPubDate($parsedItem->getDate()->getTimestamp());
     $item->setLastModified($this->time->getTime());
     $item->setRtl($this->determineRtl($parsedItem, $parsedFeed));
     // unescape content because angularjs helps against XSS
     $item->setTitle($this->decodeTwice($parsedItem->getTitle()));
     $item->setAuthor($this->decodeTwice($parsedItem->getAuthor()));
     // purification is done in the service layer
     $body = $parsedItem->getContent();
     $body = mb_convert_encoding($body, 'HTML-ENTITIES', mb_detect_encoding($body));
     $item->setBody($body);
     $enclosureUrl = $parsedItem->getEnclosureUrl();
     if ($enclosureUrl) {
         $enclosureType = $parsedItem->getEnclosureType();
         if (stripos($enclosureType, 'audio/') !== false || stripos($enclosureType, 'video/') !== false) {
             $item->setEnclosureMime($enclosureType);
             $item->setEnclosureLink($enclosureUrl);
         }
     }
     $item->generateSearchIndex();
     return $item;
 }