SimplePie_Locator::find PHP Method

find() public method

public find ( $type = SIMPLEPIE_LOCATOR_ALL, &$working )
    public function find($type = SIMPLEPIE_LOCATOR_ALL, &$working)
    {
        if ($this->is_feed($this->file)) {
            return $this->file;
        }
        if ($this->file->method & SIMPLEPIE_FILE_SOURCE_REMOTE) {
            $sniffer = $this->registry->create('Content_Type_Sniffer', array($this->file));
            if ($sniffer->get_type() !== 'text/html') {
                return null;
            }
        }
        if ($type & ~SIMPLEPIE_LOCATOR_NONE) {
            $this->get_base();
        }
        if ($type & SIMPLEPIE_LOCATOR_AUTODISCOVERY && ($working = $this->autodiscovery())) {
            return $working[0];
        }
        if ($type & (SIMPLEPIE_LOCATOR_LOCAL_EXTENSION | SIMPLEPIE_LOCATOR_LOCAL_BODY | SIMPLEPIE_LOCATOR_REMOTE_EXTENSION | SIMPLEPIE_LOCATOR_REMOTE_BODY) && $this->get_links()) {
            if ($type & SIMPLEPIE_LOCATOR_LOCAL_EXTENSION && ($working = $this->extension($this->local))) {
                return $working[0];
            }
            if ($type & SIMPLEPIE_LOCATOR_LOCAL_BODY && ($working = $this->body($this->local))) {
                return $working[0];
            }
            if ($type & SIMPLEPIE_LOCATOR_REMOTE_EXTENSION && ($working = $this->extension($this->elsewhere))) {
                return $working[0];
            }
            if ($type & SIMPLEPIE_LOCATOR_REMOTE_BODY && ($working = $this->body($this->elsewhere))) {
                return $working[0];
            }
        }
        return null;
    }

Usage Example

Ejemplo 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);
 }
All Usage Examples Of SimplePie_Locator::find