X-Git-Url: http://git.roojs.org/?p=Pman.Core;a=blobdiff_plain;f=ConvertStyle.php;h=4f52e1016cee579761774899efbaa04e21ed42c7;hp=4179c512638464ddcf5cac0a8ea7e39ca41107af;hb=8cd2a9237c684aa16bc21e3ac6d3793c49c65400;hpb=d12bb738ba1e03fe4253af79660c48e06a9b54a3 diff --git a/ConvertStyle.php b/ConvertStyle.php index 4179c512..4f52e101 100644 --- a/ConvertStyle.php +++ b/ConvertStyle.php @@ -52,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) { @@ -68,6 +68,8 @@ class Pman_Core_ConvertStyle extends Pman function convertStyle($url, $file, $is_url = true) { + $inLineCss = true; + if($is_url && !empty($url)) { $host = parse_url($url); @@ -90,8 +92,8 @@ class Pman_Core_ConvertStyle extends Pman $data = file_get_contents($file); } - if(preg_match('/^\s\s/', $data)){ - return $data; + if(preg_match('/^\s*\s*/', $data)){ + $inLineCss = false; } libxml_use_internal_errors (true); @@ -144,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){