Esempio n. 1
0
 public function compileStyleSheet($source, $dest)
 {
     $buffer = $this->getStyleVariables();
     $buffer .= JFile::read(JPATH_ROOT . '/' . $source);
     if (JDEBUG || KunenaFactory::getConfig()->debug) {
         $filters = array('ImportImports' => array('BasePath' => JPATH_ROOT . '/' . dirname($source)), 'RemoveComments' => false, 'RemoveEmptyRulesets' => false, 'RemoveEmptyAtBlocks' => false, 'ConvertLevel3Properties' => true, 'ConvertLevel3AtKeyframes' => array('RemoveSource' => false), 'Variables' => true, 'RemoveLastDelarationSemiColon' => false);
         $plugins = array('Variables' => true, 'ConvertFontWeight' => false, 'ConvertHslColors' => false, 'ConvertRgbColors' => false, 'ConvertNamedColors' => false, 'CompressColorValues' => false, 'CompressUnitValues' => false, 'CompressExpressionValues' => false);
         CssMin::setVerbose(1);
         $tokens = CssMin::minify($buffer, $filters, $plugins, false);
         $buffer = new CssKunenaFormatter($tokens, "\t");
     } else {
         $filters = array('ImportImports' => array('BasePath' => JPATH_ROOT . '/' . dirname($source)), 'RemoveComments' => true, 'RemoveEmptyRulesets' => true, 'RemoveEmptyAtBlocks' => true, 'ConvertLevel3Properties' => true, 'ConvertLevel3AtKeyframes' => array('RemoveSource' => false), 'Variables' => true, 'RemoveLastDelarationSemiColon' => true);
         $plugins = array('Variables' => true, 'ConvertFontWeight' => true, 'ConvertHslColors' => true, 'ConvertRgbColors' => true, 'ConvertNamedColors' => true, 'CompressColorValues' => true, 'CompressUnitValues' => false, 'CompressExpressionValues' => true);
         $buffer = CssMin::minify($buffer, $filters, $plugins);
     }
     $buffer = preg_replace_callback('/url\\(([^\\)]+)\\)/u', array($this, 'findUrl'), $buffer);
     JFile::write(JPATH_ROOT . '/' . $dest, $buffer);
     unset($tokens, $buffer, $filters, $plugins);
     return $dest;
 }
 private function prepareCss($css)
 {
     $filters = array("RemoveComments" => false, "RemoveEmptyRulesets" => true, "RemoveEmptyAtBlocks" => true, "ConvertLevel3AtKeyframes" => false, "ConvertLevel3Properties" => true, "Variables" => false, "RemoveLastDelarationSemiColon" => false);
     CssMin::setVerbose(true);
     $css = str_replace("-moz-box-sizing", "box-sizing", $css);
     $css = CssMin::minify($css, $filters);
     $parts = explode('}', $css);
     $new_css = '';
     foreach ($parts as $part) {
         $bits = explode(';', $part);
         foreach ($bits as $bit) {
             if (strlen($bit)) {
                 $pre = '';
                 if (strpos($bit, 'linear-gradient') !== false) {
                     if (strpos($bit, '{') !== false) {
                         $bs = explode('{', $bit);
                         $bit = $bs[1];
                         $pre = $bs[0] . '{';
                     }
                     $bit .= ";\n" . str_replace('linear-gradient(', '-webkit-linear-gradient(top, ', $bit);
                 }
                 if (strpos($bit, 'transform') !== false) {
                     if (strpos($bit, '{') !== false) {
                         $bs = explode('{', $bit);
                         $bit = $bs[1];
                         $pre = $bs[0] . '{';
                     }
                     $bit .= ";\n" . str_replace('transform', '-webkit-transform', $bit);
                 }
                 $new_css .= $pre . $bit . ";\n";
             }
         }
         $new_css .= "}\n";
     }
     $tokens = CssMin::parse($new_css);
     return new CssOtbsFormatter($tokens, "    ", 32);
 }