コード例 #1
0
ファイル: generate-less.php プロジェクト: adwleg/site
/**
 * Created by PhpStorm.
 * User: duonglh
 * Date: 8/23/14
 * Time: 3:01 PM
 */
function cupid_generate_less()
{
    require_once 'Less.php';
    $cupid_data = of_get_options();
    try {
        $primary_color = $cupid_data['primary-color'];
        $secondary_color = $cupid_data['secondary-color'];
        $button_color = $cupid_data['button-color'];
        $bullet_color = $cupid_data['bullet-color'];
        $icon_box_color = $cupid_data['icon-box-color'];
        $site_logo_url = $cupid_data['site-logo'];
        $site_logo_white_url = $cupid_data['site-logo-white'];
        $site_logo_url = str_replace(THEME_URL, '', $site_logo_url);
        $site_logo_white_url = str_replace(THEME_URL, '', $site_logo_white_url);
        $css = '@primary_color:' . $primary_color . ';';
        $css .= '@secondary_color:' . $secondary_color . ';';
        $css .= '@button_color:' . $button_color . ';';
        $css .= '@bullet_color:' . $bullet_color . ';';
        $css .= '@icon_box_color:' . $icon_box_color . ';';
        $css .= "@logo_url : '" . $site_logo_url . "';@logo_white_url : '" . $site_logo_white_url . "';";
        $css .= '@theme_url:"' . THEME_URL . '";';
        $style = $css;
        require_once ABSPATH . 'wp-admin/includes/file.php';
        require_once THEME_DIR . "lib/inc-generate-less/custom-css.php";
        $custom_css = cupid_custom_css();
        WP_Filesystem();
        global $wp_filesystem;
        $options = array('compress' => true);
        $parser = new Less_Parser($options);
        $parser->parse($css);
        $parser->parseFile(THEME_DIR . 'assets/css/less/style.less');
        $parser->parse($custom_css);
        $css = $parser->getCss();
        if (!$wp_filesystem->put_contents(THEME_DIR . "style.min.css", $css, FS_CHMOD_FILE)) {
            echo __('Could not save file', 'cupid');
            return '0';
        }
        /*$theme_info = $wp_filesystem->get_contents( THEME_DIR . "theme-info.txt" );
                $parser = new Less_Parser();
                $parser->parse($style);
                $parser->parseFile(THEME_DIR . 'assets/css/less/style.less',THEME_URL);
                $style = $parser->getCss();
        		$parser->parse($custom_css);
                $style = $theme_info . "\n" . $style;
                $style = str_replace("\r\n","\n", $style);
                $wp_filesystem->put_contents( THEME_DIR.   "style.css", $style, FS_CHMOD_FILE);*/
        return '1';
    } catch (Exception $e) {
        echo 'Caught exception: ', $e->getMessage(), "\n";
        return '0';
    }
}
コード例 #2
0
ファイル: Less.php プロジェクト: shomimn/builder
 /**
  * Parse given css file with given vars.
  * 
  * @param  string $file
  * @param  array  $vars
  * 
  * @return string
  */
 public function parse($file, array $vars, $custom)
 {
     $this->parser->parseFile($this->app['base_dir'] . '/assets/less/vendor/bootstrap/' . $file . '.less', $this->app['base_url']);
     $this->parser->modifyVars($vars);
     $css = $this->parser->getCss();
     //parse custom less if any passed
     if ($custom) {
         $this->parser->reset();
         $customCss = $this->parser->parse($custom)->getCss();
     } else {
         $customCss = '';
     }
     return $css . $customCss;
 }
コード例 #3
0
ファイル: CompilerLess.php プロジェクト: nagumo/Phest
 public function compile($source, $pathname)
 {
     $less = new \Less_Parser();
     $less->SetImportDirs(array(dirname($pathname) => './'));
     $less->parse($source);
     return $less->getCss();
 }
コード例 #4
0
ファイル: bootstrap.php プロジェクト: juijs/store.jui.io
function CssPreprocessor($content, $type)
{
    if ($type == 'css') {
    } else {
        if ($type == 'less') {
            try {
                $parser = new Less_Parser();
                $parser->parse($content);
                $content = $parser->getCss();
            } catch (Exception $e) {
                var_dump($e->getMessage());
            }
        } else {
            if ($type == 'sass') {
                $scss = new scssc();
                $content = $scss->compile($content);
            } else {
                if ($type == 'stylus') {
                    $stylus = new Stylus();
                    $content = $stylus->fromString($content)->toString();
                }
            }
        }
    }
    return $content;
}
コード例 #5
0
ファイル: LessCompiler.php プロジェクト: Umz/ImpressPages
 /**
  * @param string $themeName
  * @param string $lessFile
  * @return string
  */
 public function compileFile($themeName, $lessFile)
 {
     $model = Model::instance();
     $theme = $model->getTheme($themeName);
     $options = $theme->getOptionsAsArray();
     $configModel = ConfigModel::instance();
     $config = $configModel->getAllConfigValues($themeName);
     $less = "@import '{$lessFile}';";
     $less .= $this->generateLessVariables($options, $config);
     $css = '';
     try {
         require_once ipFile('Ip/Lib/less.php/Less.php');
         $themeDir = ipFile('Theme/' . $themeName . '/assets/');
         $ipContentDir = ipFile('Ip/Internal/Core/assets/ipContent/');
         // creating new context to pass theme assets directory dynamically to a static callback function
         $context = $this;
         $callback = function ($parseFile) use($context, $themeDir) {
             return $context->overrideImportDirectory($themeDir, $parseFile);
         };
         $parserOptions = array('import_callback' => $callback, 'cache_dir' => ipFile('file/tmp/less/'), 'relativeUrls' => false, 'sourceMap' => true);
         $parser = new \Less_Parser($parserOptions);
         $directories = array($themeDir => '', $ipContentDir => '');
         $parser->SetImportDirs($directories);
         $parser->parse($less);
         $css = $parser->getCss();
         $css = "/* Edit {$lessFile}, not this file. */" . "\n" . $css;
     } catch (\Exception $e) {
         ipLog()->error('Less compilation error: Theme - ' . $e->getMessage());
     }
     return $css;
 }
コード例 #6
0
ファイル: less.php プロジェクト: shamsbd71/canvas-framework
 public static function compile($source, $path, $todir, $importdirs)
 {
     $parser = new Less_Parser();
     $parser->SetImportDirs($importdirs);
     $parser->parse($source, CANVASLess::relativePath($todir, dirname($path)) . basename($path));
     $output = $parser->getCss();
     return $output;
 }
コード例 #7
0
ファイル: less.php プロジェクト: grlf/eyedock
 public static function compile($source, $importdirs)
 {
     $parser = new Less_Parser();
     $parser->SetImportDirs($importdirs);
     $parser->parse($source);
     $output = $parser->getCss();
     return $output;
 }
コード例 #8
0
ファイル: wp-less-to-css.php プロジェクト: jwlayug/jbst
 public function wpless2csssavecss($creds)
 {
     $plugindir = plugin_dir_path(__FILE__);
     if (!class_exists('Less_Parser')) {
         require $plugindir . 'less-php/Less.php';
     }
     $options = array('compress' => true, 'credits' => $creds);
     $parser = new Less_Parser($options);
     WP_Filesystem($creds);
     global $wp_filesystem;
     if (!$wp_filesystem->exists($rootless = trailingslashit($wp_filesystem->wp_themes_dir()) . trailingslashit(get_stylesheet()) . 'wpless2css/wpless2css.less')) {
         if (!$wp_filesystem->exists($rootless = trailingslashit($wp_filesystem->wp_themes_dir()) . trailingslashit(get_template()) . 'wpless2css/wpless2css.less')) {
             if (!$wp_filesystem->exists($rootless = trailingslashit($wp_filesystem->wp_content_dir()) . 'wpless2css/wpless2css.less')) {
                 wp_die(__('<strong>wpless2css/wpless2css.less</strong> is missing', 'wpless2css'));
             }
         }
     }
     $parser->parseFile($rootless, '../');
     $parser->parse(apply_filters('get_theme_mods', ''));
     if ($extrafiles = apply_filters('add_extra_less_files', '')) {
         foreach ($extrafiles as $extrafile) {
             $parser->parseFile(trailingslashit(str_replace('wp-content/', '', $wp_filesystem->wp_content_dir())) . $extrafile);
         }
     }
     $parser->parse(apply_filters('add_extra_less_code', ''));
     $parser->parse(get_theme_mod('customlesscode'));
     $css = $parser->getCss();
     if (is_rtl()) {
         $css = str_replace('navbar-left', 'navbar-l', $css);
         $css = str_replace('navbar-right', 'navbar-r', $css);
         $css = str_replace('left', 'wasleft', $css);
         $css = str_replace('right', 'left', $css);
         $css = str_replace('wasleft', 'right', $css);
         $css = str_replace('navbar-l', 'navbar-left', $css);
         $css = str_replace('navbar-r', 'navbar-right', $css);
         $css .= ' body{direction: rtl; unicode-bidi: embed;}';
         set_theme_mod('rtl_compiled', 1);
     } else {
         set_theme_mod('rtl_compiled', 0);
     }
     $folder = trailingslashit($wp_filesystem->wp_themes_dir()) . trailingslashit(get_stylesheet()) . '/';
     if (!$wp_filesystem->put_contents($folder . $this->filename, $css, FS_CHMOD_FILE)) {
         wp_die("error saving file!");
     }
     //file_put_contents( $this->folder.$this->filename, $css);
 }
コード例 #9
0
ファイル: Less.php プロジェクト: difra-org/difra
 /**
  * Convert LESS to CSS
  * @param string $string
  * @return string
  */
 public static function compile($string)
 {
     self::init();
     $parser = new \Less_Parser();
     $parser->SetOptions(['compress' => !Debugger::isEnabled()]);
     $parser->parse($string);
     return $parser->getCss();
 }
コード例 #10
0
function alleycat_compiler()
{
    $minimize_css = shoestrap_getVariable('minimize_css', true);
    $options = $minimize_css == 1 ? array('compress' => true) : array('compress' => false);
    $bootstrap_location = get_template_directory() . '/assets/less/';
    $bootstrap_uri = '';
    try {
        $parser = new Less_Parser($options);
        // AC LESS file
        $parser->parseFile($bootstrap_location . 'alleycat.less', $bootstrap_uri);
        // Our custom variables
        $parser->parse(shoestrap_variables());
        // Add a filter to the compiler
        $parser->parse(apply_filters('shoestrap_compiler', ''));
        $css = $parser->getCss();
    } catch (Exception $e) {
        $error_message = $e->getMessage();
        error_log($error_message);
    }
    // Below is just an ugly hack
    $css = str_replace('bootstrap/fonts/', '', $css);
    $css = str_replace(get_template_directory_uri() . '/assets/', '../', $css);
    return apply_filters('shoestrap_compiler_output', $css);
}
コード例 #11
0
ファイル: Lesser_APF.php プロジェクト: benallfree/wp-lesser
 function processSubmit($mode)
 {
     $data = get_option('Lesser_APF');
     $less = $data['lesser_' . $mode . '_less'];
     $parser = new Less_Parser();
     try {
         $parser->parse($less);
         $css = $parser->getCss();
         $data['lesser_' . $mode . '_css'] = $css;
         $data = apply_filters('lesser_before_' . $mode . '_save', $data);
         update_option('Lesser_APF', $data);
     } catch (Exception $e) {
         $this->setSettingNotice('LESS parse error: ' . $e->getMessage());
     }
 }
コード例 #12
0
 public function parse_string($template, $data = array(), $return = FALSE, $config = array())
 {
     if (!is_array($config)) {
         $config = array();
     }
     $config = array_merge($this->config, $config);
     $ci = $this->ci;
     $is_mx = false;
     if (!$return) {
         list($ci, $is_mx) = $this->detect_mx();
     }
     $parser = new Less_Parser($config);
     $parser->parse($template);
     $template = $parser->getCss();
     return $this->output($template, $return, $ci, $is_mx);
 }
コード例 #13
0
ファイル: style.php プロジェクト: just-paja/fudjan
 public function read()
 {
     parent::read();
     if (!$this->is_cached()) {
         if (class_exists('\\Less_Parser')) {
             $parser = new \Less_Parser();
             $parser->SetOptions(array('compress' => $this->minify));
             try {
                 $parser->parse($this->content);
             } catch (\Exception $e) {
                 throw new \System\Error\Format(sprintf('Error while parsing LESS styles: %s', $e->getMessage()));
             }
             $this->content = $parser->getCss();
         } else {
             throw new \System\Error\MissingDependency('Missing less parser. Please install oyejorge/less.php');
         }
     }
 }
コード例 #14
0
ファイル: Less.php プロジェクト: rdeutz/Robo
 /**
  * less compiler
  * @link https://github.com/oyejorge/less.php
  *
  * @param string $file
  * @return string
  */
 protected function less($file)
 {
     if (!class_exists('\\Less_Parser')) {
         return Result::errorMissingPackage($this, 'Less_Parser', 'oyejorge/less.php');
     }
     $lessCode = file_get_contents($file);
     $parser = new \Less_Parser();
     $parser->SetOptions($this->compilerOptions);
     if (isset($this->compilerOptions['importDirs'])) {
         $importDirs = [];
         foreach ($this->compilerOptions['importDirs'] as $dir) {
             $importDirs[$dir] = $dir;
         }
         $parser->SetImportDirs($importDirs);
     }
     $parser->parse($lessCode);
     return $parser->getCss();
 }
コード例 #15
0
ファイル: css.php プロジェクト: kadimi/bootswatch
/**
 * Adds inline CSS in header.
 */
function bootswatch_css()
{
    $css = '';
    /**
     * Fix overlapping with WordPress admin bar.
     */
    $css .= 'body.admin-bar .navbar-fixed-top{ top: 32px; }';
    /**
     * Fix overlapping with Bootstrap's fixed navbar.
     */
    if (bootswatch_use('fixed_navbar')) {
        $variables_path = bootswatch_get_option('theme') ? get_template_directory() . '/vendor/thomaspark/bootswatch/' . bootswatch_get_option('theme') . '/variables.less' : get_template_directory() . '/vendor/thomaspark/bootswatch/bower_components/bootstrap/less/variables.less';
        $less_parser = new Less_Parser();
        $less_parser->parseFile($variables_path, home_url());
        $less_parser->parse('body { padding-top: (@navbar-height + @navbar-margin-bottom); }');
        $css .= $less_parser->getCss();
    }
    printf('<style>%s</style>', $css);
    // WPCS: xss ok.
}
コード例 #16
0
 /**
  * {@inheritdoc}
  */
 public function filterLoad(AssetInterface $asset)
 {
     $parser = new \Less_Parser(array('compress' => 'compressed' == $this->formatter, 'relativeUrls' => false));
     $importDirs = array_fill_keys((array) $this->loadPaths, '/');
     $importDirs[dirname($asset->getSourceRoot() . '/' . $asset->getSourcePath())] = '/';
     $webDir = $this->webDir;
     $importDirs[] = function ($path) use($webDir) {
         $file = $webDir . '/' . $path;
         foreach (array('', '.less', '.css') as $extension) {
             if (file_exists($file . $extension)) {
                 return array($file . $extension, null);
             }
         }
         return null;
     };
     $parser->SetImportDirs($importDirs);
     $content = $asset->getContent();
     $parser->parse($content);
     $css = $parser->getCss();
     $this->cache->set(md5($content), \Less_Parser::AllParsedFiles());
     $asset->setContent($css);
 }
コード例 #17
0
 function compileLess()
 {
     require ROOT . 'lib/Less/lessc.inc.php';
     $less = array_diff(scandir(ROOT . self::CSS_SRC_PATH, 1), array('.', '..'));
     if (empty($less)) {
         return;
     }
     $real_less = [];
     // real css could be in folder, separate them from less
     foreach ($less as $file_name) {
         $file_ext = explode('.', $file_name);
         if ($file_ext[1] == 'less') {
             $real_less[] = $file_name;
         }
     }
     if (empty($real_less)) {
         return;
     }
     // done
     foreach ($real_less as $less) {
         $out_name = explode('.', $less);
         $out_name = $out_name[0] . '.css';
         $out_path = ROOT . self::CSS_SRC_PATH . '/' . $out_name;
         $lc = new Less_Parser();
         try {
             $lc->parse(file_get_contents(ROOT . self::CSS_SRC_PATH . '/' . $less));
             $style = $lc->getCss();
         } catch (exception $ex) {
             $error = "LESSC FEHLER:" . $ex->getMessage();
             die($error);
             exit;
         }
         unlink(ROOT . self::CSS_SRC_PATH . '/' . $less);
         file_put_contents($out_path, $style);
     }
 }
コード例 #18
0
ファイル: color.php プロジェクト: adwleg/site
function cupid_color_style()
{
    /*if (!is_page_template() || (defined( 'CUPID_SCRIPT_DEBUG' ) && CUPID_SCRIPT_DEBUG) ) {
    		return;
    	}*/
    global $cupid_data;
    require_once 'Less.php';
    $primary_color = $cupid_data['primary-color'];
    $secondary_color = $cupid_data['secondary-color'];
    $button_color = $cupid_data['button-color'];
    $bullet_color = $cupid_data['bullet-color'];
    $icon_box_color = $cupid_data['icon-box-color'];
    $css = '@primary_color:' . $primary_color . ';';
    $css .= '@secondary_color:' . $secondary_color . ';';
    $css .= '@button_color:' . $button_color . ';';
    $css .= '@bullet_color:' . $bullet_color . ';';
    $css .= '@icon_box_color:' . $icon_box_color . ';';
    $options = array('compress' => true);
    $parser = new Less_Parser($options);
    $parser->parse($css);
    $parser->parseFile(THEME_DIR . 'assets/css/less/color.less');
    $css = $parser->getCss();
    echo '<style type="text/css" media="screen">' . $css . '</style>';
}
コード例 #19
0
/**
 * Compiler des styles inline LESS en CSS
 *
 * @param string $style
 *   contenu du .less
 * @param array $contexte
 *   file : chemin du fichier compile
 *          utilise en cas de message d'erreur, et pour le repertoire de reference des @import
 * @return string
 */
function lesscss_compile($style, $contexte = array())
{
    static $import_dirs = null;
    require_once 'less.php/Less.php';
    if (is_null($import_dirs)) {
        $path = _chemin();
        $import_dirs = array();
        foreach ($path as $p) {
            $import_dirs[$p] = protocole_implicite(url_absolue($p ? $p : "./"));
        }
    }
    $parser = new Less_Parser();
    include_spip('inc/config');
    $parser->setOption('sourceMap', lire_config('lesscss/activer_sourcemaps', false) == "on" ? true : false);
    $parser->setImportDirs($import_dirs);
    $parser->relativeUrls = true;
    try {
        $url_absolue = $contexte['file'] ? protocole_implicite(url_absolue($contexte['file'])) : null;
        $parser->parse($style, $url_absolue);
        $out = $parser->getCss();
        if ($files = Less_Parser::AllParsedFiles() and count($files)) {
            $l = strlen(_DIR_RACINE);
            foreach ($files as $k => $file) {
                if (strncmp($file, _DIR_RACINE, $l) == 0) {
                    $files[$k] = substr($file, $l);
                }
            }
            $out = "/*\n#@" . implode("\n#@", $files) . "\n*" . "/\n" . $out;
        }
        return $out;
    } catch (exception $ex) {
        spip_log('less.php fatal error:' . $ex->getMessage(), 'less' . _LOG_ERREUR);
        erreur_squelette("LESS : Echec compilation" . (isset($contexte['file']) ? " fichier " . $contexte['file'] : "") . "<br />" . $ex->getMessage());
        return '';
    }
}
コード例 #20
0
 /**
  * Compile a LESS stylesheet
  *
  * @param $name string Unique name for this LESS stylesheet
  * @param $lessFile string Path to the LESS file to compile
  * @param $args array Optional arguments. SUpports:
  *   'baseUrl': Base URL to use when rewriting URLs in the LESS file.
  *   'addLess': Array of additional LESS files to parse before compiling
  * @return string Compiled CSS styles
  */
 public function compileLess($name, $lessFile, $args = array())
 {
     // Load the LESS compiler
     require_once 'lib/pkp/lib/vendor/oyejorge/less.php/lessc.inc.php';
     $less = new Less_Parser(array('relativeUrls' => false, 'compress' => true));
     $request = $this->_request;
     // Allow plugins to intervene
     HookRegistry::call('PageHandler::compileLess', array(&$less, &$lessFile, &$args, $name, $request));
     // Read the stylesheet
     $less->parseFile($lessFile);
     // Add extra LESS files before compiling
     if (isset($args['addLess']) && is_array($args['addLess'])) {
         foreach ($args['addLess'] as $addless) {
             $less->parseFile($addless);
         }
     }
     // Add extra LESS variables before compiling
     if (isset($args['addLessVariables'])) {
         $less->parse($args['addLessVariables']);
     }
     // Set the @baseUrl variable
     $baseUrl = !empty($args['baseUrl']) ? $args['baseUrl'] : $request->getBaseUrl(true);
     $less->parse("@baseUrl: '{$baseUrl}';");
     return $less->getCSS();
 }
コード例 #21
0
ファイル: Less.php プロジェクト: roland-d/Robo
 /**
  * less compiler
  *
  * @link https://github.com/oyejorge/less.php
  * @return string
  */
 protected function less($file)
 {
     $lessCode = file_get_contents($file);
     $parser = new \Less_Parser();
     $parser->parse($lessCode);
     return $parser->getCss();
 }
コード例 #22
0
ファイル: Combiner.php プロジェクト: Jobu/core
 /**
  * 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 Compiler();
         $objCompiler->setImportPaths(array(TL_ROOT . '/' . dirname($arrFile['name']), TL_ROOT . '/vendor/contao-components/compass/css'));
         $objCompiler->setFormatter(\Config::get('debugMode') ? 'Leafo\\ScssPhp\\Formatter\\Expanded' : 'Leafo\\ScssPhp\\Formatter\\Compressed');
         return $this->fixPaths($objCompiler->compile($content), $arrFile);
     } else {
         $strPath = dirname($arrFile['name']);
         $arrOptions = array('strictMath' => true, 'compress' => !\Config::get('debugMode'), 'import_dirs' => array(TL_ROOT . '/' . $strPath => $strPath));
         $objParser = new \Less_Parser();
         $objParser->SetOptions($arrOptions);
         $objParser->parse($content);
         return $this->fixPaths($objParser->getCss(), $arrFile);
     }
 }
コード例 #23
0
ファイル: Less.php プロジェクト: sfie/pimcore
 /**
      * old version incl. combining and using simple_dom_html
      *
      *
      *public static function processHtmlLEGACY ($body) {
         $html = str_get_html($body);
 
         if(!$html) {
             return $body;
         }
 
         $styles = $html->find("link[rel=stylesheet/less]");
 
         $stylesheetContents = array();
         $processedPaths = array();
 
         foreach ($styles as $style) {
 
             $media = $style->media;
             if(!$media) {
                 $media = "all";
             }
 
             $source = $style->href;
             $path = "";
             if (is_file(PIMCORE_ASSET_DIRECTORY . $source)) {
                 $path = PIMCORE_ASSET_DIRECTORY . $source;
             }
             else if (is_file(PIMCORE_DOCUMENT_ROOT . $source)) {
                 $path = PIMCORE_DOCUMENT_ROOT . $source;
             }
 
             // add the same file only one time
             if(in_array($path, $processedPaths)) {
                 continue;
             }
 
             if (is_file("file:/".$path)) {
 
                 $compiledContent = self::compile($path, $source);
 
                 $stylesheetContents[$media] .= $compiledContent . "\n";
                 $style->outertext = "";
 
                 $processedPaths[] = $path;
             }
         }
 
         // put compiled contents into single files, grouped by their media type
         if(count($stylesheetContents) > 0) {
             $head = $html->find("head",0);
             foreach ($stylesheetContents as $media => $content) {
                 $stylesheetPath = PIMCORE_TEMPORARY_DIRECTORY."/less_".md5($content).".css";
 
                 if(!is_file($stylesheetPath)) {
                     file_put_contents($stylesheetPath, $content);
                     @chmod($stylesheetPath, 0766);
                 }
 
                 $head->innertext = $head->innertext . "\n" . '<link rel="stylesheet" media="' . $media . '" type="text/css" href="' . str_replace(PIMCORE_DOCUMENT_ROOT,"",$stylesheetPath) . '" />'."\n";
             }
         }
 
         $body = $html->save();
 
         return $body;
     }*/
 public static function compile($path, $source = null)
 {
     $conf = \Pimcore\Config::getSystemConfig();
     $compiledContent = "";
     // check if the file is already compiled in the cache
     //$cacheKey = "less_file_" . md5_file($path);
     //if($contents = Pimcore_Model_Cache::load($cacheKey)) {
     //    return $contents;
     //}
     // use the original less compiler if configured
     if ($conf->outputfilters->lesscpath) {
         $output = array();
         exec($conf->outputfilters->lesscpath . " " . $path, $output);
         $compiledContent = implode(" ", $output);
         // add a comment to the css so that we know it's compiled by lessc
         if (!empty($compiledContent)) {
             $compiledContent = "\n\n/**** compiled with lessc (node.js) ****/\n\n" . $compiledContent;
         }
     }
     // use php implementation of lessc if it doesn't work
     if (empty($compiledContent)) {
         $parser = new \Less_Parser();
         $parser->parse(file_get_contents($path));
         $compiledContent = $parser->getCss();
         // add a comment to the css so that we know it's compiled by lessphp
         $compiledContent = "\n\n/**** compiled with lessphp/Less_Parser ****/\n\n" . $compiledContent;
     }
     if ($source) {
         // correct references inside the css
         $compiledContent = self::correctReferences($source, $compiledContent);
     }
     // put the compiled contents into the cache
     //Pimcore_Model_Cache::save($compiledContent, $cacheKey, array("less"));
     return $compiledContent;
 }
コード例 #24
0
ファイル: lessc.inc.php プロジェクト: TomArrow/less.php
 public function compile($string, $name = null)
 {
     $oldImport = $this->importDir;
     $this->importDir = (array) $this->importDir;
     $this->allParsedFiles = array();
     $parser = new Less_Parser($this->getOptions());
     $parser->SetImportDirs($this->getImportDirs());
     if (count($this->registeredVars)) {
         $parser->ModifyVars($this->registeredVars);
     }
     foreach ($this->libFunctions as $name => $func) {
         $parser->registerFunction($name, $func);
     }
     $parser->parse($string);
     $out = $parser->getCss();
     $parsed = Less_Parser::AllParsedFiles();
     foreach ($parsed as $file) {
         $this->addParsedFile($file);
     }
     $this->importDir = $oldImport;
     return $out;
 }
コード例 #25
0
ファイル: BxDolTemplate.php プロジェクト: blas-dmx/trident
 /**
  * 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();
 }
コード例 #26
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" />';
 }
コード例 #27
0
ファイル: headerlib.php プロジェクト: rjsmelo/tiki
 /**
  * Compile a new css file in temp/public using the provided theme and the custom LESS string
  *
  * @param string $custom_less        The LESS syntax string
  * @param string $themename          Theme to base the compile on
  * @param string $themeoptionname    Theme option name (for future use)
  * @param bool $use_cache            (for future use and testing)
  * @return array                     Array of CSS file paths out (can be theme and option if there's an error)
  */
 function compile_custom_less($custom_less, $themename, $themeoptionname = '', $use_cache = true)
 {
     global $tikidomainslash, $tikiroot;
     $hash = md5($custom_less . $themename . $themeoptionname);
     $target = "temp/public/{$tikidomainslash}";
     $css_file = $target . "custom_less_{$hash}.css";
     $css_files = array($css_file);
     if (!file_exists($css_file) || !$use_cache) {
         $themeLib = TikiLib::lib('theme');
         $theme_less_file = $themeLib->get_theme_path($themename, '', $themename . '.less');
         $themeoption_less_file = $themeLib->get_theme_path($themename, $themeoptionname, $themeoptionname . '.less');
         if ($theme_less_file === $themeoption_less_file) {
             $themeoption_less_file = '';
             // some theme options are CSS only
         }
         $options = array('compress' => true, 'cache_dir' => realpath($target));
         $parser = new Less_Parser($options);
         try {
             $nesting = count(array_filter(explode(DIRECTORY_SEPARATOR, $tikiroot)));
             $depth = count(array_filter(explode(DIRECTORY_SEPARATOR, $target)));
             $offset = $nesting ? str_repeat('../', $depth) : '';
             // less.php does all the work of course
             $parser->parseFile($theme_less_file, $offset . $tikiroot);
             // appears to need the relative path from temp/public where the CSS will be cached
             if ($themeoption_less_file) {
                 $parser->parseFile($themeoption_less_file, $offset . $tikiroot);
             }
             $parser->parse($custom_less);
             $css = $parser->getCss();
             file_put_contents($css_file, $css);
             chmod($css_file, 0644);
             $css_files = array($css_file);
         } catch (Exception $e) {
             if (is_writeable($css_file)) {
                 unlink($css_file);
             }
             TikiLib::lib('errorreport')->report(tra('Custom Less compilation failed with error:') . $e->getMessage());
             $css_files = array($themeLib->get_theme_path($themename, '', $themename . '.css'), $themeLib->get_theme_path($themename, $themeoptionname, ($themeoptionname ?: $themename) . '.css'));
         }
     }
     return $css_files;
 }
コード例 #28
0
ファイル: css.php プロジェクト: neslonso/Sintax
            }
            file_put_contents($cssFile, $cssLibs);
            echo $cssLibs;
        }
    }
    /******************************************************************************/
    /* css local ******************************************************************/
    ob_start();
    require SKEL_ROOT_DIR . "includes/cliente/base.css";
    require RUTA_APP . "cliente/appCss.php";
    $Page = new $page($objUsr);
    $Page->css();
    $cssLocal = ob_get_clean();
    if ($lessParse) {
        $lessParser = new Less_Parser($arrLessParserOptions);
        $lessParser->parse($cssLocal);
        $cssLocal = $lessParser->getCss();
    }
    echo "/*CSS LOCAL*/\n" . $cssLocal;
    /******************************************************************************/
} catch (Exception $e) {
    $msg = 'Error durante la generación de css.php.';
    $infoExc = "Excepcion de tipo: " . get_class($e) . ". Mensaje: " . $e->getMessage() . " en fichero " . $e->getFile() . " en linea " . $e->getLine();
    error_log($infoExc);
    error_log("TRACE: " . $e->getTraceAsString());
    $firephp->group($msg, array('Collapsed' => false, 'Color' => '#FF6600'));
    $firephp->info($infoExc);
    $firephp->info($e->getTraceAsString(), "traceAsString");
    $firephp->info($e->getTrace(), "trace");
    $firephp->groupEnd();
    ob_clean();
コード例 #29
0
ファイル: index.php プロジェクト: BozzaCoon/SPHERE-Framework
ini_set('memory_limit', '1024M');
/**
 * Setup: Loader
 */
require_once __DIR__ . '/../../Library/MOC-V/Core/AutoLoader/AutoLoader.php';
AutoLoader::getNamespaceAutoLoader('MOC\\V', __DIR__ . '/../../Library/MOC-V');
AutoLoader::getNamespaceAutoLoader('SPHERE', __DIR__ . '/../../', 'SPHERE');
/**
 * Setup: LESS-Parser
 */
require_once __DIR__ . '/../../Library/LessPhp/1.7.0.5/lessc.inc.php';
$Parser = array('cache_dir' => __DIR__ . '/Resource', 'compress' => false);
$Less = new \Less_Parser($Parser);
$Less->parseFile(__DIR__ . '/../../Library/Bootstrap/3.3.5/less/bootstrap.less');
// Grid
$Less->parse('@grid-gutter-width: 20px;');
//$Less->parse( '@body-bg: #000;' );
//$Less->parse( '@text-color: @gray-lighter;' );
//$Less->parse( '@icon-font-path: "../../../Library/Bootstrap.Glyphicons/1.9.0/glyphicons_halflings/web/html_css/fonts/";' );
//
//$Less->parse( '@headings-font-family: "CorpoALigCondensedRegular";' );
$Less->parse('@font-size-base: 13px;');
//$Less->parse( '@headings-color: @gray;' );
//$Less->parse( '@headings-small-color: @gray-light;' );
//$Less->parse( '@font-size-h1: floor((@font-size-base * 2.9));' );
//$Less->parse( '@font-size-h2: floor((@font-size-base * 2.45));' );
//$Less->parse( '@font-size-h3: floor((@font-size-base * 2.0));' );
//$Less->parse( '@font-size-h4: floor((@font-size-base * 1.55));' );
//$Less->parse( '@font-size-h5: floor((@font-size-base * 1.3));' );
//$Less->parse( '@font-size-h6: ceil((@font-size-base * 1.05));' );
//$Less->parse( '@link-color: @gray-lighter;' );
コード例 #30
0
ファイル: Compiler.php プロジェクト: vi-kon/laravel-bootstrap
 /**
  * Minify CSS
  *
  * @return string
  */
 protected function minifyCss()
 {
     $output = '';
     // Core variables and mixins
     $output .= '@import "variables.less";';
     $output .= '@import "mixins.less";';
     // Reset and dependencies
     $output .= $this->prepareCssForLess('normalize');
     $output .= $this->prepareCssForLess('print');
     $output .= $this->prepareCssForLess('glyphicons');
     // Core CSS
     $output .= $this->prepareCssForLess('scaffolding');
     $output .= $this->prepareCssForLess('type');
     $output .= $this->prepareCssForLess('code');
     $output .= $this->prepareCssForLess('grid');
     $output .= $this->prepareCssForLess('tables');
     $output .= $this->prepareCssForLess('forms');
     $output .= $this->prepareCssForLess('buttons');
     // Components
     $output .= $this->prepareCssForLess('component-animations');
     $output .= $this->prepareCssForLess('dropdowns');
     $output .= $this->prepareCssForLess('button-groups');
     $output .= $this->prepareCssForLess('input-groups');
     $output .= $this->prepareCssForLess('navs');
     $output .= $this->prepareCssForLess('navbar');
     $output .= $this->prepareCssForLess('breadcrumbs');
     $output .= $this->prepareCssForLess('pagination');
     $output .= $this->prepareCssForLess('pager');
     $output .= $this->prepareCssForLess('labels');
     $output .= $this->prepareCssForLess('badges');
     $output .= $this->prepareCssForLess('jumbotron');
     $output .= $this->prepareCssForLess('thumbnails');
     $output .= $this->prepareCssForLess('alerts');
     $output .= $this->prepareCssForLess('progress-bars');
     $output .= $this->prepareCssForLess('media');
     $output .= $this->prepareCssForLess('list-group');
     $output .= $this->prepareCssForLess('panels');
     $output .= $this->prepareCssForLess('responsive-embed');
     $output .= $this->prepareCssForLess('wells');
     $output .= $this->prepareCssForLess('close');
     // Components w/ JavaScript
     $output .= $this->prepareCssForLess('modals');
     $output .= $this->prepareCssForLess('tooltip');
     $output .= $this->prepareCssForLess('popovers');
     $output .= $this->prepareCssForLess('carousel');
     // Utility classes
     $output .= $this->prepareCssForLess('utilities');
     $output .= $this->prepareCssForLess('responsive-utilities');
     $less = new \Less_Parser();
     $less->SetImportDirs([base_path('vendor/twbs/bootstrap/less') => 'bootstrap']);
     $css = $less->parse($output, 'bootstrap.components.less')->getCss();
     $minifier = new Minify\CSS();
     $minifier->add($css);
     return $minifier->minify();
 }