예제 #1
0
파일: Gpeasy.php 프로젝트: jbzoo/less
 /**
  * @return \Less_Parser
  */
 protected function _initCompiler()
 {
     if ($this->_compiler) {
         return $this->_compiler;
     }
     $options = array('compress' => false, 'strictUnits' => false, 'strictMath' => false, 'relativeUrls' => true, 'cache_method' => false, 'sourceMap' => false, 'indentation' => '    ');
     if ($this->_isDebug()) {
         $options['sourceMap'] = true;
         $options['sourceMapRootpath'] = $this->_options->get('root_path');
         $options['sourceMapBasepath'] = $this->_options->get('root_path');
     }
     // Create compilier
     $this->_compiler = new \Less_Parser($options);
     $this->_compiler->Reset();
     // Global depends
     $mixins = $this->_options->get('autoload');
     foreach ($mixins as $mixin) {
         $this->_compiler->parseFile($mixin);
     }
     // Add custom vars
     $this->_compiler->ModifyVars((array) $this->_options->get('global_vars', []));
     // Set paths
     $importPaths = (array) $this->_options->get('import_paths', []);
     foreach ($importPaths as $fullPath => $relPath) {
         $this->setImportPath($fullPath, $relPath);
     }
     // Set cutsom functions
     $functions = (array) $this->_options->get('functions', [], 'arr');
     foreach ($functions as $name => $function) {
         $this->_compiler->registerFunction($name, $function);
     }
     return $this->_compiler;
 }
예제 #2
0
 public function Compile($less_files, $out_name, $modify_vars = [], $bootstrap_less = "mixins", $mediawiki_less = "mixins")
 {
     $lessphp = new \Less_Parser($this->cache_dir);
     switch ($bootstrap_less) {
         case "mixins":
             $lessphp->parseFile($this->bootstrap_dir . "/variables.less", "");
             $lessphp->parseFile(__DIR__ . "/custom_variables.less", "");
             $lessphp->parseFile($this->bootstrap_mixin, $this->bootstrap_mixin_url);
             break;
         case "full":
             $lessphp->SetImportDirs([$this->bootstrap_dir]);
             $lessphp->parseFile(__DIR__ . "/bootstrap.less", "");
             break;
         case "off":
             break;
     }
     switch ($mediawiki_less) {
         case "mixins":
             $lessphp->parseFile($this->mediawiki_mixin, $this->mediawiki_mixin_url);
             break;
         case "off":
             break;
     }
     foreach ($less_files as $less => $url) {
         $lessphp->parseFile($less, $url);
     }
     if ($modify_vars) {
         $lessphp->ModifyVars($modify_vars);
     }
     $css = $lessphp->getCss();
     file_put_contents($out_name, $css);
 }
예제 #3
0
 /**
  * Make a css file compiled from the LESS files collection
  *
  * @param array $lessFiles LESS files structures array
  *
  * @return array
  */
 public function makeCSS($lessFiles)
 {
     $file = $this->makeLESSResourcePath($lessFiles);
     $path = $this->getCSSResource($lessFiles);
     $url = $this->getCSSResourceURL($path);
     $data = array('file' => $path, 'media' => 'screen', 'url' => $url);
     if ($this->needToCompileLessResource($lessFiles)) {
         try {
             $originalPath = $this->getCSSResource($lessFiles, true);
             if ($path != $originalPath && $this->getLESSResourceHash($lessFiles, true) && $this->getLESSResourceHash($lessFiles, true) == $this->calcLESSResourceHash($lessFiles) && \Includes\Utils\FileManager::isFileReadable($originalPath)) {
                 $content = \Includes\Utils\FileManager::read($originalPath);
             } else {
                 // Need recreate parser for every parseFile
                 $this->parser = new \Less_Parser($this->getLessParserOptions());
                 $this->parser->parseFile($file, '');
                 $this->parser->ModifyVars($this->getModifiedLESSVars($data));
                 $content = $this->prepareLESSContent($this->parser->getCss(), $path, $data);
                 $this->setLESSResourceHash($lessFiles);
             }
             \Includes\Utils\FileManager::mkdirRecursive(dirname($path));
             \Includes\Utils\FileManager::write($path, $content);
         } catch (\Exception $e) {
             \XLite\Logger::getInstance()->registerException($e);
             $data = null;
         }
     }
     return $data;
 }
예제 #4
0
 public function getFormDynamicStyle($id)
 {
     $this->lessParser->parseFile($this->getBaseDir() . '/assets/less/style.less');
     $styleSettings = SCFP()->getSettings()->getStyleSettings();
     $this->lessParser->ModifyVars(array('id' => $id, 'no_border' => !empty($styleSettings['no_border']) ? $styleSettings['no_border'] : '', 'border_size' => !empty($styleSettings['border_size']) ? $styleSettings['border_size'] : '', 'border_style' => !empty($styleSettings['border_style']) ? $styleSettings['border_style'] : '', 'border_color' => !empty($styleSettings['border_color']) ? $styleSettings['border_color'] : '', 'field_label_text_color' => !empty($styleSettings['field_label_text_color']) ? $styleSettings['field_label_text_color'] : '', 'field_label_marker_text_color' => !empty($styleSettings['field_label_marker_text_color']) ? $styleSettings['field_label_marker_text_color'] : '', 'field_text_color' => !empty($styleSettings['field_text_color']) ? $styleSettings['field_text_color'] : '', 'no_background' => !empty($styleSettings['no_background']) ? $styleSettings['no_background'] : '', 'background_color' => !empty($styleSettings['background_color']) ? $styleSettings['background_color'] : '', 'button_color' => !empty($styleSettings['button_color']) ? $styleSettings['button_color'] : '', 'text_color' => !empty($styleSettings['text_color']) ? $styleSettings['text_color'] : '', 'hover_button_color' => !empty($styleSettings['hover_button_color']) ? $styleSettings['hover_button_color'] : '', 'hover_text_color' => !empty($styleSettings['hover_text_color']) ? $styleSettings['hover_text_color'] : ''));
     return '<style type="text/css" >' . $this->lessParser->getCss() . '</style>';
 }
예제 #5
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 Less_Parser(array('sourceMap' => $this->sourceMap));
     $parser->SetImportDirs($this->getImportDirs());
     if (count($this->registeredVars)) {
         $parser->ModifyVars($this->registeredVars);
     }
     foreach ($this->libFunctions as $name => $func) {
         $parser->registerFunction($name, $func);
     }
     $parser->parseFile($fname);
     $out = $parser->getCss();
     $parsed = Less_Parser::AllParsedFiles();
     foreach ($parsed as $file) {
         $this->addParsedFile($file);
     }
     $this->importDir = $oldImport;
     if ($outFname !== null) {
         return file_put_contents($outFname, $out);
     }
     return $out;
 }
예제 #6
0
 /**
  * {@inheritdoc}
  */
 public function compile($path, $relativePath)
 {
     $this->parsedFiles = array();
     $parser = new \Less_Parser(array('compress' => true));
     if (!empty($this->importDirs)) {
         $parser->SetImportDirs($this->importDirs);
     }
     $parser->parseFile($path);
     $parser->ModifyVars($this->variables);
     $css = $parser->getCss();
     $this->parsedFiles = $parser->allParsedFiles();
     return $css;
 }
예제 #7
0
 protected function _getInlineCSS()
 {
     require_once $this->_sDirPlugins . 'lessphp/Less.php';
     $oLessParser = new Less_Parser();
     $oConfigBase = new BxBaseConfig();
     $oLessParser->ModifyVars($oConfigBase->aLessConfig);
     foreach ($this->_aFilesCss as $sFile) {
         if (substr($sFile, -5) !== '.less') {
             continue;
         }
         $oLessParser->parseFile($this->_sPathCss . $sFile, $this->_sUrlCss);
     }
     return $oLessParser->getCss();
 }
예제 #8
0
 function css($file, $media = null)
 {
     /**
      * Only initiate automatically if:
      * - webiste is in dev mode
      * - or a ?flush is called
      */
     if (preg_match('/\\.less$/i', $file) || Director::isDev() || isset($_GET['flush'])) {
         /* If file is CSS, check if there is a LESS file */
         if (preg_match('/\\.css$/i', $file)) {
             $less = preg_replace('/\\.css$/i', '.less', $file);
             if (is_file(Director::getAbsFile($less))) {
                 $file = $less;
             }
         }
         /* If less file exists, then check/compile it */
         if (preg_match('/\\.less$/i', $file)) {
             $out = preg_replace('/\\.less$/i', '.css', $file);
             $css_file = Director::getAbsFile($out);
             $options = array();
             /* Automatically compress if in live mode */
             if (Director::isLive()) {
                 $options['compress'] = true;
             }
             try {
                 /* Force recompile & only write to css if updated */
                 if (isset($_GET['flush']) || !Director::isLive()) {
                     /* Create instance */
                     $parser = new Less_Parser($options);
                     if (!empty(self::$variables)) {
                         $parser->ModifyVars(self::$variables);
                     }
                     /* calculate the LESS file's parent URL */
                     $css_dir = rtrim(Director::baseURL(), '/') . Director::makeRelative(dirname(Director::getAbsFile($file)) . '/');
                     $parser->parseFile(Director::getAbsFile($file), $css_dir);
                     $css = $parser->getCss();
                     if (!is_file($css_file) || md5_file($css_file) != md5($css)) {
                         file_put_contents($css_file, $css);
                     }
                 }
             } catch (Exception $ex) {
                 trigger_error("Less.php fatal error: " . $ex->getMessage(), E_USER_ERROR);
             }
             $file = $out;
         }
     }
     /* Return css path */
     return parent::css($file, $media);
 }
예제 #9
0
 /**
  * @return Less_Parser
  */
 protected function _initProcessor()
 {
     // lazy load
     if (!class_exists('Less_Parser')) {
         require_once dirname(__FILE__) . '/class.less.gpeasy.php';
     }
     $options = array('compress' => true, 'strictUnits' => false, 'strictMath' => false, 'numPrecision' => 4, 'cache_method' => false);
     if ($this->_isDebug()) {
         $options['compress'] = false;
     }
     $less = new Less_Parser($options);
     // set paths
     $less->SetImportDirs(array($this->_tpl->lessFull => $this->_tpl->baseurl));
     // add custom vars
     $less->ModifyVars(array());
     return $less;
 }
 /**
  * @param string $destFile destination file path relative to server root (if null, parsed result is returned)
  * @throws Exception
  * @return mixed
  */
 public function gen($destFile = null)
 {
     $fullTargetPath = DEFAULT_PUBDIR . DIRECTORY_SEPARATOR . $destFile;
     $fullTargetDirname = dirname($fullTargetPath);
     if (!is_dir($fullTargetDirname) && false === mkdir($fullTargetDirname, 0777, true)) {
         throw new Exception("STY0005", "{$fullTargetDirname} dir could not be created for file {$destFile}");
     }
     $parser = new \Less_Parser($this->_options);
     if (isset($this->_styleConfig["sty_const"]["less_var"])) {
         $parser->ModifyVars($this->_styleConfig["sty_const"]["less_var"]);
     }
     foreach ($this->_srcFiles as $srcPath) {
         $srcFullPath = DEFAULT_PUBDIR . DIRECTORY_SEPARATOR . $srcPath;
         $parser->parseFile($srcFullPath);
     }
     $css = $parser->getCss();
     if (false === file_put_contents($fullTargetPath, $css)) {
         throw new Exception("STY0005", "{$fullTargetPath} could not be written for file {$destFile}");
     }
 }
예제 #11
0
 /**
  * @return Less_Parser
  */
 protected function _initProcessor()
 {
     // lazy load
     if (!class_exists('Less_Parser')) {
         require_once dirname(__FILE__) . '/class.less.gpeasy.php';
     }
     $options = array('compress' => 1, 'strictUnits' => 0, 'strictMath' => 0, 'relativeUrls' => 1, 'numPrecision' => 4, 'cache_method' => 0, 'sourceMap' => 0);
     if ($this->_isDebug()) {
         $options['compress'] = 0;
         $options['sourceMap'] = 1;
         $options['sourceMapRootpath'] = $this->_tpl->less;
         $options['sourceMapBasepath'] = $path = JPath::clean($this->_tpl->lessFull, '/');
     }
     $less = new Less_Parser($options);
     // set paths
     $less->SetImportDirs(array($this->_tpl->lessFull => $this->_tpl->less));
     // add custom vars
     $less->ModifyVars($this->_getCustomVars());
     return $less;
 }
 public function compiler()
 {
     global $ss_settings;
     if (isset($ss_settings['minimize_css']) && $ss_settings['minimize_css'] == 1) {
         $compress = true;
     } else {
         $compress = false;
     }
     $options = array('compress' => $compress);
     $bootstrap_location = dirname(__FILE__) . '/assets/less/';
     $webfont_location = get_template_directory() . '/assets/fonts/';
     $bootstrap_uri = '';
     $custom_less_file = get_stylesheet_directory() . '/assets/less/custom.less';
     $css = '';
     try {
         $parser = new Less_Parser($options);
         $parser->ModifyVars(array('assets-url' => '"' . STACHESTACK_ASSETS_URL . '"'));
         // The main app.less file
         $parser->parseFile($bootstrap_location . 'app.less', $bootstrap_uri);
         // Include the Elusive Icons
         $parser->parseFile($webfont_location . 'elusive-webfont.less', $bootstrap_uri);
         // Enable gradients
         if ($ss_settings['gradients_toggle'] == 1) {
             $parser->parseFile($bootstrap_location . 'gradients.less', $bootstrap_uri);
         }
         // The custom.less file
         if (is_writable($custom_less_file)) {
             $parser->parseFile($bootstrap_location . 'custom.less', $bootstrap_uri);
         }
         // Parse any custom less added by the user
         if (isset($ss_settings['user_less']) && !empty($ss_settings['user_less'])) {
             $parser->parse($ss_settings['user_less']);
         }
         // Get the extra variables & imports
         $extra_vars = do_action('ss_bootstrap_less_vars');
         $parser->parse($extra_vars);
         // Add a filter to the compiler
         $parser->parse(apply_filters('stachestack_compiler', ''));
         $css = $parser->getCss();
     } catch (Exception $e) {
         $error_message = $e->getMessage();
         die($error_message);
     }
     // Below are just some ugly hacks.
     $css = str_replace('../', get_template_directory_uri() . '/assets/', $css);
     $css = preg_replace('|https?:\\/\\/([^\\/]+)|i', null, $css);
     $css = str_replace('http:', '', $css);
     $css = str_replace('https:', '', $css);
     return apply_filters('stachestack_compiler_output', $css);
 }
 /**
  * Generate Options CSS
  *
  * @since penguin 6.0
  */
 function penguin_generate_options_css()
 {
     $options_update_name = Penguin::$THEME_NAME . '_options_update';
     //get theme update history
     $options_update = get_option($options_update_name);
     //get theme version
     $theme_old_version = get_option($options_update_name . '-ver');
     $theme_data = wp_get_theme();
     if ($theme_data->Template != '') {
         $theme_data = wp_get_theme($theme_data->Template);
     }
     if (!$theme_old_version) {
         $theme_old_version = $theme_data['Version'];
         update_option($options_update_name . '-ver', $theme_data['Version']);
     }
     /** Define some vars **/
     $uploads = wp_upload_dir();
     /** Save on different directory if on multisite **/
     if (is_multisite()) {
         $uploads_dir = $uploads['basedir'] . '/' . Penguin::$THEME_NAME . '/';
     } else {
         $uploads_dir = $uploads['basedir'] . '/' . Penguin::$THEME_NAME . '/';
     }
     if (!is_writable($uploads['basedir'])) {
         echo 'Your upload can\'t write theme style files.';
         return;
     }
     // Create necessary folders under /uploads
     if (!file_exists($uploads_dir)) {
         mkdir($uploads_dir, 0755);
     }
     if (isset($options_update['update'])) {
         if ($options_update['update'] == 'yes') {
             if (version_compare($theme_data['Version'], $theme_old_version, '>')) {
                 update_option($options_update_name . '-ver', $theme_data['Version']);
             } else {
                 if (file_exists($uploads_dir . Penguin::$THEME_NAME . '-styles.css')) {
                     if (class_exists('woocommerce') && file_exists($uploads_dir . Penguin::$THEME_NAME . '-woocommerce.css')) {
                         return;
                     } else {
                         return;
                     }
                 }
             }
         }
         $update_data = array('update' => 'yes', 'version' => intval($options_update['version']) + 1);
     } else {
         $update_data = array('update' => 'yes', 'version' => 0);
     }
     /** Capture CSS output **/
     require_once 'tools/less.php/Less.php';
     global $theme_customize_list, $woocommerce_customize_list;
     $theme_customize_list = array();
     $woocommerce_customize_list = array();
     require get_template_directory() . '/customize/customize.php';
     //theme
     $parser = new Less_Parser();
     $parser->parseFile(get_template_directory() . '/css/less/' . Penguin::$THEME_NAME . '.less', get_template_directory() . '/css/');
     $parser->ModifyVars($theme_customize_list);
     $css = $parser->getCss();
     // background custom
     ob_start();
     require get_template_directory() . '/customize/customize-bg.php';
     $css .= ob_get_clean();
     /** Write to file **/
     WP_Filesystem();
     global $wp_filesystem;
     if (!$wp_filesystem->put_contents($uploads_dir . Penguin::$THEME_NAME . '-styles.css', $css, 0644)) {
         echo 'Write theme css error.';
         return;
     }
     if (class_exists('woocommerce')) {
         //woocommerce
         $parser = new Less_Parser();
         $parser->parseFile(get_template_directory() . '/woocommerce/assets/css/woocommerce.less', get_template_directory() . '/woocommerce/assets/css/');
         $parser->ModifyVars($woocommerce_customize_list);
         $css = $parser->getCss();
         /** Write to file **/
         if (!$wp_filesystem->put_contents($uploads_dir . Penguin::$THEME_NAME . '-woocommerce.css', $css, 0644)) {
             echo 'Write woocommerce css error.';
             return;
         }
     }
     update_option($options_update_name, $update_data);
 }
예제 #14
0
/**
 * Add bootswatch CSS
 *
 * @param string $css The original CSS.
 * @param array $variables The bootswatch variables
 * @return string
 * @see theme_snap_get_bootswatch_variables
 */
function theme_snap_set_bootswatch($css, array $variables)
{
    global $CFG;
    $tag = '[[setting:snap-user-bootswatch]]';
    if (strpos($css, $tag) === false) {
        return $css;
        // Avoid doing work when tag is not present.
    }
    require_once __DIR__ . '/lessphp/Less.php';
    try {
        $parser = new Less_Parser();
        $parser->parseFile(__DIR__ . '/less/bootswatch/snap-variables.less', $CFG->wwwroot . '/');
        $parser->parseFile(__DIR__ . '/less/bootswatch/snap-user-bootswatch.less', $CFG->wwwroot . '/');
        if (!empty($variables)) {
            $parser->ModifyVars($variables);
        }
        $replacement = $parser->getCss();
    } catch (Exception $e) {
        add_to_log(get_site()->id, 'library', 'bootswatch', '', 'Failed to complile bootswatch: ' . $e->getMessage());
        $replacement = '';
        // Nothing we can do but remove the tag.
    }
    return str_replace($tag, $replacement, $css);
}
예제 #15
0
 /**
  * Allows to set variables which can be used
  * in the compiled less files.
  *
  * @param array $variables
  */
 public function setVariables(array $variables)
 {
     $this->compiler->ModifyVars($variables);
 }
예제 #16
0
 /**
  * Compiles an input less file to an output css file using the PHP compiler.
  *
  * @param  array   $input       The input .less files to be compiled.
  * @param  array   $options     Options to be passed to the php parser.
  * @param  array   $modifyVars  Less modifyVars.
  * @param  bool    $cache       Whether to cache or not.
  * @return string               If cache is not enabled will return the full
  *                              CSS compiled. Otherwise it will return the
  *                              resulting filename from the compilation.
  */
 protected function compile(array $input, $cache, array $options = [], array $modifyVars = [])
 {
     $parse = $this->prepareInputFilesForParsing($input);
     if ($cache) {
         $options += ['cache_dir' => $this->cssPath];
         return \Less_Cache::Get($parse, $options, $modifyVars);
     }
     $lessc = new \Less_Parser($options);
     foreach ($parse as $file => $path) {
         $lessc->parseFile($file, $path);
     }
     // ModifyVars must be called at the bottom of the parsing,
     // this way we're ensuring they override their default values.
     // http://lesscss.org/usage/#command-line-usage-modify-variable
     $lessc->ModifyVars($modifyVars);
     return $lessc->getCss();
 }
예제 #17
0
function generate_css_ultimate_page($page_id, $params)
{
    try {
        if (!empty($params) && isset($params['up_less_editor']) && !empty($params['up_less_editor']) && !empty($page_id)) {
            $theme_dir = trailingslashit(get_template_directory());
            $parser = new Less_Parser();
            $parser->parseFile(file_require($theme_dir . 'assets/less/style.less'), trailingslashit(get_site_url()));
            $less_variables = array();
            $lines = explode("\n", $params['up_less_editor']);
            foreach ($lines as $current) {
                $line = trim($current . '');
                if (substr($line, 0, 2) != "//" && strlen($line) > 3 && substr($line, 0, 1) == "@") {
                    $splits = explode(':', $line);
                    $variable = trim(str_replace('@', '', $splits[0]));
                    $value = trim($splits[1]);
                    if (strpos($value, '//') !== false) {
                        $pos = explode('//', $value);
                        $value = trim($pos[0]);
                    }
                    $value = str_replace(';', '', $value);
                    $value = trim($value) == '@gray-light' ? '#FFF' : $value;
                    if ($variable != '') {
                        $less_variables = array_merge($less_variables, array($variable => $value));
                    }
                }
            }
            $less_variables['base-font-body'] = isset($params['up_body_font']) && !empty($params['up_body_font']) ? '"' . $params['up_body_font'] . '"' : '"' . $less_variables['base-font-body'] . '"';
            $less_variables['base-font-heading'] = isset($params['up_heading_font']) && !empty($params['up_heading_font']) ? '"' . $params['up_heading_font'] . '"' : '"' . $less_variables['base-font-heading'] . '"';
            $less_variables['base-font-menu'] = isset($params['up_menu_font']) && !empty($params['up_menu_font']) ? '"' . $params['up_menu_font'] . '"' : '"' . $less_variables['base-font-menu'] . '"';
            $less_variables['header-height'] = isset($params['up_header_height']) && !empty($params['up_header_height']) ? (int) $params['up_header_height'] . 'px' : $less_variables['header-height'];
            // Save LESS Variables
            $encoded_str = base64_encode(serialize($less_variables));
            update_post_meta($page_id, "_less_page_variables", $encoded_str);
            $modified_vars = array();
            $less_options = get_less_variables();
            foreach ($less_options as $opt) {
                if ($opt['variable'] != 'less-heading') {
                    $var_name = $opt['variable'];
                    $var_value = trim($less_variables[$var_name]);
                    $var_value = str_replace("\\'", "'", $var_value);
                    $var_value = str_replace('\\"', '"', $var_value);
                    $var_value = str_replace('\\', '', $var_value);
                    $opval = trim($opt['value']);
                    $opval = str_replace("\\'", "'", $opval);
                    $opval = str_replace('\\"', '"', $opval);
                    $opval = str_replace('\\', '"', $opval);
                    if (isset($less_variables[$var_name]) && !empty($var_value) && $var_value != $opval) {
                        $modified_vars = array_merge($modified_vars, array($opt['variable'] => $var_value));
                    }
                }
            }
            $parser->ModifyVars($modified_vars);
            $css = $parser->getCss();
            $css = preg_replace('!/\\*[^*]*\\*+([^/][^*]*\\*+)*/!', '', $css);
            $css = str_replace(': ', ':', $css);
            $css = str_replace(array("\r\n", "\r", "\n", "\t", '  ', '    ', '    '), '', $css);
            $dir_path = themeton_less_mkdir();
            if ($dir_path !== false) {
                $lessname = trailingslashit($dir_path) . wp_get_theme()->template . '-' . $page_id . '.css';
                file_put_contents($lessname, $css);
            }
        }
    } catch (Exception $e) {
        wp_die($e->getMessage());
    }
}
예제 #18
0
파일: View.php 프로젝트: skelpo/framework
 /**
  * Returns the URL to the less/css-compiled file.
  *
  * @return string
  */
 private function getLessUrl()
 {
     $p = $this->framework->getRootDir() . "static/" . $this->module->getPathName() . "/css/";
     if (!$this->filesystem->exists($p)) {
         $this->filesystem->mkdir($p);
     }
     $cssfile = $p . "all.css";
     $cssurl = $this->rootUrl . "static/" . $this->module->getPathName() . "/css/all.css";
     // in case we have it in cache just return the url
     if ($this->filesystem->exists($cssfile) && !$this->isCacheDue()) {
         return $cssurl;
     }
     // if not go through all the dirs
     $dirs = $this->framework->getTemplateDirs();
     // our output
     $allLess = "";
     // paths with potential scss/less files
     $paths = array();
     // go through all the dirs to find the all.less
     foreach ($dirs as $dir_) {
         $file = $dir_ . $this->module->getPathName() . "/_public/" . $this->framework->getTheme()->getCssCompiler() . "/all." . $this->framework->getTheme()->getCssCompiler();
         if ($this->filesystem->exists($file)) {
             $paths[] = $dir_ . $this->module->getPathName() . "/_public/" . $this->framework->getTheme()->getCssCompiler() . "/";
             $allLess = $file;
             break;
         }
     }
     // if there is none just return an empty string
     if ($allLess == "") {
         return "";
     }
     try {
         $c = $this->framework->getTheme()->getCssCompiler();
         if ($c == "less" || $c == "") {
             // the less parser
             $parser = new \Less_Parser();
             $vars = array();
             foreach ($this->getTemplateVars() as $k => $v) {
                 if (!is_object($v) && !is_array($v)) {
                     $vars[$k] = '\'' . $v . '\'';
                 }
             }
             // are we minifying?
             \Less_Parser::$options['compress'] = $this->minifyCss;
             $parser->ModifyVars($vars);
             // parse our output
             $parser->parseFile($allLess, $this->rootUrl . 'static/' . $this->module->getPathName());
             // and get it as css
             $css = $parser->getCss();
         } else {
             if ($c == "scss") {
                 $vars = array();
                 foreach ($this->getTemplateVars() as $k => $v) {
                     if (!is_object($v) && !is_array($v)) {
                         $vars[$k] = '' . $v . '';
                     }
                 }
                 $scss = new Compiler();
                 $scssData = file_get_contents($allLess);
                 $scss->setImportPaths($paths);
                 $scss->setVariables($vars);
                 if ($this->minifyCss) {
                     $scss->setFormatter("Leafo\\ScssPhp\\Formatter\\Crunched");
                 } else {
                     $scss->setFormatter("Leafo\\ScssPhp\\Formatter\\Expanded");
                 }
                 $css = $scss->compile($scssData);
             } else {
                 if ($c == "css") {
                     // TODO: Load all css files and just put them together in one file.
                 }
             }
         }
     } catch (\Exception $e) {
         throw $e;
     }
     // remove the file if it exists
     if ($this->filesystem->exists($cssfile)) {
         $this->filesystem->remove($cssfile);
     }
     // save our output here
     $this->filesystem->dumpFile($cssfile, $css);
     // and return the url
     return $cssurl;
 }
 /**
  * Method that compiles LESS to CSS file
  * @param (string) Path to LESS file
  * @param (bool) If true additional LESS variables from "jm_bootstrap_variables" parameter will be added
  * @param (bool) Indicates if we are dealing with a file that belongs to template's core. 
  *         If yes, it means that we should add suffix for CSS file because different template styles may use
  *         different variables
  * @param (bool) When true old version of LessC will be used. Otherwise Less_Parser class. 
  */
 protected function lessToCss($lessPath, $useVars = true, $coreStyle = true, $legacyCompiler = false)
 {
     if (class_exists('lessc') == false && $legacyCompiler) {
         require_once JMF_FRAMEWORK_PATH . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'lessc' . DIRECTORY_SEPARATOR . 'lessc.inc.0.4.0.php';
     }
     if (class_exists('Less_Parser') == false && !$legacyCompiler) {
         require_once JMF_FRAMEWORK_PATH . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'less_parser' . DIRECTORY_SEPARATOR . 'Less.php';
     }
     $developer_mode = $this->params->get('devmode', false) == '1' ? true : false;
     $filename = JFile::stripExt(JFile::getName($lessPath));
     $style_id = @JFactory::getApplication()->getTemplate(true)->id;
     $css_suffix = '';
     // A suffix is simply ID of template style, eg. template.10.css
     if ($style_id > 0 && $coreStyle) {
         $css_suffix = '.' . $style_id;
     }
     // Establishing path to CSS file
     $cssPath = JPath::clean(JMF_TPL_PATH . '/css/' . $filename . $css_suffix . '.css');
     // Checking if LESS file exists. If not we should make sure that we're looking in correct directory
     if (!JFile::exists($lessPath)) {
         $lessPath = JPath::clean(JMF_TPL_PATH . '/less/' . $filename . '.less');
     }
     // If developer mode is disabled and CSS file is not older than LESS file, we do not have to compile LESS file.
     if (JFile::exists($lessPath) && JFile::exists($cssPath)) {
         $lessTime = filemtime($lessPath);
         $cssTime = filemtime($cssPath);
         if ($lessTime <= $cssTime && $developer_mode == false) {
             return JMF_TPL_URL . '/css/' . $filename . $css_suffix . '.css';
         }
     }
     // At this point, either we are in developer mode or CSS file does not exist or is older than LESS file.
     // But if CSS file does exist, we should delete it
     if (JFile::exists($cssPath)) {
         JFile::delete($cssPath);
     }
     try {
         if ($legacyCompiler) {
             // Initialising LessC compiler
             $less = new lessc();
             // Additional LESS variables
             if ($useVars) {
                 $variables = $this->params->get('jm_bootstrap_variables', array());
                 if (!empty($variables)) {
                     $less->setVariables($variables);
                 }
             }
             // Checked Compile - LessC
             $less->checkedCompile($lessPath, $cssPath);
         } else {
             // Less_Parser compiler
             $less_parser_options = array('compress' => $this->params->get('cssCompress', '0') == '1' ? true : false, 'relativeUrls' => false, 'sourceMap' => false);
             if ($developer_mode) {
                 //$less_parser_options['compress'] = false;
                 $less_parser_options['sourceMap'] = true;
                 $less_parser_options['sourceMapWriteTo'] = JPath::clean(JMF_TPL_PATH . '/css/' . $filename . $css_suffix . '.map');
                 $less_parser_options['sourceMapURL'] = JUri::base(false) . 'templates/' . JMF_TPL . '/css/' . $filename . $css_suffix . '.map';
             }
             $less_parser = new Less_Parser($less_parser_options);
             // Less_Parser - LESS file
             $less_parser->parseFile($lessPath, JMF_TPL_URL . '/css');
             // Additional LESS variables
             if ($useVars) {
                 $variables = $this->params->get('jm_bootstrap_variables', array());
                 if (!empty($variables)) {
                     // Less_Parser
                     $less_parser->ModifyVars($variables);
                 }
             }
             // Compilation - Less_Parser
             if ($css_content = $less_parser->getCss()) {
                 if (JFile::write($cssPath, $css_content) == false) {
                     throw new Exception('Cannot save CSS file. Please check your directory permissions.');
                 }
             }
         }
     } catch (exception $e) {
         throw new Exception(JText::sprintf('PLG_SYSTEM_JMFRAMEWORK_LESS_ERROR', $e->getMessage()));
     }
     // Returning CSS file's URL
     return JMF_TPL_URL . '/css/' . $filename . $css_suffix . '.css';
 }
예제 #20
0
function m_wedding_include_less()
{
    global $wpdb;
    $featured_color = m_wedding_get_options('featured_color');
    require_once 'less/Less.php';
    try {
        $options = array('cache_dir' => get_template_directory() . "/assets/less/cache", 'sourceMap' => true);
        $parser = new Less_Parser($options);
        $parser->parseFile(get_template_directory() . "/assets/less/stylesheets.less", '../');
        $parser->ModifyVars(array('font-size-base' => '16.5px', 'brand-primary' => $featured_color));
        $css = $parser->getCss();
        global $wp_filesystem;
        if (empty($wp_filesystem)) {
            require_once ABSPATH . '/wp-admin/includes/file.php';
            WP_Filesystem();
        }
        if (!$wp_filesystem->put_contents(get_template_directory() . "/assets/css/" . $wpdb->prefix . "main.css", $css, FS_CHMOD_FILE)) {
            wp_die("error saving file css!");
        }
    } catch (Exception $e) {
        $error_message = $e->getMessage();
    }
}
 /**
  * Compile styles from theme/css/all.less to assets/Theme/styles.css
  */
 public function compileStyles()
 {
     $destination = Director::baseFolder() . $this->StylesPath();
     if ($this->owner->Theme) {
         $themeDir = 'themes/' . $this->owner->Theme;
     } else {
         $themeDir = SSViewer::get_theme_folder();
     }
     $parser = new Less_Parser($this->lessEnvOptions());
     try {
         $parser->parseFile(Director::baseFolder() . '/' . $themeDir . '/css/all.less', '/' . $themeDir . '/css');
         $vars = array('base_color' => '#ffffff');
         foreach (self::$styles_variables as $var) {
             if ($this->owner->{$var}) {
                 $less_var = strtolower(preg_replace('/([a-z])([A-Z])/', '$1-$2', $var));
                 $vars[$less_var] = $this->owner->{$var};
             }
         }
         if (!empty($vars)) {
             $parser->ModifyVars($vars);
         }
         $css = $parser->getCss();
         $baseDir = Director::baseFolder() . '/assets/Theme';
         if (!is_dir($baseDir)) {
             mkdir($baseDir, 0777, true);
         }
         file_put_contents($destination, $css);
     } catch (Exception $ex) {
         SS_Log::log('Failed to create css files : ' . $ex->getMessage(), SS_Log::DEBUG);
     }
 }
예제 #22
0
 function print_css($data, $varsOverride = false)
 {
     //if ( ENVIRONMENT  == 'development' || !file_exists( APPPATH .'front/cache/'.$data.'_combined.css' ))
     if (false || !file_exists(APPPATH . 'front/cache/' . $data . '_combined.css')) {
         require SYSDIR . "/third_party/less.php/Less.php";
         $options = array('sourceMap' => ENVIRONMENT == 'development' ? true : false, 'compress' => true);
         $parser = new Less_Parser($options);
         $parser->parseFile(APPPATH . 'front/' . $data . '/style_compilator.less', '/' . APPPATH . 'front/' . $data);
         // récupération du css db pour le front
         if ($data === 'default') {
             $CI =& get_instance();
             $CI->load->model('stylesheets_model');
             $customCss = $CI->stylesheets_model->StyleSheetsContent();
             $parser->parse($customCss);
         }
         if ($varsOverride) {
             $parser->ModifyVars($varsOverride);
         }
         $css = $parser->getCss();
         file_put_contents(APPPATH . 'front/cache/' . $data . '_combined.css', $css);
     }
     echo '<link href="/' . APPPATH . 'front/cache/' . $data . '_combined.css" rel="stylesheet" type="text/css" />';
 }
예제 #23
0
 public function parseLess($strCSS, $strMapFile = false)
 {
     $style = $data ? $data : $this->user->style;
     $stylepath = $stylepath ? $stylepath : $this->style_code;
     $root_path = '../../../../../';
     //Background Image
     $template_background_file = "";
     switch ($style['background_type']) {
         //Game
         case 1:
             $template_background_file = $root_path . 'games/' . $this->config->get('default_game') . '/template_background.jpg';
             break;
             //Own
         //Own
         case 2:
             if ($style['background_img'] != '') {
                 if (strpos($style['background_img'], '://') > 1) {
                     $template_background_file = $style['background_img'];
                 } else {
                     $template_background_file = $root_path . $style['background_img'];
                 }
             }
             break;
             //Style
         //Style
         default:
             if (is_file($this->root_path . 'templates/' . $style['template_path'] . '/images/template_background.png')) {
                 $template_background_file = $root_path . 'templates/' . $style['template_path'] . '/images/template_background.png';
             } else {
                 $template_background_file = $root_path . 'templates/' . $style['template_path'] . '/images/template_background.jpg';
             }
     }
     if ($template_background_file == "") {
         //Cannot find a background file, let's take the game specific
         $template_background_file = $root_path . 'games/' . $this->config->get('default_game') . '/template_background.jpg';
     }
     $options = array();
     $lessVars = array('eqdkpURL' => '"' . $this->env->link . '"', 'eqdkpGame' => '"' . $this->config->get('default_game') . '"', 'eqdkpServerPath' => '"' . $this->server_path . '"', 'eqdkpRootPath' => '"' . $root_path . '"', 'eqdkpImagePath' => '"' . $root_path . 'images/"', 'eqdkpTemplateImagePath' => '"' . $root_path . 'templates/' . $stylepath . '/images/"', 'eqdkpTemplateBackground' => '"' . $template_background_file . '"', 'eqdkpBackgroundImage' => '"' . $template_background_file . '"', 'eqdkpBackgroundImagePosition' => $style['background_pos'] == 'normal' ? 'scroll' : 'fixed', 'eqdkpPortalWidth' => $style['portal_width'] != "" ? $style['portal_width'] : '900px', 'eqdkpColumnLeftWidth' => $style['column_left_width'] != "" ? $style['column_left_width'] : '200px', 'eqdkpColumnRightWidth' => $style['column_right_width'] != "" ? $style['column_right_width'] : '200px', 'eqdkpPortalWidthWithoutBothColumns' => intval($style['portal_width']) - intval($style['column_left_width']) - intval($style['column_right_width']) . (strpos($style['portal_width'], '%') !== false ? '%' : 'px'), 'eqdkpPortalWidthWithoutLeftColumn' => intval($style['portal_width']) - intval($style['column_left_width']) . (strpos($style['portal_width'], '%') !== false ? '%' : 'px'));
     $arrOptions = register('styles')->styleOptions();
     foreach ($arrOptions as $key => $val) {
         foreach ($val as $name => $type) {
             if ($name == 'body_font_size') {
                 $lessVars[register('styles')->convertNameToLessVar($name)] = isset($style[$name]) && strlen($style[$name]) ? $style[$name] . 'px' : '13px';
                 continue;
             }
             $lessVars[register('styles')->convertNameToLessVar($name)] = isset($style[$name]) && strlen($style[$name]) ? $style[$name] : (stripos($name, 'color') ? '#000' : '""');
         }
     }
     $gameclasses = $this->game->get_primary_classes();
     if (isset($gameclasses) && is_array($gameclasses)) {
         foreach ($gameclasses as $class_id => $class_name) {
             $lessVars['eqdkpClasscolor' . $class_id] = $this->game->get_class_color($class_id) != "" ? $this->game->get_class_color($class_id) : '""';
         }
     }
     //Add Additional LESS
     $strCSS .= $style['additional_less'];
     try {
         require_once $this->root_path . 'libraries/less/Less.php';
         $parser = new Less_Parser();
         $parser->ModifyVars($lessVars);
         $parser->parse($strCSS);
         $strCSS = $parser->getCss();
     } catch (Exception $e) {
         echo "Fatal error parsing less: " . nl2br($e->getMessage());
     }
     return $strCSS;
 }
예제 #24
0
 /**
  * Less CSS
  *
  * @param  mixed $mixed CSS string to process with Less compiler or an array with CSS file's Path and URL.
  * @return mixed string or an array with CSS file's Path and URL.
  */
 function _lessCss($mixed)
 {
     require_once BX_DIRECTORY_PATH_PLUGINS . 'lessphp/Less.php';
     if (is_array($mixed) && isset($mixed['url']) && isset($mixed['path'])) {
         $sPathFile = realpath($mixed['path']);
         $aInfoFile = pathinfo($sPathFile);
         if (!isset($aInfoFile['extension']) || $aInfoFile['extension'] != 'less') {
             return $mixed;
         }
         require_once BX_DIRECTORY_PATH_PLUGINS . 'lessphp/Cache.php';
         $aFiles = array($mixed['path'] => $mixed['url']);
         $aOptions = array('cache_dir' => $this->_sCachePublicFolderPath);
         $sFile = Less_Cache::Get($aFiles, $aOptions, $this->_oConfigTemplate->aLessConfig);
         return array('url' => $this->_sCachePublicFolderUrl . $sFile, 'path' => $this->_sCachePublicFolderPath . $sFile);
     }
     $oLess = new Less_Parser();
     $oLess->ModifyVars($this->_oConfigTemplate->aLessConfig);
     $oLess->parse($mixed);
     return $oLess->getCss();
 }
예제 #25
0
 protected function buildCss()
 {
     global $locale, $defender;
     $inputFile = CLASSES . "PHPFusion/Atom/less/atom.less";
     $outputFolder = THEMES . $this->target_folder . "/";
     $outputFile = THEMES . $this->target_folder . "/fusion_" . $this->target_folder . "_" . time() . ".css";
     $returnFile = str_replace(THEMES, '', $outputFile);
     $directories = array(INCLUDES . "atom/less/" => 'includes/atom/less/');
     $options = array('output' => $outputFile, 'compress' => $this->compress);
     $this->set_less_variables();
     if (!empty($this->less_var) && $defender::safe() && $this->Compiler) {
         if ($this->debug) {
             print_p("current less var");
             print_p($this->less_var);
             print_p($inputFile);
             print_p($outputFile);
         }
         try {
             require_once "lessc.inc.php";
             $parser = new \Less_Parser($options);
             //$parser->SetImportDirs($directories);
             $parser->parseFile($inputFile, $outputFolder);
             $parser->ModifyVars($this->less_var);
             $css = $parser->getCss();
             if (!$this->debug) {
                 $css_file = fopen($outputFile, "w");
                 if (fwrite($css_file, $css)) {
                     fclose($css_file);
                 }
                 if ($css_file) {
                     return (string) $returnFile;
                 }
             } else {
                 print_p($css);
                 // this is your css
             }
         } catch (\Exception $e) {
             $error_message = $e->getMessage();
             $defender->stop();
             addNotice('danger', $error_message);
         }
     } else {
         if (!$this->Compiler) {
             $defender->stop();
             addNotice('danger', $locale['theme_error_008']);
         } else {
             $defender->stop();
             addNotice('danger', $locale['theme_error_007']);
         }
     }
     return NULL;
 }
예제 #26
0
 /**
  * Compiles an input less file to an output css file using the PHP compiler
  * @param  array   $input       The input .less files to be compiled
  * @param  array   $options     Options to be passed to the php parser
  * @param  array   $modify_vars Less modify_vars
  * @param  boolean $cache       Whether to cache or not
  * @return string               If cache is not enabled will return the full CSS compiled.
  *                              Otherwise it will return the resulting filename from the compilation.
  */
 public function compile(array $input, array $options = [], array $modify_vars = [], $cache = true)
 {
     $to_parse = [];
     foreach ($input as $in) {
         $less = realpath(WWW_ROOT . $in);
         // If we have plugin notation (Plugin.less/file.less)
         // ensure to properly load the files
         list($plugin, $basefile) = $this->_View->pluginSplit($in, false);
         if (!empty($plugin)) {
             $less = realpath(Plugin::path($plugin) . 'webroot' . DS . $basefile);
             if ($less !== false) {
                 $to_parse[$less] = $this->assetBaseUrl($plugin, $basefile);
                 continue;
             }
         }
         if ($less !== false) {
             $to_parse[$less] = '';
         } else {
             // Plugins without plugin notation (/plugin/less/file.less)
             list($plugin, $basefile) = $this->assetSplit($in);
             if ($file = $this->pluginAssetFile([$plugin, $basefile])) {
                 $to_parse[$file] = $this->assetBaseUrl($plugin, $basefile);
             } else {
                 // Will probably throw a not found error
                 $to_parse[$in] = '';
             }
         }
     }
     if ($cache) {
         $options += ['cache_dir' => $this->css_path];
         return \Less_Cache::Get($to_parse, $options, $modify_vars);
     }
     $lessc = new \Less_Parser($options);
     foreach ($to_parse as $file => $path) {
         $lessc->parseFile($file, $path);
     }
     // ModifyVars must be called at the bottom of the parsing,
     // this way we're ensuring they override their default values.
     // http://lesscss.org/usage/#command-line-usage-modify-variable
     $lessc->ModifyVars($modify_vars);
     return $lessc->getCss();
 }
 protected static function compileCSS($sourceFileWithPath, $cssFileWithPath, $sourceFileType, $vars)
 {
     global $REX;
     if (!file_exists($sourceFileWithPath)) {
         return;
     }
     // get content of source file
     $sourceFileContent = file_get_contents($sourceFileWithPath);
     // strip comments out
     $sourceFileContent = self::stripCSSComments($sourceFileContent);
     // get file path
     $path = pathinfo($sourceFileWithPath);
     // compile source file to css
     try {
         if ($sourceFileType == 'scss') {
             // EP for scss string compilation
             $compiledCSS = rex_register_extension_point('SEO42_COMPILE_SCSS', $sourceFileContent, array('vars' => $vars));
             if ($sourceFileContent == $compiledCSS) {
                 // include compiler
                 if (!class_exists('scssc')) {
                     require_once $REX['INCLUDE_PATH'] . '/addons/seo42/classes/scssphp/scss.inc.php';
                 }
                 $formatter = new scss_formatter();
                 $formatter->indentChar = "\t";
                 $formatter->close = "}" . PHP_EOL;
                 $formatter->assignSeparator = ": ";
                 $scss = new scssc();
                 $scss->addImportPath($path['dirname']);
                 $scss->setFormatter($formatter);
                 $compiledCSS = $scss->compile($sourceFileContent);
             }
         } else {
             // EP for less string compilation
             $compiledCSS = rex_register_extension_point('SEO42_COMPILE_LESS', $sourceFileContent, array('vars' => $vars, 'path' => $path['dirname']));
             if ($sourceFileContent == $compiledCSS) {
                 // include compiler
                 if (!class_exists('Less_Parser')) {
                     require_once $REX['INCLUDE_PATH'] . '/addons/seo42/classes/lessphp/Less.php';
                 }
                 $parser = new Less_Parser(array());
                 $parser->SetImportDirs(array(realpath($path['dirname']) => ''));
                 $parser->parse($sourceFileContent);
                 $parser->ModifyVars($vars);
                 $compiledCSS = $parser->getCss();
             }
         }
     } catch (Exception $e) {
         echo '" />';
         // close tag as we are probably in an open link tag in head section of website
         echo '<p style="margin: 5px;"><code>';
         echo '<strong>' . strtoupper($sourceFileType) . ' Compile Error:</strong><br/>';
         echo $e->getMessage();
         echo '</code></p>';
         exit;
     }
     // write css
     $fileHandle = fopen($cssFileWithPath, 'w');
     fwrite($fileHandle, $compiledCSS);
     fclose($fileHandle);
 }
예제 #28
0
 /**
  * Returns LESS compiler set up for use with MediaWiki
  *
  * @since 1.22
  * @since 1.26 added $extraVars parameter
  * @param Config $config
  * @param array $extraVars Associative array of extra (i.e., other than the
  *   globally-configured ones) that should be used for compilation.
  * @throws MWException
  * @return Less_Parser
  */
 public static function getLessCompiler(Config $config, $extraVars = array())
 {
     // When called from the installer, it is possible that a required PHP extension
     // is missing (at least for now; see bug 47564). If this is the case, throw an
     // exception (caught by the installer) to prevent a fatal error later on.
     if (!class_exists('Less_Parser')) {
         throw new MWException('MediaWiki requires the less.php parser');
     }
     $parser = new Less_Parser();
     $parser->ModifyVars(array_merge(self::getLessVars($config), $extraVars));
     $parser->SetImportDirs(array_fill_keys($config->get('ResourceLoaderLESSImportPaths'), ''));
     $parser->SetOption('relativeUrls', false);
     $parser->SetCacheDir($config->get('CacheDirectory') ?: wfTempDir());
     return $parser;
 }
예제 #29
0
} else {
    $cache = $input_less;
}
$readCache = $yjsgLess->cachedCompile($cache);
if (!is_array($cache) || $readCache["updated"] > $cache["updated"] || !file_exists($output_css)) {
    try {
        // set compiler options
        if ($compiler_compressed == 1) {
            $options = array('compress' => true, 'relativeUrls' => false);
        } else {
            $options = array('compress' => false, 'relativeUrls' => false);
        }
        $parser = new Less_Parser($options);
        // check if template is legacy
        if ($yjsg->preplugin()) {
            $parser->ModifyVars(array('legacy' => 'true'));
        } else {
            $parser->ModifyVars(array('legacy' => 'false'));
        }
        //  use compiler to compress css if bootstrap is not loaded
        if ($bootstrap_here) {
            $parser->ModifyVars(array('loadbootstrap' => 'true'));
        } else {
            $parser->ModifyVars(array('loadbootstrap' => 'false'));
        }
        // set custom.css/less file var if is turned on
        if ($custom_css == 1 && $compile_css == 1) {
            $parser->ModifyVars(array('custom_css' => '"../../../../../../templates/' . $this->template . '/css/custom.css"'));
        } else {
            $parser->ModifyVars(array('custom_css' => '"custom.less"'));
        }