[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/lib/lessphp/Visitor/ -> import.php (source)

   1  <?php
   2  
   3  /*
   4  class Less_Visitor_import extends Less_VisitorReplacing{
   5  
   6      public $_visitor;
   7      public $_importer;
   8      public $importCount;
   9  
  10      function __construct( $evalEnv ){
  11          $this->env = $evalEnv;
  12          $this->importCount = 0;
  13          parent::__construct();
  14      }
  15  
  16  
  17      function run( $root ){
  18          $root = $this->visitObj($root);
  19          $this->isFinished = true;
  20  
  21          //if( $this->importCount === 0) {
  22          //    $this->_finish();
  23          //}
  24      }
  25  
  26      function visitImport($importNode, &$visitDeeper ){
  27          $importVisitor = $this;
  28          $inlineCSS = $importNode->options['inline'];
  29  
  30          if( !$importNode->css || $inlineCSS ){
  31              $evaldImportNode = $importNode->compileForImport($this->env);
  32  
  33              if( $evaldImportNode && (!$evaldImportNode->css || $inlineCSS) ){
  34                  $importNode = $evaldImportNode;
  35                  $this->importCount++;
  36                  $env = clone $this->env;
  37  
  38                  if( (isset($importNode->options['multiple']) && $importNode->options['multiple']) ){
  39                      $env->importMultiple = true;
  40                  }
  41  
  42                  //get path & uri
  43                  $path_and_uri = null;
  44                  if( is_callable(Less_Parser::$options['import_callback']) ){
  45                      $path_and_uri = call_user_func(Less_Parser::$options['import_callback'],$importNode);
  46                  }
  47  
  48                  if( !$path_and_uri ){
  49                      $path_and_uri = $importNode->PathAndUri();
  50                  }
  51  
  52                  if( $path_and_uri ){
  53                      list($full_path, $uri) = $path_and_uri;
  54                  }else{
  55                      $full_path = $uri = $importNode->getPath();
  56                  }
  57  
  58  
  59                  //import once
  60                  if( $importNode->skip( $full_path, $env) ){
  61                      return array();
  62                  }
  63  
  64                  if( $importNode->options['inline'] ){
  65                      //todo needs to reference css file not import
  66                      //$contents = new Less_Tree_Anonymous($importNode->root, 0, array('filename'=>$importNode->importedFilename), true );
  67  
  68                      Less_Parser::AddParsedFile($full_path);
  69                      $contents = new Less_Tree_Anonymous( file_get_contents($full_path), 0, array(), true );
  70  
  71                      if( $importNode->features ){
  72                          return new Less_Tree_Media( array($contents), $importNode->features->value );
  73                      }
  74  
  75                      return array( $contents );
  76                  }
  77  
  78  
  79                  // css ?
  80                  if( $importNode->css ){
  81                      $features = ( $importNode->features ? $importNode->features->compile($env) : null );
  82                      return new Less_Tree_Import( $importNode->compilePath( $env), $features, $importNode->options, $this->index);
  83                  }
  84  
  85                  return $importNode->ParseImport( $full_path, $uri, $env );
  86              }
  87  
  88          }
  89  
  90          $visitDeeper = false;
  91          return $importNode;
  92      }
  93  
  94  
  95      function visitRule( $ruleNode, &$visitDeeper ){
  96          $visitDeeper = false;
  97          return $ruleNode;
  98      }
  99  
 100      function visitDirective($directiveNode, $visitArgs){
 101          array_unshift($this->env->frames,$directiveNode);
 102          return $directiveNode;
 103      }
 104  
 105      function visitDirectiveOut($directiveNode) {
 106          array_shift($this->env->frames);
 107      }
 108  
 109      function visitMixinDefinition($mixinDefinitionNode, $visitArgs) {
 110          array_unshift($this->env->frames,$mixinDefinitionNode);
 111          return $mixinDefinitionNode;
 112      }
 113  
 114      function visitMixinDefinitionOut($mixinDefinitionNode) {
 115          array_shift($this->env->frames);
 116      }
 117  
 118      function visitRuleset($rulesetNode, $visitArgs) {
 119          array_unshift($this->env->frames,$rulesetNode);
 120          return $rulesetNode;
 121      }
 122  
 123      function visitRulesetOut($rulesetNode) {
 124          array_shift($this->env->frames);
 125      }
 126  
 127      function visitMedia($mediaNode, $visitArgs) {
 128          array_unshift($this->env->frames, $mediaNode->ruleset);
 129          return $mediaNode;
 130      }
 131  
 132      function visitMediaOut($mediaNode) {
 133          array_shift($this->env->frames);
 134      }
 135  
 136  }
 137  */
 138  
 139  


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