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


PHP lessc::setVariables方法代码示例

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


在下文中一共展示了lessc::setVariables方法的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: Core_View_Helper_Css

function Core_View_Helper_Css($files)
{
    include_once LIBRARY_PATH . '/Less/lessc.inc.php';
    $options = Core_Resource_View::getOptions();
    $less = new lessc();
    foreach ($files as $key => $file) {
        if (substr($file, 0, 1) != '/') {
            $filePaths[] = APPLICATION_PATH . '/theme/' . $options['theme'] . '/' . $file;
        } else {
            $filePaths[] = BASE_PATH . $file;
        }
    }
    if ($options['combineCss']) {
        $fileDate = 0;
        $cacheFile = '';
        foreach ($filePaths as $filePath) {
            $fileDate = max(filemtime($filePath), $fileDate);
            $cacheFile .= $filePath;
        }
        $cacheFile = md5($cacheFile) . '.css';
        $cacheFilePath = BASE_PATH . '/public/cache/' . $cacheFile;
        $cacheFileDate = file_exists($cacheFilePath) ? filemtime($cacheFilePath) : 0;
        if ($cacheFileDate < $fileDate) {
            $fileContent = '';
            $less->setVariables(array('themeUrl' => "'" . BASE_URL . '/app/theme/' . $options['theme'] . "'", 'publicUrl' => "'" . BASE_URL . '/public' . "'"));
            foreach ($filePaths as $filePath) {
                $ext = pathinfo($filePath, PATHINFO_EXTENSION);
                if ($ext == 'less') {
                    $fileContent .= $less->compileFile($filePath) . PHP_EOL;
                } else {
                    $fileContent .= file_get_contents($filePath) . PHP_EOL;
                }
            }
            file_put_contents($cacheFilePath, $options['minify'] ? Core_Helper_Minify::minifyCss($fileContent) : $fileContent);
        }
        $fileLinks = array(BASE_URL . '/public/cache/' . $cacheFile);
    } else {
        foreach ($filePaths as $key => $filePath) {
            $ext = pathinfo($filePath, PATHINFO_EXTENSION);
            if ($ext == 'less') {
                $less->setVariables(array('themeUrl' => "'" . BASE_URL . '/app/theme/' . $options['theme'] . "'"));
                $cacheFile = md5($filePath) . '.css';
                $cacheFilePath = BASE_PATH . '/public/cache/' . $cacheFile;
                $less->checkedCompile($filePath, $cacheFilePath);
                $fileLinks[] = BASE_URL . '/public/cache/' . $cacheFile;
            } else {
                $fileLinks[] = BASE_URL . '/' . trim(str_replace(BASE_PATH, '', $filePath), '/');
            }
        }
    }
    foreach ($fileLinks as $link) {
        echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"{$link}\" />" . PHP_EOL;
    }
}
开发者ID:2eye-studios,项目名称:development,代码行数:54,代码来源:Css.php

示例3: actionLess

 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()));
 }
开发者ID:buildshop,项目名称:bs-common,代码行数:25,代码来源:TemplateController.php

示例4: 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

示例5: CompileOptionsLess

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');
}
开发者ID:Karpec,项目名称:geo-mac,代码行数:31,代码来源:helpers.dynamic.css.php

示例6: bootstrap

 /**
  * Prepares the style compiler by adding variables to environment.
  * 
  * @param	array<string>		$variables
  * @return	string
  */
 protected function bootstrap(array $variables)
 {
     // add reset like a boss
     $content = $this->prepareFile(WCF_DIR . 'style/bootstrap/reset.less');
     // apply style variables
     $this->compiler->setVariables($variables);
     // add mixins
     $content .= $this->prepareFile(WCF_DIR . 'style/bootstrap/mixin.less');
     return $content;
 }
开发者ID:nick-strohm,项目名称:WCF,代码行数:16,代码来源:StyleCompiler.class.php

示例7: filterDump

 /**
  * Filters an asset just before it's dumped.
  *
  * @param AssetInterface $asset
  */
 public function filterDump(AssetInterface $asset)
 {
     $compiler = new \lessc();
     $this->dispatch(new LoadThemeVariables($variables = new Collection()));
     $compiler->setVariables($variables->all());
     if ($dir = $asset->getSourceDirectory()) {
         $compiler->importDir = $dir;
     }
     foreach ($this->loadPaths as $loadPath) {
         $compiler->addImportDir($loadPath);
     }
     $asset->setContent($compiler->parse($this->parser->parse($asset->getContent())));
 }
开发者ID:huglester,项目名称:streams-platform,代码行数:18,代码来源:LessFilter.php

示例8: compileChildLessFile

function compileChildLessFile($input, $output, $params)
{
    $less = new lessc();
    $less->setVariables($params);
    // input and output location
    $inputFile = get_stylesheet_directory() . '/less/' . $input;
    $outputFile = get_stylesheet_directory() . '/css/' . $output;
    try {
        $less->compileFile($inputFile, $outputFile);
    } catch (Exception $ex) {
        echo "lessphp fatal error: " . $ex->getMessage();
    }
}
开发者ID:roadthemez,项目名称:roadthemes,代码行数:13,代码来源:lesscompiler.php

示例9: parse

 /**
  * Parse a Less file to CSS
  */
 public function parse($src, $dst, $options)
 {
     $this->auto = isset($options['auto']) ? $options['auto'] : $this->auto;
     $variables = $this->variables;
     $assetManager = Yii::$app->assetManager;
     // Final url of the file being compiled
     $assetUrl = substr($dst, strpos($assetManager->basePath, $assetManager->baseUrl));
     $variables['published-url'] = '"' . $assetUrl . '"';
     // Root for the published folder
     $variables['published-base-url'] = '"/' . implode('/', array_slice(explode('/', ltrim($assetUrl, '/')), 0, 2)) . '"';
     $less = new \lessc();
     $less->setVariables($variables);
     // Compressed setting
     if ($this->compressed) {
         $less->setFormatter('compressed');
     }
     \Less_Parser::$default_options['compress'] = $this->compressed;
     \Less_Parser::$default_options['relativeUrls'] = $this->relativeUrls;
     // Send out pre-compile event
     $event = new \yii\base\Event();
     $this->runtime = ['sourceFile' => $src, 'destinationFile' => $dst, 'compiler' => $less];
     $event->sender = $this;
     Event::trigger($this, self::EVENT_BEFORE_COMPILE, $event);
     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;
             }
             $newCache = $less->cachedCompile($cache);
             if (!is_array($cache) || $newCache["updated"] > $cache["updated"]) {
                 $cacheMgr->set($cacheId, $newCache);
                 file_put_contents($dst, $newCache['compiled']);
             }
         } else {
             $less->compileFile($src, $dst);
         }
         // If needed, respect the users configuration
         if ($assetManager->fileMode !== null) {
             @chmod($dst, $assetManager->fileMode);
         }
         unset($this->less);
     } catch (\Exception $e) {
         throw new \Exception(__CLASS__ . ': Failed to compile less file : ' . $e->getMessage() . '.');
     }
 }
开发者ID:dfatt,项目名称:yii2-asset-converter,代码行数:53,代码来源:Less.php

示例10: _getInlineCSS

 protected function _getInlineCSS()
 {
     $s = '';
     require_once $this->_sDirPlugins . 'lessphp/lessc.inc.php';
     $oLess = new lessc();
     $oConfigBase = new BxBaseConfig();
     $oLess->setVariables($oConfigBase->aLessConfig);
     foreach ($this->_aFilesCss as $sFile) {
         if (substr($sFile, -5) !== '.less') {
             continue;
         }
         $s .= $oLess->compileFile($this->_sPathCss . $sFile) . "\n";
     }
     return $s;
 }
开发者ID:Baloo7super,项目名称:dolphin,代码行数:15,代码来源:BxDolInstallView.php

示例11: lessc

 function sh_theme_color_scheme($color = '')
 {
     $dir = SH_TH_ROOT;
     include_once $dir . '/includes/thirdparty/lessc.inc.php';
     if (!$color) {
         $color = _WSH()->option('custom_color_scheme');
     }
     if (!$color) {
         return;
     }
     $less = new lessc();
     $less->setVariables(array("color" => $color));
     // create a new cache object, and compile
     $cache = $less->cachedCompile(_WSH()->includes("/css/color.less"));
     return $cache['compiled'];
     file_put_contents(_WSH()->includes('/css/colors.css'), $cache["compiled"]);
 }
开发者ID:estrategasdigitales,项目名称:kanet,代码行数:17,代码来源:functions.php

示例12: thim_generate_less2css

function thim_generate_less2css($fileout, $type, $less_variables = array(), $compile_file = '')
{
    if (!$compile_file) {
        $compile_file = TP_THEME_DIR . 'less' . DIRECTORY_SEPARATOR . 'theme-options.less';
    }
    $css = "";
    WP_Filesystem();
    global $wp_filesystem;
    $compiler = new lessc();
    $compiler->setFormatter('compressed');
    // set less varivalbles
    $compiler->setVariables($less_variables);
    // chose file less to compile
    $css .= $compiler->compileFile($compile_file);
    // get customcss
    $css .= thim_get_customcss();
    // minifile css
    $regex = array("`^([\t\\s]+)`ism" => '', "`^\\/\\*(.+?)\\*\\/`ism" => "", "`([\n\\A;]+)\\/\\*(.+?)\\*\\/`ism" => "\$1", "`([\n\\A;\\s]+)//(.+?)[\n\r]`ism" => "\$1\n", "`(^[\r\n]*|[\r\n]+)[\\s\t]*[\r\n]+`ism" => "", "/\n/i" => "");
    $css = preg_replace(array_keys($regex), $regex, $css);
    /***********************************
     * 		Create style.css file
     ***********************************/
    $style = thim_file_get_contents(TP_THEME_DIR . "inc/theme-info.txt");
    // Determine whether Multisite support is enabled
    if (is_multisite()) {
        // Write Theme Info into style.css
        if (!file_put_contents($fileout . $type, $style, LOCK_EX)) {
            @chmod($fileout . $type, 0777);
            file_put_contents($fileout . $type, $style, LOCK_EX);
        }
        // Write the rest to specific site style-ID.css
        $fileout = $fileout . '-' . get_current_blog_id();
        if (!file_put_contents($fileout . $type, $css, FILE_APPEND)) {
            @chmod($fileout . $type, 0777);
            file_put_contents($fileout . $type, $css, FILE_APPEND);
        }
    } else {
        // If this is not multisite, we write them all in style.css file
        $style .= $css;
        if (!file_put_contents($fileout . $type, $style, LOCK_EX)) {
            @chmod($fileout . $type, 0777);
            file_put_contents($fileout . $type, $style, LOCK_EX);
        }
    }
}
开发者ID:vinhnq1211,项目名称:funy,代码行数:45,代码来源:class-tp-less2css.php

示例13: actions

 /**
  * Compiles Bootstrap LESS codes and save the result in database.
  *
  * @return mixed
  */
 function actions($options)
 {
     global $wp_filesystem;
     $uploads = wp_upload_dir();
     if (!empty($options['less'])) {
         require_once plugin_dir_path(__FILE__) . 'lib/lessphp/lessc.inc.php';
         $lessphp = new lessc();
         $lessphp->setVariables(wp_parse_args($options['vars'], $this->default_bootstrap_variables()));
         $less = file_get_contents(dirname(__FILE__) . '/lib/bootstrap/less/mixins.less');
         foreach ($options['less'] as $raw_less) {
             $less .= file_get_contents(dirname(__FILE__) . '/lib/bootstrap/less/' . $raw_less . '.less');
         }
         /* compile LESS and minify the result */
         $css = $this->minify_css($lessphp->parse($less));
         WP_Filesystem();
         $wp_filesystem->put_contents(trailingslashit($uploads['basedir']) . 'bootstrap.css', $css, 0644);
     } else {
         @unlink(trailingslashit($uploads['basedir']) . 'bootstrap.css');
     }
     return $options;
 }
开发者ID:rinodung,项目名称:kenhcongdong,代码行数:26,代码来源:bootstrap.php

示例14: less_css

function less_css($handle)
{
    include DUDE_THEME_DIR . "/less/variables.php";
    // output css file name
    $css_path = DUDE_THEME_DIR . '/css/' . "{$handle}.css";
    // automatically regenerate files if source's modified time has changed or vars have changed
    try {
        // initialise the parser
        $less = new lessc();
        // load the cache
        $cache_path = DUDE_THEME_DIR . "/cache/{$handle}.css.cache";
        if (file_exists($cache_path)) {
            $cache = unserialize(file_get_contents($cache_path));
        }
        // If the cache or root path in it are invalid then regenerate
        if (empty($cache) || empty($cache['less']['root']) || !file_exists($cache['less']['root'])) {
            $cache = array('vars' => $vars, 'less' => DUDE_THEME_DIR . "/less/{$handle}.less");
        }
        // less config
        $less->setFormatter("compressed");
        $less->setVariables($vars);
        $less_cache = $less->cachedCompile($cache['less'], false);
        if (!file_exists($css_path) || empty($cache) || empty($cache['less']['updated']) || $less_cache['updated'] > $cache['less']['updated']) {
            file_put_contents($cache_path, serialize(array('vars' => $vars, 'less' => $less_cache)));
            file_put_contents($css_path, $less_cache['compiled']);
        } elseif ($vars !== $cache['vars']) {
            $less_cache = $less->cachedCompile($cache['less'], true);
            file_put_contents($cache_path, serialize(array('vars' => $vars, 'less' => $less_cache)));
            file_put_contents($css_path, $less_cache['compiled']);
        }
    } catch (exception $ex) {
        qa_fatal_error($ex->getMessage());
    }
    // return the compiled stylesheet with the query string it had if any
    $url = DUDE_THEME_URL . "/css/{$handle}.css";
    echo '<link href="' . $url . '" type="text/css" rel="stylesheet">';
}
开发者ID:rahularyan,项目名称:dude-theme,代码行数:37,代码来源:less.php

示例15: _initProcessor

 /**
  * @return lessc
  */
 protected function _initProcessor()
 {
     // lazy load
     if (!class_exists('lessc')) {
         require_once dirname(__FILE__) . '/class.less.leafo.php';
     }
     $less = new lessc();
     if ($this->_isDebug()) {
         $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 = ", ";
     } else {
         // compress mode
         $formatter = new lessc_formatter_compressed();
         $formatter->closeSingle = "}\n";
         $formatter->close = "}\n";
     }
     // set formatter
     $less->setFormatter($formatter);
     $less->setPreserveComments(false);
     // add paths for imports
     $less->addImportDir($this->_tpl->lessFull);
     $less->addImportDir(JPATH_ROOT);
     // from php
     $less->setVariables(array('css' => str_replace($this->_tpl->baseurl, '', $this->_tpl->css), 'less' => str_replace($this->_tpl->baseurl, '', $this->_tpl->less), 'images' => str_replace($this->_tpl->baseurl, '', $this->_tpl->img), 'debug' => (int) $this->_isDebug()));
     // add custom functions
     $less->registerFunction('data-uri', array($this, 'lib_dataUri'));
     return $less;
 }
开发者ID:nikoyar,项目名称:jblank,代码行数:39,代码来源:css.less.leafo.php


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