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


PHP lessc::setPreserveComments方法代码示例

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


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

示例3: compile

 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;
 }
开发者ID:shamsbd71,项目名称:canvas-framework,代码行数:25,代码来源:legacy.less.php

示例4: compile

 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;
 }
开发者ID:joshjim27,项目名称:jobsglobal,代码行数:9,代码来源:legacy.less.php

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

示例6: filterLoad

 public function filterLoad(AssetInterface $asset)
 {
     $lc = new \lessc();
     if ($dir = $asset->getSourceDirectory()) {
         $lc->importDir = $dir;
     }
     foreach ($this->loadPaths as $loadPath) {
         $lc->addImportDir($loadPath);
     }
     if ($this->formatter) {
         $lc->setFormatter($this->formatter);
     }
     if (null !== $this->preserveComments) {
         $lc->setPreserveComments($this->preserveComments);
     }
     $asset->setContent($lc->parse($asset->getContent(), $this->presets));
 }
开发者ID:samj1912,项目名称:repo,代码行数:17,代码来源:LessphpFilter.php

示例7: filterLoad

 public function filterLoad(AssetInterface $asset)
 {
     $root = $asset->getSourceRoot();
     $path = $asset->getSourcePath();
     $lc = new \lessc();
     if ($root && $path) {
         $lc->importDir = dirname($root . '/' . $path);
     }
     foreach ($this->loadPaths as $loadPath) {
         $lc->addImportDir($loadPath);
     }
     if ($this->formatter) {
         $lc->setFormatter($this->formatter);
     }
     if (null !== $this->preserveComments) {
         $lc->setPreserveComments($this->preserveComments);
     }
     $asset->setContent($lc->parse($asset->getContent(), $this->presets));
 }
开发者ID:alexBLR,项目名称:firmware,代码行数:19,代码来源:LessphpFilter.php

示例8: build

 /**
  * Build the Less file
  *
  * @param string $dest      The destination CSS file
  * @param bool   $force     If set to true, will build whereas the cache status
  * @param array  $variables Less variables to set before compiling the Less file
  */
 public function build($dest, $force = false, $variables = array())
 {
     if (!is_dir(dirname($dest))) {
         mkdir(dirname($dest), 0755, true);
     }
     $compiler = new \lessc();
     $lastCompilationFile = App::cache()->getCacheFilePath($this->getLastCompilationInfoFilename());
     if (!$force && is_file($lastCompilationFile)) {
         $cache = (include $lastCompilationFile);
     } else {
         $cache = $this->source;
     }
     $compiler->setFormatter('compressed');
     $compiler->setPreserveComments(false);
     $compilation = $compiler->cachedCompile($cache, $force);
     if (!is_array($cache) || $compilation['updated'] > $cache['updated']) {
         file_put_contents($dest, '/*** ' . date('Y-m-d H:i:s') . ' ***/' . PHP_EOL . $compilation['compiled']);
         $event = new Event('built-less', array('source' => $this->source, 'dest' => $dest));
         $event->trigger();
         // Save the compilation information
         unset($compilation['compiled']);
         $this->saveLastCompilationInfo($compilation);
     }
 }
开发者ID:elvyrra,项目名称:hawk,代码行数:31,代码来源:Less.php

示例9: _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

示例10: autoCompileLess

function autoCompileLess()
{
    // include lessc.inc
    require_once get_template_directory() . '/inc/less/lessc.inc.php';
    // input and output location
    $inputFile = get_template_directory() . '/assets/css/styles.less';
    $outputFile = get_template_directory() . '/assets/css/styles.css';
    // load the cache
    $cacheFile = $inputFile . ".cache";
    if (file_exists($cacheFile)) {
        $cache = unserialize(file_get_contents($cacheFile));
    } else {
        $cache = $inputFile;
    }
    $less = new lessc();
    // create a new cache object, and compile
    $less->setPreserveComments(true);
    $newCache = $less->cachedCompile($cache);
    // output a LESS file, and cache file only if it has been modified since last compile
    if (!is_array($cache) || $newCache["updated"] > $cache["updated"]) {
        file_put_contents($cacheFile, serialize($newCache));
        file_put_contents($outputFile, $newCache['compiled']);
    }
}
开发者ID:rinodung,项目名称:wordpress-demo,代码行数:24,代码来源:lessc.connect.php

示例11: ro_theme_autoCompileLess

function ro_theme_autoCompileLess($inputFile, $outputFile)
{
    require_once ABS_PATH_FR . '/inc/lessc.inc.php';
    global $tb_options;
    $less = new lessc();
    $less->setFormatter("classic");
    $less->setPreserveComments(true);
    /*Styling Options*/
    $tb_primary_color = $tb_options['tb_primary_color'];
    $tb_secondary_color = $tb_options['tb_secondary_color'];
    $variables = array("tb_primary_color" => $tb_primary_color, "tb_secondary_color" => $tb_secondary_color);
    $less->setVariables($variables);
    $cacheFile = $inputFile . ".cache";
    if (file_exists($cacheFile)) {
        $cache = unserialize(file_get_contents($cacheFile));
    } else {
        $cache = $inputFile;
    }
    $newCache = $less->cachedCompile($inputFile);
    if (!is_array($cache) || $newCache["updated"] > $cache["updated"]) {
        file_put_contents($cacheFile, serialize($newCache));
        file_put_contents($outputFile, $newCache['compiled']);
    }
}
开发者ID:tldjssla,项目名称:jejufoodwinefestival,代码行数:24,代码来源:presets.php

示例12: autoCompileLess

/**
 * Compile less to css. Creates a cache-file of the last compiled less-file.
 *
 * This code is originally from the manual of lessphp.
 *
 * @param string $inputFile  the filename of the less-file.
 * @param string $outputFile the filename of the css-file to be created.
 * @param array  $config     with configuration details.
 *
 * @return void
 */
function autoCompileLess($inputFile, $outputFile, $config)
{
    $cacheFile = $inputFile . ".cache";
    if (file_exists($cacheFile)) {
        $cache = unserialize(file_get_contents($cacheFile));
    } else {
        $cache = $inputFile;
    }
    $less = new lessc();
    // Add custom less functions
    if (isset($config['functions'])) {
        foreach ($config['functions'] as $key => $val) {
            $less->registerFunction($key, $val);
        }
    }
    // Add import dirs
    if (isset($config['imports'])) {
        foreach ($config['imports'] as $val) {
            $less->addImportDir($val);
        }
    }
    // Set output formatter
    if (isset($config['formatter'])) {
        $less->setFormatter($config['formatter']);
    }
    // Preserve comments
    if (isset($config['comments'])) {
        $less->setPreserveComments($config['comments']);
    }
    // Compile a new cache
    $newCache = $less->cachedCompile($cache);
    if (!is_array($cache) || $newCache["updated"] > $cache["updated"]) {
        file_put_contents($cacheFile, serialize($newCache));
        file_put_contents($outputFile, $newCache['compiled']);
    }
}
开发者ID:fnlive,项目名称:Anax-MVC,代码行数:47,代码来源:style.php

示例13: beforesave

 public function beforesave()
 {
     $change = true;
     if (!empty($_POST['bootstrap'])) {
         $change = $this->cfg['bootstrap'] != $_POST['bootstrap'];
     }
     if ($change) {
         include_once JPATH_SITE . '/components/com_acctexp/lib/lessphp/lessc.inc.php';
         $less = new lessc();
         $less->setImportDir(array(JPATH_SITE . '/media/com_acctexp/less/'));
         //$less->setFormatter("compressed");
         $less->setPreserveComments(true);
         if (!isset($_POST['bootstrap'])) {
             $this->cfg['bootstrap'] = true;
         } else {
             $this->cfg['bootstrap'] = $_POST['bootstrap'];
         }
         if ($this->cfg['bootstrap']) {
             $less->compileFile(JPATH_SITE . "/media/com_acctexp/less/template.etacarinae.less", JPATH_SITE . '/media/com_acctexp/css/template.etacarinae.css');
         } else {
             $less->compileFile(JPATH_SITE . "/media/com_acctexp/less/template.etacarinae-reuse-bootstrap.less", JPATH_SITE . '/media/com_acctexp/css/template.etacarinae.css');
         }
     }
 }
开发者ID:Ibrahim1,项目名称:aec,代码行数:24,代码来源:template.php

示例14: parse_stylesheet

 /**
  * Lessify the stylesheet and return the href of the compiled file
  *
  * @param  string $src    Source URL of the file to be parsed
  * @param  string $handle An identifier for the file used to create the file name in the cache
  * @return string         URL of the compiled stylesheet
  */
 public function parse_stylesheet($src, $handle)
 {
     // we only want to handle .less files
     if (!preg_match('/\\.less(\\.php)?$/', preg_replace('/\\?.*$/', '', $src))) {
         return $src;
     }
     // get file path from $src
     if (!strstr($src, '?')) {
         $src .= '?';
     }
     // prevent non-existent index warning when using list() & explode()
     // Match the URL schemes between WP_CONTENT_URL and $src,
     // so the str_replace further down will work
     $src_scheme = parse_url($src, PHP_URL_SCHEME);
     $wp_content_url_scheme = parse_url(WP_CONTENT_URL, PHP_URL_SCHEME);
     if ($src_scheme != $wp_content_url_scheme) {
         $src = set_url_scheme($src, $wp_content_url_scheme);
     }
     list($less_path, $query_string) = explode('?', str_replace(WP_CONTENT_URL, WP_CONTENT_DIR, $src));
     // output css file name
     $css_path = trailingslashit($this->get_cache_dir()) . "{$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 = "{$css_path}.cache";
         if (file_exists($cache_path)) {
             $cache = unserialize(file_get_contents($cache_path));
         }
         // vars to pass into the compiler - default @themeurl var for image urls etc...
         $this->vars['themeurl'] = '~"' . get_stylesheet_directory_uri() . '"';
         $this->vars['lessurl'] = '~"' . dirname($src) . '"';
         $this->vars = apply_filters('less_vars', $this->vars, $handle);
         // 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' => $this->vars, 'less' => $less_path);
         }
         // less config
         $less->setFormatter(apply_filters('less_compression', $this->compression));
         $less->setPreserveComments(apply_filters('less_preserve_comments', $this->preserve_comments));
         $less->setVariables($this->vars);
         // add directories to scan for imports
         $import_dirs = apply_filters('less_import_dirs', $this->import_dirs);
         if (!empty($import_dirs)) {
             foreach ((array) $import_dirs as $dir) {
                 $less->addImportDir($dir);
             }
         }
         // register and unregister functions
         foreach ($this->registered_functions as $name => $callable) {
             $less->registerFunction($name, $callable);
         }
         foreach ($this->unregistered_functions as $name) {
             $less->unregisterFunction($name);
         }
         // allow devs to mess around with the less object configuration
         do_action_ref_array('lessc', array(&$less));
         // $less->cachedCompile only checks for changed file modification times
         // if using the theme customiser (changed variables not files) then force a compile
         if ($this->vars !== $cache['vars']) {
             $force = true;
         } else {
             $force = false;
         }
         $less_cache = $less->cachedCompile($cache['less'], apply_filters('less_force_compile', $force));
         if (empty($cache) || empty($cache['less']['updated']) || $less_cache['updated'] > $cache['less']['updated'] || $this->vars !== $cache['vars']) {
             file_put_contents($cache_path, serialize(array('vars' => $this->vars, 'less' => $less_cache)));
             file_put_contents($css_path, $less_cache['compiled']);
         }
     } catch (exception $ex) {
         wp_die($ex->getMessage());
     }
     // restore query string it had if any
     $url = trailingslashit($this->get_cache_dir(false)) . "{$handle}.css" . (!empty($query_string) ? "?{$query_string}" : '');
     // restore original url scheme
     $url = set_url_scheme($url, $src_scheme);
     return add_query_arg('ver', $less_cache['updated'], $url);
 }
开发者ID:straczowski,项目名称:solawi_theme,代码行数:86,代码来源:wp-less.php

示例15: lessen

 public function lessen(&$errors)
 {
     // Convert LESS files
     include_once JPATH_SITE . '/components/com_acctexp/lib/lessphp/lessc.inc.php';
     $less = new lessc();
     $less->setImportDir(array(JPATH_SITE . '/media/com_acctexp/less/'));
     $less->setPreserveComments(true);
     $v = new JVersion();
     if ($v->isCompatible('3.0')) {
         $less->compileFile(JPATH_SITE . "/media/com_acctexp/less/admin-j3.less", JPATH_SITE . '/media/com_acctexp/css/admin.css');
     } else {
         $less->compileFile(JPATH_SITE . "/media/com_acctexp/less/admin.less", JPATH_SITE . '/media/com_acctexp/css/admin.css');
     }
 }
开发者ID:Ibrahim1,项目名称:aec,代码行数:14,代码来源:install.acctexp.php


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