9 class Less_Tree_Url
extends Less_Tree
{
13 public $currentFileInfo;
17 public function __construct($value, $currentFileInfo = null, $isEvald = null){
18 $this->value
= $value;
19 $this->currentFileInfo
= $currentFileInfo;
20 $this->isEvald
= $isEvald;
23 function accept( $visitor ){
24 $this->value
= $visitor->visitObj($this->value
);
28 * @see Less_Tree::genCSS
30 function genCSS( $output ){
31 $output->add( 'url(' );
32 $this->value
->genCSS( $output );
37 * @param Less_Functions $ctx
39 public function compile($ctx){
40 $val = $this->value
->compile($ctx);
42 if( !$this->isEvald
){
43 // Add the base path if the URL is relative
44 if( Less_Parser
::$options['relativeUrls']
45 && $this->currentFileInfo
46 && is_string($val->value
)
47 && Less_Environment
::isPathRelative($val->value
)
49 $rootpath = $this->currentFileInfo
['uri_root'];
51 $rootpath = preg_replace('/[\(\)\'"\s]/', '\\$1', $rootpath );
53 $val->value
= $rootpath . $val->value
;
56 $val->value
= Less_Environment
::normalizePath( $val->value
);
59 // Add cache buster if enabled
60 if( Less_Parser
::$options['urlArgs'] ){
61 if( !preg_match('/^\s*data:/',$val->value
) ){
62 $delimiter = strpos($val->value
,'?') === false ?
'?' : '&';
63 $urlArgs = $delimiter . Less_Parser
::$options['urlArgs'];
64 $hash_pos = strpos($val->value
,'#');
65 if( $hash_pos !== false ){
66 $val->value
= substr_replace($val->value
,$urlArgs, $hash_pos, 0);
68 $val->value
.= $urlArgs;
73 return new Less_Tree_URL($val, $this->currentFileInfo
, true);