예제 #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 getTitle()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getTitle', array());
     return parent::getTitle();
 }
예제 #3
0
 protected function addItem(Application $app, \DOMDocument $document, \DOMNode $node, FeedEntry $entry)
 {
     $item = $this->addTag($document, $node, 'item');
     $feed = $entry->getFeed();
     if ($feed->isPublic()) {
         $link = $app['feed.link-generator-collection']->generatePublic($feed, FeedLinkGenerator::FORMAT_RSS);
     } else {
         $link = $app['feed.link-generator-collection']->generate($feed, $app['authentication']->getUser(), FeedLinkGenerator::FORMAT_RSS);
     }
     $this->addTag($document, $item, 'title', $entry->getTitle());
     $this->addTag($document, $item, 'description', $entry->getSubtitle());
     $author = sprintf('%s (%s)', $entry->getAuthorEmail(), $entry->getAuthorName());
     $created_on = $entry->getCreatedOn()->format(DATE_RFC2822);
     $this->addTag($document, $item, 'author', $author);
     $this->addTag($document, $item, 'pubDate', $created_on);
     $this->addTag($document, $item, 'guid', $link->getURI());
     $this->addTag($document, $item, 'link', $link->getURI());
     /**
      *  Missing :
      *
      *  category  Includes the item in one or more categories. More.
      *  comments  URL of a page for comments relating to the item. More.
      *  enclosure  Describes a media object that is attached to the item. More.
      *  source    The RSS channel that the item came from. More.
      *
      */
     foreach ($entry->getItems() as $content) {
         $this->addContent($app, $document, $item, $content);
     }
     return $item;
 }
예제 #4
0
파일: V1.php 프로젝트: nlegoff/Phraseanet
 /**
  * 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() . '/'];
 }
예제 #5
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() . '/'];
 }
예제 #6
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;
 }