Example #1
0
 public function resolve()
 {
     $it = new ValueIterator($this->stylesheet, 'ju1ius\\Css\\Value\\Url', true);
     $bIsAbsBaseUrl = $this->base_url->isAbsoluteUrl() || $this->base_url->isAbsolutePath();
     foreach ($it as $value) {
         $url = new Uri($value->getUrl()->getString());
         $isAbsPath = $url->isAbsolutePath();
         $isAbsUrl = $url->isAbsoluteUrl();
         // resolve only if:
         if (!$isAbsUrl && !$isAbsPath) {
             // $url is not absolute url or absolute path
             $url = $this->base_url->join($url);
             $value->setUrl(new Value\String((string) $url));
         } else {
             if ($isAbsPath && $bIsAbsBaseUrl) {
                 // $url is absolute path and base url is absolute
                 // get the base domain from url
                 $base_url = $this->base_url->getRootUrl();
                 $url = $base_url->join($url);
                 $value->setUrl(new Value\String((string) $url));
             }
         }
     }
 }
Example #2
0
 /**
  * Loads a CSS file into a Source\File object.
  *
  * Relies on the CURL extension to load network urls
  *
  * @param string|ju1ius\Uri $url The url of the file
  *
  * @throws StyleSheetNotFoundException if file doesn't exist or is not readable
  *
  * @return Source\File
  **/
 public static function loadUrl($url)
 {
     /*{{{*/
     $uri = Uri::parse($url);
     $response = self::_loadUrl($uri);
     $content = $response['body'];
     $charset = $response['charset'];
     $infos = self::_loadString($response['body']);
     // FIXME: Http header sometimes return wrong results
     /*
     if ($response['charset'] && !$preferFileCharset) {
         $infos['charset'] = $response['charset'];
     }
     */
     return new Source\File($url, $infos['contents'], $infos['charset']);
 }