Merge branch 'MDL-35155-27' of git://github.com/danpoltawski/moodle into MOODLE_27_STABLE
[moodle.git] / lib / lessphp / Tree / Extend.php
blob98402560489f7fc8bd198af89e6c461a100fcd55
1 <?php
3 /**
4 * Extend
6 * @package Less
7 * @subpackage tree
8 */
9 class Less_Tree_Extend extends Less_Tree{
11 public $selector;
12 public $option;
13 public $index;
14 public $selfSelectors = array();
15 public $allowBefore;
16 public $allowAfter;
17 public $firstExtendOnThisSelectorPath;
18 public $type = 'Extend';
19 public $ruleset;
22 public $object_id;
23 public $parent_ids = array();
25 /**
26 * @param integer $index
28 function __construct($selector, $option, $index){
29 static $i = 0;
30 $this->selector = $selector;
31 $this->option = $option;
32 $this->index = $index;
34 switch($option){
35 case "all":
36 $this->allowBefore = true;
37 $this->allowAfter = true;
38 break;
39 default:
40 $this->allowBefore = false;
41 $this->allowAfter = false;
42 break;
45 $this->object_id = $i++;
46 $this->parent_ids = array($this->object_id);
49 function accept( $visitor ){
50 $this->selector = $visitor->visitObj( $this->selector );
53 function compile( $env ){
54 Less_Parser::$has_extends = true;
55 $this->selector = $this->selector->compile($env);
56 return $this;
57 //return new Less_Tree_Extend( $this->selector->compile($env), $this->option, $this->index);
60 function findSelfSelectors( $selectors ){
61 $selfElements = array();
64 for( $i = 0, $selectors_len = count($selectors); $i < $selectors_len; $i++ ){
65 $selectorElements = $selectors[$i]->elements;
66 // duplicate the logic in genCSS function inside the selector node.
67 // future TODO - move both logics into the selector joiner visitor
68 if( $i && $selectorElements && $selectorElements[0]->combinator === "") {
69 $selectorElements[0]->combinator = ' ';
71 $selfElements = array_merge( $selfElements, $selectors[$i]->elements );
74 $this->selfSelectors = array(new Less_Tree_Selector($selfElements));