[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/lib/lessphp/Tree/ -> Extend.php (source)

   1  <?php
   2  
   3  /**
   4   * Extend
   5   *
   6   * @package Less
   7   * @subpackage tree
   8   */
   9  class Less_Tree_Extend extends Less_Tree{
  10  
  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;
  20  
  21  
  22      public $object_id;
  23      public $parent_ids = array();
  24  
  25      /**
  26       * @param integer $index
  27       */
  28      public function __construct($selector, $option, $index){
  29          static $i = 0;
  30          $this->selector = $selector;
  31          $this->option = $option;
  32          $this->index = $index;
  33  
  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;
  43          }
  44  
  45          $this->object_id = $i++;
  46          $this->parent_ids = array($this->object_id);
  47      }
  48  
  49      public function accept( $visitor ){
  50          $this->selector = $visitor->visitObj( $this->selector );
  51      }
  52  
  53      public 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);
  58      }
  59  
  60      public function findSelfSelectors( $selectors ){
  61          $selfElements = array();
  62  
  63  
  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 = ' ';
  70              }
  71              $selfElements = array_merge( $selfElements, $selectors[$i]->elements );
  72          }
  73  
  74          $this->selfSelectors = array(new Less_Tree_Selector($selfElements));
  75      }
  76  
  77  }


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1