当前位置: 首页>>代码示例>>PHP>>正文


PHP lessc::setFormatter方法代码示例

本文整理汇总了PHP中lessc::setFormatter方法的典型用法代码示例。如果您正苦于以下问题:PHP lessc::setFormatter方法的具体用法?PHP lessc::setFormatter怎么用?PHP lessc::setFormatter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lessc的用法示例。


在下文中一共展示了lessc::setFormatter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _initCompiler

 /**
  * {@inheritdoc}
  */
 protected function _initCompiler()
 {
     if ($this->_compiler) {
         return $this->_compiler;
     }
     $this->_compiler = new \lessc();
     if (class_exists('\\lessc_formatter_lessjs')) {
         $formatter = new \lessc_formatter_lessjs();
         // configurate css view
         $formatter->openSingle = ' { ';
         $formatter->closeSingle = "}\n";
         $formatter->close = "}\n";
         $formatter->indentChar = '    ';
         $formatter->disableSingle = true;
         $formatter->breakSelectors = true;
         $formatter->assignSeparator = ': ';
         $formatter->selectorSeparator = ', ';
         $this->_compiler->setFormatter($formatter);
     }
     $this->_compiler->setPreserveComments(false);
     // Set paths
     $importPaths = (array) $this->_options->get('import_paths', []);
     foreach ($importPaths as $fullPath => $relPath) {
         $this->setImportPath($fullPath, $relPath);
     }
     // Set paths
     $this->_compiler->setVariables((array) $this->_options->get('global_vars', []));
     return $this->_compiler;
 }
开发者ID:jbzoo,项目名称:less,代码行数:32,代码来源:Leafo.php

示例2: __construct

 public function __construct(Ai1ec_Registry_Object $registry, $default_theme_url = AI1EC_DEFAULT_THEME_URL)
 {
     parent::__construct($registry);
     $this->lessc = $this->_registry->get('lessc');
     $this->lessc->setFormatter('compressed');
     $this->default_theme_url = $this->sanitize_default_theme_url($default_theme_url);
     $this->parsed_css = '';
     $this->files = array('style.less', 'event.less', 'calendar.less');
 }
开发者ID:washingtonstateuniversity,项目名称:WSUWP2-CAHNRS-Plugin-Collection,代码行数:9,代码来源:lessphp.php

示例3: auto_less_compile

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();
    }
}
开发者ID:jrevillaa,项目名称:rest_drupal,代码行数:26,代码来源:less-compile.php

示例4: lessCompile

 /**
  * @param string $src
  * @return string
  */
 public function lessCompile($src)
 {
     $path = $this->lessCompiledPath . DIRECTORY_SEPARATOR . basename($src, '.less') . '.css';
     $lessCompile = false;
     if (!$this->lessForceCompile && $this->lessCompile) {
         $lessFiles = $this->_cacheGet('EAssetManager-less-updated-' . $src);
         if ($lessFiles && is_array($lessFiles)) {
             foreach ($lessFiles as $_file => $_time) {
                 if (filemtime($_file) != $_time) {
                     $lessCompile = true;
                     break;
                 }
             }
         } else {
             $lessCompile = true;
         }
         unset($lessFiles);
     }
     if (!file_exists($path) || $lessCompile || $this->lessForceCompile) {
         if (!$this->_lessc) {
             $this->_lessc = new lessc();
         }
         $this->_lessc->setFormatter($this->lessFormatter);
         $lessCache = $this->_lessc->cachedCompile($src);
         file_put_contents($path, $lessCache['compiled'], LOCK_EX);
         $this->_cacheSet('EAssetManager-less-updated-' . $src, $lessCache['files']);
     }
     return $path;
 }
开发者ID:inpassor,项目名称:yii-eassetmanager,代码行数:33,代码来源:EAssetManager.php

示例5: boot

 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");
         }
     }
 }
开发者ID:raphaelvigee,项目名称:ff-silex-less-provider,代码行数:32,代码来源:LessServiceProvider.php

示例6: _compileCss

 /**
  * 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);
         }
     }
 }
开发者ID:laiello,项目名称:plankonindia,代码行数:36,代码来源:AssetGenerator.php

示例7: css

 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);
 }
开发者ID:helpfulrobot,项目名称:tardinha-silverstripe-lesscss,代码行数:33,代码来源:LessCompiler.php

示例8: bigboom_generate_custom_color_scheme

/**
 * 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();
}
开发者ID:Qualitair,项目名称:ecommerce,代码行数:35,代码来源:meta-boxes.php

示例9: _compileCss

 /**
  * 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);
         }
     }
 }
开发者ID:saydulk,项目名称:croogo,代码行数:40,代码来源:AssetGenerator.php

示例10: shoestrap_buttons_css

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 
}
开发者ID:rhensley,项目名称:shoestrap,代码行数:28,代码来源:buttons.php

示例11: autoCompilerLess

 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);
         }
     }
 }
开发者ID:ProjectSoft-STUDIONIONS,项目名称:plugin-lesscompiler-modxevo,代码行数:59,代码来源:plugin.lesscompiler.php

示例12: generate_less_css

function generate_less_css()
{
    include_once __DIR__ . '/../vendor/lessc.inc.php';
    $less = new lessc();
    $less->setFormatter("compressed");
    $less_file = __DIR__ . "/../less/site.less";
    $css_file = __DIR__ . "/../css/style.css";
    return $less->compileFile($less_file, $css_file);
}
开发者ID:nosval,项目名称:WPBlank,代码行数:9,代码来源:assets.php

示例13: compileTo

 /**
  * 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);
 }
开发者ID:biggtfish,项目名称:cms,代码行数:19,代码来源:Less.php

示例14: buildString

 /**
  * Builds a LESS/CSS resource from string
  *
  * @param string $string
  *
  * @return type
  * The compiled and compressed CSS
  */
 public static function buildString($string)
 {
     $obj = new \lessc();
     $obj->setFormatter('compressed');
     try {
         $output = $obj->compile($string);
     } catch (\Exception $e) {
         throw $e;
     }
     return $output;
 }
开发者ID:apexstudios,项目名称:yamwlib,代码行数:19,代码来源:CssBuilder.php

示例15: compile

 /**
  * 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']);
     }
 }
开发者ID:stonyyi,项目名称:anahita,代码行数:57,代码来源:less.php


注:本文中的lessc::setFormatter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。