Esempio n. 1
0
 public function checkATOMEntryNode(\DOMNode $node, \DOMXPath $xpath, Feed $feed, FeedEntry $entry)
 {
     foreach ($node->childNodes as $child) {
         if ($child->nodeType !== XML_TEXT_NODE) {
             switch ($child->nodeName) {
                 case 'id':
                     $this->assertEquals(sprintf('%sentry/%d/', self::$DI['app']['feed.user-link-generator']->generatePublic($feed, 'atom', 1)->getURI(), $entry->getId()), $child->nodeValue);
                     break;
                 case 'link':
                     foreach ($child->attributes as $attribute) {
                         if ($attribute->name == "href") {
                             $this->assertEquals(sprintf('%sentry/%d/', self::$DI['app']['feed.user-link-generator']->generatePublic($feed, 'atom', 1)->getURI(), $entry->getId()), $attribute->value);
                             break;
                         }
                     }
                     break;
                 case 'updated':
                     $this->assertEquals($entry->getUpdatedOn()->format(DATE_ATOM), $child->nodeValue);
                     break;
                 case 'published':
                     $this->assertEquals($entry->getCreatedOn()->format(DATE_ATOM), $child->nodeValue);
                     break;
                 case 'title':
                     $this->assertEquals($entry->getTitle(), $child->nodeValue);
                     break;
                 case 'content':
                     $this->assertEquals($entry->getSubtitle(), $child->nodeValue);
                     break;
                 case 'author':
                     foreach ($node->childNodes as $child) {
                         if ($child->nodeType !== XML_TEXT_NODE && $child->nodeName == "email") {
                             $this->assertEquals($entry->getAuthorEmail(), $child->nodeValue);
                         }
                         if ($child->nodeType !== XML_TEXT_NODE && $child->nodeName == "name") {
                             $this->assertEquals($entry->getAuthorName(), $child->nodeValue);
                         }
                     }
                     break;
             }
         }
     }
     $content = $entry->getItems()->toArray();
     $available_medium = ['image', 'audio', 'video'];
     array_walk($content, $this->removeBadItems($content, $available_medium));
     $media_group = $xpath->query("/Atom:feed/Atom:entry[0]/media:group");
     if ($media_group->length > 0) {
         foreach ($media_group as $media) {
             $entry_item = array_shift($content);
             if ($entry_item instanceof FeedEntry) {
                 $this->verifyMediaItem($entry_item, $media);
             }
         }
     }
 }
 /**
  * {@inheritDoc}
  */
 public function getUpdatedOn()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getUpdatedOn', array());
     return parent::getUpdatedOn();
 }
Esempio n. 3
0
 /**
  * Retrieve detailled information about one feed entry
  *
  * @param  FeedEntry $entry
  * @return array
  */
 protected function list_publication_entry(FeedEntry $entry)
 {
     $items = [];
     foreach ($entry->getItems() as $item) {
         $items[] = $this->list_publication_entry_item($item);
     }
     return ['id' => $entry->getId(), 'author_email' => $entry->getAuthorEmail(), 'author_name' => $entry->getAuthorName(), 'created_on' => $entry->getCreatedOn()->format(DATE_ATOM), 'updated_on' => $entry->getUpdatedOn()->format(DATE_ATOM), 'title' => $entry->getTitle(), 'subtitle' => $entry->getSubtitle(), 'items' => $items, 'feed_id' => $entry->getFeed()->getId(), 'feed_url' => '/feeds/' . $entry->getFeed()->getId() . '/content/', 'url' => '/feeds/entry/' . $entry->getId() . '/'];
 }
Esempio n. 4
0
 /**
  * Retrieve detailled information about one feed entry
  *
  * @param  FeedEntry $entry
  *
  * @return array
  */
 private function list_publication_entry(Application $app, FeedEntry $entry)
 {
     $items = array_map(function ($item) use($app) {
         return $this->list_publication_entry_item($app, $item);
     }, iterator_to_array($entry->getItems()));
     return ['id' => $entry->getId(), 'author_email' => $entry->getAuthorEmail(), 'author_name' => $entry->getAuthorName(), 'created_on' => $entry->getCreatedOn()->format(DATE_ATOM), 'updated_on' => $entry->getUpdatedOn()->format(DATE_ATOM), 'title' => $entry->getTitle(), 'subtitle' => $entry->getSubtitle(), 'items' => $items, 'feed_id' => $entry->getFeed()->getId(), 'feed_title' => $entry->getFeed()->getTitle(), 'feed_url' => '/feeds/' . $entry->getFeed()->getId() . '/content/', 'url' => '/feeds/entry/' . $entry->getId() . '/'];
 }
Esempio n. 5
0
 protected function addItem(Application $app, \DOMDocument $document, \DOMNode $feed, FeedEntry $entry, FeedLink $link)
 {
     $entry_node = $this->addTag($document, $feed, 'entry');
     $link = sprintf('%sentry/%d/', $link->getURI(), $entry->getId());
     $this->addTag($document, $entry_node, 'id', $link);
     $link_tag = $this->addTag($document, $entry_node, 'link');
     $link_tag->setAttribute('rel', 'self');
     $link_tag->setAttribute('href', $link);
     $updated_on = $entry->getUpdatedOn()->format(DATE_ATOM);
     $created_on = $entry->getCreatedOn()->format(DATE_ATOM);
     $this->addTag($document, $entry_node, 'updated', $updated_on);
     $this->addTag($document, $entry_node, 'published', $created_on);
     $this->addTag($document, $entry_node, 'title', $entry->getTitle());
     $author = $this->addTag($document, $entry_node, 'author');
     if ($entry->getAuthorEmail()) {
         $this->addTag($document, $author, 'email', $entry->getAuthorEmail());
     }
     if ($entry->getAuthorName()) {
         $this->addTag($document, $author, 'name', $entry->getAuthorName());
     }
     $this->addTag($document, $entry_node, 'content', $entry->getSubtitle());
     foreach ($entry->getItems() as $content) {
         $this->addContent($app, $document, $entry_node, $content);
     }
     return $entry_node;
 }