コード例 #1
0
ファイル: Atom.php プロジェクト: shylar/picoFeed
 /**
  * Find the item enclosure
  *
  * @access public
  * @param  SimpleXMLElement   $entry   Feed item
  * @param  \PicoFeed\Item     $item    Item object
  * @param  \PicoFeed\Feed     $feed    Feed object
  */
 public function findItemEnclosure(SimpleXMLElement $entry, Item $item, Feed $feed)
 {
     foreach ($entry->link as $link) {
         if ((string) $link['rel'] === 'enclosure') {
             $item->enclosure_url = (string) $link['href'];
             $item->enclosure_type = (string) $link['type'];
             if (Filter::isRelativePath($item->enclosure_url)) {
                 $item->enclosure_url = Filter::getAbsoluteUrl($item->enclosure_url, $feed->url);
             }
             break;
         }
     }
 }
コード例 #2
0
ファイル: FilterTest.php プロジェクト: shylar/picoFeed
    public function testIsRelativePath()
    {
        $f = new Filter('<a href="/bla/bla">link</a>', 'http://blabla');
        $this->assertTrue($f->isRelativePath('/bbla'));
        $this->assertTrue($f->isRelativePath('../../bbla'));
        $this->assertFalse($f->isRelativePath('http://google.fr'));
        $this->assertFalse($f->isRelativePath('//superurl'));
        $this->assertFalse($f->isRelativePath('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA
AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
9TXL0Y4OHwAAAABJRU5ErkJggg=='));
    }
コード例 #3
0
ファイル: Rss20.php プロジェクト: shylar/picoFeed
 /**
  * Find the item enclosure
  *
  * @access public
  * @param  SimpleXMLElement   $entry   Feed item
  * @param  \PicoFeed\Item     $item    Item object
  * @param  \PicoFeed\Feed     $feed    Feed object
  */
 public function findItemEnclosure(SimpleXMLElement $entry, Item $item, Feed $feed)
 {
     if (isset($entry->enclosure)) {
         $item->enclosure_url = $this->getNamespaceValue($entry->enclosure, $this->namespaces, 'origEnclosureLink');
         if (empty($item->enclosure_url)) {
             $item->enclosure_url = isset($entry->enclosure['url']) ? (string) $entry->enclosure['url'] : '';
         }
         $item->enclosure_type = isset($entry->enclosure['type']) ? (string) $entry->enclosure['type'] : '';
         if (Filter::isRelativePath($item->enclosure_url)) {
             $item->enclosure_url = Filter::getAbsoluteUrl($item->enclosure_url, $feed->url);
         }
     }
 }