示例#1
0
文件: Rss10.php 项目: aduroo/feed-api
 /**
  * Find the item language.
  *
  * @param SimpleXMLElement      $entry Feed item
  * @param \AsteFeed\Parser\Item $item  Item object
  * @param \AsteFeed\Parser\Feed $feed  Feed object
  */
 public function findItemLanguage(SimpleXMLElement $entry, Item $item, Feed $feed)
 {
     $language = XmlParser::getXPathResult($entry, 'dc:language', $this->namespaces);
     $item->language = (string) current($language) ?: $feed->language;
 }
示例#2
0
文件: Atom.php 项目: aduroo/feed-api
 /**
  * Get the entry content.
  *
  * @param SimpleXMLElement $entry XML Entry
  *
  * @return string
  */
 private function getContent(SimpleXMLElement $entry)
 {
     $content = current(XmlParser::getXPathResult($entry, 'atom:content', $this->namespaces) ?: XmlParser::getXPathResult($entry, 'content'));
     if (!empty($content) && count($content->children())) {
         $xml_string = '';
         foreach ($content->children() as $child) {
             $xml_string .= $child->asXML();
         }
         return $xml_string;
     } elseif (trim((string) $content) !== '') {
         return (string) $content;
     }
     $summary = XmlParser::getXPathResult($entry, 'atom:summary', $this->namespaces) ?: XmlParser::getXPathResult($entry, 'summary');
     return (string) current($summary);
 }
示例#3
0
文件: Rss20.php 项目: aduroo/feed-api
 /**
  * Find the item media.
  *
  * @param SimpleXMLElement      $entry Feed item
  * @param \AsteFeed\Parser\Item $item  Item object
  * @param \AsteFeed\Parser\Feed $feed  Feed object
  */
 public function findItemMedia(SimpleXMLElement $entry, Item $item, Feed $feed)
 {
     $item->media = new Media();
     $mediaTags = XmlParser::getXPathResult($entry, 'media:*', $this->namespaces);
     foreach ($mediaTags as $mediaTag) {
         $name = $mediaTag->getName();
         $array = [];
         foreach ($mediaTag->attributes() as $key => $value) {
             $array[$key] = (string) $value;
         }
         if (strlen($mediaTag) > 0) {
             $array['content'];
         }
         if ($name == "thumbnail") {
             $item->media->thumbnails[] = $array;
         } else {
             $item->media->{$name} = $array;
         }
     }
 }