mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 14:27:22 +01:00
Merge branch 'MDL-49518-master' of git://github.com/gurgus/moodle
This commit is contained in:
commit
2c92e06106
136
lib/lessphp/Cache.php
Normal file → Executable file
136
lib/lessphp/Cache.php
Normal file → Executable file
@ -11,7 +11,17 @@ require_once( dirname(__FILE__).'/Version.php');
|
||||
*/
|
||||
class Less_Cache{
|
||||
|
||||
public static $cache_dir = false; // directory less.php can use for storing data
|
||||
// directory less.php can use for storing data
|
||||
public static $cache_dir = false;
|
||||
|
||||
// prefix for the storing data
|
||||
public static $prefix = 'lessphp_';
|
||||
|
||||
// prefix for the storing vars
|
||||
public static $prefix_vars = 'lessphpvars_';
|
||||
|
||||
// specifies the number of seconds after which data created by less.php will be seen as 'garbage' and potentially cleaned up
|
||||
public static $gc_lifetime = 604800;
|
||||
|
||||
|
||||
/**
|
||||
@ -21,10 +31,10 @@ class Less_Cache{
|
||||
*
|
||||
* @param array $less_files Array of .less files to compile
|
||||
* @param array $parser_options Array of compiler options
|
||||
* @param boolean $use_cache Set to false to regenerate the css file
|
||||
* @param array $modify_vars Array of variables
|
||||
* @return string Name of the css file
|
||||
*/
|
||||
public static function Get( $less_files, $parser_options = array(), $use_cache = true ){
|
||||
public static function Get( $less_files, $parser_options = array(), $modify_vars = array() ){
|
||||
|
||||
|
||||
//check $cache_dir
|
||||
@ -36,25 +46,49 @@ class Less_Cache{
|
||||
throw new Exception('cache_dir not set');
|
||||
}
|
||||
|
||||
if( isset($parser_options['prefix']) ){
|
||||
Less_Cache::$prefix = $parser_options['prefix'];
|
||||
}
|
||||
|
||||
if( empty(Less_Cache::$prefix) ){
|
||||
throw new Exception('prefix not set');
|
||||
}
|
||||
|
||||
if( isset($parser_options['prefix_vars']) ){
|
||||
Less_Cache::$prefix_vars = $parser_options['prefix_vars'];
|
||||
}
|
||||
|
||||
if( empty(Less_Cache::$prefix_vars) ){
|
||||
throw new Exception('prefix_vars not set');
|
||||
}
|
||||
|
||||
self::CheckCacheDir();
|
||||
$less_files = (array)$less_files;
|
||||
|
||||
|
||||
//create a file for variables
|
||||
if( !empty($modify_vars) ){
|
||||
$lessvars = Less_Parser::serializeVars($modify_vars);
|
||||
$vars_file = Less_Cache::$cache_dir . Less_Cache::$prefix_vars . sha1($lessvars) . '.less';
|
||||
|
||||
if( !file_exists($vars_file) ){
|
||||
file_put_contents($vars_file, $lessvars);
|
||||
}
|
||||
|
||||
$less_files += array($vars_file => '/');
|
||||
}
|
||||
|
||||
|
||||
// generate name for compiled css file
|
||||
$less_files = (array)$less_files;
|
||||
$hash = md5(json_encode($less_files));
|
||||
$list_file = Less_Cache::$cache_dir.'lessphp_'.$hash.'.list';
|
||||
$list_file = Less_Cache::$cache_dir . Less_Cache::$prefix . $hash . '.list';
|
||||
|
||||
|
||||
// check cached content
|
||||
if( $use_cache === true && file_exists($list_file) ){
|
||||
if( !isset($parser_options['use_cache']) || $parser_options['use_cache'] === true ){
|
||||
if( file_exists($list_file) ){
|
||||
|
||||
$list = explode("\n",file_get_contents($list_file));
|
||||
|
||||
//pop the cached name that should match $compiled_name
|
||||
$cached_name = array_pop($list);
|
||||
if( !preg_match('/^lessphp_[a-f0-9]+\.css$/',$cached_name) ){
|
||||
$list[] = $cached_name;
|
||||
$cached_name = false;
|
||||
}
|
||||
self::ListFiles($list_file, $list, $cached_name);
|
||||
$compiled_name = self::CompiledName($list);
|
||||
|
||||
// if $cached_name != $compiled_name, we know we need to recompile
|
||||
@ -64,11 +98,10 @@ class Less_Cache{
|
||||
|
||||
if( $output_file && file_exists($output_file) ){
|
||||
@touch($list_file);
|
||||
@touch($output_file);
|
||||
return basename($output_file); // for backwards compatibility, we just return the name of the file
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$compiled = self::Cache( $less_files, $parser_options );
|
||||
@ -102,10 +135,12 @@ class Less_Cache{
|
||||
*
|
||||
* @param array $less_files Array of .less files to compile
|
||||
* @param array $parser_options Array of compiler options
|
||||
* @param array $modify_vars Array of variables
|
||||
* @return string Name of the css file
|
||||
*/
|
||||
public static function Regen( $less_files, $parser_options = array() ){
|
||||
return self::Get( $less_files, $parser_options, false );
|
||||
public static function Regen( $less_files, $parser_options = array(), $modify_vars = array() ){
|
||||
$parser_options['use_cache'] = false;
|
||||
return self::Get( $less_files, $parser_options, $modify_vars );
|
||||
}
|
||||
|
||||
public static function Cache( &$less_files, $parser_options = array() ){
|
||||
@ -167,7 +202,7 @@ class Less_Cache{
|
||||
$temp[] = filemtime($file)."\t".filesize($file)."\t".$file;
|
||||
}
|
||||
|
||||
return 'lessphp_'.sha1(json_encode($temp)).'.css';
|
||||
return Less_Cache::$prefix.sha1(json_encode($temp)).'.css';
|
||||
}
|
||||
|
||||
|
||||
@ -196,6 +231,10 @@ class Less_Cache{
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete unused less.php files
|
||||
*
|
||||
*/
|
||||
public static function CleanCache(){
|
||||
static $clean = false;
|
||||
|
||||
@ -205,15 +244,49 @@ class Less_Cache{
|
||||
|
||||
$files = scandir(Less_Cache::$cache_dir);
|
||||
if( $files ){
|
||||
$check_time = time() - 604800;
|
||||
$check_time = time() - self::$gc_lifetime;
|
||||
foreach($files as $file){
|
||||
if( strpos($file,'lessphp_') !== 0 ){
|
||||
|
||||
// don't delete if the file wasn't created with less.php
|
||||
if( strpos($file,Less_Cache::$prefix) !== 0 ){
|
||||
continue;
|
||||
}
|
||||
|
||||
$full_path = Less_Cache::$cache_dir.'/'.$file;
|
||||
if( filemtime($full_path) > $check_time ){
|
||||
|
||||
// make sure the file still exists
|
||||
// css files may have already been deleted
|
||||
if( !file_exists($full_path) ){
|
||||
continue;
|
||||
}
|
||||
$mtime = filemtime($full_path);
|
||||
|
||||
// don't delete if it's a relatively new file
|
||||
if( $mtime > $check_time ){
|
||||
continue;
|
||||
}
|
||||
|
||||
$parts = explode('.',$file);
|
||||
$type = array_pop($parts);
|
||||
|
||||
|
||||
// delete css files based on the list files
|
||||
if( $type === 'css' ){
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// delete the list file and associated css file
|
||||
if( $type === 'list' ){
|
||||
self::ListFiles($full_path, $list, $css_file_name);
|
||||
if( $css_file_name ){
|
||||
$css_file = Less_Cache::$cache_dir.'/'.$css_file_name;
|
||||
if( file_exists($css_file) ){
|
||||
unlink($css_file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unlink($full_path);
|
||||
}
|
||||
}
|
||||
@ -221,4 +294,23 @@ class Less_Cache{
|
||||
$clean = true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the list of less files and generated css file from a list file
|
||||
*
|
||||
*/
|
||||
static function ListFiles($list_file, &$list, &$css_file_name ){
|
||||
|
||||
$list = explode("\n",file_get_contents($list_file));
|
||||
|
||||
//pop the cached name that should match $compiled_name
|
||||
$css_file_name = array_pop($list);
|
||||
|
||||
if( !preg_match('/^' . Less_Cache::$prefix . '[a-f0-9]+\.css$/',$css_file_name) ){
|
||||
$list[] = $css_file_name;
|
||||
$css_file_name = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
0
lib/lessphp/Colors.php
Normal file → Executable file
0
lib/lessphp/Colors.php
Normal file → Executable file
0
lib/lessphp/Configurable.php
Normal file → Executable file
0
lib/lessphp/Configurable.php
Normal file → Executable file
7
lib/lessphp/Environment.php
Normal file → Executable file
7
lib/lessphp/Environment.php
Normal file → Executable file
@ -47,6 +47,11 @@ class Less_Environment{
|
||||
|
||||
public static $mixin_stack = 0;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $functions = array();
|
||||
|
||||
|
||||
public function Init(){
|
||||
|
||||
@ -114,7 +119,7 @@ class Less_Environment{
|
||||
* @return string Canonicalized path
|
||||
*
|
||||
*/
|
||||
static function normalizePath($path){
|
||||
public static function normalizePath($path){
|
||||
|
||||
$segments = explode('/',$path);
|
||||
$segments = array_reverse($segments);
|
||||
|
6
lib/lessphp/Exception/Chunk.php
Normal file → Executable file
6
lib/lessphp/Exception/Chunk.php
Normal file → Executable file
@ -46,7 +46,7 @@ class Less_Exception_Chunk extends Less_Exception_Parser{
|
||||
* We don't actually need the chunks
|
||||
*
|
||||
*/
|
||||
function Chunks(){
|
||||
protected function Chunks(){
|
||||
$level = 0;
|
||||
$parenLevel = 0;
|
||||
$lastMultiCommentEndBrace = null;
|
||||
@ -173,12 +173,12 @@ class Less_Exception_Chunk extends Less_Exception_Parser{
|
||||
//$this->emitChunk(true);
|
||||
}
|
||||
|
||||
function CharCode($pos){
|
||||
public function CharCode($pos){
|
||||
return ord($this->input[$pos]);
|
||||
}
|
||||
|
||||
|
||||
function fail( $msg, $index = null ){
|
||||
public function fail( $msg, $index = null ){
|
||||
|
||||
if( !$index ){
|
||||
$this->index = $this->parserCurrentIndex;
|
||||
|
0
lib/lessphp/Exception/Compiler.php
Normal file → Executable file
0
lib/lessphp/Exception/Compiler.php
Normal file → Executable file
5
lib/lessphp/Exception/Parser.php
Normal file → Executable file
5
lib/lessphp/Exception/Parser.php
Normal file → Executable file
@ -99,8 +99,13 @@ class Less_Exception_Parser extends Exception{
|
||||
*/
|
||||
public function getLineNumber(){
|
||||
if( $this->index ){
|
||||
// https://bugs.php.net/bug.php?id=49790
|
||||
if (ini_get("mbstring.func_overload")) {
|
||||
return substr_count(substr($this->input, 0, $this->index), "\n") + 1;
|
||||
} else {
|
||||
return substr_count($this->input, "\n", 0, $this->index) + 1;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
24
lib/lessphp/Functions.php
Normal file → Executable file
24
lib/lessphp/Functions.php
Normal file → Executable file
@ -21,7 +21,7 @@ class Less_Functions{
|
||||
/**
|
||||
* @param string $op
|
||||
*/
|
||||
static public function operate( $op, $a, $b ){
|
||||
public static function operate( $op, $a, $b ){
|
||||
switch ($op) {
|
||||
case '+': return $a + $b;
|
||||
case '-': return $a - $b;
|
||||
@ -30,11 +30,11 @@ class Less_Functions{
|
||||
}
|
||||
}
|
||||
|
||||
static public function clamp($val, $max = 1){
|
||||
public static function clamp($val, $max = 1){
|
||||
return min( max($val, 0), $max);
|
||||
}
|
||||
|
||||
static function fround( $value ){
|
||||
public static function fround( $value ){
|
||||
|
||||
if( $value === 0 ){
|
||||
return $value;
|
||||
@ -47,7 +47,7 @@ class Less_Functions{
|
||||
return $value;
|
||||
}
|
||||
|
||||
static public function number($n){
|
||||
public static function number($n){
|
||||
|
||||
if ($n instanceof Less_Tree_Dimension) {
|
||||
return floatval( $n->unit->is('%') ? $n->value / 100 : $n->value);
|
||||
@ -58,7 +58,7 @@ class Less_Functions{
|
||||
}
|
||||
}
|
||||
|
||||
static public function scaled($n, $size = 255 ){
|
||||
public static function scaled($n, $size = 255 ){
|
||||
if( $n instanceof Less_Tree_Dimension && $n->unit->is('%') ){
|
||||
return (float)$n->value * $size / 100;
|
||||
} else {
|
||||
@ -102,7 +102,7 @@ class Less_Functions{
|
||||
/**
|
||||
* @param double $h
|
||||
*/
|
||||
function hsla_hue($h, $m1, $m2){
|
||||
public function hsla_hue($h, $m1, $m2){
|
||||
$h = $h < 0 ? $h + 1 : ($h > 1 ? $h - 1 : $h);
|
||||
if ($h * 6 < 1) return $m1 + ($m2 - $m1) * $h * 6;
|
||||
else if ($h * 2 < 1) return $m2;
|
||||
@ -520,7 +520,7 @@ class Less_Functions{
|
||||
/**
|
||||
* @param boolean $isMin
|
||||
*/
|
||||
function _minmax( $isMin, $args ){
|
||||
private function _minmax( $isMin, $args ){
|
||||
|
||||
$arg_count = count($args);
|
||||
|
||||
@ -715,12 +715,12 @@ class Less_Functions{
|
||||
return null;
|
||||
}
|
||||
|
||||
function length($values){
|
||||
public function length($values){
|
||||
$n = (property_exists($values,'value') && is_array($values->value)) ? count($values->value) : 1;
|
||||
return new Less_Tree_Dimension($n);
|
||||
}
|
||||
|
||||
function datauri($mimetypeNode, $filePathNode = null ) {
|
||||
public function datauri($mimetypeNode, $filePathNode = null ) {
|
||||
|
||||
$filePath = ( $filePathNode ? $filePathNode->value : null );
|
||||
$mimetype = $mimetypeNode->value;
|
||||
@ -796,7 +796,7 @@ class Less_Functions{
|
||||
}
|
||||
|
||||
//svg-gradient
|
||||
function svggradient( $direction ){
|
||||
public function svggradient( $direction ){
|
||||
|
||||
$throw_message = 'svg-gradient expects direction, start_color [start_position], [color position,]..., end_color [end_position]';
|
||||
$arguments = func_get_args();
|
||||
@ -995,7 +995,7 @@ class Less_Functions{
|
||||
}
|
||||
|
||||
// non-w3c functions:
|
||||
function colorBlendAverage($cb, $cs ){
|
||||
public function colorBlendAverage($cb, $cs ){
|
||||
return ($cb + $cs) / 2;
|
||||
}
|
||||
|
||||
@ -1003,7 +1003,7 @@ class Less_Functions{
|
||||
return $this->colorBlend( array($this,'colorBlendNegation'), $color1, $color2 );
|
||||
}
|
||||
|
||||
function colorBlendNegation($cb, $cs){
|
||||
public function colorBlendNegation($cb, $cs){
|
||||
return 1 - abs($cb + $cs - 1);
|
||||
}
|
||||
|
||||
|
0
lib/lessphp/Less.php.combine
Normal file → Executable file
0
lib/lessphp/Less.php.combine
Normal file → Executable file
11
lib/lessphp/Mime.php
Normal file → Executable file
11
lib/lessphp/Mime.php
Normal file → Executable file
@ -16,10 +16,15 @@ class Less_Mime{
|
||||
'.gif' => 'image/gif',
|
||||
'.jpg' => 'image/jpeg',
|
||||
'.jpeg'=> 'image/jpeg',
|
||||
'.png' => 'image/png'
|
||||
'.png' => 'image/png',
|
||||
'.ttf' => 'application/x-font-ttf',
|
||||
'.otf' => 'application/x-font-otf',
|
||||
'.eot' => 'application/vnd.ms-fontobject',
|
||||
'.woff' => 'application/x-font-woff',
|
||||
'.svg' => 'image/svg+xml',
|
||||
);
|
||||
|
||||
static function lookup( $filepath ){
|
||||
public static function lookup( $filepath ){
|
||||
$parts = explode('.',$filepath);
|
||||
$ext = '.'.strtolower(array_pop($parts));
|
||||
|
||||
@ -29,7 +34,7 @@ class Less_Mime{
|
||||
return self::$_types[$ext];
|
||||
}
|
||||
|
||||
static function charsets_lookup( $type = null ){
|
||||
public static function charsets_lookup( $type = null ){
|
||||
// assumes all text types are UTF-8
|
||||
return $type && preg_match('/^text\//',$type) ? 'UTF-8' : '';
|
||||
}
|
||||
|
4
lib/lessphp/Output/Mapped.php
Normal file → Executable file
4
lib/lessphp/Output/Mapped.php
Normal file → Executable file
@ -93,7 +93,7 @@ class Less_Output_Mapped extends Less_Output {
|
||||
$this->column, // generated_column
|
||||
count($sourceLines), // original_line
|
||||
strlen($sourceColumns), // original_column
|
||||
$fileInfo['currentUri']
|
||||
$fileInfo
|
||||
);
|
||||
}else{
|
||||
for($i = 0, $count = count($lines); $i < $count; $i++){
|
||||
@ -102,7 +102,7 @@ class Less_Output_Mapped extends Less_Output {
|
||||
$i === 0 ? $this->column : 0, // generated_column
|
||||
count($sourceLines) + $i, // original_line
|
||||
$i === 0 ? strlen($sourceColumns) : 0, // original_column
|
||||
$fileInfo['currentUri']
|
||||
$fileInfo
|
||||
);
|
||||
}
|
||||
}
|
||||
|
115
lib/lessphp/Parser.php
Normal file → Executable file
115
lib/lessphp/Parser.php
Normal file → Executable file
@ -26,7 +26,9 @@ class Less_Parser{
|
||||
'import_dirs' => array(),
|
||||
'import_callback' => null,
|
||||
'cache_dir' => null,
|
||||
'cache_method' => 'php', //false, 'serialize', 'php', 'var_export';
|
||||
'cache_method' => 'php', // false, 'serialize', 'php', 'var_export', 'callback';
|
||||
'cache_callback_get' => null,
|
||||
'cache_callback_set' => null,
|
||||
|
||||
'sourceMap' => false, // whether to output a source map
|
||||
'sourceMapBasepath' => null,
|
||||
@ -139,7 +141,25 @@ class Less_Parser{
|
||||
Less_Parser::$options[$option] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a new custom function
|
||||
*
|
||||
* @param string $name function name
|
||||
* @param callable $callback callback
|
||||
*/
|
||||
public function registerFunction($name, $callback) {
|
||||
$this->env->functions[$name] = $callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removed an already registered function
|
||||
*
|
||||
* @param string $name function name
|
||||
*/
|
||||
public function unregisterFunction($name) {
|
||||
if( isset($this->env->functions[$name]) )
|
||||
unset($this->env->functions[$name]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -154,6 +174,7 @@ class Less_Parser{
|
||||
$locale = setlocale(LC_NUMERIC, 0);
|
||||
setlocale(LC_NUMERIC, "C");
|
||||
|
||||
try {
|
||||
|
||||
$root = new Less_Tree_Ruleset(array(), $this->rules );
|
||||
$root->root = true;
|
||||
@ -182,10 +203,19 @@ class Less_Parser{
|
||||
$css = preg_replace('/(^(\s)+)|((\s)+$)/', '', $css);
|
||||
}
|
||||
|
||||
} catch (Exception $exc) {
|
||||
// Intentional fall-through so we can reset environment
|
||||
}
|
||||
|
||||
//reset php settings
|
||||
@ini_set('precision',$precision);
|
||||
setlocale(LC_NUMERIC, $locale);
|
||||
|
||||
// Rethrow exception after we handled resetting the environment
|
||||
if (!empty($exc)) {
|
||||
throw $exc;
|
||||
}
|
||||
|
||||
return $css;
|
||||
}
|
||||
|
||||
@ -298,8 +328,13 @@ class Less_Parser{
|
||||
|
||||
|
||||
$previousFileInfo = $this->env->currentFileInfo;
|
||||
$filename = self::WinPath($filename);
|
||||
|
||||
|
||||
if( $filename ){
|
||||
$filename = self::WinPath(realpath($filename));
|
||||
}
|
||||
$uri_root = self::WinPath($uri_root);
|
||||
|
||||
$this->SetFileInfo($filename, $uri_root);
|
||||
|
||||
self::AddParsedFile($filename);
|
||||
@ -327,7 +362,7 @@ class Less_Parser{
|
||||
*/
|
||||
public function ModifyVars( $vars ){
|
||||
|
||||
$this->input = $this->serializeVars( $vars );
|
||||
$this->input = Less_Parser::serializeVars( $vars );
|
||||
$this->_parse();
|
||||
|
||||
return $this;
|
||||
@ -431,7 +466,17 @@ class Less_Parser{
|
||||
* @param string $file_path
|
||||
*/
|
||||
private function _parse( $file_path = null ){
|
||||
if (ini_get("mbstring.func_overload")) {
|
||||
$mb_internal_encoding = ini_get("mbstring.internal_encoding");
|
||||
@ini_set("mbstring.internal_encoding", "ascii");
|
||||
}
|
||||
|
||||
$this->rules = array_merge($this->rules, $this->GetRules( $file_path ));
|
||||
|
||||
//reset php settings
|
||||
if (isset($mb_internal_encoding)) {
|
||||
@ini_set("mbstring.internal_encoding", $mb_internal_encoding);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -446,7 +491,21 @@ class Less_Parser{
|
||||
$this->SetInput($file_path);
|
||||
|
||||
$cache_file = $this->CacheFile( $file_path );
|
||||
if( $cache_file && file_exists($cache_file) ){
|
||||
if( $cache_file ){
|
||||
if( Less_Parser::$options['cache_method'] == 'callback' ){
|
||||
if( is_callable(Less_Parser::$options['cache_callback_get']) ){
|
||||
$cache = call_user_func_array(
|
||||
Less_Parser::$options['cache_callback_get'],
|
||||
array($this, $file_path, $cache_file)
|
||||
);
|
||||
|
||||
if( $cache ){
|
||||
$this->UnsetInput();
|
||||
return $cache;
|
||||
}
|
||||
}
|
||||
|
||||
}elseif( file_exists($cache_file) ){
|
||||
switch(Less_Parser::$options['cache_method']){
|
||||
|
||||
// Using serialize
|
||||
@ -468,6 +527,7 @@ class Less_Parser{
|
||||
return include($cache_file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$rules = $this->parsePrimary();
|
||||
|
||||
@ -480,7 +540,15 @@ class Less_Parser{
|
||||
|
||||
//save the cache
|
||||
if( $cache_file ){
|
||||
if( Less_Parser::$options['cache_method'] == 'callback' ){
|
||||
if( is_callable(Less_Parser::$options['cache_callback_set']) ){
|
||||
call_user_func_array(
|
||||
Less_Parser::$options['cache_callback_set'],
|
||||
array($this, $file_path, $cache_file, $rules)
|
||||
);
|
||||
}
|
||||
|
||||
}else{
|
||||
//msg('write cache file');
|
||||
switch(Less_Parser::$options['cache_method']){
|
||||
case 'serialize':
|
||||
@ -497,6 +565,7 @@ class Less_Parser{
|
||||
|
||||
Less_Cache::CleanCache();
|
||||
}
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
@ -539,7 +608,7 @@ class Less_Parser{
|
||||
|
||||
public function CacheFile( $file_path ){
|
||||
|
||||
if( $file_path && Less_Parser::$options['cache_method'] && Less_Cache::$cache_dir ){
|
||||
if( $file_path && $this->CacheEnabled() ){
|
||||
|
||||
$env = get_object_vars($this->env);
|
||||
unset($env['frames']);
|
||||
@ -551,7 +620,7 @@ class Less_Parser{
|
||||
$parts[] = $env;
|
||||
$parts[] = Less_Version::cache_version;
|
||||
$parts[] = Less_Parser::$options['cache_method'];
|
||||
return Less_Cache::$cache_dir.'lessphp_'.base_convert( sha1(json_encode($parts) ), 16, 36).'.lesscache';
|
||||
return Less_Cache::$cache_dir . Less_Cache::$prefix . base_convert( sha1(json_encode($parts) ), 16, 36) . '.lesscache';
|
||||
}
|
||||
}
|
||||
|
||||
@ -636,12 +705,14 @@ class Less_Parser{
|
||||
*/
|
||||
private function MatchFuncs($toks){
|
||||
|
||||
if( $this->pos < $this->input_len ){
|
||||
foreach($toks as $tok){
|
||||
$match = $this->$tok();
|
||||
if( $match ){
|
||||
return $match;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -864,7 +935,11 @@ class Less_Parser{
|
||||
if ($e) {
|
||||
$this->MatchChar('~');
|
||||
}
|
||||
$str = $this->MatchReg('/\\G"((?:[^"\\\\\r\n]|\\\\.)*)"|\'((?:[^\'\\\\\r\n]|\\\\.)*)\'/');
|
||||
|
||||
// Fix for #124: match escaped newlines
|
||||
//$str = $this->MatchReg('/\\G"((?:[^"\\\\\r\n]|\\\\.)*)"|\'((?:[^\'\\\\\r\n]|\\\\.)*)\'/');
|
||||
$str = $this->MatchReg('/\\G"((?:[^"\\\\\r\n]|\\\\.|\\\\\r\n|\\\\[\n\r\f])*)"|\'((?:[^\'\\\\\r\n]|\\\\.|\\\\\r\n|\\\\[\n\r\f])*)\'/');
|
||||
|
||||
if( $str ){
|
||||
$result = $str[0][0] == '"' ? $str[1] : $str[2];
|
||||
return $this->NewObj5('Less_Tree_Quoted',array($str[0], $result, $e, $index, $this->env->currentFileInfo) );
|
||||
@ -1562,6 +1637,7 @@ class Less_Parser{
|
||||
// in the input, to see if it's a ` ` character.
|
||||
//
|
||||
private function parseCombinator(){
|
||||
if( $this->pos < $this->input_len ){
|
||||
$c = $this->input[$this->pos];
|
||||
if ($c === '>' || $c === '+' || $c === '~' || $c === '|' || $c === '^' ){
|
||||
|
||||
@ -1580,6 +1656,7 @@ class Less_Parser{
|
||||
return ' ';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// A CSS selector (see selector below)
|
||||
@ -1618,7 +1695,9 @@ class Less_Parser{
|
||||
//if( count($extendList) ){
|
||||
//error("Extend can only be used at the end of selector");
|
||||
//}
|
||||
if( $this->pos < $this->input_len ){
|
||||
$c = $this->input[ $this->pos ];
|
||||
}
|
||||
$elements[] = $e;
|
||||
$e = null;
|
||||
}
|
||||
@ -2378,7 +2457,7 @@ class Less_Parser{
|
||||
}
|
||||
}
|
||||
|
||||
public function serializeVars( $vars ){
|
||||
public static function serializeVars( $vars ){
|
||||
$s = '';
|
||||
|
||||
foreach($vars as $name => $value){
|
||||
@ -2426,7 +2505,7 @@ class Less_Parser{
|
||||
*/
|
||||
public function NewObj0($class){
|
||||
$obj = new $class();
|
||||
if( Less_Cache::$cache_dir ){
|
||||
if( $this->CacheEnabled() ){
|
||||
$obj->cache_string = ' new '.$class.'()';
|
||||
}
|
||||
return $obj;
|
||||
@ -2434,7 +2513,7 @@ class Less_Parser{
|
||||
|
||||
public function NewObj1($class, $arg){
|
||||
$obj = new $class( $arg );
|
||||
if( Less_Cache::$cache_dir ){
|
||||
if( $this->CacheEnabled() ){
|
||||
$obj->cache_string = ' new '.$class.'('.Less_Parser::ArgString($arg).')';
|
||||
}
|
||||
return $obj;
|
||||
@ -2442,7 +2521,7 @@ class Less_Parser{
|
||||
|
||||
public function NewObj2($class, $args){
|
||||
$obj = new $class( $args[0], $args[1] );
|
||||
if( Less_Cache::$cache_dir ){
|
||||
if( $this->CacheEnabled() ){
|
||||
$this->ObjCache( $obj, $class, $args);
|
||||
}
|
||||
return $obj;
|
||||
@ -2450,7 +2529,7 @@ class Less_Parser{
|
||||
|
||||
public function NewObj3($class, $args){
|
||||
$obj = new $class( $args[0], $args[1], $args[2] );
|
||||
if( Less_Cache::$cache_dir ){
|
||||
if( $this->CacheEnabled() ){
|
||||
$this->ObjCache( $obj, $class, $args);
|
||||
}
|
||||
return $obj;
|
||||
@ -2458,7 +2537,7 @@ class Less_Parser{
|
||||
|
||||
public function NewObj4($class, $args){
|
||||
$obj = new $class( $args[0], $args[1], $args[2], $args[3] );
|
||||
if( Less_Cache::$cache_dir ){
|
||||
if( $this->CacheEnabled() ){
|
||||
$this->ObjCache( $obj, $class, $args);
|
||||
}
|
||||
return $obj;
|
||||
@ -2466,7 +2545,7 @@ class Less_Parser{
|
||||
|
||||
public function NewObj5($class, $args){
|
||||
$obj = new $class( $args[0], $args[1], $args[2], $args[3], $args[4] );
|
||||
if( Less_Cache::$cache_dir ){
|
||||
if( $this->CacheEnabled() ){
|
||||
$this->ObjCache( $obj, $class, $args);
|
||||
}
|
||||
return $obj;
|
||||
@ -2474,7 +2553,7 @@ class Less_Parser{
|
||||
|
||||
public function NewObj6($class, $args){
|
||||
$obj = new $class( $args[0], $args[1], $args[2], $args[3], $args[4], $args[5] );
|
||||
if( Less_Cache::$cache_dir ){
|
||||
if( $this->CacheEnabled() ){
|
||||
$this->ObjCache( $obj, $class, $args);
|
||||
}
|
||||
return $obj;
|
||||
@ -2482,7 +2561,7 @@ class Less_Parser{
|
||||
|
||||
public function NewObj7($class, $args){
|
||||
$obj = new $class( $args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6] );
|
||||
if( Less_Cache::$cache_dir ){
|
||||
if( $this->CacheEnabled() ){
|
||||
$this->ObjCache( $obj, $class, $args);
|
||||
}
|
||||
return $obj;
|
||||
@ -2531,6 +2610,10 @@ class Less_Parser{
|
||||
return str_replace('\\', '/', $path);
|
||||
}
|
||||
|
||||
public function CacheEnabled(){
|
||||
return (Less_Parser::$options['cache_method'] && (Less_Cache::$cache_dir || (Less_Parser::$options['cache_method'] == 'callback')));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
0
lib/lessphp/SourceMap/Base64VLQ.php
Normal file → Executable file
0
lib/lessphp/SourceMap/Base64VLQ.php
Normal file → Executable file
46
lib/lessphp/SourceMap/Generator.php
Normal file → Executable file
46
lib/lessphp/SourceMap/Generator.php
Normal file → Executable file
@ -36,6 +36,9 @@ class Less_SourceMap_Generator extends Less_Configurable {
|
||||
// output source contents?
|
||||
'outputSourceFiles' => false,
|
||||
|
||||
// base path for filename normalization
|
||||
'sourceMapRootpath' => '',
|
||||
|
||||
// base path for filename normalization
|
||||
'sourceMapBasepath' => ''
|
||||
);
|
||||
@ -74,6 +77,7 @@ class Less_SourceMap_Generator extends Less_Configurable {
|
||||
* @var array
|
||||
*/
|
||||
protected $sources = array();
|
||||
protected $source_keys = array();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@ -90,8 +94,9 @@ class Less_SourceMap_Generator extends Less_Configurable {
|
||||
|
||||
|
||||
// fix windows paths
|
||||
if( isset($this->options['sourceMapBasepath']) ){
|
||||
$this->options['sourceMapBasepath'] = str_replace('\\', '/', $this->options['sourceMapBasepath']);
|
||||
if( !empty($this->options['sourceMapRootpath']) ){
|
||||
$this->options['sourceMapRootpath'] = str_replace('\\', '/', $this->options['sourceMapRootpath']);
|
||||
$this->options['sourceMapRootpath'] = rtrim($this->options['sourceMapRootpath'],'/').'/';
|
||||
}
|
||||
}
|
||||
|
||||
@ -161,16 +166,22 @@ class Less_SourceMap_Generator extends Less_Configurable {
|
||||
* @return string
|
||||
*/
|
||||
protected function normalizeFilename($filename){
|
||||
|
||||
$filename = str_replace('\\', '/', $filename);
|
||||
$rootpath = $this->getOption('sourceMapRootpath');
|
||||
$basePath = $this->getOption('sourceMapBasepath');
|
||||
|
||||
if( $basePath && ($pos = strpos($filename, $basePath)) !== false ){
|
||||
$filename = substr($filename, $pos + strlen($basePath));
|
||||
// "Trim" the 'sourceMapBasepath' from the output filename.
|
||||
if (strpos($filename, $basePath) === 0) {
|
||||
$filename = substr($filename, strlen($basePath));
|
||||
}
|
||||
|
||||
// Remove extra leading path separators.
|
||||
if(strpos($filename, '\\') === 0 || strpos($filename, '/') === 0){
|
||||
$filename = substr($filename, 1);
|
||||
}
|
||||
}
|
||||
return sprintf('%s%s', $this->getOption('sourceMapRootpath'), $filename);
|
||||
|
||||
return $rootpath . $filename;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -182,19 +193,17 @@ class Less_SourceMap_Generator extends Less_Configurable {
|
||||
* @param integer $originalColumn The column number in original file
|
||||
* @param string $sourceFile The original source file
|
||||
*/
|
||||
public function addMapping($generatedLine, $generatedColumn, $originalLine, $originalColumn, $sourceFile){
|
||||
public function addMapping($generatedLine, $generatedColumn, $originalLine, $originalColumn, $fileInfo ){
|
||||
|
||||
$this->mappings[] = array(
|
||||
'generated_line' => $generatedLine,
|
||||
'generated_column' => $generatedColumn,
|
||||
'original_line' => $originalLine,
|
||||
'original_column' => $originalColumn,
|
||||
'source_file' => $sourceFile
|
||||
'source_file' => $fileInfo['currentUri']
|
||||
);
|
||||
|
||||
|
||||
$norm_file = $this->normalizeFilename($sourceFile);
|
||||
|
||||
$this->sources[$norm_file] = $sourceFile;
|
||||
$this->sources[$fileInfo['currentUri']] = $fileInfo['filename'];
|
||||
}
|
||||
|
||||
|
||||
@ -228,8 +237,10 @@ class Less_SourceMap_Generator extends Less_Configurable {
|
||||
|
||||
|
||||
// A list of original sources used by the 'mappings' entry.
|
||||
$sourceMap['sources'] = array_keys($this->sources);
|
||||
|
||||
$sourceMap['sources'] = array();
|
||||
foreach($this->sources as $source_uri => $source_filename){
|
||||
$sourceMap['sources'][] = $this->normalizeFilename($source_filename);
|
||||
}
|
||||
|
||||
|
||||
// A list of symbol names used by the 'mappings' entry.
|
||||
@ -280,6 +291,9 @@ class Less_SourceMap_Generator extends Less_Configurable {
|
||||
return '';
|
||||
}
|
||||
|
||||
$this->source_keys = array_flip(array_keys($this->sources));
|
||||
|
||||
|
||||
// group mappings by generated line number.
|
||||
$groupedMap = $groupedMapEncoded = array();
|
||||
foreach($this->mappings as $m){
|
||||
@ -303,7 +317,7 @@ class Less_SourceMap_Generator extends Less_Configurable {
|
||||
|
||||
// find the index
|
||||
if( $m['source_file'] ){
|
||||
$index = $this->findFileIndex($this->normalizeFilename($m['source_file']));
|
||||
$index = $this->findFileIndex($m['source_file']);
|
||||
if( $index !== false ){
|
||||
$mapEncoded .= $this->encoder->encode($index - $lastOriginalIndex);
|
||||
$lastOriginalIndex = $index;
|
||||
@ -333,7 +347,7 @@ class Less_SourceMap_Generator extends Less_Configurable {
|
||||
* @return integer|false
|
||||
*/
|
||||
protected function findFileIndex($filename){
|
||||
return array_search($filename, array_keys($this->sources));
|
||||
return $this->source_keys[$filename];
|
||||
}
|
||||
|
||||
}
|
0
lib/lessphp/Tree.php
Normal file → Executable file
0
lib/lessphp/Tree.php
Normal file → Executable file
0
lib/lessphp/Tree/Alpha.php
Normal file → Executable file
0
lib/lessphp/Tree/Alpha.php
Normal file → Executable file
2
lib/lessphp/Tree/Anonymous.php
Normal file → Executable file
2
lib/lessphp/Tree/Anonymous.php
Normal file → Executable file
@ -29,7 +29,7 @@ class Less_Tree_Anonymous extends Less_Tree{
|
||||
return new Less_Tree_Anonymous($this->value, $this->index, $this->currentFileInfo, $this->mapLines);
|
||||
}
|
||||
|
||||
function compare($x){
|
||||
public function compare($x){
|
||||
if( !is_object($x) ){
|
||||
return -1;
|
||||
}
|
||||
|
4
lib/lessphp/Tree/Assignment.php
Normal file → Executable file
4
lib/lessphp/Tree/Assignment.php
Normal file → Executable file
@ -12,12 +12,12 @@ class Less_Tree_Assignment extends Less_Tree{
|
||||
public $value;
|
||||
public $type = 'Assignment';
|
||||
|
||||
function __construct($key, $val) {
|
||||
public function __construct($key, $val) {
|
||||
$this->key = $key;
|
||||
$this->value = $val;
|
||||
}
|
||||
|
||||
function accept( $visitor ){
|
||||
public function accept( $visitor ){
|
||||
$this->value = $visitor->visitObj( $this->value );
|
||||
}
|
||||
|
||||
|
8
lib/lessphp/Tree/Attribute.php
Normal file → Executable file
8
lib/lessphp/Tree/Attribute.php
Normal file → Executable file
@ -13,13 +13,13 @@ class Less_Tree_Attribute extends Less_Tree{
|
||||
public $value;
|
||||
public $type = 'Attribute';
|
||||
|
||||
function __construct($key, $op, $value){
|
||||
public function __construct($key, $op, $value){
|
||||
$this->key = $key;
|
||||
$this->op = $op;
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
function compile($env){
|
||||
public function compile($env){
|
||||
|
||||
$key_obj = is_object($this->key);
|
||||
$val_obj = is_object($this->value);
|
||||
@ -37,11 +37,11 @@ class Less_Tree_Attribute extends Less_Tree{
|
||||
/**
|
||||
* @see Less_Tree::genCSS
|
||||
*/
|
||||
function genCSS( $output ){
|
||||
public function genCSS( $output ){
|
||||
$output->add( $this->toCSS() );
|
||||
}
|
||||
|
||||
function toCSS(){
|
||||
public function toCSS(){
|
||||
$value = $this->key;
|
||||
|
||||
if( $this->op ){
|
||||
|
16
lib/lessphp/Tree/Call.php
Normal file → Executable file
16
lib/lessphp/Tree/Call.php
Normal file → Executable file
@ -10,10 +10,10 @@
|
||||
class Less_Tree_Call extends Less_Tree{
|
||||
public $value;
|
||||
|
||||
var $name;
|
||||
var $args;
|
||||
var $index;
|
||||
var $currentFileInfo;
|
||||
protected $name;
|
||||
protected $args;
|
||||
protected $index;
|
||||
protected $currentFileInfo;
|
||||
public $type = 'Call';
|
||||
|
||||
public function __construct($name, $args, $index, $currentFileInfo = null ){
|
||||
@ -23,7 +23,7 @@ class Less_Tree_Call extends Less_Tree{
|
||||
$this->currentFileInfo = $currentFileInfo;
|
||||
}
|
||||
|
||||
function accept( $visitor ){
|
||||
public function accept( $visitor ){
|
||||
$this->args = $visitor->visitArray( $this->args );
|
||||
}
|
||||
|
||||
@ -79,6 +79,12 @@ class Less_Tree_Call extends Less_Tree{
|
||||
} catch (Exception $e) {
|
||||
throw new Less_Exception_Compiler('error evaluating function `' . $this->name . '` '.$e->getMessage().' index: '. $this->index);
|
||||
}
|
||||
} elseif( isset( $env->functions[$nameLC] ) && is_callable( $env->functions[$nameLC] ) ) {
|
||||
try {
|
||||
$result = call_user_func_array( $env->functions[$nameLC], $args );
|
||||
} catch (Exception $e) {
|
||||
throw new Less_Exception_Compiler('error evaluating function `' . $this->name . '` '.$e->getMessage().' index: '. $this->index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
6
lib/lessphp/Tree/Color.php
Normal file → Executable file
6
lib/lessphp/Tree/Color.php
Normal file → Executable file
@ -71,7 +71,7 @@ class Less_Tree_Color extends Less_Tree{
|
||||
// Values are capped between `0` and `255`, rounded and zero-padded.
|
||||
//
|
||||
if( $alpha < 1 ){
|
||||
if( $alpha === 0 && isset($this->isTransparentKeyword) && $this->isTransparentKeyword ){
|
||||
if( ( $alpha === 0 || $alpha === 0.0 ) && isset($this->isTransparentKeyword) && $this->isTransparentKeyword ){
|
||||
return 'transparent';
|
||||
}
|
||||
|
||||
@ -148,7 +148,7 @@ class Less_Tree_Color extends Less_Tree{
|
||||
}
|
||||
|
||||
//Adapted from http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript
|
||||
function toHSV() {
|
||||
public function toHSV() {
|
||||
$r = $this->rgb[0] / 255;
|
||||
$g = $this->rgb[1] / 255;
|
||||
$b = $this->rgb[2] / 255;
|
||||
@ -196,7 +196,7 @@ class Less_Tree_Color extends Less_Tree{
|
||||
$x->alpha === $this->alpha) ? 0 : -1;
|
||||
}
|
||||
|
||||
function toHex( $v ){
|
||||
public function toHex( $v ){
|
||||
|
||||
$ret = '#';
|
||||
foreach($v as $c){
|
||||
|
0
lib/lessphp/Tree/Comment.php
Normal file → Executable file
0
lib/lessphp/Tree/Comment.php
Normal file → Executable file
0
lib/lessphp/Tree/Condition.php
Normal file → Executable file
0
lib/lessphp/Tree/Condition.php
Normal file → Executable file
@ -11,24 +11,24 @@ class Less_Tree_DefaultFunc{
|
||||
static $error_;
|
||||
static $value_;
|
||||
|
||||
static function compile(){
|
||||
public static function compile(){
|
||||
if( self::$error_ ){
|
||||
throw Exception(self::$error_);
|
||||
throw new Exception(self::$error_);
|
||||
}
|
||||
if( self::$value_ !== null ){
|
||||
return self::$value_ ? new Less_Tree_Keyword('true') : new Less_Tree_Keyword('false');
|
||||
}
|
||||
}
|
||||
|
||||
static function value( $v ){
|
||||
public static function value( $v ){
|
||||
self::$value_ = $v;
|
||||
}
|
||||
|
||||
static function error( $e ){
|
||||
public static function error( $e ){
|
||||
self::$error_ = $e;
|
||||
}
|
||||
|
||||
static function reset(){
|
||||
public static function reset(){
|
||||
self::$value_ = self::$error_ = null;
|
||||
}
|
||||
}
|
@ -12,16 +12,16 @@ class Less_Tree_DetachedRuleset extends Less_Tree{
|
||||
public $frames;
|
||||
public $type = 'DetachedRuleset';
|
||||
|
||||
function __construct( $ruleset, $frames = null ){
|
||||
public function __construct( $ruleset, $frames = null ){
|
||||
$this->ruleset = $ruleset;
|
||||
$this->frames = $frames;
|
||||
}
|
||||
|
||||
function accept($visitor) {
|
||||
public function accept($visitor) {
|
||||
$this->ruleset = $visitor->visitObj($this->ruleset);
|
||||
}
|
||||
|
||||
function compile($env){
|
||||
public function compile($env){
|
||||
if( $this->frames ){
|
||||
$frames = $this->frames;
|
||||
}else{
|
||||
@ -30,7 +30,7 @@ class Less_Tree_DetachedRuleset extends Less_Tree{
|
||||
return new Less_Tree_DetachedRuleset($this->ruleset, $frames);
|
||||
}
|
||||
|
||||
function callEval($env) {
|
||||
public function callEval($env) {
|
||||
if( $this->frames ){
|
||||
return $this->ruleset->compile( $env->copyEvalEnv( array_merge($this->frames,$env->frames) ) );
|
||||
}
|
||||
|
6
lib/lessphp/Tree/Dimension.php
Normal file → Executable file
6
lib/lessphp/Tree/Dimension.php
Normal file → Executable file
@ -24,7 +24,7 @@ class Less_Tree_Dimension extends Less_Tree{
|
||||
}
|
||||
}
|
||||
|
||||
function accept( $visitor ){
|
||||
public function accept( $visitor ){
|
||||
$this->unit = $visitor->visitObj( $this->unit );
|
||||
}
|
||||
|
||||
@ -147,11 +147,11 @@ class Less_Tree_Dimension extends Less_Tree{
|
||||
}
|
||||
}
|
||||
|
||||
function unify() {
|
||||
public function unify() {
|
||||
return $this->convertTo(array('length'=> 'px', 'duration'=> 's', 'angle' => 'rad' ));
|
||||
}
|
||||
|
||||
function convertTo($conversions) {
|
||||
public function convertTo($conversions) {
|
||||
$value = $this->value;
|
||||
$unit = clone $this->unit;
|
||||
|
||||
|
4
lib/lessphp/Tree/Directive.php
Normal file → Executable file
4
lib/lessphp/Tree/Directive.php
Normal file → Executable file
@ -31,7 +31,7 @@ class Less_Tree_Directive extends Less_Tree{
|
||||
}
|
||||
|
||||
|
||||
function accept( $visitor ){
|
||||
public function accept( $visitor ){
|
||||
if( $this->rules ){
|
||||
$this->rules = $visitor->visitObj( $this->rules );
|
||||
}
|
||||
@ -44,7 +44,7 @@ class Less_Tree_Directive extends Less_Tree{
|
||||
/**
|
||||
* @see Less_Tree::genCSS
|
||||
*/
|
||||
function genCSS( $output ){
|
||||
public function genCSS( $output ){
|
||||
$value = $this->value;
|
||||
$rules = $this->rules;
|
||||
$output->add( $this->name, $this->currentFileInfo, $this->index );
|
||||
|
2
lib/lessphp/Tree/Element.php
Normal file → Executable file
2
lib/lessphp/Tree/Element.php
Normal file → Executable file
@ -29,7 +29,7 @@ class Less_Tree_Element extends Less_Tree{
|
||||
$this->currentFileInfo = $currentFileInfo;
|
||||
}
|
||||
|
||||
function accept( $visitor ){
|
||||
public function accept( $visitor ){
|
||||
if( $this->value_is_object ){ //object or string
|
||||
$this->value = $visitor->visitObj( $this->value );
|
||||
}
|
||||
|
6
lib/lessphp/Tree/Expression.php
Normal file → Executable file
6
lib/lessphp/Tree/Expression.php
Normal file → Executable file
@ -18,7 +18,7 @@ class Less_Tree_Expression extends Less_Tree{
|
||||
$this->parens = $parens;
|
||||
}
|
||||
|
||||
function accept( $visitor ){
|
||||
public function accept( $visitor ){
|
||||
$this->value = $visitor->visitArray( $this->value );
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ class Less_Tree_Expression extends Less_Tree{
|
||||
/**
|
||||
* @see Less_Tree::genCSS
|
||||
*/
|
||||
function genCSS( $output ){
|
||||
public function genCSS( $output ){
|
||||
$val_len = count($this->value);
|
||||
for( $i = 0; $i < $val_len; $i++ ){
|
||||
$this->value[$i]->genCSS( $output );
|
||||
@ -81,7 +81,7 @@ class Less_Tree_Expression extends Less_Tree{
|
||||
}
|
||||
}
|
||||
|
||||
function throwAwayComments() {
|
||||
public function throwAwayComments() {
|
||||
|
||||
if( is_array($this->value) ){
|
||||
$new_value = array();
|
||||
|
8
lib/lessphp/Tree/Extend.php
Normal file → Executable file
8
lib/lessphp/Tree/Extend.php
Normal file → Executable file
@ -25,7 +25,7 @@ class Less_Tree_Extend extends Less_Tree{
|
||||
/**
|
||||
* @param integer $index
|
||||
*/
|
||||
function __construct($selector, $option, $index){
|
||||
public function __construct($selector, $option, $index){
|
||||
static $i = 0;
|
||||
$this->selector = $selector;
|
||||
$this->option = $option;
|
||||
@ -46,18 +46,18 @@ class Less_Tree_Extend extends Less_Tree{
|
||||
$this->parent_ids = array($this->object_id);
|
||||
}
|
||||
|
||||
function accept( $visitor ){
|
||||
public function accept( $visitor ){
|
||||
$this->selector = $visitor->visitObj( $this->selector );
|
||||
}
|
||||
|
||||
function compile( $env ){
|
||||
public function compile( $env ){
|
||||
Less_Parser::$has_extends = true;
|
||||
$this->selector = $this->selector->compile($env);
|
||||
return $this;
|
||||
//return new Less_Tree_Extend( $this->selector->compile($env), $this->option, $this->index);
|
||||
}
|
||||
|
||||
function findSelfSelectors( $selectors ){
|
||||
public function findSelfSelectors( $selectors ){
|
||||
$selfElements = array();
|
||||
|
||||
|
||||
|
28
lib/lessphp/Tree/Import.php
Normal file → Executable file
28
lib/lessphp/Tree/Import.php
Normal file → Executable file
@ -27,7 +27,7 @@ class Less_Tree_Import extends Less_Tree{
|
||||
public $root;
|
||||
public $type = 'Import';
|
||||
|
||||
function __construct($path, $features, $options, $index, $currentFileInfo = null ){
|
||||
public function __construct($path, $features, $options, $index, $currentFileInfo = null ){
|
||||
$this->options = $options;
|
||||
$this->index = $index;
|
||||
$this->path = $path;
|
||||
@ -58,7 +58,7 @@ class Less_Tree_Import extends Less_Tree{
|
||||
// ruleset.
|
||||
//
|
||||
|
||||
function accept($visitor){
|
||||
public function accept($visitor){
|
||||
|
||||
if( $this->features ){
|
||||
$this->features = $visitor->visitObj($this->features);
|
||||
@ -73,7 +73,7 @@ class Less_Tree_Import extends Less_Tree{
|
||||
/**
|
||||
* @see Less_Tree::genCSS
|
||||
*/
|
||||
function genCSS( $output ){
|
||||
public function genCSS( $output ){
|
||||
if( $this->css ){
|
||||
|
||||
$output->add( '@import ', $this->currentFileInfo, $this->index );
|
||||
@ -87,7 +87,7 @@ class Less_Tree_Import extends Less_Tree{
|
||||
}
|
||||
}
|
||||
|
||||
function toCSS(){
|
||||
public function toCSS(){
|
||||
$features = $this->features ? ' ' . $this->features->toCSS() : '';
|
||||
|
||||
if ($this->css) {
|
||||
@ -100,7 +100,7 @@ class Less_Tree_Import extends Less_Tree{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
function getPath(){
|
||||
public function getPath(){
|
||||
if ($this->path instanceof Less_Tree_Quoted) {
|
||||
$path = $this->path->value;
|
||||
$path = ( isset($this->css) || preg_match('/(\.[a-z]*$)|([\?;].*)$/',$path)) ? $path : $path . '.less';
|
||||
@ -114,11 +114,11 @@ class Less_Tree_Import extends Less_Tree{
|
||||
return preg_replace('/[\?#][^\?]*$/','',$path);
|
||||
}
|
||||
|
||||
function compileForImport( $env ){
|
||||
public function compileForImport( $env ){
|
||||
return new Less_Tree_Import( $this->path->compile($env), $this->features, $this->options, $this->index, $this->currentFileInfo);
|
||||
}
|
||||
|
||||
function compilePath($env) {
|
||||
public function compilePath($env) {
|
||||
$path = $this->path->compile($env);
|
||||
$rootpath = '';
|
||||
if( $this->currentFileInfo && $this->currentFileInfo['rootpath'] ){
|
||||
@ -142,7 +142,7 @@ class Less_Tree_Import extends Less_Tree{
|
||||
return $path;
|
||||
}
|
||||
|
||||
function compile( $env ){
|
||||
public function compile( $env ){
|
||||
|
||||
$evald = $this->compileForImport($env);
|
||||
|
||||
@ -199,7 +199,7 @@ class Less_Tree_Import extends Less_Tree{
|
||||
*
|
||||
* @param Less_Tree_Import $evald
|
||||
*/
|
||||
function PathAndUri(){
|
||||
public function PathAndUri(){
|
||||
|
||||
$evald_path = $this->getPath();
|
||||
|
||||
@ -231,13 +231,17 @@ class Less_Tree_Import extends Less_Tree{
|
||||
$full_path = $path;
|
||||
return array( $full_path, $uri );
|
||||
}
|
||||
}else{
|
||||
}elseif( !empty($rootpath) ){
|
||||
$path = rtrim($rootpath,'/\\').'/'.ltrim($evald_path,'/\\');
|
||||
|
||||
if( file_exists($path) ){
|
||||
$full_path = Less_Environment::normalizePath($path);
|
||||
$uri = Less_Environment::normalizePath(dirname($rooturi.$evald_path));
|
||||
return array( $full_path, $uri );
|
||||
} elseif( file_exists($path.'.less') ){
|
||||
$full_path = Less_Environment::normalizePath($path.'.less');
|
||||
$uri = Less_Environment::normalizePath(dirname($rooturi.$evald_path.'.less'));
|
||||
return array( $full_path, $uri );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -250,7 +254,7 @@ class Less_Tree_Import extends Less_Tree{
|
||||
*
|
||||
* @return Less_Tree_Media|array
|
||||
*/
|
||||
function ParseImport( $full_path, $uri, $env ){
|
||||
public function ParseImport( $full_path, $uri, $env ){
|
||||
|
||||
$import_env = clone $env;
|
||||
if( (isset($this->options['reference']) && $this->options['reference']) || isset($this->currentFileInfo['reference']) ){
|
||||
@ -279,7 +283,7 @@ class Less_Tree_Import extends Less_Tree{
|
||||
*/
|
||||
private function Skip($path, $env){
|
||||
|
||||
$path = realpath($path);
|
||||
$path = Less_Parser::winPath(realpath($path));
|
||||
|
||||
if( $path && Less_Parser::FileParsed($path) ){
|
||||
|
||||
|
0
lib/lessphp/Tree/Javascript.php
Normal file → Executable file
0
lib/lessphp/Tree/Javascript.php
Normal file → Executable file
0
lib/lessphp/Tree/Keyword.php
Normal file → Executable file
0
lib/lessphp/Tree/Keyword.php
Normal file → Executable file
6
lib/lessphp/Tree/Media.php
Normal file → Executable file
6
lib/lessphp/Tree/Media.php
Normal file → Executable file
@ -28,7 +28,7 @@ class Less_Tree_Media extends Less_Tree{
|
||||
$this->rules[0]->allowImports = true;
|
||||
}
|
||||
|
||||
function accept( $visitor ){
|
||||
public function accept( $visitor ){
|
||||
$this->features = $visitor->visitObj($this->features);
|
||||
$this->rules = $visitor->visitArray($this->rules);
|
||||
}
|
||||
@ -36,7 +36,7 @@ class Less_Tree_Media extends Less_Tree{
|
||||
/**
|
||||
* @see Less_Tree::genCSS
|
||||
*/
|
||||
function genCSS( $output ){
|
||||
public function genCSS( $output ){
|
||||
|
||||
$output->add( '@media ', $this->currentFileInfo, $this->index );
|
||||
$this->features->genCSS( $output );
|
||||
@ -169,7 +169,7 @@ class Less_Tree_Media extends Less_Tree{
|
||||
return $result;
|
||||
}
|
||||
|
||||
function bubbleSelectors($selectors) {
|
||||
public function bubbleSelectors($selectors) {
|
||||
|
||||
if( !$selectors) return;
|
||||
|
||||
|
4
lib/lessphp/Tree/Mixin/Call.php
Normal file → Executable file
4
lib/lessphp/Tree/Mixin/Call.php
Normal file → Executable file
@ -107,7 +107,7 @@ class Less_Tree_Mixin_Call extends Less_Tree{
|
||||
} else {
|
||||
$defaultResult = $defTrue;
|
||||
if( ($count[$defTrue] + $count[$defFalse]) > 1 ){
|
||||
throw 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) + '`' );
|
||||
}
|
||||
}
|
||||
|
||||
@ -145,7 +145,7 @@ class Less_Tree_Mixin_Call extends Less_Tree{
|
||||
throw new Less_Exception_Compiler('No matching definition was found for `'.$this->Format( $args ).'`', null, $this->index, $this->currentFileInfo);
|
||||
|
||||
}else{
|
||||
throw new Less_Exception_Compiler(trim($this->selector->toCSS()) . " is undefined", null, $this->index);
|
||||
throw new Less_Exception_Compiler(trim($this->selector->toCSS()) . " is undefined in ".$this->currentFileInfo['filename'], null, $this->index);
|
||||
}
|
||||
|
||||
}
|
||||
|
9
lib/lessphp/Tree/Mixin/Definition.php
Normal file → Executable file
9
lib/lessphp/Tree/Mixin/Definition.php
Normal file → Executable file
@ -15,7 +15,7 @@ class Less_Tree_Mixin_Definition extends Less_Tree_Ruleset{
|
||||
|
||||
|
||||
// less.js : /lib/less/tree/mixin.js : tree.mixin.Definition
|
||||
public function __construct($name, $params, $rules, $condition, $variadic = false, $frames = null ){
|
||||
public function __construct($name, $params, $rules, $condition, $variadic = false, $frames = array() ){
|
||||
$this->name = $name;
|
||||
$this->selectors = array(new Less_Tree_Selector(array( new Less_Tree_Element(null, $name))));
|
||||
|
||||
@ -190,6 +190,11 @@ class Less_Tree_Mixin_Definition extends Less_Tree_Ruleset{
|
||||
return true;
|
||||
}
|
||||
|
||||
// set array to prevent error on array_merge
|
||||
if(!is_array($this->frames)) {
|
||||
$this->frames = array();
|
||||
}
|
||||
|
||||
$frame = $this->compileParams($env, array_merge($this->frames,$env->frames), $args );
|
||||
|
||||
$compile_env = new Less_Environment();
|
||||
@ -199,6 +204,8 @@ class Less_Tree_Mixin_Definition extends Less_Tree_Ruleset{
|
||||
, $env->frames // the current environment frames
|
||||
);
|
||||
|
||||
$compile_env->functions = $env->functions;
|
||||
|
||||
return (bool)$this->condition->compile($compile_env);
|
||||
}
|
||||
|
||||
|
2
lib/lessphp/Tree/NameValue.php
Normal file → Executable file
2
lib/lessphp/Tree/NameValue.php
Normal file → Executable file
@ -25,7 +25,7 @@ class Less_Tree_NameValue extends Less_Tree{
|
||||
$this->currentFileInfo = $currentFileInfo;
|
||||
}
|
||||
|
||||
function genCSS( $output ){
|
||||
public function genCSS( $output ){
|
||||
|
||||
$output->add(
|
||||
$this->name
|
||||
|
6
lib/lessphp/Tree/Negative.php
Normal file → Executable file
6
lib/lessphp/Tree/Negative.php
Normal file → Executable file
@ -11,7 +11,7 @@ class Less_Tree_Negative extends Less_Tree{
|
||||
public $value;
|
||||
public $type = 'Negative';
|
||||
|
||||
function __construct($node){
|
||||
public function __construct($node){
|
||||
$this->value = $node;
|
||||
}
|
||||
|
||||
@ -22,12 +22,12 @@ class Less_Tree_Negative extends Less_Tree{
|
||||
/**
|
||||
* @see Less_Tree::genCSS
|
||||
*/
|
||||
function genCSS( $output ){
|
||||
public function genCSS( $output ){
|
||||
$output->add( '-' );
|
||||
$this->value->genCSS( $output );
|
||||
}
|
||||
|
||||
function compile($env) {
|
||||
public function compile($env) {
|
||||
if( Less_Environment::isMathOn() ){
|
||||
$ret = new Less_Tree_Operation('*', array( new Less_Tree_Dimension(-1), $this->value ) );
|
||||
return $ret->compile($env);
|
||||
|
4
lib/lessphp/Tree/Operation.php
Normal file → Executable file
4
lib/lessphp/Tree/Operation.php
Normal file → Executable file
@ -22,7 +22,7 @@ class Less_Tree_Operation extends Less_Tree{
|
||||
$this->isSpaced = $isSpaced;
|
||||
}
|
||||
|
||||
function accept($visitor) {
|
||||
public function accept($visitor) {
|
||||
$this->operands = $visitor->visitArray($this->operands);
|
||||
}
|
||||
|
||||
@ -55,7 +55,7 @@ class Less_Tree_Operation extends Less_Tree{
|
||||
/**
|
||||
* @see Less_Tree::genCSS
|
||||
*/
|
||||
function genCSS( $output ){
|
||||
public function genCSS( $output ){
|
||||
$this->operands[0]->genCSS( $output );
|
||||
if( $this->isSpaced ){
|
||||
$output->add( " " );
|
||||
|
4
lib/lessphp/Tree/Paren.php
Normal file → Executable file
4
lib/lessphp/Tree/Paren.php
Normal file → Executable file
@ -15,14 +15,14 @@ class Less_Tree_Paren extends Less_Tree{
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
function accept($visitor){
|
||||
public function accept($visitor){
|
||||
$this->value = $visitor->visitObj($this->value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Less_Tree::genCSS
|
||||
*/
|
||||
function genCSS( $output ){
|
||||
public function genCSS( $output ){
|
||||
$output->add( '(' );
|
||||
$this->value->genCSS( $output );
|
||||
$output->add( ')' );
|
||||
|
2
lib/lessphp/Tree/Quoted.php
Normal file → Executable file
2
lib/lessphp/Tree/Quoted.php
Normal file → Executable file
@ -63,7 +63,7 @@ class Less_Tree_Quoted extends Less_Tree{
|
||||
return new Less_Tree_Quoted($this->quote . $value . $this->quote, $value, $this->escaped, $this->index, $this->currentFileInfo);
|
||||
}
|
||||
|
||||
function compare($x) {
|
||||
public function compare($x) {
|
||||
|
||||
if( !Less_Parser::is_method($x, 'toCSS') ){
|
||||
return -1;
|
||||
|
8
lib/lessphp/Tree/Rule.php
Normal file → Executable file
8
lib/lessphp/Tree/Rule.php
Normal file → Executable file
@ -32,14 +32,14 @@ class Less_Tree_Rule extends Less_Tree{
|
||||
$this->variable = ( is_string($name) && $name[0] === '@');
|
||||
}
|
||||
|
||||
function accept($visitor) {
|
||||
public function accept($visitor) {
|
||||
$this->value = $visitor->visitObj( $this->value );
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Less_Tree::genCSS
|
||||
*/
|
||||
function genCSS( $output ){
|
||||
public function genCSS( $output ){
|
||||
|
||||
$output->add( $this->name . Less_Environment::$_outputMap[': '], $this->currentFileInfo, $this->index);
|
||||
try{
|
||||
@ -100,7 +100,7 @@ class Less_Tree_Rule extends Less_Tree{
|
||||
}
|
||||
|
||||
|
||||
function CompileName( $env, $name ){
|
||||
public function CompileName( $env, $name ){
|
||||
$output = new Less_Output();
|
||||
foreach($name as $n){
|
||||
$n->compile($env)->genCSS($output);
|
||||
@ -108,7 +108,7 @@ class Less_Tree_Rule extends Less_Tree{
|
||||
return $output->toString();
|
||||
}
|
||||
|
||||
function makeImportant(){
|
||||
public function makeImportant(){
|
||||
return new Less_Tree_Rule($this->name, $this->value, '!important', $this->merge, $this->index, $this->currentFileInfo, $this->inline);
|
||||
}
|
||||
|
||||
|
8
lib/lessphp/Tree/Ruleset.php
Normal file → Executable file
8
lib/lessphp/Tree/Ruleset.php
Normal file → Executable file
@ -24,10 +24,10 @@ class Less_Tree_Ruleset extends Less_Tree{
|
||||
public $multiMedia;
|
||||
public $allExtends;
|
||||
|
||||
var $ruleset_id;
|
||||
var $originalRuleset;
|
||||
public $ruleset_id;
|
||||
public $originalRuleset;
|
||||
|
||||
var $first_oelements;
|
||||
public $first_oelements;
|
||||
|
||||
public function SetRulesetIndex(){
|
||||
$this->ruleset_id = Less_Parser::$next_id++;
|
||||
@ -50,7 +50,7 @@ class Less_Tree_Ruleset extends Less_Tree{
|
||||
$this->SetRulesetIndex();
|
||||
}
|
||||
|
||||
function accept( $visitor ){
|
||||
public function accept( $visitor ){
|
||||
if( $this->paths ){
|
||||
$paths_len = count($this->paths);
|
||||
for($i = 0,$paths_len; $i < $paths_len; $i++ ){
|
||||
|
@ -11,13 +11,13 @@ class Less_Tree_RulesetCall extends Less_Tree{
|
||||
public $variable;
|
||||
public $type = "RulesetCall";
|
||||
|
||||
function __construct($variable){
|
||||
public function __construct($variable){
|
||||
$this->variable = $variable;
|
||||
}
|
||||
|
||||
function accept($visitor) {}
|
||||
public function accept($visitor) {}
|
||||
|
||||
function compile( $env ){
|
||||
public function compile( $env ){
|
||||
$variable = new Less_Tree_Variable($this->variable);
|
||||
$detachedRuleset = $variable->compile($env);
|
||||
return $detachedRuleset->callEval($env);
|
||||
|
12
lib/lessphp/Tree/Selector.php
Normal file → Executable file
12
lib/lessphp/Tree/Selector.php
Normal file → Executable file
@ -45,7 +45,7 @@ class Less_Tree_Selector extends Less_Tree{
|
||||
$this->CacheElements();
|
||||
}
|
||||
|
||||
function accept($visitor) {
|
||||
public function accept($visitor) {
|
||||
$this->elements = $visitor->visitArray($this->elements);
|
||||
$this->extendList = $visitor->visitArray($this->extendList);
|
||||
if( $this->condition ){
|
||||
@ -57,7 +57,7 @@ class Less_Tree_Selector extends Less_Tree{
|
||||
}
|
||||
}
|
||||
|
||||
function createDerived( $elements, $extendList = null, $evaldCondition = null ){
|
||||
public function createDerived( $elements, $extendList = null, $evaldCondition = null ){
|
||||
$newSelector = new Less_Tree_Selector( $elements, ($extendList ? $extendList : $this->extendList), null, $this->index, $this->currentFileInfo, $this->isReferenced);
|
||||
$newSelector->evaldCondition = $evaldCondition ? $evaldCondition : $this->evaldCondition;
|
||||
return $newSelector;
|
||||
@ -142,7 +142,7 @@ class Less_Tree_Selector extends Less_Tree{
|
||||
/**
|
||||
* @see Less_Tree::genCSS
|
||||
*/
|
||||
function genCSS( $output, $firstSelector = true ){
|
||||
public function genCSS( $output, $firstSelector = true ){
|
||||
|
||||
if( !$firstSelector && $this->elements[0]->combinator === "" ){
|
||||
$output->add(' ', $this->currentFileInfo, $this->index);
|
||||
@ -153,15 +153,15 @@ class Less_Tree_Selector extends Less_Tree{
|
||||
}
|
||||
}
|
||||
|
||||
function markReferenced(){
|
||||
public function markReferenced(){
|
||||
$this->isReferenced = true;
|
||||
}
|
||||
|
||||
function getIsReferenced(){
|
||||
public function getIsReferenced(){
|
||||
return !isset($this->currentFileInfo['reference']) || !$this->currentFileInfo['reference'] || $this->isReferenced;
|
||||
}
|
||||
|
||||
function getIsOutput(){
|
||||
public function getIsOutput(){
|
||||
return $this->evaldCondition;
|
||||
}
|
||||
|
||||
|
0
lib/lessphp/Tree/UnicodeDescriptor.php
Normal file → Executable file
0
lib/lessphp/Tree/UnicodeDescriptor.php
Normal file → Executable file
26
lib/lessphp/Tree/Unit.php
Normal file → Executable file
26
lib/lessphp/Tree/Unit.php
Normal file → Executable file
@ -13,19 +13,19 @@ class Less_Tree_Unit extends Less_Tree{
|
||||
public $backupUnit;
|
||||
public $type = 'Unit';
|
||||
|
||||
function __construct($numerator = array(), $denominator = array(), $backupUnit = null ){
|
||||
public function __construct($numerator = array(), $denominator = array(), $backupUnit = null ){
|
||||
$this->numerator = $numerator;
|
||||
$this->denominator = $denominator;
|
||||
$this->backupUnit = $backupUnit;
|
||||
}
|
||||
|
||||
function __clone(){
|
||||
public function __clone(){
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Less_Tree::genCSS
|
||||
*/
|
||||
function genCSS( $output ){
|
||||
public function genCSS( $output ){
|
||||
|
||||
if( $this->numerator ){
|
||||
$output->add( $this->numerator[0] );
|
||||
@ -37,7 +37,7 @@ class Less_Tree_Unit extends Less_Tree{
|
||||
}
|
||||
}
|
||||
|
||||
function toString(){
|
||||
public function toString(){
|
||||
$returnStr = implode('*',$this->numerator);
|
||||
foreach($this->denominator as $d){
|
||||
$returnStr .= '/'.$d;
|
||||
@ -45,7 +45,7 @@ class Less_Tree_Unit extends Less_Tree{
|
||||
return $returnStr;
|
||||
}
|
||||
|
||||
function __toString(){
|
||||
public function __toString(){
|
||||
return $this->toString();
|
||||
}
|
||||
|
||||
@ -53,33 +53,33 @@ class Less_Tree_Unit extends Less_Tree{
|
||||
/**
|
||||
* @param Less_Tree_Unit $other
|
||||
*/
|
||||
function compare($other) {
|
||||
public function compare($other) {
|
||||
return $this->is( $other->toString() ) ? 0 : -1;
|
||||
}
|
||||
|
||||
function is($unitString){
|
||||
public function is($unitString){
|
||||
return $this->toString() === $unitString;
|
||||
}
|
||||
|
||||
function isLength(){
|
||||
public function isLength(){
|
||||
$css = $this->toCSS();
|
||||
return !!preg_match('/px|em|%|in|cm|mm|pc|pt|ex/',$css);
|
||||
}
|
||||
|
||||
function isAngle() {
|
||||
public function isAngle() {
|
||||
return isset( Less_Tree_UnitConversions::$angle[$this->toCSS()] );
|
||||
}
|
||||
|
||||
function isEmpty(){
|
||||
public function isEmpty(){
|
||||
return !$this->numerator && !$this->denominator;
|
||||
}
|
||||
|
||||
function isSingular() {
|
||||
public function isSingular() {
|
||||
return count($this->numerator) <= 1 && !$this->denominator;
|
||||
}
|
||||
|
||||
|
||||
function usedUnits(){
|
||||
public function usedUnits(){
|
||||
$result = array();
|
||||
|
||||
foreach(Less_Tree_UnitConversions::$groups as $groupName){
|
||||
@ -101,7 +101,7 @@ class Less_Tree_Unit extends Less_Tree{
|
||||
return $result;
|
||||
}
|
||||
|
||||
function cancel(){
|
||||
public function cancel(){
|
||||
$counter = array();
|
||||
$backup = null;
|
||||
|
||||
|
0
lib/lessphp/Tree/UnitConversions.php
Normal file → Executable file
0
lib/lessphp/Tree/UnitConversions.php
Normal file → Executable file
4
lib/lessphp/Tree/Url.php
Normal file → Executable file
4
lib/lessphp/Tree/Url.php
Normal file → Executable file
@ -20,14 +20,14 @@ class Less_Tree_Url extends Less_Tree{
|
||||
$this->isEvald = $isEvald;
|
||||
}
|
||||
|
||||
function accept( $visitor ){
|
||||
public function accept( $visitor ){
|
||||
$this->value = $visitor->visitObj($this->value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Less_Tree::genCSS
|
||||
*/
|
||||
function genCSS( $output ){
|
||||
public function genCSS( $output ){
|
||||
$output->add( 'url(' );
|
||||
$this->value->genCSS( $output );
|
||||
$output->add( ')' );
|
||||
|
2
lib/lessphp/Tree/Value.php
Normal file → Executable file
2
lib/lessphp/Tree/Value.php
Normal file → Executable file
@ -15,7 +15,7 @@ class Less_Tree_Value extends Less_Tree{
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
function accept($visitor) {
|
||||
public function accept($visitor) {
|
||||
$this->value = $visitor->visitArray($this->value);
|
||||
}
|
||||
|
||||
|
7
lib/lessphp/Tree/Variable.php
Normal file → Executable file
7
lib/lessphp/Tree/Variable.php
Normal file → Executable file
@ -26,7 +26,7 @@ class Less_Tree_Variable extends Less_Tree{
|
||||
public function compile($env) {
|
||||
|
||||
if( $this->name[1] === '@' ){
|
||||
$v = new Less_Tree_Variable(substr($this->name, 1), $this->index + 1);
|
||||
$v = new Less_Tree_Variable(substr($this->name, 1), $this->index + 1, $this->currentFileInfo);
|
||||
$name = '@' . $v->compile($env)->value;
|
||||
}else{
|
||||
$name = $this->name;
|
||||
@ -40,12 +40,13 @@ class Less_Tree_Variable extends Less_Tree{
|
||||
|
||||
foreach($env->frames as $frame){
|
||||
if( $v = $frame->variable($name) ){
|
||||
$r = $v->value->compile($env);
|
||||
$this->evaluating = false;
|
||||
return $v->value->compile($env);
|
||||
return $r;
|
||||
}
|
||||
}
|
||||
|
||||
throw new Less_Exception_Compiler("variable " . $name . " is undefined", null, $this->index );
|
||||
throw new Less_Exception_Compiler("variable " . $name . " is undefined in file ".$this->currentFileInfo["filename"], null, $this->index, $this->currentFileInfo);
|
||||
}
|
||||
|
||||
}
|
||||
|
2
lib/lessphp/Version.php
Normal file → Executable file
2
lib/lessphp/Version.php
Normal file → Executable file
@ -8,7 +8,7 @@
|
||||
*/
|
||||
class Less_Version{
|
||||
|
||||
const version = '1.7.0.1'; // The current build number of less.php
|
||||
const version = '1.7.0.3'; // 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
|
||||
|
||||
|
10
lib/lessphp/Visitor.php
Normal file → Executable file
10
lib/lessphp/Visitor.php
Normal file → Executable file
@ -8,15 +8,15 @@
|
||||
*/
|
||||
class Less_Visitor{
|
||||
|
||||
var $methods = array();
|
||||
var $_visitFnCache = array();
|
||||
protected $methods = array();
|
||||
protected $_visitFnCache = array();
|
||||
|
||||
function __construct(){
|
||||
public function __construct(){
|
||||
$this->_visitFnCache = get_class_methods(get_class($this));
|
||||
$this->_visitFnCache = array_flip($this->_visitFnCache);
|
||||
}
|
||||
|
||||
function visitObj( $node ){
|
||||
public function visitObj( $node ){
|
||||
|
||||
$funcName = 'visit'.$node->type;
|
||||
if( isset($this->_visitFnCache[$funcName]) ){
|
||||
@ -40,7 +40,7 @@ class Less_Visitor{
|
||||
return $node;
|
||||
}
|
||||
|
||||
function visitArray( $nodes ){
|
||||
public function visitArray( $nodes ){
|
||||
|
||||
array_map( array($this,'visitObj'), $nodes);
|
||||
return $nodes;
|
||||
|
22
lib/lessphp/Visitor/extendFinder.php
Normal file → Executable file
22
lib/lessphp/Visitor/extendFinder.php
Normal file → Executable file
@ -12,7 +12,7 @@ class Less_Visitor_extendFinder extends Less_Visitor{
|
||||
public $allExtendsStack;
|
||||
public $foundExtends;
|
||||
|
||||
function __construct(){
|
||||
public function __construct(){
|
||||
$this->contexts = array();
|
||||
$this->allExtendsStack = array(array());
|
||||
parent::__construct();
|
||||
@ -21,21 +21,21 @@ class Less_Visitor_extendFinder extends Less_Visitor{
|
||||
/**
|
||||
* @param Less_Tree_Ruleset $root
|
||||
*/
|
||||
function run($root){
|
||||
public function run($root){
|
||||
$root = $this->visitObj($root);
|
||||
$root->allExtends =& $this->allExtendsStack[0];
|
||||
return $root;
|
||||
}
|
||||
|
||||
function visitRule($ruleNode, &$visitDeeper ){
|
||||
public function visitRule($ruleNode, &$visitDeeper ){
|
||||
$visitDeeper = false;
|
||||
}
|
||||
|
||||
function visitMixinDefinition( $mixinDefinitionNode, &$visitDeeper ){
|
||||
public function visitMixinDefinition( $mixinDefinitionNode, &$visitDeeper ){
|
||||
$visitDeeper = false;
|
||||
}
|
||||
|
||||
function visitRuleset($rulesetNode){
|
||||
public function visitRuleset($rulesetNode){
|
||||
|
||||
if( $rulesetNode->root ){
|
||||
return;
|
||||
@ -71,7 +71,7 @@ class Less_Visitor_extendFinder extends Less_Visitor{
|
||||
$this->contexts[] = $rulesetNode->selectors;
|
||||
}
|
||||
|
||||
function allExtendsStackPush($rulesetNode, $selectorPath, $extend, &$j){
|
||||
public function allExtendsStackPush($rulesetNode, $selectorPath, $extend, &$j){
|
||||
$this->foundExtends = true;
|
||||
$extend = clone $extend;
|
||||
$extend->findSelfSelectors( $selectorPath );
|
||||
@ -86,27 +86,27 @@ class Less_Visitor_extendFinder extends Less_Visitor{
|
||||
}
|
||||
|
||||
|
||||
function visitRulesetOut( $rulesetNode ){
|
||||
public function visitRulesetOut( $rulesetNode ){
|
||||
if( !is_object($rulesetNode) || !$rulesetNode->root ){
|
||||
array_pop($this->contexts);
|
||||
}
|
||||
}
|
||||
|
||||
function visitMedia( $mediaNode ){
|
||||
public function visitMedia( $mediaNode ){
|
||||
$mediaNode->allExtends = array();
|
||||
$this->allExtendsStack[] =& $mediaNode->allExtends;
|
||||
}
|
||||
|
||||
function visitMediaOut(){
|
||||
public function visitMediaOut(){
|
||||
array_pop($this->allExtendsStack);
|
||||
}
|
||||
|
||||
function visitDirective( $directiveNode ){
|
||||
public function visitDirective( $directiveNode ){
|
||||
$directiveNode->allExtends = array();
|
||||
$this->allExtendsStack[] =& $directiveNode->allExtends;
|
||||
}
|
||||
|
||||
function visitDirectiveOut(){
|
||||
public function visitDirectiveOut(){
|
||||
array_pop($this->allExtendsStack);
|
||||
}
|
||||
}
|
||||
|
0
lib/lessphp/Visitor/import.php
Normal file → Executable file
0
lib/lessphp/Visitor/import.php
Normal file → Executable file
12
lib/lessphp/Visitor/joinSelector.php
Normal file → Executable file
12
lib/lessphp/Visitor/joinSelector.php
Normal file → Executable file
@ -13,19 +13,19 @@ class Less_Visitor_joinSelector extends Less_Visitor{
|
||||
/**
|
||||
* @param Less_Tree_Ruleset $root
|
||||
*/
|
||||
function run( $root ){
|
||||
public function run( $root ){
|
||||
return $this->visitObj($root);
|
||||
}
|
||||
|
||||
function visitRule( $ruleNode, &$visitDeeper ){
|
||||
public function visitRule( $ruleNode, &$visitDeeper ){
|
||||
$visitDeeper = false;
|
||||
}
|
||||
|
||||
function visitMixinDefinition( $mixinDefinitionNode, &$visitDeeper ){
|
||||
public function visitMixinDefinition( $mixinDefinitionNode, &$visitDeeper ){
|
||||
$visitDeeper = false;
|
||||
}
|
||||
|
||||
function visitRuleset( $rulesetNode ){
|
||||
public function visitRuleset( $rulesetNode ){
|
||||
|
||||
$paths = array();
|
||||
|
||||
@ -54,11 +54,11 @@ class Less_Visitor_joinSelector extends Less_Visitor{
|
||||
$this->contexts[] = $paths; //different from less.js. Placed after joinSelectors() so that $this->contexts will get correct $paths
|
||||
}
|
||||
|
||||
function visitRulesetOut(){
|
||||
public function visitRulesetOut(){
|
||||
array_pop($this->contexts);
|
||||
}
|
||||
|
||||
function visitMedia($mediaNode) {
|
||||
public function visitMedia($mediaNode) {
|
||||
$context = end($this->contexts); //$context = $this->contexts[ count($this->contexts) - 1];
|
||||
|
||||
if( !count($context) || (is_object($context[0]) && $context[0]->multiMedia) ){
|
||||
|
0
lib/lessphp/Visitor/processExtends.php
Normal file → Executable file
0
lib/lessphp/Visitor/processExtends.php
Normal file → Executable file
28
lib/lessphp/Visitor/toCSS.php
Normal file → Executable file
28
lib/lessphp/Visitor/toCSS.php
Normal file → Executable file
@ -10,43 +10,43 @@ class Less_Visitor_toCSS extends Less_VisitorReplacing{
|
||||
|
||||
private $charset;
|
||||
|
||||
function __construct(){
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Less_Tree_Ruleset $root
|
||||
*/
|
||||
function run( $root ){
|
||||
public function run( $root ){
|
||||
return $this->visitObj($root);
|
||||
}
|
||||
|
||||
function visitRule( $ruleNode ){
|
||||
public function visitRule( $ruleNode ){
|
||||
if( $ruleNode->variable ){
|
||||
return array();
|
||||
}
|
||||
return $ruleNode;
|
||||
}
|
||||
|
||||
function visitMixinDefinition($mixinNode){
|
||||
public function visitMixinDefinition($mixinNode){
|
||||
// mixin definitions do not get eval'd - this means they keep state
|
||||
// so we have to clear that state here so it isn't used if toCSS is called twice
|
||||
$mixinNode->frames = array();
|
||||
return array();
|
||||
}
|
||||
|
||||
function visitExtend(){
|
||||
public function visitExtend(){
|
||||
return array();
|
||||
}
|
||||
|
||||
function visitComment( $commentNode ){
|
||||
public function visitComment( $commentNode ){
|
||||
if( $commentNode->isSilent() ){
|
||||
return array();
|
||||
}
|
||||
return $commentNode;
|
||||
}
|
||||
|
||||
function visitMedia( $mediaNode, &$visitDeeper ){
|
||||
public function visitMedia( $mediaNode, &$visitDeeper ){
|
||||
$mediaNode->accept($this);
|
||||
$visitDeeper = false;
|
||||
|
||||
@ -56,7 +56,7 @@ class Less_Visitor_toCSS extends Less_VisitorReplacing{
|
||||
return $mediaNode;
|
||||
}
|
||||
|
||||
function visitDirective( $directiveNode ){
|
||||
public function visitDirective( $directiveNode ){
|
||||
if( isset($directiveNode->currentFileInfo['reference']) && (!property_exists($directiveNode,'isReferenced') || !$directiveNode->isReferenced) ){
|
||||
return array();
|
||||
}
|
||||
@ -80,7 +80,7 @@ class Less_Visitor_toCSS extends Less_VisitorReplacing{
|
||||
return $directiveNode;
|
||||
}
|
||||
|
||||
function checkPropertiesInRoot( $rulesetNode ){
|
||||
public function checkPropertiesInRoot( $rulesetNode ){
|
||||
|
||||
if( !$rulesetNode->firstRoot ){
|
||||
return;
|
||||
@ -95,7 +95,7 @@ class Less_Visitor_toCSS extends Less_VisitorReplacing{
|
||||
}
|
||||
|
||||
|
||||
function visitRuleset( $rulesetNode, &$visitDeeper ){
|
||||
public function visitRuleset( $rulesetNode, &$visitDeeper ){
|
||||
|
||||
$visitDeeper = false;
|
||||
|
||||
@ -192,7 +192,7 @@ class Less_Visitor_toCSS extends Less_VisitorReplacing{
|
||||
return $paths;
|
||||
}
|
||||
|
||||
function _removeDuplicateRules( &$rules ){
|
||||
protected function _removeDuplicateRules( &$rules ){
|
||||
// remove duplicates
|
||||
$ruleCache = array();
|
||||
for( $i = count($rules)-1; $i >= 0 ; $i-- ){
|
||||
@ -219,7 +219,7 @@ class Less_Visitor_toCSS extends Less_VisitorReplacing{
|
||||
}
|
||||
}
|
||||
|
||||
function _mergeRules( &$rules ){
|
||||
protected function _mergeRules( &$rules ){
|
||||
$groups = array();
|
||||
|
||||
//obj($rules);
|
||||
@ -271,7 +271,7 @@ class Less_Visitor_toCSS extends Less_VisitorReplacing{
|
||||
|
||||
}
|
||||
|
||||
static function toExpression($values){
|
||||
public static function toExpression($values){
|
||||
$mapped = array();
|
||||
foreach($values as $p){
|
||||
$mapped[] = $p->value;
|
||||
@ -279,7 +279,7 @@ class Less_Visitor_toCSS extends Less_VisitorReplacing{
|
||||
return new Less_Tree_Expression( $mapped );
|
||||
}
|
||||
|
||||
static function toValue($values){
|
||||
public static function toValue($values){
|
||||
//return new Less_Tree_Value($values); ??
|
||||
|
||||
$mapped = array();
|
||||
|
6
lib/lessphp/VisitorReplacing.php
Normal file → Executable file
6
lib/lessphp/VisitorReplacing.php
Normal file → Executable file
@ -8,7 +8,7 @@
|
||||
*/
|
||||
class Less_VisitorReplacing extends Less_Visitor{
|
||||
|
||||
function visitObj( $node ){
|
||||
public function visitObj( $node ){
|
||||
|
||||
$funcName = 'visit'.$node->type;
|
||||
if( isset($this->_visitFnCache[$funcName]) ){
|
||||
@ -34,7 +34,7 @@ class Less_VisitorReplacing extends Less_Visitor{
|
||||
return $node;
|
||||
}
|
||||
|
||||
function visitArray( $nodes ){
|
||||
public function visitArray( $nodes ){
|
||||
|
||||
$newNodes = array();
|
||||
foreach($nodes as $node){
|
||||
@ -50,7 +50,7 @@ class Less_VisitorReplacing extends Less_Visitor{
|
||||
return $newNodes;
|
||||
}
|
||||
|
||||
function flatten( $arr, &$out ){
|
||||
public function flatten( $arr, &$out ){
|
||||
|
||||
foreach($arr as $item){
|
||||
if( !is_array($item) ){
|
||||
|
@ -1,7 +1,7 @@
|
||||
less.php
|
||||
--------
|
||||
|
||||
Tag downloaded: v1.7.0.1
|
||||
Tag downloaded: v1.7.0.3
|
||||
Downloaded from: https://github.com/oyejorge/less.php
|
||||
|
||||
All the files from the folder lib/Less are copied in
|
||||
|
@ -32,7 +32,7 @@
|
||||
<location>lessphp</location>
|
||||
<name>less.php</name>
|
||||
<license>Apache</license>
|
||||
<version>1.7.0.1</version>
|
||||
<version>1.7.0.3</version>
|
||||
<licenseversion>2.0</licenseversion>
|
||||
</library>
|
||||
<library>
|
||||
|
Loading…
x
Reference in New Issue
Block a user