예제 #1
0
파일: Cache.php 프로젝트: mathewdenis/avada
 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;
 }
예제 #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;
 }