Esempio n. 1
0
 /**
  * Parse the import url and return the rules
  *
  * @return Avada_Less_Tree_Media|array
  */
 public function ParseImport($full_path, $uri, $env)
 {
     $import_env = clone $env;
     if (isset($this->options['reference']) && $this->options['reference'] || isset($this->currentFileInfo['reference'])) {
         $import_env->currentFileInfo['reference'] = true;
     }
     if (isset($this->options['multiple']) && $this->options['multiple']) {
         $import_env->importMultiple = true;
     }
     $parser = new avada_Less_Parser($import_env);
     $root = $parser->parseFile($full_path, $uri, true);
     $ruleset = new Avada_Less_Tree_Ruleset(array(), $root->rules);
     $ruleset->evalImports($import_env);
     return $this->features ? new Avada_Less_Tree_Media($ruleset->rules, $this->features->value) : $ruleset->rules;
 }
Esempio n. 2
0
 public function compileFile($fname, $outFname = null)
 {
     if (!is_readable($fname)) {
         throw new Exception('load error: failed to find ' . $fname);
     }
     $pi = pathinfo($fname);
     $oldImport = $this->importDir;
     $this->importDir = (array) $this->importDir;
     $this->importDir[] = realpath($pi['dirname']) . '/';
     $this->allParsedFiles = array();
     $this->addParsedFile($fname);
     $parser = new avada_Less_Parser();
     $parser->SetImportDirs($this->getImportDirs());
     foreach ($this->libFunctions as $name => $func) {
         $parser->registerFunction($name, $func);
     }
     $parser->parseFile($fname);
     if (count($this->registeredVars)) {
         $parser->ModifyVars($this->registeredVars);
     }
     $out = $parser->getCss();
     $parsed = avada_Less_Parser::AllParsedFiles();
     foreach ($parsed as $file) {
         $this->addParsedFile($file);
     }
     $this->importDir = $oldImport;
     if ($outFname !== null) {
         return file_put_contents($outFname, $out);
     }
     return $out;
 }