public function run()
 {
     if (!$this->srcPath) {
         throw new \UnexpectedValueException("Please specify srcPath first.");
     }
     if (!$this->targetPath) {
         throw new \UnexpectedValueException("Please specify targetPath first.");
     }
     if (!is_dir($this->targetPath)) {
         mkdir($this->targetPath, 0777);
     }
     $lastLessEditTime = 0;
     foreach (\Nette\Utils\Finder::find("*.less")->from($this->getSrcPath()) as $file) {
         $lastLessEditTime = max($lastLessEditTime, $file->getMTime());
     }
     $lastCompileTime = 0;
     foreach (\Nette\Utils\Finder::find("*.css")->from($this->getTargetPath()) as $file) {
         $lastCompileTime = max($lastCompileTime, $file->getMTime());
     }
     $compiler = new \lessc();
     foreach ($this->getfilesMapping() as $src => $target) {
         if (!is_file($this->targetPath . "/" . $target) || $lastLessEditTime > $lastCompileTime) {
             $compiler->compileFile($this->srcPath . "/" . $src, $this->targetPath . "/" . $target);
         }
     }
 }
function CompileOptionsLess($inputFile)
{
    global $dynamo_tpl;
    require_once get_template_directory() . '/dynamo_framework/lib/lessc.inc.php';
    $less = new lessc();
    $less->setPreserveComments(true);
    $url = "'" . get_template_directory_uri() . "'";
    $body_bg_image = "'" . get_option($dynamo_tpl->name . '_body_bg_image') . "'";
    $page404_bg_image = "'" . get_option($dynamo_tpl->name . '_page404_bg_image') . "'";
    $subheader_area_bgimage = "'" . get_option($dynamo_tpl->name . '_subheader_area_bgimage') . "'";
    $branding_logo_image = "'" . get_option($dynamo_tpl->name . '_branding_logo_image') . "'";
    $expander_bgimage = "'" . get_option($dynamo_tpl->name . '_expander_bgimage') . "'";
    $footer_bg_image = "'" . get_option($dynamo_tpl->name . '_footer_bg_image') . "'";
    $expander_bgimage = "'" . get_option($dynamo_tpl->name . '_expander_bgimage') . "'";
    $footerbgtype = 'n';
    if (get_option($dynamo_tpl->name . '_footer_pattern', 'none') != 'none') {
        $footerbgtype = 'p';
    }
    if (get_option($dynamo_tpl->name . '_footer_bg_image') != '') {
        $footerbgtype = 'i';
    }
    $expanderbgtype = 'n';
    if (get_option($dynamo_tpl->name . '_expander_pattern', 'none') != 'none') {
        $expanderbgtype = 'p';
    }
    if (get_option($dynamo_tpl->name . '_expander_bgimage') != '') {
        $expanderbgtype = 'i';
    }
    $less->setVariables(array("url" => $url, "fontsize_body" => get_option($dynamo_tpl->name . '_fontsize_body', '13px'), "fontsize_h1" => get_option($dynamo_tpl->name . '_fontsize_h1', '40px'), "fontsize_h2" => get_option($dynamo_tpl->name . '_fontsize_h2', '30px'), "fontsize_h3" => get_option($dynamo_tpl->name . '_fontsize_h3', '18px'), "fontsize_h4" => get_option($dynamo_tpl->name . '_fontsize_h4', '16px'), "fontsize_h5" => get_option($dynamo_tpl->name . '_fontsize_h5', '14px'), "fontsize_h6" => get_option($dynamo_tpl->name . '_fontsize_h6', '12px'), "maincontent_accent_color" => get_option($dynamo_tpl->name . '_maincontent_accent_color', '#3296dc'), "maincontent_secondary_accent_color" => get_option($dynamo_tpl->name . '_maincontent_secondary_accent_color', '#000000'), "page_wrap_state" => get_option($dynamo_tpl->name . '_page_wrap_state', 'streched'), "page_bgcolor" => get_option($dynamo_tpl->name . '_page_bgcolor', '#ffffff'), "page_pattern" => get_option($dynamo_tpl->name . '_page_pattern', 'none'), "body_bg_image_state" => get_option($dynamo_tpl->name . '_body_bg_image_state', 'N'), "body_bg_image" => $body_bg_image, "body_bgcolor" => get_option($dynamo_tpl->name . '_body_bgcolor', '#ffffff'), "body_pattern" => get_option($dynamo_tpl->name . '_body_pattern', 'none'), "paspartu_state" => get_option($dynamo_tpl->name . '_paspartu_state', 'N'), "paspartu_bg_color" => get_option($dynamo_tpl->name . '_paspartu_bg_color', '#ffffff'), "paspartu_width" => get_option($dynamo_tpl->name . '_paspartu_width', '30') . 'px', "top_bar_bg_color" => get_option($dynamo_tpl->name . '_top_bar_bg_color', '#000000'), "top_bar_text_color" => get_option($dynamo_tpl->name . '_top_bar_text_color', '#ffffff'), "top_bar_link_color" => get_option($dynamo_tpl->name . '_top_bar_link_color', '#3296dc'), "top_bar_hlink_color" => get_option($dynamo_tpl->name . '_top_bar_hlink_color', '#f2f2f2'), "top_bar_icon_color" => get_option($dynamo_tpl->name . '_top_bar_icon_color', '#ffffff'), "branding_logo_type" => get_option($dynamo_tpl->name . '_branding_logo_type'), "branding_logo_image" => $branding_logo_image, "branding_logo_image_width" => get_option($dynamo_tpl->name . '_branding_logo_image_width', '160') . 'px', "branding_logo_image_height" => get_option($dynamo_tpl->name . '_branding_logo_image_height', '50') . 'px', "branding_logo_top_margin" => get_option($dynamo_tpl->name . '_branding_logo_top_margin', '30') . 'px', "branding_logo_bottom_margin" => get_option($dynamo_tpl->name . '_branding_logo_bottom_margin', '10') . 'px', "sticky_logo_top_margin" => get_option($dynamo_tpl->name . '_sticky_logo_top_margin', '10') . 'px', "menu_top_bg_color" => get_option($dynamo_tpl->name . '_menu_top_bg_color', 'transparent'), "top_mainmenu_link_color" => get_option($dynamo_tpl->name . '_top_mainmenu_link_color', '#222222'), "top_mainmenu_hlink_color" => get_option($dynamo_tpl->name . '_top_mainmenu_hlink_color', '#3296dc'), "sticky_header_bgcolor" => get_option($dynamo_tpl->name . '_sticky_header_bgcolor', 'rgba(255,255,255,0.95)'), "sticky_mainmenu_link_color" => get_option($dynamo_tpl->name . '_sticky_mainmenu_link_color', '#222222'), "sticky_mainmenu_hlink_color" => get_option($dynamo_tpl->name . '_sticky_mainmenu_hlink_color', '#3296dc'), "aside_logo_image_width" => get_option($dynamo_tpl->name . '_aside_logo_image_width', '101') . 'px', "aside_logo_image_height" => get_option($dynamo_tpl->name . '_aside_logo_image_height', '35') . 'px', "aside_mainmenu_bg_color" => get_option($dynamo_tpl->name . '_aside_mainmenu_bg_color', '#ffffff'), "aside_mainmenu_link_color" => get_option($dynamo_tpl->name . '_aside_mainmenu_link_color', '#222222'), "aside_mainmenu_hlink_color" => get_option($dynamo_tpl->name . '_aside_mainmenu_hlink_color', '#3296dc'), "submenu_bgcolor" => get_option($dynamo_tpl->name . '_submenu_bgcolor', '#ffffff'), "submenu_topbordercolor" => get_option($dynamo_tpl->name . '_submenu_topbordercolor', '#3296dc'), "submenu_link_color" => get_option($dynamo_tpl->name . '_submenu_link_color', '#AFB4B9'), "submenu_hlink_color" => get_option($dynamo_tpl->name . '_submenu_hlink_color', '#AFB4B9'), "submenu_hbg_color" => get_option($dynamo_tpl->name . '_submenu_hbg_color', '#F6F6F6'), "overlay_mainmenu_bg_color" => get_option($dynamo_tpl->name . '_overlay_mainmenu_bg_color', '#ffffff'), "overlay_mainmenu_link_color" => get_option($dynamo_tpl->name . '_overlay_mainmenu_link_color', '#222222'), "overlay_mainmenu_hlink_color" => get_option($dynamo_tpl->name . '_overlay_mainmenu_hlink_color', '#3296dc'), "overlay_mainmenu_bg_color" => get_option($dynamo_tpl->name . '_overlay_mainmenu_bg_color', '#ffffff'), "overlay_mainmenu_link_color" => get_option($dynamo_tpl->name . '_overlay_mainmenu_link_color', '#222222'), "overlay_mainmenu_hlink_color" => get_option($dynamo_tpl->name . '_overlay_mainmenu_hlink_color', '#3296dc'), "overlapping_header_bgcolor" => get_option($dynamo_tpl->name . '_overlapping_header_bgcolor', '#ffffff'), "overlapping_mainmenu_link_color_light" => get_option($dynamo_tpl->name . '_overlapping_mainmenu_link_color_light', '#ffffff'), "overlapping_mainmenu_hlink_color_light" => get_option($dynamo_tpl->name . '_overlapping_mainmenu_hlink_color_light', '#3296dc'), "overlapping_mainmenu_link_color_dark" => get_option($dynamo_tpl->name . '_overlapping_mainmenu_link_color_dark', '#222222'), "overlapping_mainmenu_hlink_color_dark" => get_option($dynamo_tpl->name . '_overlapping_mainmenu_hlink_color_dark', '#3296dc'), "subheader_bgcolor" => get_option($dynamo_tpl->name . '_subheader_bgcolor', '#F7F8FA'), "subheader_pattern" => get_option($dynamo_tpl->name . '_subheader_pattern', 'none'), "subheader_area_bgimage" => $subheader_area_bgimage, "subheader_text_color" => get_option($dynamo_tpl->name . '_subheader_text_color', '#ffffff'), "expander_bgcolor" => get_option($dynamo_tpl->name . '_expander_bgcolor', '#222222'), "expander_bgimage" => $expander_bgimage, "expander_pattern" => get_option($dynamo_tpl->name . '_expander_pattern', 'none'), "expander_text_color" => get_option($dynamo_tpl->name . '_eexpander_text_color', '#ffffff'), "expander_link_color" => get_option($dynamo_tpl->name . '_expander_link_color', '#3296dc'), "expander_hlink_color" => get_option($dynamo_tpl->name . '_expander_hlink_color', '#f6f6f6'), "expanderbgtype" => $expanderbgtype, "maincontent_text_color" => get_option($dynamo_tpl->name . '_maincontent_text_color', '#7A7A7A'), "maincontent_headers_color" => get_option($dynamo_tpl->name . '_maincontent_headers_color', '#7A7A7A'), "maincontent_link_color" => get_option($dynamo_tpl->name . '_maincontent_link_color', '#3296dc'), "maincontent_hlink_color" => get_option($dynamo_tpl->name . '_maincontent_hlink_color', '#76797C'), "footer_bg_color" => get_option($dynamo_tpl->name . '_footer_bg_color', '#232D37'), "footer_bg_image" => $footer_bg_image, "footer_pattern" => get_option($dynamo_tpl->name . '_footer_pattern', 'none'), "footer_text_color" => get_option($dynamo_tpl->name . '_footer_text_color', '#BCC1C5'), "footer_header_color" => get_option($dynamo_tpl->name . '_footer_header_color', '#ffffff'), "footer_link_color" => get_option($dynamo_tpl->name . '_footer_link_color', '#ffffff'), "footer_hlink_color" => get_option($dynamo_tpl->name . '_footer_hlink_color', '#3296dc'), "footerbgtype" => $footerbgtype, "copyrightbgcolor" => get_option($dynamo_tpl->name . '_copyright_bg_color', 'rgba(0,0,0,.2)'), "copyrightbordercolor" => get_option($dynamo_tpl->name . '_copyright_border_color', 'rgba(0,0,0,0)'), "copyrighttextcolor" => get_option($dynamo_tpl->name . '_copyright_text_color', '#A2A2A2'), "copyrightlinkcolor" => get_option($dynamo_tpl->name . '_copyright_link_color', '#A2A2A2'), "copyrighthlinkcolor" => get_option($dynamo_tpl->name . '_copyright_hlink_color', '#fff'), "page404_bg_image" => $page404_bg_image, "page404_bg_image_state" => get_option($dynamo_tpl->name . '_404_bg_image_state', 'N')));
    $less->compileFile(get_template_directory() . '/css/less/' . $inputFile, get_template_directory() . '/css/dynamic.css');
}
 /**
  * Parse a Less file to CSS
  */
 public function parse($src, $dst, $options)
 {
     $this->auto = isset($options['auto']) ? $options['auto'] : $this->auto;
     try {
         if ($this->auto) {
             /* @var FileCache $cacheMgr */
             $cacheMgr = Yii::createObject('yii\\caching\\FileCache');
             $cacheMgr->init();
             $cacheId = 'less#' . $dst;
             $cache = $cacheMgr->get($cacheId);
             if ($cache === false || @filemtime($dst) < @filemtime($src)) {
                 $cache = $src;
             }
             $less = new \lessc();
             $newCache = $less->cachedCompile($cache);
             if (!is_array($cache) || $newCache["updated"] > $cache["updated"]) {
                 $cacheMgr->set($cacheId, $newCache);
                 file_put_contents($dst, $newCache['compiled']);
             }
         } else {
             $less = new \lessc();
             $less->compileFile($src, $dst);
         }
     } catch (Exception $e) {
         throw new Exception(__CLASS__ . ': Failed to compile less file : ' . $e->getMessage() . '.');
     }
 }
 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 CSS files used by admin ui
  *
  * @throws Exception
  */
 protected function _compileCss()
 {
     $bootstrapPath = WWW_ROOT . 'bootstrap';
     if (!file_exists($bootstrapPath)) {
         if (!$this->_clone) {
             throw new Exception('You don\'t have "bootstrap" directory in ' . WWW_ROOT);
         }
         CakeLog::info('Cloning Bootstrap...');
         chdir(WWW_ROOT);
         exec('git clone git://github.com/twitter/bootstrap');
     }
     chdir($bootstrapPath);
     exec('git checkout -f v2.2.0');
     App::import('Vendor', 'Lessc', array('file' => 'lessphp' . DS . 'lessc.inc.php'));
     $lessc = new lessc();
     $formatter = new lessc_formatter_lessjs();
     $formatter->compressColors = false;
     ini_set('precision', 16);
     $lessc->setFormatter($formatter);
     $files = array('less' . DS . 'admin.less' => CSS . 'croogo-bootstrap.css', 'less' . DS . 'admin-responsive.less' => CSS . 'croogo-bootstrap-responsive.css');
     foreach ($files as $file => $output) {
         $out = str_replace(APP, '', $output);
         if ($lessc->compileFile(WWW_ROOT . $file, $output)) {
             $text = __('CSS : %s created', $out);
             CakeLog::info($text);
         } else {
             $text = __('CSS : %s failed', $out);
             CakeLog::error($text);
         }
     }
 }
function auto_less_compile($inputFile, $outputFile)
{
    // load the cache
    $cacheFile = $inputFile . ".cache";
    if (file_exists($cacheFile)) {
        $cache = unserialize(file_get_contents($cacheFile));
    } else {
        $cache = $inputFile;
    }
    // custom formatter
    $formatter = new lessc_formatter_classic();
    $formatter->indentChar = "\t";
    $less = new lessc();
    $less->setFormatter($formatter);
    try {
        // create a new cache object, and compile
        $newCache = $less->cachedCompile($cache);
        // the next time we run, write only if it has updated
        if (!is_array($cache) || $newCache["updated"] > $cache["updated"]) {
            file_put_contents($cacheFile, serialize($newCache));
            file_put_contents($outputFile, $newCache['compiled']);
        }
    } catch (Exception $ex) {
        echo "lessphp fatal error: " . $ex->getMessage();
    }
}
Exemple #7
0
 public function __invoke($file, $minify = null)
 {
     if (!is_file($this->getOptions()->getPublicDir() . $file)) {
         throw new \InvalidArgumentException('File "' . $this->getOptions()->getPublicDir() . $file . '" not found.');
     }
     $less = new \lessc();
     $info = pathinfo($file);
     $newFile = $this->getOptions()->getDestinationDir() . $info['filename'] . '.' . filemtime($this->getOptions()->getPublicDir() . $file) . '.css';
     $_file = $this->getOptions()->getPublicDir() . $newFile;
     if (!is_file($_file)) {
         $globPattern = $this->getOptions()->getPublicDir() . $this->getOptions()->getDestinationDir() . $info['filename'] . '.*.css';
         foreach (Glob::glob($globPattern, Glob::GLOB_BRACE) as $match) {
             if (preg_match("/^" . $info['filename'] . "\\.[0-9]{10}\\.css\$/", basename($match))) {
                 unlink($match);
             }
         }
         $compiledFile = new \SplFileObject($_file, 'w');
         $result = $less->compileFile($this->getOptions()->getPublicDir() . $file);
         if (is_null($minify) && $this->getOptions()->getMinify() || $minify === true) {
             $result = \CssMin::minify($result);
         }
         $compiledFile->fwrite($result);
     }
     return $newFile;
 }
 function css($file, $media = null)
 {
     /* 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, then check/compile it */
     if (preg_match('/\\.less$/i', $file)) {
         $compiler = 'checkedCompile';
         $out = preg_replace('/\\.less$/i', '.css', $file);
         /* Force recompile if ?flush */
         if (isset($_GET['flush'])) {
             $compiler = 'compileFile';
         }
         /* Create instance */
         $less = new lessc();
         /* Automatically compress if in live mode */
         if (DIRECTOR::isLive()) {
             $less->setFormatter("compressed");
         }
         try {
             $less->{$compiler}(Director::getAbsFile($file), Director::getAbsFile($out));
         } catch (Exception $ex) {
             trigger_error("lessphp fatal error: " . $ex->getMessage(), E_USER_ERROR);
         }
         $file = $out;
     }
     /* Return css path */
     return parent::css($file, $media);
 }
Exemple #9
0
 protected function doProcess($inputPath, $outputPath)
 {
     $this->ensureInitialized();
     if ($this->jsToolOptions === false) {
         $less = new \lessc();
         if ($this->pieCrust->isCachingEnabled()) {
             $cacheUri = 'less/' . sha1($inputPath);
             $cacheData = $this->readCacheData($cacheUri);
             if ($cacheData) {
                 $lastUpdated = $cacheData['updated'];
             } else {
                 $lastUpdated = false;
                 $cacheData = $inputPath;
             }
             $cacheData = $less->cachedCompile($cacheData);
             $this->writeCacheData($cacheUri, $cacheData);
             if (!$lastUpdated || $cacheData['updated'] > $lastUpdated) {
                 file_put_contents($outputPath, $cacheData['compiled']);
             }
         } else {
             $less->compileFile($inputPath, $outputPath);
         }
     } else {
         $exe = $this->jsToolOptions['bin'];
         $options = $this->jsToolOptions['options'];
         $cmd = "{$exe} {$options} \"{$inputPath}\" \"{$outputPath}\"";
         $this->logger->debug('$> ' . $cmd);
         shell_exec($cmd);
     }
 }
Exemple #10
0
/**
 * Generate custom color scheme css
 *
 * @since 1.0
 */
function bigboom_generate_custom_color_scheme()
{
    parse_str($_POST['data'], $data);
    if (!isset($data['custom_color_scheme'])) {
        return;
    }
    if (!$data['custom_color_scheme']) {
        return;
    }
    $color_1 = $data['custom_color_1'];
    if (!$color_1) {
        return;
    }
    // Prepare LESS to compile
    $less = file_get_contents(THEME_DIR . '/css/color-schemes/mixin.less');
    $less .= ".custom-color-scheme { .color-scheme({$color_1}); }";
    // Compile
    require THEME_DIR . '/inc/libs/lessc.inc.php';
    $compiler = new lessc();
    $compiler->setFormatter('compressed');
    $css = $compiler->compile($less);
    // Get file path
    $upload_dir = wp_upload_dir();
    $dir = path_join($upload_dir['basedir'], 'custom-css');
    $file = $dir . '/color-scheme.css';
    // Create directory if it doesn't exists
    wp_mkdir_p($dir);
    @file_put_contents($file, $css);
    wp_send_json_success();
}
Exemple #11
0
 /**
  * Process asset content
  *
  * @param   string $content
  * @param   Asset  $asset
  *
  * @return  string
  */
 public static function process($content, Asset $asset)
 {
     // Set Less
     $lc = new lessc();
     $lc->importDir = dirname($asset->source_file()) . DIRECTORY_SEPARATOR;
     return $lc->parse($content);
 }
 public function boot(Application $app)
 {
     // Validate this params.
     $this->validate($app);
     // Define default formatter if not already set.
     $formatter = isset($app['less.formatter']) ? $app['less.formatter'] : self::FORMATTER_CLASSIC;
     $sources = $app['less.sources'];
     $target = $app['less.target'];
     $targetContent = '';
     $needToRecompile = false;
     !is_array($sources) and $sources = array($sources);
     foreach ($sources as $source) {
         if (!$needToRecompile) {
             $needToRecompile = $this->targetNeedsRecompile($source, $target);
         }
         if ($needToRecompile) {
             $handle = new \lessc($source);
             $handle->setFormatter($formatter);
             $targetContent .= $handle->parse();
         }
     }
     if (isset($handle)) {
         if ($targetContent) {
             file_put_contents($target, $targetContent);
             if (isset($app['less.target_mode'])) {
                 chmod($target, $app['less.target_mode']);
             }
         } else {
             throw new \Exception("No content after parsing less source files. Please check your .less files");
         }
     }
 }
 public function actionLess()
 {
     Yii::import('mod.core.models.less.*');
     if (isset($_POST['Less'])) {
         $path = Yii::getPathOfAlias('webroot.themes.default.less');
         Yii::import('app.phpless.lessc');
         $less = new lessc();
         $param = array();
         foreach ($_POST['Less'] as $key => $val) {
             $param[$key] = $val;
         }
         Yii::app()->settings->set('less', $param);
         $less->setVariables($param);
         /* $less->setVariables(array(
            'btn-default-bgcolor' => '#e0e0e0', //#e0e0e0
            'btn-primary-bgcolor' => '#265a88',
            'btn-success-bgcolor' => '#419641',
            'btn-info-bgcolor' => '#2aabd2',
            'btn-warning-bgcolor' => '#eb9316',
            'btn-danger-bgcolor' => '#c12e2a',
            )); */
         $less->compileFile($path . "/bootstrap-theme.less", Yii::getPathOfAlias('webroot.themes.default.assets.css') . "/bootstrap-theme.css");
     }
     $this->render('less', array('gradient' => new LessGradient()));
 }
Exemple #14
0
 private function compileLess()
 {
     $lessc = new lessc();
     $lessIndexPath = DIR_TEMPLATE . '/default/stylesheet/less/index.less';
     $cssIndexPath = DIR_TEMPLATE . '/default/stylesheet/stylesheet.css';
     $lessc->checkedCompile($lessIndexPath, $cssIndexPath);
 }
Exemple #15
0
 public function compileLess($inputFile, $outputFile)
 {
     if (!class_exists('lessc')) {
         require_once KPATH_FRAMEWORK . '/external/lessc/lessc.php';
     }
     // Load the cache.
     $cacheDir = JPATH_CACHE . '/kunena';
     if (!is_dir($cacheDir)) {
         KunenaFolder::create($cacheDir);
     }
     $cacheFile = "{$cacheDir}/kunena.bootstrap.{$inputFile}.cache";
     if (is_file($cacheFile)) {
         $cache = unserialize(file_get_contents($cacheFile));
     } else {
         $cache = KPATH_MEDIA . '/less/bootstrap/' . $inputFile;
     }
     $outputFile = KPATH_MEDIA . '/css/joomla25/' . $outputFile;
     $less = new lessc();
     //$less->setVariables($this->style_variables);
     $newCache = $less->cachedCompile($cache);
     if (!is_array($cache) || $newCache['updated'] > $cache['updated'] || !is_file($outputFile)) {
         $cache = serialize($newCache);
         KunenaFile::write($cacheFile, $cache);
         KunenaFile::write($outputFile, $newCache['compiled']);
     }
 }
Exemple #16
0
function shoestrap_buttons_css()
{
    $btn_color = get_theme_mod('shoestrap_buttons_color');
    // Make sure colors are properly formatted
    $btn_color = '#' . str_replace('#', '', $btn_color);
    // if no color has been selected, set to #0066cc. This prevents errors with the php-less compiler.
    if (strlen($btn_color) < 3) {
        $btn_color = '#0066cc';
    }
    ?>

  <style>
    <?php 
    if (class_exists('lessc')) {
        $less = new lessc();
        $less->setVariables(array("btnColor" => $btn_color));
        $less->setFormatter("compressed");
        if (shoestrap_get_brightness($btn_color) <= 160) {
            // The code below is a copied from bootstrap's buttons.less + mixins.less files
            echo $less->compile("\n          @btnColorHighlight: darken(spin(@btnColor, 5%), 10%);\n  \n          .gradientBar(@primaryColor, @secondaryColor, @textColor: #fff, @textShadow: 0 -1px 0 rgba(0,0,0,.25)) {\n            color: @textColor;\n            text-shadow: @textShadow;\n            #gradient > .vertical(@primaryColor, @secondaryColor);\n            border-color: @secondaryColor @secondaryColor darken(@secondaryColor, 15%);\n            border-color: rgba(0,0,0,.1) rgba(0,0,0,.1) fadein(rgba(0,0,0,.1), 15%);\n          }\n  \n          #gradient {\n            .vertical(@startColor: #555, @endColor: #333) {\n              background-color: mix(@startColor, @endColor, 60%);\n              background-image: -moz-linear-gradient(top, @startColor, @endColor); // FF 3.6+\n              background-image: -webkit-gradient(linear, 0 0, 0 100%, from(@startColor), to(@endColor)); // Safari 4+, Chrome 2+\n              background-image: -webkit-linear-gradient(top, @startColor, @endColor); // Safari 5.1+, Chrome 10+\n              background-image: -o-linear-gradient(top, @startColor, @endColor); // Opera 11.10\n              background-image: linear-gradient(to bottom, @startColor, @endColor); // Standard, IE10\n              background-repeat: repeat-x;\n            }\n          }\n  \n          .buttonBackground(@startColor, @endColor, @textColor: #fff, @textShadow: 0 -1px 0 rgba(0,0,0,.25)) {\n            .gradientBar(@startColor, @endColor, @textColor, @textShadow);\n            *background-color: @endColor; /* Darken IE7 buttons by default so they stand out more given they won't have borders */\n            .reset-filter();\n            &:hover, &:active, &.active, &.disabled, &[disabled] {\n              color: @textColor;\n              background-color: @endColor;\n              *background-color: darken(@endColor, 5%);\n            }\n          }\n          .btn, .btn-primary{\n            .buttonBackground(@btnColor, @btnColorHighlight);\n          }\n        ");
        } else {
            echo $less->compile("\n          @btnColorHighlight: darken(@btnColor, 15%);\n  \n          .gradientBar(@primaryColor, @secondaryColor, @textColor: #333, @textShadow: 0 -1px 0 rgba(0,0,0,.25)) {\n            color: @textColor;\n            text-shadow: @textShadow;\n            #gradient > .vertical(@primaryColor, @secondaryColor);\n            border-color: @secondaryColor @secondaryColor darken(@secondaryColor, 15%);\n            border-color: rgba(0,0,0,.1) rgba(0,0,0,.1) fadein(rgba(0,0,0,.1), 15%);\n          }\n  \n          #gradient {\n            .vertical(@startColor: #555, @endColor: #333) {\n              background-color: mix(@startColor, @endColor, 60%);\n              background-image: -moz-linear-gradient(top, @startColor, @endColor); // FF 3.6+\n              background-image: -webkit-gradient(linear, 0 0, 0 100%, from(@startColor), to(@endColor)); // Safari 4+, Chrome 2+\n              background-image: -webkit-linear-gradient(top, @startColor, @endColor); // Safari 5.1+, Chrome 10+\n              background-image: -o-linear-gradient(top, @startColor, @endColor); // Opera 11.10\n              background-image: linear-gradient(to bottom, @startColor, @endColor); // Standard, IE10\n              background-repeat: repeat-x;\n            }\n          }\n  \n          .buttonBackground(@startColor, @endColor, @textColor: #333, @textShadow: 0 -1px 0 rgba(0,0,0,.25)) {\n            .gradientBar(@startColor, @endColor, @textColor, @textShadow);\n            *background-color: @endColor; /* Darken IE7 buttons by default so they stand out more given they won't have borders */\n            .reset-filter();\n            &:hover, &:active, &.active, &.disabled, &[disabled] {\n              color: @textColor;\n              background-color: @endColor;\n              *background-color: darken(@endColor, 5%);\n            }\n          }\n          .btn, .btn-primary{\n            .buttonBackground(@btnColor, @btnColorHighlight);\n          }\n        ");
        }
    }
    ?>
  </style>
  <?php 
}
Exemple #17
0
function jollyness_preprocess_html(&$vars)
{
    //Process portfolio color
    if ($portfolio_category = taxonomy_vocabulary_machine_name_load('portfolio_category')) {
        $terms = taxonomy_get_tree($portfolio_category->vid);
        $less = new lessc();
        $css = '';
        $color = '';
        $class = '';
        foreach ($terms as $t) {
            $term = taxonomy_term_load($t->tid);
            $class = drupal_html_class($t->name);
            if (!empty($term->field_color)) {
                foreach ($term->field_color as $v) {
                    $color = $v[0]['value'];
                    break;
                }
            }
            if ($color) {
                $css .= ".dexp-masonry-filter,.dexp-portfolio-filter{.{$class} span:before{background-color: {$color} !important;}}";
                $css .= ".{$class} .portfolio-item-overlay{background-color: rgba(red({$color}), green({$color}), blue({$color}), 0.7) !important;}";
            }
        }
        $css = $less->compile($css);
        drupal_add_css($css, array('type' => 'inline'));
    }
}
Exemple #18
0
 /**
  * Compile CSS files used by admin ui
  *
  * @throws Exception
  */
 protected function _compileCss()
 {
     $bootstrapPath = $this->_croogoWebroot . 'bootstrap';
     if (!file_exists($bootstrapPath)) {
         if (!$this->_clone) {
             throw new Exception('You don\'t have "bootstrap" directory in ' . WWW_ROOT);
         }
         chdir($this->_croogoPath);
         CakeLog::info('Cloning Bootstrap...');
         $command = sprintf('git clone -b %s %s %s', escapeshellarg($this->_tags['bootstrap']), escapeshellarg($this->_repos['bootstrap']), escapeshellarg($bootstrapPath));
         CakeLog::info("\t{$command}");
         exec($command);
     }
     chdir($bootstrapPath);
     exec(sprintf('git checkout -f %s', escapeshellarg($this->_tags['bootstrap'])));
     App::import('Vendor', 'Croogo.Lessc', array('file' => 'lessphp' . DS . 'lessc.inc.php'));
     $lessc = new lessc();
     $formatter = new lessc_formatter_lessjs();
     $formatter->compressColors = false;
     ini_set('precision', 16);
     $lessc->setFormatter($formatter);
     $files = array('less' . DS . 'admin.less' => 'css' . DS . 'croogo-bootstrap.css', 'less' . DS . 'admin-responsive.less' => 'css' . DS . 'croogo-bootstrap-responsive.css');
     foreach ($files as $file => $output) {
         $file = $this->_croogoWebroot . $file;
         $output = $this->_croogoWebroot . $output;
         $out = str_replace(APP, '', $output);
         if ($lessc->compileFile($file, $output)) {
             $text = __d('croogo', 'CSS : %s created', $out);
             CakeLog::info($text);
         } else {
             $text = __d('croogo', 'CSS : %s failed', $out);
             CakeLog::error($text);
         }
     }
 }
Exemple #19
0
 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  *
  * @return int|null|void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if ('development' != $input->getArgument('environment') && 'production' != $input->getArgument('environment')) {
         return $output->writeln($input->getArgument('environment') . ' environment not found');
     }
     $jsMinifier = new JS();
     $cssMinifier = new CSS();
     $output->writeln('Building environment: ' . $input->getArgument('environment'));
     $output->write('Generating JavaScript build file...');
     $jsFiles = FileSystem::listDirectoryRecursive(Application::webRoot() . '/js', '/^.+\\.js$/i');
     $buildFile = fopen(Application::webRoot() . '/min/build.js', 'w');
     foreach ($jsFiles as $filePath) {
         fwrite($buildFile, file_get_contents($filePath) . "\n\n");
     }
     fclose($buildFile);
     $output->writeln('done');
     $output->write('Shrinking JavaScript...');
     $jsMinifier->add(Application::webRoot() . '/min/build.js');
     $jsMinifier->minify(Application::webRoot() . '/min/build.min.js');
     $output->writeln('done');
     $output->write('Compiling less files...');
     $less = new \lessc();
     $less->compileFile(Application::webRoot() . '/media/importer.less', Application::webRoot() . '/min/build.css');
     $output->writeln('done');
     $output->write('Shrinking css files...');
     $cssMinifier->add(Application::webRoot() . '/min/build.css');
     $cssMinifier->minify(Application::webRoot() . '/min/build.min.css');
     $output->writeln('done');
     return null;
 }
 function autoCompilerLess($params)
 {
     global $modx;
     $inputFile = MODX_BASE_PATH . $params["input_less"];
     $outputFile = MODX_BASE_PATH . $params["output_css"];
     define("PHPLESS_CSS_PATH", dirname($outputFile) . "/");
     define("PHPLESS_IMAGESIZE", 32);
     if (!is_file(MODX_BASE_PATH . $params["input_less"])) {
         return;
     }
     if (!class_exists('lessc')) {
         include $params['less_path'] . 'lessc.inc.php';
     }
     if (!class_exists('DataUriLess')) {
         include $params['less_path'] . 'class.datauriless.php';
     }
     $cacheFile = $inputFile . ".cache";
     if (is_file($cacheFile)) {
         $cache = unserialize(file_get_contents($cacheFile));
     } else {
         $cache = $inputFile;
     }
     switch ($params['output_formating']) {
         case 'lessjs':
         case 'compressed':
             $formatter = 'lessjs';
             break;
         case 'classic':
             $formatter = $params['output_formating'];
             break;
         case 'tabing':
             $formatter = new lessc_formatter_classic();
             $formatter->indentChar = "\t";
             break;
         default:
             $formatter = 'lessjs';
             break;
     }
     $less = new lessc();
     $less->setFormatter($formatter);
     try {
         $newCache = $less->cachedCompile($cache);
     } catch (Exception $ex) {
         $modx->logEvent(0, 3, $ex->getMessage(), $e->activePlugin);
     }
     if (!is_array($cache) || $newCache["updated"] > $cache["updated"] || !is_file($outputFile)) {
         file_put_contents($cacheFile, serialize($newCache));
         $datauri = new DataUriLess($newCache['compiled']);
         $output_compile = $datauri->run();
         if (@file_put_contents($outputFile, $output_compile)) {
             //if($params["compiler_log"]==="true"){
             $e =& $modx->Event;
             $modx->logEvent($modx->toDateFormat(time() + $modx->config['server_offset_time']), 1, "less файл скомпилирован " . $modx->nicesize(filesize($outputFile)), $e->activePlugin);
             //}
         } else {
             $modx->logEvent(0, 3, "Невозможно сохранить CSS файл", $e->activePlugin);
         }
     }
 }
Exemple #21
0
 /**
  * Get LESS compiler (if undefined, set it with path for @import directives)
  *
  * @param boolean $reset
  */
 protected function getEnvironment($reset = false)
 {
     if ($reset === true || null === $this->lessc) {
         $this->lessc = new \lessc();
         $this->lessc->addImportDir($this->getConfigFor('phr_template_dir'));
     }
     return $this->lessc;
 }
Exemple #22
0
 /**
  * Compile the LESS at the given path.
  *
  * @param  string  $path
  * @return void
  */
 public function compile($path)
 {
     $less = new \lessc();
     $contents = $less->compileFile($path);
     if (!is_null($this->cachePath)) {
         $this->files->put($this->getCompiledPath($path), $contents);
     }
 }
Exemple #23
0
 /**
  * Compile LESS
  * @param string $in
  * @param string $out
  */
 public function compile($in, $out)
 {
     if ($this->cacheDir) {
         $this->autoCompileLess($in, $out);
     } else {
         $this->compiler->checkedCompile($in, $out);
     }
 }
Exemple #24
0
 /**
  * @see PreFileFilter::__invoke()
  */
 public static function __invoke($code, \Lohini\WebLoader\WebLoader $loader, $file = NULL)
 {
     if ($file === NULL || strtolower(pathinfo($file, PATHINFO_EXTENSION)) != 'less') {
         return $code;
     }
     $filter = new \lessc($file);
     return $filter->parse();
 }
Exemple #25
0
 /**
  * @return void
  */
 public function compileLessFiles()
 {
     foreach ($this->findLessFiles() as $lessFile) {
         $cssNameFile = self::getCssFileName($lessFile);
         $less = new lessc($lessFile);
         file_put_contents(sfConfig::get('sf_root_dir') . '/' . $this->getCssPaths() . '/' . $cssNameFile, $less->parse());
     }
 }
Exemple #26
0
function applyDefaultTheme()
{
    $less = new lessc();
    try {
        $less->checkedCompile("./style/main.less", "./style/style.css");
    } catch (exception $e) {
        echo $e->getMessage();
    }
}
Exemple #27
0
 public static function parse($source, $isFile = true)
 {
     $parser = new lessc();
     try {
         return $isFile ? $parser->compileFile($source) : $parser->compile($source);
     } catch (Exception $e) {
         return '/** LESS PARSE ERROR: ' . $e->getMessage() . ' **/';
     }
 }
 /**
  * @param \AssetsBundle\AssetFile\AssetFile $oAssetFile
  * @return string
  */
 public function filterAssetFile(\AssetsBundle\AssetFile\AssetFile $oAssetFile)
 {
     $oLessParser = new \lessc();
     $oLessParser->addImportDir(getcwd());
     $oLessParser->setAllowUrlRewrite(true);
     //Prevent time limit errors
     set_time_limit(0);
     return trim($oLessParser->compile($oAssetFile->getAssetFileContents()));
 }
 /**
  * Convert an image URI to a base64-encoded data URI.
  *
  * @par Example:
  * @code
  *   .fancy-button {
  *       background-image: embed('../images/button-bg.png');
  *   }
  * @endcode
  * @param array $frame
  * @param lessc $less
  * @return string
  */
 public static function embed($frame, $less)
 {
     $base = pathinfo($less->parser->sourceName, PATHINFO_DIRNAME);
     $url = trim($less->compileValue($frame), '"\'');
     $file = realpath($base . '/' . $url);
     $data = CSSMin::encodeImageAsDataURI($file);
     $less->addParsedFile($file);
     return CSSMin::buildUrlValue($data);
 }
Exemple #30
0
 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;
 }