find() public method

public find ( $type = SIMPLEPIE_LOCATOR_ALL, &$working )
Esempio n. 1
0
 /**
  * @dataProvider firefoxtests
  */
 public function test_from_file($data)
 {
     $locator = new SimplePie_Locator($data, 0, null, 'MockSimplePie_File', false);
     $expected = SimplePie_Misc::get_element('link', $data->body);
     $feed = $locator->find(SIMPLEPIE_LOCATOR_ALL, $all);
     $this->assertFalse($locator->is_feed($data), 'HTML document not be a feed itself');
     $this->assertInstanceOf('MockSimplePie_File', $feed);
     $expected = array_map(array(get_class(), 'map_url_attrib'), $expected);
     $success = array_filter($expected, array(get_class(), 'filter_success'));
     $found = array_map(array(get_class(), 'map_url_file'), $all);
     $this->assertEquals($success, $found);
 }
Esempio n. 2
0
 static function getFeedlinks($url)
 {
     if (!is_string($url)) {
         return false;
     }
     $parsed = @parse_url($url);
     if (empty($parsed['scheme'])) {
         return false;
     }
     if (!in_array($parsed['scheme'], array('http', 'https'))) {
         return false;
     }
     $timeout = 10;
     $redirects = 5;
     $headers = null;
     $useragent = null;
     $file = new SimplePie_File($url, $timeout, $redirects, $headers, $useragent);
     $locator = new SimplePie_Locator($file, $timeout, $useragent);
     $r = $locator->find();
     return !empty($r->url) ? array($r->url) : false;
 }
Esempio n. 3
0
 /**
  * @dataProvider firefoxtests
  */
 public function test_from_file($data)
 {
     $locator = new SimplePie_Locator($data, 0, null, false);
     $registry = new SimplePie_Registry();
     $registry->register('File', 'MockSimplePie_File');
     $locator->set_registry($registry);
     $expected = array();
     $document = new DOMDocument();
     $document->loadHTML($data->body);
     $xpath = new DOMXPath($document);
     foreach ($xpath->query('//link') as $element) {
         $expected[] = 'http://example.com' . $element->getAttribute('href');
     }
     //$expected = SimplePie_Misc::get_element('link', $data->body);
     $feed = $locator->find(SIMPLEPIE_LOCATOR_ALL, $all);
     $this->assertFalse($locator->is_feed($data), 'HTML document not be a feed itself');
     $this->assertInstanceOf('MockSimplePie_File', $feed);
     $success = array_filter($expected, array(get_class(), 'filter_success'));
     $found = array_map(array(get_class(), 'map_url_file'), $all);
     $this->assertEquals($success, $found);
 }
Esempio n. 4
0
 public static function autoDiscovery($url)
 {
     $parts = parse_url($url);
     if (empty($parts['path'])) {
         $url .= '/';
     }
     $result = '';
     $proxy = null;
     if (sfConfig::get('op_http_proxy')) {
         $proxy = sfConfig::get('op_http_proxy');
     }
     $file = @new SimplePie_File($url, 10, 5, null, null, false, $proxy);
     $locator = new SimplePie_Locator($file, 10, null, 'SimplePie_File', 10, $proxy);
     $feedUrl = $locator->find();
     if (SimplePie_Misc::is_a($feedUrl, 'SimplePie_File')) {
         $result = $feedUrl->url;
     }
     return $result;
 }
Esempio n. 5
0
 /**
  * RSS/Atom Auto-Discovery に対応したlinkタグからURLを抽出する(static)
  */
 function auto_discovery($url)
 {
     // path 未指定の場合は「/」に設定する
     $parts = parse_url($url);
     if (empty($parts['path'])) {
         $url .= '/';
     }
     $result = '';
     if (OPENPNE_USE_HTTP_PROXY) {
         $proxy = OPENPNE_HTTP_PROXY_HOST . ":" . OPENPNE_HTTP_PROXY_PORT;
     }
     $file = @new SimplePie_File($url, 10, 5, null, null, false, $proxy);
     $locator = new SimplePie_Locator($file, 10, null, 'SimplePie_File', 10, $proxy);
     $feed_url = $locator->find();
     if (SimplePie_Misc::is_a($feed_url, 'SimplePie_File')) {
         $result = $feed_url->url;
     }
     return $result;
 }