diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-11-09 11:44:09 +0100 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-11-09 11:44:09 +0100 |
commit | b9e330109b58fac55c3728dd3c543552fcabd353 (patch) | |
tree | 93d386ca453b4b90f517018eb63a4b64df22e8ba /vendor/fguillot/picofeed/lib/PicoFeed/Client | |
parent | e5d18a22c3c15acf61f97da4965a551b83df05cb (diff) |
update picofeed to 0.1.0
Diffstat (limited to 'vendor/fguillot/picofeed/lib/PicoFeed/Client')
5 files changed, 47 insertions, 48 deletions
diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Client/Client.php b/vendor/fguillot/picofeed/lib/PicoFeed/Client/Client.php index 7328b2c75..e962ba4e8 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Client/Client.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Client/Client.php @@ -3,7 +3,7 @@ namespace PicoFeed\Client; use LogicException; -use PicoFeed\Logging\Logging; +use PicoFeed\Logging\Logger; /** * Client class @@ -166,9 +166,9 @@ abstract class Client $this->url = $url; } - Logging::setMessage(get_called_class().' Fetch URL: '.$this->url); - Logging::setMessage(get_called_class().' Etag provided: '.$this->etag); - Logging::setMessage(get_called_class().' Last-Modified provided: '.$this->last_modified); + Logger::setMessage(get_called_class().' Fetch URL: '.$this->url); + Logger::setMessage(get_called_class().' Etag provided: '.$this->etag); + Logger::setMessage(get_called_class().' Last-Modified provided: '.$this->last_modified); $response = $this->doRequest(); @@ -204,7 +204,7 @@ abstract class Client } if ($this->is_modified === false) { - Logging::setMessage(get_called_class().' Resource not modified'); + Logger::setMessage(get_called_class().' Resource not modified'); } } @@ -297,10 +297,10 @@ abstract class Client } } - Logging::setMessage(get_called_class().' HTTP status code: '.$status); + Logger::setMessage(get_called_class().' HTTP status code: '.$status); foreach ($headers as $name => $value) { - Logging::setMessage(get_called_class().' HTTP header: '.$name.' => '.$value); + Logger::setMessage(get_called_class().' HTTP header: '.$name.' => '.$value); } return array($status, $headers); diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Client/Curl.php b/vendor/fguillot/picofeed/lib/PicoFeed/Client/Curl.php index 9cf3eb6f4..4e4658639 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Client/Curl.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Client/Curl.php @@ -2,7 +2,7 @@ namespace PicoFeed\Client; -use PicoFeed\Logging\Logging; +use PicoFeed\Logging\Logger; /** * cURL HTTP client @@ -129,18 +129,18 @@ class Curl extends Client { if ($this->proxy_hostname) { - Logging::setMessage(get_called_class().' Proxy: '.$this->proxy_hostname.':'.$this->proxy_port); + Logger::setMessage(get_called_class().' Proxy: '.$this->proxy_hostname.':'.$this->proxy_port); curl_setopt($ch, CURLOPT_PROXYPORT, $this->proxy_port); curl_setopt($ch, CURLOPT_PROXYTYPE, 'HTTP'); curl_setopt($ch, CURLOPT_PROXY, $this->proxy_hostname); if ($this->proxy_username) { - Logging::setMessage(get_called_class().' Proxy credentials: Yes'); + Logger::setMessage(get_called_class().' Proxy credentials: Yes'); curl_setopt($ch, CURLOPT_PROXYUSERPWD, $this->proxy_username.':'.$this->proxy_password); } else { - Logging::setMessage(get_called_class().' Proxy credentials: No'); + Logger::setMessage(get_called_class().' Proxy credentials: No'); } } @@ -185,16 +185,16 @@ class Curl extends Client $ch = $this->prepareContext(); curl_exec($ch); - Logging::setMessage(get_called_class().' cURL total time: '.curl_getinfo($ch, CURLINFO_TOTAL_TIME)); - Logging::setMessage(get_called_class().' cURL dns lookup time: '.curl_getinfo($ch, CURLINFO_NAMELOOKUP_TIME)); - Logging::setMessage(get_called_class().' cURL connect time: '.curl_getinfo($ch, CURLINFO_CONNECT_TIME)); - Logging::setMessage(get_called_class().' cURL speed download: '.curl_getinfo($ch, CURLINFO_SPEED_DOWNLOAD)); - Logging::setMessage(get_called_class().' cURL effective url: '.curl_getinfo($ch, CURLINFO_EFFECTIVE_URL)); + Logger::setMessage(get_called_class().' cURL total time: '.curl_getinfo($ch, CURLINFO_TOTAL_TIME)); + Logger::setMessage(get_called_class().' cURL dns lookup time: '.curl_getinfo($ch, CURLINFO_NAMELOOKUP_TIME)); + Logger::setMessage(get_called_class().' cURL connect time: '.curl_getinfo($ch, CURLINFO_CONNECT_TIME)); + Logger::setMessage(get_called_class().' cURL speed download: '.curl_getinfo($ch, CURLINFO_SPEED_DOWNLOAD)); + Logger::setMessage(get_called_class().' cURL effective url: '.curl_getinfo($ch, CURLINFO_EFFECTIVE_URL)); $curl_errno = curl_errno($ch); if ($curl_errno) { - Logging::setMessage(get_called_class().' cURL error: '.curl_error($ch)); + Logger::setMessage(get_called_class().' cURL error: '.curl_error($ch)); curl_close($ch); $this->handleError($curl_errno); @@ -246,11 +246,12 @@ class Curl extends Client * * @access private * @param string $location Redirected URL - * @return boolean|array + * @return array */ private function handleRedirection($location) { $nb_redirects = 0; + $result = array(); $this->url = $location; $this->body = ''; $this->body_length = 0; @@ -262,7 +263,7 @@ class Curl extends Client $nb_redirects++; if ($nb_redirects >= $this->max_redirects) { - return false; + throw new MaxRedirectException('Maximum number of redirections reached'); } $result = $this->doRequest(false); @@ -275,11 +276,11 @@ class Curl extends Client $this->headers_counter = 0; } else { - return $result; + break; } } - return false; + return $result; } /** diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Client/Favicon.php b/vendor/fguillot/picofeed/lib/PicoFeed/Client/Favicon.php index b6d3b6d26..5b63cf044 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Client/Favicon.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Client/Favicon.php @@ -5,7 +5,7 @@ namespace PicoFeed\Client; use DOMXpath; use PicoFeed\Config\Config; -use PicoFeed\Logging\Logging; +use PicoFeed\Logging\Logger; use PicoFeed\Parser\XmlParser; /** @@ -67,7 +67,7 @@ class Favicon { try { - Logging::setMessage(get_called_class().' Download => '.$url); + Logger::setMessage(get_called_class().' Download => '.$url); $client = Client::getInstance(); $client->setConfig($this->config); diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Client/Grabber.php b/vendor/fguillot/picofeed/lib/PicoFeed/Client/Grabber.php index a072fc805..57661cb7b 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Client/Grabber.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Client/Grabber.php @@ -5,7 +5,7 @@ namespace PicoFeed\Client; use DOMXPath; use PicoFeed\Encoding\Encoding; -use PicoFeed\Logging\Logging; +use PicoFeed\Logging\Logger; use PicoFeed\Filter\Filter; use PicoFeed\Parser\XmlParser; @@ -147,7 +147,7 @@ class Grabber * Set config object * * @access public - * @param \PicoFeed\Config $config Config instance + * @param \PicoFeed\Config\Config $config Config instance * @return \PicoFeed\Grabber */ public function setConfig($config) @@ -188,30 +188,30 @@ class Grabber { if ($this->html) { - Logging::setMessage(get_called_class().' Fix encoding'); - Logging::setMessage(get_called_class().': HTTP Encoding "'.$this->encoding.'"'); + Logger::setMessage(get_called_class().' Fix encoding'); + Logger::setMessage(get_called_class().': HTTP Encoding "'.$this->encoding.'"'); $this->html = Filter::stripHeadTags($this->html); $this->html = Encoding::convert($this->html, $this->encoding); - Logging::setMessage(get_called_class().' Content length: '.strlen($this->html).' bytes'); + Logger::setMessage(get_called_class().' Content length: '.strlen($this->html).' bytes'); $rules = $this->getRules(); if (is_array($rules)) { - Logging::setMessage(get_called_class().' Parse content with rules'); + Logger::setMessage(get_called_class().' Parse content with rules'); $this->parseContentWithRules($rules); } else { - Logging::setMessage(get_called_class().' Parse content with candidates'); + Logger::setMessage(get_called_class().' Parse content with candidates'); $this->parseContentWithCandidates(); } } else { - Logging::setMessage(get_called_class().' No content fetched'); + Logger::setMessage(get_called_class().' No content fetched'); } - Logging::setMessage(get_called_class().' Content length: '.strlen($this->content).' bytes'); - Logging::setMessage(get_called_class().' Grabber done'); + Logger::setMessage(get_called_class().' Content length: '.strlen($this->content).' bytes'); + Logger::setMessage(get_called_class().' Grabber done'); return $this->content !== ''; } @@ -260,14 +260,12 @@ class Grabber $files[] = substr($hostname, 0, $pos); } - // Logging::setMessage(var_export($files, true)); - foreach ($files as $file) { $filename = __DIR__.'/../Rules/'.$file.'.php'; if (file_exists($filename)) { - Logging::setMessage(get_called_class().' Load rule: '.$file); + Logger::setMessage(get_called_class().' Load rule: '.$file); return include $filename; } } @@ -283,7 +281,7 @@ class Grabber */ public function parseContentWithRules(array $rules) { - // Logging::setMessage($this->html); + // Logger::setMessage($this->html); $dom = XmlParser::getHtmlDocument('<?xml version="1.0" encoding="UTF-8">'.$this->html); $xpath = new DOMXPath($dom); @@ -329,13 +327,13 @@ class Grabber // Try to lookup in each tag foreach ($this->candidatesAttributes as $candidate) { - Logging::setMessage(get_called_class().' Try this candidate: "'.$candidate.'"'); + Logger::setMessage(get_called_class().' Try this candidate: "'.$candidate.'"'); $nodes = $xpath->query('//*[(contains(@class, "'.$candidate.'") or @id="'.$candidate.'") and not (contains(@class, "nav") or contains(@class, "page"))]'); if ($nodes !== false && $nodes->length > 0) { $this->content = $dom->saveXML($nodes->item(0)); - Logging::setMessage(get_called_class().' Find candidate "'.$candidate.'" ('.strlen($this->content).' bytes)'); + Logger::setMessage(get_called_class().' Find candidate "'.$candidate.'" ('.strlen($this->content).' bytes)'); break; } } @@ -347,16 +345,16 @@ class Grabber if ($nodes !== false && $nodes->length > 0) { $this->content = $dom->saveXML($nodes->item(0)); - Logging::setMessage(get_called_class().' Find <article/> tag ('.strlen($this->content).' bytes)'); + Logger::setMessage(get_called_class().' Find <article/> tag ('.strlen($this->content).' bytes)'); } } if (strlen($this->content) < 50) { - Logging::setMessage(get_called_class().' No enought content fetched, get the full body'); + Logger::setMessage(get_called_class().' No enought content fetched, get the full body'); $this->content = $dom->saveXML($dom->firstChild); } - Logging::setMessage(get_called_class().' Strip garbage'); + Logger::setMessage(get_called_class().' Strip garbage'); $this->stripGarbage(); } @@ -378,7 +376,7 @@ class Grabber $nodes = $xpath->query('//'.$tag); if ($nodes !== false && $nodes->length > 0) { - Logging::setMessage(get_called_class().' Strip tag: "'.$tag.'"'); + Logger::setMessage(get_called_class().' Strip tag: "'.$tag.'"'); foreach ($nodes as $node) { $node->parentNode->removeChild($node); } @@ -390,7 +388,7 @@ class Grabber $nodes = $xpath->query('//*[contains(@class, "'.$attribute.'") or contains(@id, "'.$attribute.'")]'); if ($nodes !== false && $nodes->length > 0) { - Logging::setMessage(get_called_class().' Strip attribute: "'.$attribute.'"'); + Logger::setMessage(get_called_class().' Strip attribute: "'.$attribute.'"'); foreach ($nodes as $node) { $node->parentNode->removeChild($node); } diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Client/Stream.php b/vendor/fguillot/picofeed/lib/PicoFeed/Client/Stream.php index bc9809c4d..a0058f9b0 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Client/Stream.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Client/Stream.php @@ -2,7 +2,7 @@ namespace PicoFeed\Client; -use PicoFeed\Logging\Logging; +use PicoFeed\Logging\Logger; /** * Stream context HTTP client @@ -63,16 +63,16 @@ class Stream extends Client if ($this->proxy_hostname) { - Logging::setMessage(get_called_class().' Proxy: '.$this->proxy_hostname.':'.$this->proxy_port); + Logger::setMessage(get_called_class().' Proxy: '.$this->proxy_hostname.':'.$this->proxy_port); $context['http']['proxy'] = 'tcp://'.$this->proxy_hostname.':'.$this->proxy_port; $context['http']['request_fulluri'] = true; if ($this->proxy_username) { - Logging::setMessage(get_called_class().' Proxy credentials: Yes'); + Logger::setMessage(get_called_class().' Proxy credentials: Yes'); } else { - Logging::setMessage(get_called_class().' Proxy credentials: No'); + Logger::setMessage(get_called_class().' Proxy credentials: No'); } } |