[ Index ] |
PHP Cross Reference of moodle-2.8 |
[Summary view] [Print] [Text view]
1 <?php 2 3 4 /** 5 * Environment 6 * 7 * @package Less 8 * @subpackage environment 9 */ 10 class Less_Environment{ 11 12 //public $paths = array(); // option - unmodified - paths to search for imports on 13 //public static $files = array(); // list of files that have been imported, used for import-once 14 //public $rootpath; // option - rootpath to append to URL's 15 //public static $strictImports = null; // option - 16 //public $insecure; // option - whether to allow imports from insecure ssl hosts 17 //public $processImports; // option - whether to process imports. if false then imports will not be imported 18 //public $javascriptEnabled; // option - whether JavaScript is enabled. if undefined, defaults to true 19 //public $useFileCache; // browser only - whether to use the per file session cache 20 public $currentFileInfo; // information about the current file - for error reporting and importing and making urls relative etc. 21 22 public $importMultiple = false; // whether we are currently importing multiple copies 23 24 25 /** 26 * @var array 27 */ 28 public $frames = array(); 29 30 /** 31 * @var array 32 */ 33 public $mediaBlocks = array(); 34 35 /** 36 * @var array 37 */ 38 public $mediaPath = array(); 39 40 public static $parensStack = 0; 41 42 public static $tabLevel = 0; 43 44 public static $lastRule = false; 45 46 public static $_outputMap; 47 48 public static $mixin_stack = 0; 49 50 51 public function Init(){ 52 53 self::$parensStack = 0; 54 self::$tabLevel = 0; 55 self::$lastRule = false; 56 self::$mixin_stack = 0; 57 58 if( Less_Parser::$options['compress'] ){ 59 60 Less_Environment::$_outputMap = array( 61 ',' => ',', 62 ': ' => ':', 63 '' => '', 64 ' ' => ' ', 65 ':' => ' :', 66 '+' => '+', 67 '~' => '~', 68 '>' => '>', 69 '|' => '|', 70 '^' => '^', 71 '^^' => '^^' 72 ); 73 74 }else{ 75 76 Less_Environment::$_outputMap = array( 77 ',' => ', ', 78 ': ' => ': ', 79 '' => '', 80 ' ' => ' ', 81 ':' => ' :', 82 '+' => ' + ', 83 '~' => ' ~ ', 84 '>' => ' > ', 85 '|' => '|', 86 '^' => ' ^ ', 87 '^^' => ' ^^ ' 88 ); 89 90 } 91 } 92 93 94 public function copyEvalEnv($frames = array() ){ 95 $new_env = new Less_Environment(); 96 $new_env->frames = $frames; 97 return $new_env; 98 } 99 100 101 public static function isMathOn(){ 102 return !Less_Parser::$options['strictMath'] || Less_Environment::$parensStack; 103 } 104 105 public static function isPathRelative($path){ 106 return !preg_match('/^(?:[a-z-]+:|\/)/',$path); 107 } 108 109 110 /** 111 * Canonicalize a path by resolving references to '/./', '/../' 112 * Does not remove leading "../" 113 * @param string path or url 114 * @return string Canonicalized path 115 * 116 */ 117 static function normalizePath($path){ 118 119 $segments = explode('/',$path); 120 $segments = array_reverse($segments); 121 122 $path = array(); 123 $path_len = 0; 124 125 while( $segments ){ 126 $segment = array_pop($segments); 127 switch( $segment ) { 128 129 case '.': 130 break; 131 132 case '..': 133 if( !$path_len || ( $path[$path_len-1] === '..') ){ 134 $path[] = $segment; 135 $path_len++; 136 }else{ 137 array_pop($path); 138 $path_len--; 139 } 140 break; 141 142 default: 143 $path[] = $segment; 144 $path_len++; 145 break; 146 } 147 } 148 149 return implode('/',$path); 150 } 151 152 153 public function unshiftFrame($frame){ 154 array_unshift($this->frames, $frame); 155 } 156 157 public function shiftFrame(){ 158 return array_shift($this->frames); 159 } 160 161 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:29:05 2014 | Cross-referenced by PHPXref 0.7.1 |