X-Git-Url: http://git.roojs.org/?p=Pman.Core;a=blobdiff_plain;f=ConvertStyle.php;h=4f52e1016cee579761774899efbaa04e21ed42c7;hp=d7738e2182214837fb5afa771ba2fb601d81b2e1;hb=refs%2Fheads%2Fwip_alan_T6343_generic_progress_bar_delete;hpb=4c8117b8ccd56625cb0bedf096ed2a03b5957dc3 diff --git a/ConvertStyle.php b/ConvertStyle.php index d7738e21..4f52e101 100644 --- a/ConvertStyle.php +++ b/ConvertStyle.php @@ -26,6 +26,10 @@ class Pman_Core_ConvertStyle extends Pman $ui = parse_url($base); + if($ui['host'] == 'localhost'){ + return $ui['scheme'] .'://'.$ui['host']. $ui['path'] . '/'. $url; + } + if (substr($url,0,2) == '//') { return $ui['scheme'] .':' . $url; } @@ -48,10 +52,10 @@ class Pman_Core_ConvertStyle extends Pman function checkHeader($url) { - if(strpos($url, 'https') !== false) - { - $this->jerr('accept HTTP url only!'); - } + // if(strpos($url, 'https') !== false) + // { + // $this->jerr('accept HTTP url only!'); + // } $headers = get_headers($url, 1); if(strpos(is_array($headers['Content-Type']) ? $headers['Content-Type'][0] : $headers['Content-Type'], 'text/html') === false) { @@ -62,9 +66,11 @@ class Pman_Core_ConvertStyle extends Pman var $styleSheets = array(); - function convertStyle($url = '', $file = false, $is_external = true) + function convertStyle($url, $file, $is_url = true) { - if(!empty($url)) + $inLineCss = true; + + if($is_url && !empty($url)) { $host = parse_url($url); require_once 'System.php'; @@ -82,10 +88,13 @@ class Pman_Core_ConvertStyle extends Pman } } - if(!empty($file)){ + if(!$is_url){ $data = file_get_contents($file); } + if(preg_match('/^\s*\s*/', $data)){ + $inLineCss = false; + } libxml_use_internal_errors (true); $doc = new DOMDocument('1.0', 'UTF-8'); @@ -100,9 +109,7 @@ class Pman_Core_ConvertStyle extends Pman $img->setAttribute('src', $this->relPath($url, $href)); continue; } - if($is_external){ - $this->jerr('Please use the absolutely url for image src!'); - } + $this->jerr('Please use the absolutely url for image src!'); } } @@ -139,6 +146,10 @@ class Pman_Core_ConvertStyle extends Pman $data = $doc->saveHTML(); + if(!$inLineCss){ + return $data; + } + $htmldoc = new HTML_CSS_InlineStyle($data); if(count($this->styleSheets) > 0){ foreach ($this->styleSheets as $styleSheet){