Ejemplo n.º 1
0
 public function compare($x)
 {
     if (!avada_Less_Parser::is_method($x, 'toCSS')) {
         return -1;
     }
     $left = $this->toCSS();
     $right = $x->toCSS();
     if ($left === $right) {
         return 0;
     }
     return $left < $right ? -1 : 1;
 }
Ejemplo n.º 2
0
 public static function Cache(&$less_files, $parser_options = array())
 {
     // get less.php if it exists
     $file = dirname(__FILE__) . '/Less.php';
     if (file_exists($file) && !class_exists('avada_Less_Parser')) {
         require_once $file;
     }
     $parser_options['cache_dir'] = avada_Less_Cache::$cache_dir;
     $parser = new avada_Less_Parser($parser_options);
     // combine files
     foreach ($less_files as $file_path => $uri_or_less) {
         //treat as less markup if there are newline characters
         if (strpos($uri_or_less, "\n") !== false) {
             $parser->Parse($uri_or_less);
             continue;
         }
         $parser->ParseFile($file_path, $uri_or_less);
     }
     $compiled = $parser->getCss();
     $less_files = $parser->allParsedFiles();
     return $compiled;
 }
Ejemplo n.º 3
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;
 }