Beispiel #1
0
 /**
  * @since 1.0.9
  */
 function parseText($content, $contentCameFromCache = false)
 {
     $this->content = $content;
     if (!$this->content) {
         if ($this->ch) {
             $message = curl_error($this->ch);
             self::error("Failed to download {$this->url}<br /><small>{$message}</small>");
             return false;
         } else {
             self::error("Content queued from {$this->url} was null or empty.");
             return false;
         }
     }
     if ($this->parserType == COREYLIB_PARSER_XML) {
         if (!($this->sxml = simplexml_load_string($this->content, null, LIBXML_NOCDATA))) {
             self::error("Failed to parse content.");
             return false;
         }
         $this->tree = new clNode($this->sxml);
     }
     if ($this->cacheFor && !$contentCameFromCache && !clAPI::$options['nocache']) {
         clCache::saveContent($this->cacheName, $this->content, $this->cacheFor);
     }
     return true;
 }
 /**
  * @since 1.0.9
  */
 function parseText($content, $contentCameFromCache = false)
 {
     $this->content = $content;
     if (!$this->content) {
         if ($this->ch) {
             $message = curl_error($this->ch);
             self::error("Failed to download {$this->url}<br /><small>{$message}</small>");
             return false;
         } else {
             self::error("Content queued from {$this->url} was null or empty.");
             return false;
         }
     }
     if ($this->parserType == COREYLIB_PARSER_XML) {
         if (!($this->sxml = simplexml_load_string($this->content, 'SimpleXMLElement', LIBXML_NOCDATA))) {
             self::error("Failed to parse content.");
             return false;
         }
         //$this->sxml['xmlns'] = '';
         $default_ns = null;
         if (count(array_keys($namespaces = $this->sxml->getNamespaces(true)))) {
             // capture the default namespace
             $default_ns = isset($namespaces['']) ? $namespaces[''] : null;
         }
         if ($default_ns) {
             $this->tree = new clNode($this->sxml, $namespaces, $this->sxml->getName(), $default_ns);
         } else {
             $this->tree = new clNode($this->sxml);
         }
     }
     if ($this->cacheFor && !$contentCameFromCache && !clAPI::$options['nocache']) {
         clCache::saveContent($this->cacheName, $this->content, $this->cacheFor);
     }
     return true;
 }
 function parse($cacheFor = 0)
 {
     $this->content = false;
     $qs = $this->queryString();
     $url = $this->url . ($qs ? '?' . $qs : '');
     $cacheName = $url . md5($this->username . $this->password);
     $contentCameFromCache = false;
     if ($cacheFor && !clAPI::$options['nocache']) {
         $this->content = clCache::cached($cacheName, $cacheFor, true);
     }
     if ($this->content === false) {
         $try = 0;
         do {
             $try++;
             $this->content = $this->download($url);
         } while (empty($this->content) && $try < clAPI::$options['max_download_tries']);
     } else {
         $contentCameFromCache = true;
     }
     if (!$this->content) {
         self::error("Failed to download {$this->url}");
         return false;
     }
     if ($this->parserType == COREYLIB_PARSER_XML) {
         if (!($this->sxml = simplexml_load_string($this->content, null, LIBXML_NOCDATA))) {
             self::error("Failed to parse {$this->url}");
             return false;
         }
         $this->tree = new clNode($this->sxml);
     }
     if ($cacheFor && !$contentCameFromCache && !clAPI::$options['nocache']) {
         clCache::saveContent($cacheName, $this->content, $cacheFor);
     }
     return true;
 }