예제 #1
0
 /**
  * Clean aggregation cache directory
  *
  * @return void
  */
 public function doActionCleanAggregationCache()
 {
     \Includes\Utils\FileManager::unlinkRecursive(LC_DIR_CACHE_RESOURCES);
     \Less_Cache::SetCacheDir(LC_DIR_DATACACHE);
     \Less_Cache::CleanCache();
     \XLite\Core\TopMessage::addInfo('Aggregation cache has been cleaned');
 }
 /**
  * Return the results of parsePrimary for $file_path
  * Use cache and save cached results if possible
  *
  * @param string|null $file_path
  */
 private function GetRules($file_path)
 {
     $this->SetInput($file_path);
     $cache_file = $this->CacheFile($file_path);
     if ($cache_file) {
         if (Less_Parser::$options['cache_method'] == 'callback') {
             if (is_callable(Less_Parser::$options['cache_callback_get'])) {
                 $cache = call_user_func_array(Less_Parser::$options['cache_callback_get'], array($this, $file_path, $cache_file));
                 if ($cache) {
                     $this->UnsetInput();
                     return $cache;
                 }
             }
         } elseif (file_exists($cache_file)) {
             switch (Less_Parser::$options['cache_method']) {
                 // Using serialize
                 // Faster but uses more memory
                 case 'serialize':
                     $cache = unserialize(file_get_contents($cache_file));
                     if ($cache) {
                         touch($cache_file);
                         $this->UnsetInput();
                         return $cache;
                     }
                     break;
                     // Using generated php code
                 // Using generated php code
                 case 'var_export':
                 case 'php':
                     $this->UnsetInput();
                     return include $cache_file;
             }
         }
     }
     $rules = $this->parsePrimary();
     if ($this->pos < $this->input_len) {
         throw new Less_Exception_Chunk($this->input, null, $this->furthest, $this->env->currentFileInfo);
     }
     $this->UnsetInput();
     //save the cache
     if ($cache_file) {
         if (Less_Parser::$options['cache_method'] == 'callback') {
             if (is_callable(Less_Parser::$options['cache_callback_set'])) {
                 call_user_func_array(Less_Parser::$options['cache_callback_set'], array($this, $file_path, $cache_file, $rules));
             }
         } else {
             //msg('write cache file');
             switch (Less_Parser::$options['cache_method']) {
                 case 'serialize':
                     file_put_contents($cache_file, serialize($rules));
                     break;
                 case 'php':
                     file_put_contents($cache_file, '<?php return ' . self::ArgString($rules) . '; ?>');
                     break;
                 case 'var_export':
                     //Requires __set_state()
                     file_put_contents($cache_file, '<?php return ' . var_export($rules, true) . '; ?>');
                     break;
             }
             Less_Cache::CleanCache();
         }
     }
     return $rules;
 }
예제 #3
0
 /**
  * Clean cache
  */
 protected function cleanCache()
 {
     \Less_Cache::$gc_lifetime = 2;
     // Unchangeable?
     \Less_Cache::CleanCache();
 }
예제 #4
0
 /**
  * Compile scripts for the specified theme.
  *
  * @param string $theme Theme name
  *
  * @return void
  */
 protected function processTheme($theme)
 {
     $lessFiles = $this->getAllLessFiles($theme);
     if (empty($lessFiles)) {
         $this->logMessage("No LESS in " . $theme);
         return;
     }
     $this->logMessage("Processing " . $theme);
     foreach ($lessFiles as $less) {
         if (is_string($less)) {
             $this->compileFile($theme, $less);
         }
     }
     \Less_Cache::SetCacheDir(APPLICATION_PATH . '/themes/' . $theme . '/css/less/');
     \Less_Cache::CleanCache();
     // deletes week old files
 }
예제 #5
0
파일: Less.php 프로젝트: jwlayug/jbst
 /**
  * Return the results of parsePrimary for $file_path
  * Use cache and save cached results if possible
  *
  * @param string|null $file_path
  */
 private function GetRules($file_path)
 {
     $this->SetInput($file_path);
     $cache_file = false;
     if ($file_path) {
         WP_Filesystem(Less_Parser::$options['credits']);
         global $wp_filesystem;
         $this->input = $wp_filesystem->get_contents($file_path);
     }
     $rules = $this->parsePrimary();
     if ($this->pos < $this->input_len) {
         throw new Less_Exception_Chunk($this->input, null, $this->furthest, $this->env->currentFileInfo);
     }
     $this->UnsetInput();
     //save the cache
     if ($cache_file) {
         //msg('write cache file');
         switch (Less_Parser::$options['cache_method']) {
             case 'serialize':
                 fpc($cache_file, serialize($rules));
                 break;
             case 'php':
                 fpc($cache_file, '<?php return ' . self::ArgString($rules) . '; ?>');
                 break;
             case 'var_export':
                 //Requires __set_state()
                 fpc($cache_file, '<?php return ' . var_export($rules, true) . '; ?>');
                 break;
         }
         Less_Cache::CleanCache();
     }
     return $rules;
 }
예제 #6
0
파일: less.php 프로젝트: Tommar/vino2
 /**
  * Return the results of parsePrimary for $file_path
  * Use cache and save cached results if possible
  *
  * @param string|null $file_path
  */
 private function GetRules($file_path)
 {
     $cache_file = false;
     if ($file_path) {
         if (Less_Parser::$options['cache_method']) {
             $cache_file = $this->CacheFile($file_path);
             if ($cache_file && file_exists($cache_file)) {
                 switch (Less_Parser::$options['cache_method']) {
                     // Using serialize
                     // Faster but uses more memory
                     case 'serialize':
                         $cache = unserialize(file_get_contents($cache_file));
                         if ($cache) {
                             touch($cache_file);
                             return $cache;
                         }
                         break;
                         // Using generated php code
                     // Using generated php code
                     case 'var_export':
                     case 'php':
                         return include $cache_file;
                 }
             }
         }
         $this->input = file_get_contents($file_path);
     }
     $this->pos = $this->farthest = 0;
     // Remove potential UTF Byte Order Mark
     $this->input = preg_replace('/\\G\\xEF\\xBB\\xBF/', '', $this->input);
     $this->input_len = strlen($this->input);
     $this->setFileContent();
     $rules = $this->parsePrimary();
     if ($this->pos < $this->input_len) {
         throw new Less_Exception_Chunk($this->input, null, $this->farthest, $this->env->currentFileInfo);
     }
     // free up a little memory
     unset($this->input, $this->pos);
     //save the cache
     if ($cache_file) {
         switch (Less_Parser::$options['cache_method']) {
             case 'serialize':
                 file_put_contents($cache_file, serialize($rules));
                 break;
             case 'php':
                 file_put_contents($cache_file, '<?php return ' . self::ArgString($rules) . '; ?>');
                 break;
             case 'var_export':
                 /**
                  * Requires __set_state()
                  */
                 file_put_contents($cache_file, '<?php return ' . var_export($rules, true) . '; ?>');
                 break;
         }
         Less_Cache::CleanCache();
     }
     return $rules;
 }
예제 #7
0
<?php

require locate_template('/lib/less/Less.php');
// Set our options for the less compiler
$bitstrappier_less_options = array('compress' => true, 'cache_dir' => get_stylesheet_directory() . '/assets/css/cache', 'cache_method' => 'php');
// The LESS file to compile and cache.
$bitstrappier_less_file = array(get_stylesheet_directory() . '/assets/less/main.less' => get_bloginfo('template_url'));
// Define the LESS file to compile, in this case the main.less
$bitstrappier_css_file_name = Less_Cache::Get($bitstrappier_less_file, $bitstrappier_less_options);
Less_Cache::CleanCache();
// Store the CSS file name in a URL with its template path
$s8_stylesheet_url = get_bloginfo('template_url') . '/assets/css/cache/' . $bitstrappier_css_file_name;