diff --git a/lib/lessphp/Cache.php b/lib/lessphp/Cache.php index 8c8be39530e..bf5bf9218f2 100644 --- a/lib/lessphp/Cache.php +++ b/lib/lessphp/Cache.php @@ -83,13 +83,12 @@ class Less_Cache{ $hash = md5(json_encode($less_files)); $list_file = Less_Cache::$cache_dir . Less_Cache::$prefix . $hash . '.list'; - // check cached content if( !isset($parser_options['use_cache']) || $parser_options['use_cache'] === true ){ if( file_exists($list_file) ){ self::ListFiles($list_file, $list, $cached_name); - $compiled_name = self::CompiledName($list); + $compiled_name = self::CompiledName($list, $hash); // if $cached_name is the same as the $compiled name, don't regenerate if( !$cached_name || $cached_name === $compiled_name ){ @@ -109,7 +108,7 @@ class Less_Cache{ return false; } - $compiled_name = self::CompiledName( $less_files ); + $compiled_name = self::CompiledName( $less_files, $hash ); $output_file = self::OutputFile($compiled_name, $parser_options ); @@ -194,7 +193,7 @@ class Less_Cache{ } - private static function CompiledName( $files ){ + private static function CompiledName( $files, $extrahash ){ //save the file list $temp = array(Less_Version::cache_version); @@ -202,7 +201,7 @@ class Less_Cache{ $temp[] = filemtime($file)."\t".filesize($file)."\t".$file; } - return Less_Cache::$prefix.sha1(json_encode($temp)).'.css'; + return Less_Cache::$prefix.sha1(json_encode($temp).$extrahash).'.css'; } diff --git a/lib/lessphp/Exception/Chunk.php b/lib/lessphp/Exception/Chunk.php index 036900f3c45..97fce1b382f 100644 --- a/lib/lessphp/Exception/Chunk.php +++ b/lib/lessphp/Exception/Chunk.php @@ -120,7 +120,7 @@ class Less_Exception_Chunk extends Less_Exception_Parser{ } } if ($matched) { continue; } - return $this->fail("unmatched `" + chr($cc) + "`", $currentChunkStartIndex); + return $this->fail("unmatched `" . chr($cc) . "`", $currentChunkStartIndex); // /, check for comment case 47: diff --git a/lib/lessphp/Functions.php b/lib/lessphp/Functions.php index 419bee32ff5..a7e00577960 100644 --- a/lib/lessphp/Functions.php +++ b/lib/lessphp/Functions.php @@ -739,7 +739,7 @@ class Less_Functions{ public function argb($color) { if (!$color instanceof Less_Tree_Color) { - throw new Less_Exception_Compiler('The first argument to argb must be a color' . ($dark instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); + throw new Less_Exception_Compiler('The first argument to argb must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); } return new Less_Tree_Anonymous($color->toARGB()); @@ -1034,10 +1034,10 @@ class Less_Functions{ public function multiply($color1 = null, $color2 = null ){ if (!$color1 instanceof Less_Tree_Color) { - throw new Less_Exception_Compiler('The first argument to multiply must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); + throw new Less_Exception_Compiler('The first argument to multiply must be a color' . ($color1 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); } if (!$color2 instanceof Less_Tree_Color) { - throw new Less_Exception_Compiler('The second argument to multiply must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); + throw new Less_Exception_Compiler('The second argument to multiply must be a color' . ($color2 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); } return $this->colorBlend( array($this,'colorBlendMultiply'), $color1, $color2 ); @@ -1049,10 +1049,10 @@ class Less_Functions{ public function screen($color1 = null, $color2 = null ){ if (!$color1 instanceof Less_Tree_Color) { - throw new Less_Exception_Compiler('The first argument to screen must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); + throw new Less_Exception_Compiler('The first argument to screen must be a color' . ($color1 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); } if (!$color2 instanceof Less_Tree_Color) { - throw new Less_Exception_Compiler('The second argument to screen must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); + throw new Less_Exception_Compiler('The second argument to screen must be a color' . ($color2 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); } return $this->colorBlend( array($this,'colorBlendScreen'), $color1, $color2 ); @@ -1064,10 +1064,10 @@ class Less_Functions{ public function overlay($color1 = null, $color2 = null){ if (!$color1 instanceof Less_Tree_Color) { - throw new Less_Exception_Compiler('The first argument to overlay must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); + throw new Less_Exception_Compiler('The first argument to overlay must be a color' . ($color1 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); } if (!$color2 instanceof Less_Tree_Color) { - throw new Less_Exception_Compiler('The second argument to overlay must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); + throw new Less_Exception_Compiler('The second argument to overlay must be a color' . ($color2 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); } return $this->colorBlend( array($this,'colorBlendOverlay'), $color1, $color2 ); @@ -1082,10 +1082,10 @@ class Less_Functions{ public function softlight($color1 = null, $color2 = null){ if (!$color1 instanceof Less_Tree_Color) { - throw new Less_Exception_Compiler('The first argument to softlight must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); + throw new Less_Exception_Compiler('The first argument to softlight must be a color' . ($color1 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); } if (!$color2 instanceof Less_Tree_Color) { - throw new Less_Exception_Compiler('The second argument to softlight must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); + throw new Less_Exception_Compiler('The second argument to softlight must be a color' . ($color2 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); } return $this->colorBlend( array($this,'colorBlendSoftlight'), $color1, $color2 ); @@ -1104,10 +1104,10 @@ class Less_Functions{ public function hardlight($color1 = null, $color2 = null){ if (!$color1 instanceof Less_Tree_Color) { - throw new Less_Exception_Compiler('The first argument to hardlight must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); + throw new Less_Exception_Compiler('The first argument to hardlight must be a color' . ($color1 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); } if (!$color2 instanceof Less_Tree_Color) { - throw new Less_Exception_Compiler('The second argument to hardlight must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); + throw new Less_Exception_Compiler('The second argument to hardlight must be a color' . ($color2 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); } return $this->colorBlend( array($this,'colorBlendHardlight'), $color1, $color2 ); @@ -1119,10 +1119,10 @@ class Less_Functions{ public function difference($color1 = null, $color2 = null) { if (!$color1 instanceof Less_Tree_Color) { - throw new Less_Exception_Compiler('The first argument to difference must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); + throw new Less_Exception_Compiler('The first argument to difference must be a color' . ($color1 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); } if (!$color2 instanceof Less_Tree_Color) { - throw new Less_Exception_Compiler('The second argument to difference must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); + throw new Less_Exception_Compiler('The second argument to difference must be a color' . ($color2 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); } return $this->colorBlend( array($this,'colorBlendDifference'), $color1, $color2 ); @@ -1134,10 +1134,10 @@ class Less_Functions{ public function exclusion( $color1 = null, $color2 = null ){ if (!$color1 instanceof Less_Tree_Color) { - throw new Less_Exception_Compiler('The first argument to exclusion must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); + throw new Less_Exception_Compiler('The first argument to exclusion must be a color' . ($color1 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); } if (!$color2 instanceof Less_Tree_Color) { - throw new Less_Exception_Compiler('The second argument to exclusion must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); + throw new Less_Exception_Compiler('The second argument to exclusion must be a color' . ($color2 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); } return $this->colorBlend( array($this,'colorBlendExclusion'), $color1, $color2 ); @@ -1149,10 +1149,10 @@ class Less_Functions{ public function average($color1 = null, $color2 = null){ if (!$color1 instanceof Less_Tree_Color) { - throw new Less_Exception_Compiler('The first argument to average must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); + throw new Less_Exception_Compiler('The first argument to average must be a color' . ($color1 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); } if (!$color2 instanceof Less_Tree_Color) { - throw new Less_Exception_Compiler('The second argument to average must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); + throw new Less_Exception_Compiler('The second argument to average must be a color' . ($color2 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); } return $this->colorBlend( array($this,'colorBlendAverage'), $color1, $color2 ); @@ -1165,10 +1165,10 @@ class Less_Functions{ public function negation($color1 = null, $color2 = null ){ if (!$color1 instanceof Less_Tree_Color) { - throw new Less_Exception_Compiler('The first argument to negation must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); + throw new Less_Exception_Compiler('The first argument to negation must be a color' . ($color1 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); } if (!$color2 instanceof Less_Tree_Color) { - throw new Less_Exception_Compiler('The second argument to negation must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); + throw new Less_Exception_Compiler('The second argument to negation must be a color' . ($color2 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); } return $this->colorBlend( array($this,'colorBlendNegation'), $color1, $color2 ); diff --git a/lib/lessphp/Less.php.combine b/lib/lessphp/Less.php.combine old mode 100644 new mode 100755 diff --git a/lib/lessphp/Parser.php b/lib/lessphp/Parser.php index 86d455f1dda..3871eb42dba 100644 --- a/lib/lessphp/Parser.php +++ b/lib/lessphp/Parser.php @@ -20,7 +20,7 @@ class Less_Parser{ 'strictUnits' => false, // whether units need to evaluate correctly 'strictMath' => false, // whether math has to be within parenthesis 'relativeUrls' => true, // option - whether to adjust URL's to be relative - 'urlArgs' => array(), // whether to add args into url tokens + 'urlArgs' => '', // whether to add args into url tokens 'numPrecision' => 8, 'import_dirs' => array(), @@ -35,6 +35,8 @@ class Less_Parser{ 'sourceMapWriteTo' => null, 'sourceMapURL' => null, + 'indentation' => ' ', + 'plugins' => array(), ); @@ -87,7 +89,7 @@ class Less_Parser{ // mbstring.func_overload > 1 bugfix // The encoding value must be set for each source file, // therefore, to conserve resources and improve the speed of this design is taken here - if (ini_get('mbstring.func_overload')) { + if (ini_get('mbstring.func_overload')) { $this->mb_internal_encoding = ini_get('mbstring.internal_encoding'); @ini_set('mbstring.internal_encoding', 'ascii'); } @@ -220,7 +222,7 @@ class Less_Parser{ @ini_set('precision',$precision); setlocale(LC_NUMERIC, $locale); - // If you previously defined $this->mb_internal_encoding + // If you previously defined $this->mb_internal_encoding // is required to return the encoding as it was before if ($this->mb_internal_encoding != '') { @ini_set("mbstring.internal_encoding", $this->mb_internal_encoding); @@ -1989,7 +1991,7 @@ class Less_Parser{ } private function parseImportOption(){ - $opt = $this->MatchReg('/\\G(less|css|multiple|once|inline|reference)/'); + $opt = $this->MatchReg('/\\G(less|css|multiple|once|inline|reference|optional)/'); if( $opt ){ return $opt[1]; } @@ -2623,5 +2625,3 @@ class Less_Parser{ } } - - diff --git a/lib/lessphp/Tree.php b/lib/lessphp/Tree.php index 0de1b40723f..6fb104bc709 100644 --- a/lib/lessphp/Tree.php +++ b/lib/lessphp/Tree.php @@ -49,8 +49,8 @@ class Less_Tree{ // Non-compressed - $tabSetStr = "\n".str_repeat( ' ' , Less_Environment::$tabLevel-1 ); - $tabRuleStr = $tabSetStr.' '; + $tabSetStr = "\n".str_repeat( Less_Parser::$options['indentation'] , Less_Environment::$tabLevel-1 ); + $tabRuleStr = $tabSetStr.Less_Parser::$options['indentation']; $output->add( " {" ); for($i = 0; $i < $ruleCnt; $i++ ){ @@ -87,4 +87,4 @@ class Less_Tree{ return $obj; } -} \ No newline at end of file +} diff --git a/lib/lessphp/Tree/Dimension.php b/lib/lessphp/Tree/Dimension.php index b693f57d793..2bfb9d54b95 100644 --- a/lib/lessphp/Tree/Dimension.php +++ b/lib/lessphp/Tree/Dimension.php @@ -98,7 +98,7 @@ class Less_Tree_Dimension extends Less_Tree{ $other = $other->convertTo( $this->unit->usedUnits()); if( Less_Parser::$options['strictUnits'] && $other->unit->toString() !== $unit->toCSS() ){ - throw new Less_Exception_Compiler("Incompatible units. Change the units or use the unit function. Bad units: '".$unit->toString() . "' and ".$other->unit->toString()+"'."); + throw new Less_Exception_Compiler("Incompatible units. Change the units or use the unit function. Bad units: '" . $unit->toString() . "' and " . $other->unit->toString() . "'."); } $value = Less_Functions::operate( $op, $this->value, $other->value); diff --git a/lib/lessphp/Tree/Import.php b/lib/lessphp/Tree/Import.php index e327b756364..9730d438ae4 100644 --- a/lib/lessphp/Tree/Import.php +++ b/lib/lessphp/Tree/Import.php @@ -182,6 +182,11 @@ class Less_Tree_Import extends Less_Tree{ return array( $contents ); } + // optional (need to be before "CSS" to support optional CSS imports. CSS should be checked only if empty($this->currentFileInfo)) + if( isset($this->options['optional']) && $this->options['optional'] && !file_exists($full_path) && (!$evald->css || !empty($this->currentFileInfo))) { + return array(); + } + // css ? if( $evald->css ){ @@ -304,4 +309,3 @@ class Less_Tree_Import extends Less_Tree{ } } - diff --git a/lib/lessphp/Tree/Mixin/Call.php b/lib/lessphp/Tree/Mixin/Call.php index d7e2a137cbe..04eb426d9f5 100644 --- a/lib/lessphp/Tree/Mixin/Call.php +++ b/lib/lessphp/Tree/Mixin/Call.php @@ -107,7 +107,7 @@ class Less_Tree_Mixin_Call extends Less_Tree{ } else { $defaultResult = $defTrue; if( ($count[$defTrue] + $count[$defFalse]) > 1 ){ - throw new Exception( 'Ambiguous use of `default()` found when matching for `'. $this->format($args) + '`' ); + throw new Exception( 'Ambiguous use of `default()` found when matching for `' . $this->format($args) . '`' ); } } @@ -160,12 +160,12 @@ class Less_Tree_Mixin_Call extends Less_Tree{ foreach($args as $a){ $argValue = ''; if( $a['name'] ){ - $argValue += $a['name']+':'; + $argValue .= $a['name'] . ':'; } if( is_object($a['value']) ){ - $argValue += $a['value']->toCSS(); + $argValue .= $a['value']->toCSS(); }else{ - $argValue += '???'; + $argValue .= '???'; } $message[] = $argValue; } diff --git a/lib/lessphp/Tree/NameValue.php b/lib/lessphp/Tree/NameValue.php index e65737c2fe1..31cbe03ed52 100644 --- a/lib/lessphp/Tree/NameValue.php +++ b/lib/lessphp/Tree/NameValue.php @@ -17,6 +17,7 @@ class Less_Tree_NameValue extends Less_Tree{ public $index; public $currentFileInfo; public $type = 'NameValue'; + public $important = ''; public function __construct($name, $value = null, $index = null, $currentFileInfo = null ){ $this->name = $name; @@ -31,6 +32,7 @@ class Less_Tree_NameValue extends Less_Tree{ $this->name . Less_Environment::$_outputMap[': '] . $this->value + . $this->important . (((Less_Environment::$lastRule && Less_Parser::$options['compress'])) ? "" : ";") , $this->currentFileInfo, $this->index); } @@ -38,4 +40,12 @@ class Less_Tree_NameValue extends Less_Tree{ public function compile ($env){ return $this; } + + public function makeImportant(){ + $new = new Less_Tree_NameValue($this->name, $this->value, $this->index, $this->currentFileInfo); + $new->important = ' !important'; + return $new; + } + + } diff --git a/lib/lessphp/Tree/Ruleset.php b/lib/lessphp/Tree/Ruleset.php index 93d3d6b7bd8..9f9eb1ba748 100644 --- a/lib/lessphp/Tree/Ruleset.php +++ b/lib/lessphp/Tree/Ruleset.php @@ -264,7 +264,7 @@ class Less_Tree_Ruleset extends Less_Tree{ $important_rules = array(); foreach($this->rules as $rule){ - if( $rule instanceof Less_Tree_Rule || $rule instanceof Less_Tree_Ruleset ){ + if( $rule instanceof Less_Tree_Rule || $rule instanceof Less_Tree_Ruleset || $rule instanceof Less_Tree_NameValue ){ $important_rules[] = $rule->makeImportant(); }else{ $important_rules[] = $rule; @@ -365,8 +365,8 @@ class Less_Tree_Ruleset extends Less_Tree{ $tabRuleStr = $tabSetStr = ''; if( !Less_Parser::$options['compress'] ){ if( Less_Environment::$tabLevel ){ - $tabRuleStr = "\n".str_repeat( ' ' , Less_Environment::$tabLevel ); - $tabSetStr = "\n".str_repeat( ' ' , Less_Environment::$tabLevel-1 ); + $tabRuleStr = "\n".str_repeat( Less_Parser::$options['indentation'] , Less_Environment::$tabLevel ); + $tabSetStr = "\n".str_repeat( Less_Parser::$options['indentation'] , Less_Environment::$tabLevel-1 ); }else{ $tabSetStr = $tabRuleStr = "\n"; } diff --git a/lib/lessphp/Version.php b/lib/lessphp/Version.php index 704ec6e07b3..ad03db4eb5b 100644 --- a/lib/lessphp/Version.php +++ b/lib/lessphp/Version.php @@ -8,8 +8,8 @@ */ class Less_Version{ - const version = '1.7.0.9'; // The current build number of less.php - const less_version = '1.7'; // The less.js version that this build should be compatible with - const cache_version = '170'; // The parser cache version + const version = '1.7.0.10'; // The current build number of less.php + const less_version = '1.7.0'; // The less.js version that this build should be compatible with + const cache_version = '170'; // The parser cache version } diff --git a/lib/lessphp/Visitor/processExtends.php b/lib/lessphp/Visitor/processExtends.php index c01f9c5d684..d076cbbbff4 100644 --- a/lib/lessphp/Visitor/processExtends.php +++ b/lib/lessphp/Visitor/processExtends.php @@ -112,7 +112,7 @@ class Less_Visitor_processExtends extends Less_Visitor{ $selectorTwo = "{unable to calculate}"; } - throw new Less_Exception_Parser("extend circular reference detected. One of the circular extends is currently:"+$selectorOne+":extend(" + $selectorTwo+")"); + throw new Less_Exception_Parser("extend circular reference detected. One of the circular extends is currently:" . $selectorOne . ":extend(" . $selectorTwo . ")"); } // now process the new extends on the existing rules so that we can handle a extending b extending c ectending d extending e... diff --git a/lib/thirdpartylibs.xml b/lib/thirdpartylibs.xml index fc8ffe02e18..44c363b6e0d 100644 --- a/lib/thirdpartylibs.xml +++ b/lib/thirdpartylibs.xml @@ -32,7 +32,7 @@ lessphp less.php Apache - 1.7.0.9 + 1.7.0.10 2.0