[ Index ] |
PHP Cross Reference of moodle-2.8 |
[Summary view] [Print] [Text view]
1 <?php 2 3 4 /** 5 * Call 6 * 7 * @package Less 8 * @subpackage tree 9 */ 10 class Less_Tree_Call extends Less_Tree{ 11 public $value; 12 13 var $name; 14 var $args; 15 var $index; 16 var $currentFileInfo; 17 public $type = 'Call'; 18 19 public function __construct($name, $args, $index, $currentFileInfo = null ){ 20 $this->name = $name; 21 $this->args = $args; 22 $this->index = $index; 23 $this->currentFileInfo = $currentFileInfo; 24 } 25 26 function accept( $visitor ){ 27 $this->args = $visitor->visitArray( $this->args ); 28 } 29 30 // 31 // When evaluating a function call, 32 // we either find the function in `tree.functions` [1], 33 // in which case we call it, passing the evaluated arguments, 34 // or we simply print it out as it appeared originally [2]. 35 // 36 // The *functions.js* file contains the built-in functions. 37 // 38 // The reason why we evaluate the arguments, is in the case where 39 // we try to pass a variable to a function, like: `saturate(@color)`. 40 // The function should receive the value, not the variable. 41 // 42 public function compile($env=null){ 43 $args = array(); 44 foreach($this->args as $a){ 45 $args[] = $a->compile($env); 46 } 47 48 $nameLC = strtolower($this->name); 49 switch($nameLC){ 50 case '%': 51 $nameLC = '_percent'; 52 break; 53 54 case 'get-unit': 55 $nameLC = 'getunit'; 56 break; 57 58 case 'data-uri': 59 $nameLC = 'datauri'; 60 break; 61 62 case 'svg-gradient': 63 $nameLC = 'svggradient'; 64 break; 65 } 66 67 $result = null; 68 if( $nameLC === 'default' ){ 69 $result = Less_Tree_DefaultFunc::compile(); 70 71 }else{ 72 73 if( method_exists('Less_Functions',$nameLC) ){ // 1. 74 try { 75 76 $func = new Less_Functions($env, $this->currentFileInfo); 77 $result = call_user_func_array( array($func,$nameLC),$args); 78 79 } catch (Exception $e) { 80 throw new Less_Exception_Compiler('error evaluating function `' . $this->name . '` '.$e->getMessage().' index: '. $this->index); 81 } 82 } 83 } 84 85 if( $result !== null ){ 86 return $result; 87 } 88 89 90 return new Less_Tree_Call( $this->name, $args, $this->index, $this->currentFileInfo ); 91 } 92 93 /** 94 * @see Less_Tree::genCSS 95 */ 96 public function genCSS( $output ){ 97 98 $output->add( $this->name . '(', $this->currentFileInfo, $this->index ); 99 $args_len = count($this->args); 100 for($i = 0; $i < $args_len; $i++ ){ 101 $this->args[$i]->genCSS( $output ); 102 if( $i + 1 < $args_len ){ 103 $output->add( ', ' ); 104 } 105 } 106 107 $output->add( ')' ); 108 } 109 110 111 //public function toCSS(){ 112 // return $this->compile()->toCSS(); 113 //} 114 115 }
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 |