space_seperated_tokens() 공개 메소드

public space_seperated_tokens ( $string )
예제 #1
0
 function result()
 {
     if ($this->data['file']->url != 'http://diveintomark.org/tests/client/autodiscovery/') {
         parent::result();
     }
     static $done = array();
     $links = SimplePie_Misc::get_element('link', $this->data['file']->body);
     foreach ($links as $link) {
         if (!empty($link['attribs']['href']['data']) && !empty($link['attribs']['rel']['data'])) {
             $rel = array_unique(SimplePie_Misc::space_seperated_tokens(strtolower($link['attribs']['rel']['data'])));
             $href = SimplePie_Misc::absolutize_url(trim($link['attribs']['href']['data']), $this->data['file']->url);
             if (!in_array($href, $done) && in_array('next', $rel)) {
                 $done[] = $this->data['url'] = $href;
                 break;
             }
         }
     }
     if ($this->data['url']) {
         $this->run();
     }
 }
예제 #2
0
 function autodiscovery()
 {
     $links = array_merge(SimplePie_Misc::get_element('link', $this->file->body), SimplePie_Misc::get_element('a', $this->file->body), SimplePie_Misc::get_element('area', $this->file->body));
     $done = array();
     foreach ($links as $link) {
         if ($this->checked_feeds == $this->max_checked_feeds) {
             break;
         }
         if (isset($link['attribs']['href']['data']) && isset($link['attribs']['rel']['data'])) {
             $rel = array_unique(SimplePie_Misc::space_seperated_tokens(strtolower($link['attribs']['rel']['data'])));
             if ($this->base_location < $link['offset']) {
                 $href = SimplePie_Misc::absolutize_url(trim($link['attribs']['href']['data']), $this->base);
             } else {
                 $href = SimplePie_Misc::absolutize_url(trim($link['attribs']['href']['data']), $this->http_base);
             }
             if (!in_array($href, $done) && in_array('feed', $rel) || in_array('alternate', $rel) && !empty($link['attribs']['type']['data']) && in_array(strtolower(SimplePie_Misc::parse_mime($link['attribs']['type']['data'])), array('application/rss+xml', 'application/atom+xml'))) {
                 $this->checked_feeds++;
                 $feed =& new $this->file_class($href, $this->timeout, 5, null, $this->useragent);
                 if ($this->is_feed($feed)) {
                     return $feed;
                 }
             }
             $done[] = $href;
         }
     }
     return null;
 }
예제 #3
0
 public function autodiscovery()
 {
     $links = array_merge(SimplePie_Misc::get_element('link', $this->file->body), SimplePie_Misc::get_element('a', $this->file->body), SimplePie_Misc::get_element('area', $this->file->body));
     $done = array();
     $feeds = array();
     foreach ($links as $link) {
         if ($this->checked_feeds === $this->max_checked_feeds) {
             break;
         }
         if (isset($link['attribs']['href']['data']) && isset($link['attribs']['rel']['data'])) {
             $rel = array_unique(SimplePie_Misc::space_seperated_tokens(strtolower($link['attribs']['rel']['data'])));
             if ($this->base_location < $link['offset']) {
                 $href = SimplePie_Misc::absolutize_url(trim($link['attribs']['href']['data']), $this->base);
             } else {
                 $href = SimplePie_Misc::absolutize_url(trim($link['attribs']['href']['data']), $this->http_base);
             }
             if (!in_array($href, $done) && in_array('feed', $rel) || in_array('alternate', $rel) && !empty($link['attribs']['type']['data']) && in_array(strtolower(SimplePie_Misc::parse_mime($link['attribs']['type']['data'])), array('application/rss+xml', 'application/atom+xml')) && !isset($feeds[$href])) {
                 $this->checked_feeds++;
                 $headers = array('Accept' => 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1');
                 $feed = new $this->file_class($href, $this->timeout, 5, $headers, $this->useragent);
                 if ($feed->success && ($feed->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed)) {
                     $feeds[$href] = $feed;
                 }
             }
             $done[] = $href;
         }
     }
     if (!empty($feeds)) {
         return array_values($feeds);
     } else {
         return null;
     }
 }