public static function compile($source, $path, $todir, $importdirs) { // call Less to compile $parser = new lessc(); $parser->setImportDir(array_keys($importdirs)); $parser->setPreserveComments(true); $output = $parser->compile($source); // update url $arr = preg_split(CANVASLess::$rsplitbegin . CANVASLess::$kfilepath . CANVASLess::$rsplitend, $output, -1, PREG_SPLIT_DELIM_CAPTURE); $output = ''; $file = $relpath = ''; $isfile = false; foreach ($arr as $s) { if ($isfile) { $isfile = false; $file = $s; $relpath = CANVASLess::relativePath($todir, dirname($file)); $output .= "\n#" . CANVASLess::$kfilepath . "{content: \"{$file}\";}\n"; } else { $output .= ($file ? CANVASPath::updateUrl($s, $relpath) : $s) . "\n\n"; $isfile = true; } } return $output; }
/** * Compile the Less file in $origin to the CSS $destination file * * @param string $origin Input Less path * @param string $destination Output CSS path */ public static function compile($origin, $destination) { $less = new \lessc(); $less->indentChar = \Config::get('asset.indent_with'); $less->setImportDir(array(dirname($origin), dirname($destination))); $raw_css = $less->compile(file_get_contents($origin)); $destination = pathinfo($destination); \File::update($destination['dirname'], $destination['basename'], $raw_css); }
/** * Compile less -> css * @param str $inputFile * @param str $outputFile * @return boolean */ public static function less($inputFile, $outputFile) { if (JFile::exists($inputFile)) { $less = new lessc(); $less->setImportDir(array(dirname($inputFile))); return $less->compileFile($inputFile, $outputFile); } return false; }
public static function compile($source, $importdirs) { // call Less to compile $parser = new lessc(); $parser->setImportDir(array_keys($importdirs)); $parser->setPreserveComments(true); $output = $parser->compile($source); return $output; }
public function testCheckedCachedCompile() { $server = new lessc(); $server->setImportDir(__DIR__ . '/inputs/test-imports/'); $css = $server->checkedCachedCompile(__DIR__ . '/inputs/import.less', '/tmp/less.css'); $this->assertFileExists('/tmp/less.css'); $this->assertFileExists('/tmp/less.css.meta'); $this->assertEquals($css, file_get_contents('/tmp/less.css')); $this->assertNotNull(unserialize(file_get_contents('/tmp/less.css.meta'))); }
/** * Compiles LESS code into CSS code using <em>lessphp</em>, http://leafo.net/lessphp * * @param string $less Less code * @return string CSS code * @throws dmInvalidLessException */ public function compile($less, array $importDirs = array()) { $lessCompiler = new lessc(); $lessCompiler->setImportDir($importDirs); try { return $lessCompiler->compile($less); } catch (Exception $e) { throw new dmInvalidLessException($e->getMessage()); } }
/** * Compile all files into one file. * * @param string $filePath File location. * @param string $format Formatter for less. * * @return void */ public function compileTo($filePath, $format = 'compressed') { $less = ''; foreach ($this->_files as $file) { $less .= file_get_contents($file) . "\n\n"; } $this->_lessc->setImportDir($this->_importDirs); $this->_lessc->setFormatter($format); $result = $this->_lessc->compile($less); file_put_contents($filePath, $result); }
/** * lessphp compiler * @link https://github.com/leafo/lessphp * * @param string $file * * @return string */ protected function lessphp($file) { if (!class_exists('\\lessc')) { return Result::errorMissingPackage($this, 'lessc', 'leafo/lessphp'); } $lessCode = file_get_contents($file); $less = new \lessc(); if (isset($this->compilerOptions['importDirs'])) { $less->setImportDir($this->compilerOptions['importDirs']); } return $less->compile($lessCode); }
/** * Compiles a less css file. The the compiler will create a css file output. * * @param array $config Array of less compile configuration */ public function compile($config = array()) { $config = new KConfig($config); $config->append(array('parse_urls' => true, 'compress' => true, 'import' => array(), 'force' => false, 'output' => null, 'input' => null)); $less = new lessc(); $less->setPreserveComments(!$config->compress); if ($config->compress) { $less->setFormatter('compressed'); } $config['import'] = $config['import']; $less->setImportDir($config['import']); $cache_file = JPATH_CACHE . '/less-' . md5($config->input); if (file_exists($cache_file)) { $cache = unserialize(file_get_contents($cache_file)); } else { $cache = $config->input; } $force = $config->force; //if output doesn't exsit then force compile if (!is_readable($config->output)) { $force = true; } //check if any of the import folder have changed or //if yes then re-compile if (is_array($cache)) { foreach ($config['import'] as $path) { if (is_readable($path) && filemtime($path) > $cache['updated']) { $force = true; break; } } } try { $new_cache = $less->cachedCompile($cache, $force); } catch (Exception $e) { print $e->getMessage(); return; } if (!is_array($cache) || $new_cache['updated'] > $cache['updated']) { if ($config->parse_urls) { $new_cache['compiled'] = $this->_parseUrls($new_cache['compiled'], $config->import); } //store the cache file_put_contents($cache_file, serialize($new_cache)); //store the compiled file //create a directory if if (!file_exists(dirname($config->output))) { mkdir(dirname($config->output), 0755); } file_put_contents($config->output, $new_cache['compiled']); } }
public function compileCss(&$templateData, $cssFileName) { glz_importLib('lessphp/lessc.inc.php'); $less = new lessc(); $less->setImportDir(array(__DIR__ . '/less/')); $css = file_get_contents(__DIR__ . '/less/styles.less'); $css = $this->applyCssVariables($templateData, $less, $css); $css = $this->applyFont($templateData, $less, $css); $css = $less->compile($css); $css = str_replace(array('../img/', '../font/'), array('../static/movio/templates/Movio/img/', '../static/movio/templates/Movio/font/'), $css); $css .= PHP_EOL . $templateData->customCss; file_put_contents($cssFileName, $css); $templateData->css = '<link rel="stylesheet" href="' . $cssFileName . '" type="text/css" media="screen" />'; }
public function compileCss(&$templateData, $cssFileName) { glz_importLib('lessphp/lessc.inc.php'); $less = new lessc(); $less->setImportDir(array(__DIR__ . '/less/')); $css = file_get_contents(__DIR__ . '/less/styles.less'); $css = $this->applyCssVariables($templateData, $less, $css); $css = $this->applyFont($templateData, $less, $css); $css = $less->compile($css); $css = $this->fixUrl($css); $css = $this->addLogoAndCustomCss($templateData, $css); file_put_contents($cssFileName, $css); $templateData->css = '<link rel="stylesheet" href="' . $cssFileName . '" type="text/css" media="screen" />'; }
function loadcssfile($file, $cacheFile) { // load the cache if (file_exists($cacheFile)) { $cache = unserialize(file_get_contents($cacheFile)); } else { $cache = $file; } $less = new lessc(); $less->setFormatter("compressed"); $less->setImportDir(array(__ROOT__ . DS . ".." . DS . "style" . DS . "less")); $newCache = $less->cachedCompile($cache); if (!is_array($cache) || $newCache["updated"] > $cache["updated"]) { @file_put_contents($cacheFile, serialize($newCache)); } return $newCache['compiled']; }
protected function parseLess($input) { $parsed = false; try { //include lessc library require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'include' . DIRECTORY_SEPARATOR . 'lessc.inc.php'; //setup the parser $lessc = new lessc(); if ($this->compress) { $lessc->setFormatter("compressed"); } $importDir = array_merge($this->importDir, array(dirname($input))); $lessc->setImportDir($importDir); //parse the file $parsed = $lessc->parse($input); } catch (exception $e) { throw new CException(__CLASS__ . ': Failed to compile less file with message: ' . $e->getMessage() . '.'); } return $parsed; }
public function set($content, $vars = null) { $less = new \lessc(); $lessContent = ($vars === null ? $this->get(true) : $vars) . "/** START CSS */\n"; $newContent = $lessContent . trim($content); $less->setImportDir(PHPFOX_DIR . 'less/'); $content = str_replace('../../../../PF.Base/less/', '', $newContent); $parsed = $less->compile($content); $path = $this->_theme->getPath() . 'flavor/' . $this->_theme->flavor_folder; file_put_contents($path . '.less', $newContent); file_put_contents($path . '.css', $parsed); $this->db->update(':setting', array('value_actual' => (int) \Phpfox::getParam('core.css_edit_id') + 1), 'var_name = \'css_edit_id\''); $this->cache->del('setting'); return true; // file_put_contents($this->_theme->getPath() . 'flavor/' . $this->_theme->flavor_folder . '.min.css', $parsed); // if ($this->_get()) { /* $this->db->update(':theme_template', [ 'html_data' => $parsed, 'html_data_original' => $content, 'time_stamp_update' => PHPFOX_TIME ], [ 'folder' => $this->_theme->folder, 'type_id' => 'css', 'name' => $this->_theme->flavor_folder . '.css' ]); */ // return true; // } /* $this->db->insert(':theme_template', [ 'folder' => $this->_theme->folder, 'type_id' => 'css', 'name' => $this->_theme->flavor_folder . '.css', 'html_data' => $parsed, 'html_data_original' => $content, 'time_stamp' => PHPFOX_TIME ]); */ return true; }
public function beforesave() { $change = true; if (!empty($_POST['bootstrap'])) { $change = $this->cfg['bootstrap'] != $_POST['bootstrap']; } if ($change) { include_once JPATH_SITE . '/components/com_acctexp/lib/lessphp/lessc.inc.php'; $less = new lessc(); $less->setImportDir(array(JPATH_SITE . '/media/com_acctexp/less/')); //$less->setFormatter("compressed"); $less->setPreserveComments(true); if (!isset($_POST['bootstrap'])) { $this->cfg['bootstrap'] = true; } else { $this->cfg['bootstrap'] = $_POST['bootstrap']; } if ($this->cfg['bootstrap']) { $less->compileFile(JPATH_SITE . "/media/com_acctexp/less/template.etacarinae.less", JPATH_SITE . '/media/com_acctexp/css/template.etacarinae.css'); } else { $less->compileFile(JPATH_SITE . "/media/com_acctexp/less/template.etacarinae-reuse-bootstrap.less", JPATH_SITE . '/media/com_acctexp/css/template.etacarinae.css'); } } }
/** * Initialize less compiler * @param $formatterName * @param $z_textColor * @param $z_themeColor * @param $z_themeColor2 * @param $z_themeColorBtn * @param $z_themeColorHeader * @param $z_path * @return lessc */ protected function initializeLessCompiler($formatterName, $z_textColor, $z_themeColor, $z_themeColor2, $z_themeColorBtn, $z_themeColorHeader, $z_path) { $lessCompiler = new lessc(); $lessCompiler->setPreserveComments(false); $lessCompiler->setFormatter($formatterName); $lessCompiler->setImportDir($this->getLessFilesPath()); $lessCompiler->setVariables(array("z_textColor" => $z_textColor, "z_themeColor" => $z_themeColor, "z_themeColor2" => $z_themeColor2, "z_themeColorBtn" => $z_themeColorBtn, "z_themeColorHeader" => $z_themeColorHeader, "z_path" => $z_path)); return $lessCompiler; }
function compile_redux_dependencies() { //this is only in developing $complie_every_load = WP_DEBUG ? true : false; $minify = WP_DEBUG ? false : true; $widgets = apply_filters('redux-widgets-options', array()); $_js = array(); $_js_frontend = array(); $_less = array(); global $wp_filesystem; // Initialize the Wordpress filesystem, no more using file_put_contents function if (empty($wp_filesystem)) { require_once ABSPATH . '/wp-admin/includes/file.php'; WP_Filesystem(); } //we need to include color and spaces fields for sections $widgets[] = array('fields' => array(array('type' => 'color'), array('type' => 'spacing'))); foreach ($widgets as $sections) { foreach ($sections['fields'] as $field) { if (file_exists(ReduxPageBuilder::$_dir . '/inc/fields/' . $field['type'] . '/field_' . $field['type'] . '.js')) { $_js[$field['type']] = ReduxPageBuilder::$_dir . '/inc/fields/' . $field['type'] . '/field_' . $field['type'] . '.js'; } elseif (file_exists(ReduxFramework::$_dir . 'inc/fields/' . $field['type'] . '/field_' . $field['type'] . '.js')) { $_js[$field['type']] = ReduxFramework::$_dir . 'inc/fields/' . $field['type'] . '/field_' . $field['type'] . '.js'; } if (file_exists(ReduxPageBuilder::$_dir . '/inc/fields/' . $field['type'] . '/field_' . $field['type'] . '.less')) { $_less[$field['type']] = ReduxPageBuilder::$_dir . '/inc/fields/' . $field['type'] . '/field_' . $field['type'] . '.less'; } elseif (file_exists(ReduxFramework::$_dir . 'inc/fields/' . $field['type'] . '/field_' . $field['type'] . '.less')) { $_less[$field['type']] = ReduxFramework::$_dir . 'inc/fields/' . $field['type'] . '/field_' . $field['type'] . '.less'; } } } //JS if (!get_option('cached_redux_js')) { update_option('cached_redux_js', serialize($_js)); } if (get_option('cached_redux_js') != serialize($_js) || $complie_every_load) { //we recomplie here $_js['numeric'] = ReduxPageBuilder::$_dir . 'assets/js/jquery.numeric.min.js'; $_js['select2'] = ReduxPageBuilder::$_dir . 'assets/js/select2.min.js'; $_js['redux'] = ReduxPageBuilder::$_dir . 'assets/js/redux.js'; require_once 'minify/jsmin-1.1.1.php'; $js = ''; foreach ($_js as $file) { $js .= $minify ? JSMin::minify(file_get_contents($file)) : file_get_contents($file); } $js = str_replace('#redux-main', '#dialog', $js); file_put_contents(ReduxPageBuilder::$_dir . "assets/js/builder.min.js", $js); } //JS frontend if (!get_option('cached_redux_js_frontend')) { update_option('cached_redux_js_frontend', serialize($_js_frontend)); } if (get_option('cached_redux_js_frontend') != serialize($_js_frontend) || $complie_every_load) { $include_bs = apply_filters('builder-include-bs', true); if ($include_bs) { $_js_frontend['bootstrap'] = ReduxPageBuilder::$_dir . 'assets/js/bootstrap.min.js'; } //we recomplie here $_js_frontend['fancybox'] = ReduxPageBuilder::$_dir . 'assets/js/jquery.fancybox-1.3.4.js'; $_js_frontend['mousewheel'] = ReduxPageBuilder::$_dir . 'assets/js/jquery.mousewheel-3.0.4.pack.js'; $_js_frontend['mixitup'] = ReduxPageBuilder::$_dir . 'assets/js/jquery.mixitup.js'; $_js_frontend['frontend'] = ReduxPageBuilder::$_dir . 'assets/js/builder-frontend.js'; require_once 'minify/jsmin-1.1.1.php'; $js = ''; foreach ($_js_frontend as $file) { $js .= $minify ? JSMin::minify(file_get_contents($file)) : file_get_contents($file); } file_put_contents(ReduxPageBuilder::$_dir . "assets/js/builder-frontend.min.js", $js); } //LESS if (!get_option('cached_redux_less')) { update_option('cached_redux_less', serialize($_less)); } if (get_option('cached_redux_less') != serialize($_less) || $complie_every_load) { $_less['general'] = ReduxPageBuilder::$_dir . 'assets/less/style.less'; $_less['select2'] = ReduxPageBuilder::$_dir . 'assets/less/select2.less'; $_less['BS-ui'] = ReduxPageBuilder::$_dir . 'assets/less/jquery-ui-1.10.0.custom.less'; //we recomplie here if (!class_exists('lessc')) { require_once ReduxPageBuilder::$_dir . '/inc/lessc.inc.php'; } $less = new lessc(); if ($minify) { $less->setFormatter("compressed"); } $css = ''; foreach ($_less as $file) { $css .= $less->compile(file_get_contents($file)); } $css = str_replace('#redux-main', '#dialog', $css); file_put_contents(ReduxPageBuilder::$_dir . "assets/css/builder.min.css", $css); } if ($complie_every_load) { if (!class_exists('lessc')) { require_once FRAMEWORK_DIR . '/lessc.inc.php'; } $less = new lessc(); //$less->setFormatter("compressed"); $less->setImportDir(array(ReduxPageBuilder::$_dir . "assets/less/")); if (function_exists('cadr_variables_less')) { $_less = cadr_variables_less(); $_less .= file_get_contents(ReduxPageBuilder::$_dir . "assets/less/frontend-builder.less"); $_less .= get_builder_css(); $content = $less->compile($_less); $file = ReduxPageBuilder::$_dir . "assets/css/frontend-builder.css"; if (is_writeable($file) || !file_exists($file) && is_writeable(dirname($file))) { $wp_filesystem->put_contents($file, $content, FS_CHMOD_FILE); } } $less->checkedCompile(ReduxPageBuilder::$_dir . "assets/less/frontend-builder.less", ReduxPageBuilder::$_dir . "assets/css/frontend-builder.css"); } }
/** * Compile LESS into CSS. * * @param string|array $source_filename * @param string $target_filename * @param array $variables (optional) * @parsm bool $minify (optional) * @return bool */ public static function compileLESS($source_filename, $target_filename, $variables = array(), $minify = false) { // Get the cleaned and concatenated content. $content = self::concatCSS($source_filename, $target_filename); // Compile! try { $less_compiler = new \lessc(); $less_compiler->setFormatter($minify ? 'compressed' : 'lessjs'); $less_compiler->setImportDir(array(dirname(is_array($source_filename) ? array_first($source_filename) : $source_filename))); if ($variables) { $less_compiler->setVariables($variables); } $charset = strpos($content, '@charset') === false ? '@charset "UTF-8";' . "\n" : ''; $content = $charset . $less_compiler->compile($content) . "\n"; $result = true; } catch (\Exception $e) { $content = '/*' . "\n" . 'Error while compiling LESS:' . "\n" . $e->getMessage() . "\n" . '*/' . "\n"; $result = false; } // Save the result to the target file. Storage::write($target_filename, $content); return $result; }
public function lessen(&$errors) { // Convert LESS files include_once JPATH_SITE . '/components/com_acctexp/lib/lessphp/lessc.inc.php'; $less = new lessc(); $less->setImportDir(array(JPATH_SITE . '/media/com_acctexp/less/')); $less->setPreserveComments(true); $v = new JVersion(); if ($v->isCompatible('3.0')) { $less->compileFile(JPATH_SITE . "/media/com_acctexp/less/admin-j3.less", JPATH_SITE . '/media/com_acctexp/css/admin.css'); } else { $less->compileFile(JPATH_SITE . "/media/com_acctexp/less/admin.less", JPATH_SITE . '/media/com_acctexp/css/admin.css'); } }
require_once locate_template('/lib/3rdparty/lessc.inc.php'); if (class_exists('lessc') && ya_options()->getCpanelValue('developer_mode')) { define('LESS_PATH', get_template_directory() . '/assets/less'); define('CSS__PATH', get_template_directory() . '/assets/css'); $scheme = ya_options()->getCpanelValue('scheme'); $scheme_vars = get_template_directory() . '/templates/presets/default.php'; $output_cssf = CSS__PATH . '/app-default.css'; if ($scheme && file_exists(get_template_directory() . '/templates/presets/' . $scheme . '.php')) { $scheme_vars = get_template_directory() . '/templates/presets/' . $scheme . '.php'; $output_cssf = CSS__PATH . "/app-{$scheme}.css"; } if (file_exists($scheme_vars)) { include $scheme_vars; try { // less variables by theme_mod // $less_variables['sidebar-width'] = ya_options()->sidebar_collapse_width.'px'; $less = new lessc(); $less->setImportDir(array(LESS_PATH . '/app/', LESS_PATH . '/bootstrap/')); $less->setVariables($less_variables); $cache = $less->cachedCompile(LESS_PATH . '/app.less'); file_put_contents($output_cssf, $cache["compiled"]); if (ya_options()->getCpanelValue('responsive_support')) { $responsive_cache = $less->cachedCompile(LESS_PATH . '/app-responsive.less'); file_put_contents(CSS__PATH . '/app-responsive.css', $responsive_cache["compiled"]); } } catch (Exception $e) { var_dump($e); exit; } } }
$last_modified = file_exists($cfile) ? filemtime($cfile) : 0; if (is_array($bigtree["config"]["css"]["files"][$css_file])) { foreach ($bigtree["config"]["css"]["files"][$css_file] as $style) { $m = file_exists(SITE_ROOT . "css/{$style}") ? filemtime(SITE_ROOT . "css/{$style}") : 0; if ($m > $mtime) { $mtime = $m; } } // If we have a newer CSS file to include or we haven't cached yet, do it now. if (!file_exists($cfile) || $mtime > $last_modified) { $data = ""; if (is_array($bigtree["config"]["css"]["files"][$css_file])) { // if we need LESS if (strpos(implode(" ", $bigtree["config"]["css"]["files"][$css_file]), "less") > -1) { $less_compiler = new lessc(); $less_compiler->setImportDir(array(SITE_ROOT . "css/")); } foreach ($bigtree["config"]["css"]["files"][$css_file] as $style_file) { $style = file_get_contents(SITE_ROOT . "css/{$style_file}"); if (strpos($style_file, "less") > -1) { // convert LESS $style = $less_compiler->compile($style); } else { // normal CSS if ($bigtree["config"]["css"]["prefix"]) { // Replace CSS3 easymode $style = BigTree::formatCSS3($style); } } $data .= $style . "\n"; }
/** * Using less parser parse variables into valid template * @param array $variables * @return string Parsed bootstrap with given variables */ public function parseTemplate($variables) { $bootstrap = file_get_contents($this->moduledir . 'bootstrap' . DS . 'bootstrap.less'); //1st parse bootstrap for imports $bootstrap = preg_replace_callback('/(@import[\\s]+"([a-z\\.-]+)";)/', function ($matches) { if ($matches[0]) { return file_get_contents(MAINDIR . 'includes' . DS . 'modules' . DS . 'Other' . DS . 'styleswitcher' . DS . 'bootstrap' . DS . 'less' . DS . $matches[2]); } }, $bootstrap); $str = "\r\n"; $customcss = $variables['@customcss']; unset($variables['@customcss']); foreach ($variables as $k => $v) { $str .= $k . ": " . $v . ";\r\n"; } $bootstrap = $str . $bootstrap . $customcss; $less = new lessc(); $less->setFormatter("compressed"); $less->setImportDir(array("bootstrap/less", "less", $this->moduledir . "bootstrap/less", $this->moduledir . "bootstrap")); return $less->compile($bootstrap); }
function compile($less_input, $less_variables, $import_dirs) { $less = new lessc(); $less->setVariables($less_variables); $less->setImportDir($import_dirs); return $less->compile($less_input); }
public function buildFile($fileName, $locationBuild = 'module', $themeName = 'default') { switch ($locationBuild) { case 'app': $suffixPath = ''; //check later break; case 'static': $suffixPath = ''; //check later break; case 'module': $suffixPath = PHPFOX_DIR_MODULE; break; default: $suffixPath = PHPFOX_DIR_MODULE; break; } //get less variable and remove import $variable = $this->get(true); $aVariable = explode(';', $variable); foreach ($aVariable as $key => $var) { $string = str_replace("\r", "", $var); $string = str_replace("\n", "", $string); $string = trim(trim($string, '\\n'), ' '); if (strpos($string, '@import') !== false) { $variable = str_replace($string . ';', '', $variable); } } $less = new \lessc(); //build $lessContent = $variable . file_get_contents($suffixPath . $fileName); if (strtolower($themeName) == 'bootstrap') { $less->setImportDir([PHPFOX_DIR . 'theme/frontend/bootstrap/less/']); } else { $less->setImportDir(PHPFOX_DIR . 'less/'); } $content = str_replace('../../../../PF.Base/less/', '', $lessContent); $parsed = $less->compile($content); $fileName = trim($fileName, '/'); $path = $this->_theme->getPath() . 'flavor/' . substr(str_replace([PHPFOX_DS, '/', '\\'], ['_', '_', '_'], $fileName), 0, -4); $path = trim($path, '.'); file_put_contents($path . '.css', $parsed); }
/** * Updates and compiles Twitter Bootstrap with Font Awesome. * * This will update to the latest and rebuild the less files. * By default Font Awesome fonts will be used instead of Twitter Bootstrap's * default glyphs. You can pass the first argument false if you do not want this. * * This will also update the Twitter Bootstrap based editor, bootstrap-wysihtml5. * * @param $fontAwesome Flag false if you do NOT want to use Font Awesome instead of Twitter Bootstrap glyphs * @return [type] [description] */ public function updateBootstrap($fontAwesome = true) { $appRoot = $this->_appConfig['path']; $libDir = $appRoot . '/libraries/li3b_core'; echo "Updating all things Twitter Bootstrap...\n"; system("(cd {$libDir} && {$this->_gitCommand} submodule update --recursive) 2>&1"); $twitterBootstrapDir = $libDir . '/webroot/bootstrap'; $twitterBootstrapLess = $twitterBootstrapDir . '/less/bootstrap.less'; $twitterBootstrapResponsiveLess = $twitterBootstrapDir . '/less/responsive.less'; $cssOutputDir = $libDir . '/webroot/css'; $fontOutputDir = $libDir . '/webroot/font'; $twitterBootstrapFontAwesomeLess = $twitterBootstrapDir . '/less/bootstrap-with-font-awesome.less'; $twitterBootstrapFontAwesomeLessTmp = $twitterBootstrapDir . '/less/bootstrap-with-font-awesome.less.tmp'; $fontAwesomeDir = $libDir . '/webroot/font-awesome'; $fontAwesomeLess = $fontAwesomeDir . '/less/font-awesome.less'; // If using Font Awesome icons (default behavior). if ($fontAwesome) { copy($twitterBootstrapLess, $twitterBootstrapFontAwesomeLess); $reading = fopen($twitterBootstrapFontAwesomeLess, 'r'); $writing = fopen($twitterBootstrapFontAwesomeLessTmp, 'w'); $replaced = false; while (!feof($reading)) { $line = fgets($reading); if (stristr($line, '@import "sprites.less";')) { $line = '@import "font-awesome.less";' . "\n"; $replaced = true; } fputs($writing, $line); } fclose($reading); fclose($writing); // might as well not overwrite the file if we didn't replace anything if ($replaced) { rename($twitterBootstrapFontAwesomeLessTmp, $twitterBootstrapFontAwesomeLess); } else { unlink($twitterBootstrapFontAwesomeLessTmp); } // Copy over the font files. copy($fontAwesomeDir . '/font/fontawesome-webfont.eot', $fontOutputDir . '/fontawesome-webfont.eot'); copy($fontAwesomeDir . '/font/fontawesome-webfont.ttf', $fontOutputDir . '/fontawesome-webfont.ttf'); copy($fontAwesomeDir . '/font/fontawesome-webfont.woff', $fontOutputDir . '/fontawesome-webfont.woff'); copy($fontAwesomeDir . '/font/FontAwesome.otf', $fontOutputDir . '/FontAwesome.otf'); } // Sure, this could be another library, but I want it bundled with li3b_core. // Since when did PHP become a dependency nightmare?? // TODO: Think about using and requiring Composer for everything... require $libDir . '/util/lessphp/lessc.inc.php'; $less = new \lessc(); $less->setFormatter("compressed"); $less->setImportDir(array($fontAwesomeDir . '/less', $twitterBootstrapDir . '/less')); if (file_exists($twitterBootstrapLess)) { try { if ($fontAwesome) { $less->checkedCompile($twitterBootstrapFontAwesomeLess, $cssOutputDir . '/bootstrap.min.css'); // Tidy up and remove the new Twitter Bootstrap with Font Awesome LESS file. unlink($twitterBootstrapFontAwesomeLess); echo 'Compiled Twitter Bootstrap LESS with Font Awesome.'; echo $this->nl(); } else { $less->checkedCompile($twitterBootstrapLess, $cssOutputDir . '/bootstrap.min.css'); echo 'Compiled Twitter Bootstrap LESS.'; echo $this->nl(); } } catch (exception $e) { echo 'Fatal error compiling Twitter Bootstrap LESS file: ' . $e->getMessage(); } // Compile the Twitter Bootstrap responsive LESS file. try { $less->checkedCompile($twitterBootstrapResponsiveLess, $cssOutputDir . '/bootstrap-responsive.min.css'); } catch (exception $e) { echo 'Fatal error compiling Twitter Bootstrap LESS file: ' . $e->getMessage(); } } }
/** * Returns LESS compiler set up for use with MediaWiki * * @param Config $config * @throws MWException * @since 1.22 * @return lessc */ public static function getLessCompiler(Config $config) { // 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('lessc')) { throw new MWException('MediaWiki requires the lessphp compiler'); } if (!function_exists('ctype_digit')) { throw new MWException('lessc requires the Ctype extension'); } $less = new lessc(); $less->setPreserveComments(true); $less->setVariables(self::getLessVars($config)); $less->setImportDir($config->get('ResourceLoaderLESSImportPaths')); foreach ($config->get('ResourceLoaderLESSFunctions') as $name => $func) { $less->registerFunction($name, $func); } return $less; }
protected function autoCompileLess($inputFile) { global $okt; $outputFile = OKT_PUBLIC_PATH . '/cache/' . md5($inputFile) . '.css'; $cacheFile = $outputFile . '.cache'; if (file_exists($cacheFile)) { $cache = unserialize(file_get_contents($cacheFile)); } else { $cache = $inputFile; } try { $less = new lessc(); $less->setPreserveComments(true); $less->setImportDir(array(isset($okt->theme->path) ? $okt->theme->path . '/css/' : null, OKT_PUBLIC_PATH . '/css/less/')); $less->setVariables($okt->theme->getLessVariables()); $newCache = $less->cachedCompile($cache); } catch (Exception $ex) { $okt->error->set('lessphp fatal error: ' . $ex->getMessage()); } if (!is_array($cache) || $newCache['updated'] > $cache['updated']) { file_put_contents($cacheFile, serialize($newCache)); file_put_contents($outputFile, $newCache['compiled']); } return str_replace(OKT_PUBLIC_PATH, $okt->config->app_path . OKT_PUBLIC_DIR, $outputFile); }
/** * @see \wcf\system\SingletonFactory::init() */ protected function init() { require_once WCF_DIR . 'lib/system/style/lessc.inc.php'; $this->compiler = new \lessc(); $this->compiler->setImportDir(array(WCF_DIR)); }
/** * Handle SCSS/LESS files * * @param string $content The file content * @param array $arrFile The file array * * @return string The modified file content */ protected function handleScssLess($content, $arrFile) { if ($arrFile['extension'] == self::SCSS) { $objCompiler = new \scssc(); new \scss_compass($objCompiler); $objCompiler->setImportPaths(array(TL_ROOT . '/' . dirname($arrFile['name']), TL_ROOT . '/vendor/leafo/scssphp-compass/stylesheets')); $objCompiler->setFormatter(\Config::get('debugMode') ? 'scss_formatter' : 'scss_formatter_compressed'); } else { $objCompiler = new \lessc(); $objCompiler->setImportDir(array(TL_ROOT . '/' . dirname($arrFile['name']))); $objCompiler->setFormatter(\Config::get('debugMode') ? 'lessjs' : 'compressed'); } return $this->fixPaths($objCompiler->compile($content), $arrFile); }
case 'recallinstall': include_once JPATH_SITE . '/administrator/components/com_acctexp/install.acctexp.php'; com_install(); break; case 'initsettings': $aecConfig = new aecConfig(); $aecConfig->initParams(); echo 'SPLINES RETICULATED.'; break; case 'parsertest': $top = new templateOverrideParser(); break; case 'lessen': include_once JPATH_SITE . '/components/com_acctexp/lib/lessphp/lessc.inc.php'; $less = new lessc(); $less->setImportDir(array(JPATH_SITE . '/media/com_acctexp/less/')); //$less->setFormatter("compressed"); $less->setPreserveComments(true); $v = new JVersion(); if ($v->isCompatible('3.0')) { $less->compileFile(JPATH_SITE . "/media/com_acctexp/less/admin-j3.less", JPATH_SITE . '/media/com_acctexp/css/admin.css'); } else { $less->compileFile(JPATH_SITE . "/media/com_acctexp/less/admin.less", JPATH_SITE . '/media/com_acctexp/css/admin.css'); } break; default: $class = 'aecAdmin' . ucfirst($entity); /** @var aecAdminEntity $class */ $class = new $class($id, $entity); $class->call($task); break;