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


PHP Less_Parser::SetImportDirs方法代码示例

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


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

示例1: filterLoad

 /**
  * Filters an asset after it has been loaded.
  *
  * @param  \Assetic\Asset\AssetInterface  $asset
  * @return void
  */
 public function filterLoad(AssetInterface $asset)
 {
     $max_nesting_level = ini_get('xdebug.max_nesting_level');
     $memory_limit = ini_get('memory_limit');
     if ($max_nesting_level && $max_nesting_level < 200) {
         ini_set('xdebug.max_nesting_level', 200);
     }
     if ($memory_limit && $memory_limit < 256) {
         ini_set('memory_limit', '256M');
     }
     $root = $asset->getSourceRoot();
     $path = $asset->getSourcePath();
     $dirs = array();
     $lc = new \Less_Parser(array('compress' => true));
     if ($root && $path) {
         $dirs[] = dirname($root . '/' . $path);
     }
     foreach ($this->loadPaths as $loadPath) {
         $dirs[] = $loadPath;
     }
     $lc->SetImportDirs($dirs);
     $url = parse_url($this->getRequest()->getUriForPath(''));
     $absolutePath = str_replace(public_path(), '', $root);
     if (isset($url['path'])) {
         $absolutePath = $url['path'] . $absolutePath;
     }
     $lc->parseFile($root . '/' . $path, $absolutePath);
     $asset->setContent($lc->getCss());
 }
开发者ID:cartalyst,项目名称:assetic-filters,代码行数:35,代码来源:LessphpFilter.php

示例2: Compile

 public function Compile($less_files, $out_name, $modify_vars = [], $bootstrap_less = "mixins", $mediawiki_less = "mixins")
 {
     $lessphp = new \Less_Parser($this->cache_dir);
     switch ($bootstrap_less) {
         case "mixins":
             $lessphp->parseFile($this->bootstrap_dir . "/variables.less", "");
             $lessphp->parseFile(__DIR__ . "/custom_variables.less", "");
             $lessphp->parseFile($this->bootstrap_mixin, $this->bootstrap_mixin_url);
             break;
         case "full":
             $lessphp->SetImportDirs([$this->bootstrap_dir]);
             $lessphp->parseFile(__DIR__ . "/bootstrap.less", "");
             break;
         case "off":
             break;
     }
     switch ($mediawiki_less) {
         case "mixins":
             $lessphp->parseFile($this->mediawiki_mixin, $this->mediawiki_mixin_url);
             break;
         case "off":
             break;
     }
     foreach ($less_files as $less => $url) {
         $lessphp->parseFile($less, $url);
     }
     if ($modify_vars) {
         $lessphp->ModifyVars($modify_vars);
     }
     $css = $lessphp->getCss();
     file_put_contents($out_name, $css);
 }
开发者ID:iamchenxin,项目名称:bootstraplessc,代码行数:32,代码来源:BootstrapLessc.php

示例3: compileFile

 public function compileFile($fname, $outFname = null)
 {
     if (!is_readable($fname)) {
         throw new Exception('load error: failed to find ' . $fname);
     }
     $pi = pathinfo($fname);
     $oldImport = $this->importDir;
     $this->importDir = (array) $this->importDir;
     $this->importDir[] = realpath($pi['dirname']) . '/';
     $this->allParsedFiles = array();
     $this->addParsedFile($fname);
     $parser = new Less_Parser(array('sourceMap' => $this->sourceMap));
     $parser->SetImportDirs($this->getImportDirs());
     if (count($this->registeredVars)) {
         $parser->ModifyVars($this->registeredVars);
     }
     foreach ($this->libFunctions as $name => $func) {
         $parser->registerFunction($name, $func);
     }
     $parser->parseFile($fname);
     $out = $parser->getCss();
     $parsed = Less_Parser::AllParsedFiles();
     foreach ($parsed as $file) {
         $this->addParsedFile($file);
     }
     $this->importDir = $oldImport;
     if ($outFname !== null) {
         return file_put_contents($outFname, $out);
     }
     return $out;
 }
开发者ID:bradcrumb,项目名称:lesscompiler,代码行数:31,代码来源:LessCompiler.php

示例4: Cache

 public static function Cache(&$less_files, $parser_options = array())
 {
     //prepare the processor
     if (!class_exists('Less_Parser')) {
         include_once 'Less.php';
     }
     $parser = new Less_Parser($parser_options);
     $parser->SetCacheDir(self::$cache_dir);
     $parser->SetImportDirs(self::$import_dirs);
     // combine files
     try {
         foreach ($less_files as $file_path => $uri_or_less) {
             //treat as less markup if there are newline characters
             if (strpos($uri_or_less, "\n") !== false) {
                 $parser->Parse($uri_or_less);
                 continue;
             }
             $parser->ParseFile($file_path, $uri_or_less);
         }
         $compiled = $parser->getCss();
     } catch (Exception $e) {
         self::$error = $e;
         return false;
     }
     $less_files = $parser->allParsedFiles();
     return $compiled;
 }
开发者ID:Tommar,项目名称:remate,代码行数:27,代码来源:lesscache.php

示例5: compile

 public function compile($source, $pathname)
 {
     $less = new \Less_Parser();
     $less->SetImportDirs(array(dirname($pathname) => './'));
     $less->parse($source);
     return $less->getCss();
 }
开发者ID:nagumo,项目名称:Phest,代码行数:7,代码来源:CompilerLess.php

示例6: compileFile

 /**
  * @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;
 }
开发者ID:Umz,项目名称:ImpressPages,代码行数:36,代码来源:LessCompiler.php

示例7: empty

 function compile_botstrap_less_adm($theme, $input, $output = '', $compress = false)
 {
     global $cfg;
     $output = empty($output) ? $input : $output;
     $output = $cfg['themes_dir'] . '/admin/' . $theme . '/css/' . $output . '.css';
     $input = $cfg['themes_dir'] . '/admin/' . $theme . '/less/' . $input . '.less';
     if (file_exists($output) && file_exists($input)) {
         $filetimecss = filemtime($output);
         $filetimeless = filemtime($input);
         //	cot_print('css', cot_date('datetime_full', $filetimecss), 'less', cot_date('datetime_full', $filetimeless), cot_date('datetime_full'), $filetimecss > $filetimeless);
         if ($filetimecss > $filetimeless) {
             return false;
         } else {
             unlink($output);
             //	cot_print("deleted");
         }
     }
     $options = array('relativeUrls' => false);
     if ($compress) {
         $options['compress'] = true;
     }
     $parser = new Less_Parser($options);
     $parser->SetImportDirs(array($cfg['themes_dir'] . '/admin/' . $theme . '/less' => $cfg['themes_dir'] . '/admin/' . $theme . '/less', $cfg['plugins_dir'] . "/bootstrap/bootstrap/less" => $cfg['plugins_dir'] . "/bootstrap/bootstrap/less"));
     $parser->parseFile($input);
     $css = $parser->getCss();
     if (!file_exists($cfg['themes_dir'] . '/admin/' . $theme . '/css')) {
         mkdir($cfg['themes_dir'] . '/admin/' . $theme . '/css');
     }
     file_put_contents($output, $css);
     return true;
 }
开发者ID:esclkm,项目名称:cot-admintheme-comaterial,代码行数:31,代码来源:comaterial.php

示例8: compile

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

示例9: compile

 public static function compile($source, $importdirs)
 {
     $parser = new Less_Parser();
     $parser->SetImportDirs($importdirs);
     $parser->parse($source);
     $output = $parser->getCss();
     return $output;
 }
开发者ID:grlf,项目名称:eyedock,代码行数:8,代码来源:less.php

示例10: setImportPath

 /**
  * {@inheritdoc}
  */
 public function setImportPath($fullPath, $relPath = null)
 {
     $this->_initCompiler();
     $relPath = $relPath ?: $this->_options->get('root_url');
     if (!FS::isDir($fullPath)) {
         throw new Exception('Undefined import path: ' . $fullPath);
     }
     $importPaths = \Less_Parser::$options['import_dirs'];
     $importPaths[$fullPath] = $relPath;
     $this->_compiler->SetImportDirs($importPaths);
 }
开发者ID:jbzoo,项目名称:less,代码行数:14,代码来源:Gpeasy.php

示例11: compile

 /**
  * {@inheritdoc}
  */
 public function compile($path, $relativePath)
 {
     $this->parsedFiles = array();
     $parser = new \Less_Parser(array('compress' => true));
     if (!empty($this->importDirs)) {
         $parser->SetImportDirs($this->importDirs);
     }
     $parser->parseFile($path);
     $parser->ModifyVars($this->variables);
     $css = $parser->getCss();
     $this->parsedFiles = $parser->allParsedFiles();
     return $css;
 }
开发者ID:mikoweb,项目名称:vsymfo-document,代码行数:16,代码来源:LessPreprocessor.php

示例12: register

 public function register()
 {
     Event::listen('watcher:check', function ($options) {
         $timestamp = strtotime($options->timestamp);
         $reload = false;
         if (isset($options->less_process) && is_array($options->less_process) && $timestamp) {
             $lessCompiler = new \Less_Parser();
             if (isset($options->less_importdirs) && is_array($options->less_importdirs)) {
                 $importDirs = array();
                 foreach ($options->less_importdirs as $importdir) {
                     $importdir = realpath(base_path($importdir));
                     if (is_dir($importdir)) {
                         $importDirs[] = $importdir;
                         foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($importdir)) as $x) {
                             if (!$x->isDir() && $x->getCTime() > $timestamp) {
                                 $reload = true;
                             }
                         }
                     }
                 }
                 $lessCompiler->SetImportDirs($importDirs);
             }
             foreach ($options->less_process as $source => $output) {
                 $source = realpath(base_path($source));
                 $output = realpath(base_path($output));
                 if (!$output) {
                     $output = base_path($output);
                 }
                 if (is_file($source)) {
                     if ($reload) {
                         touch($source);
                     }
                     if (filemtime($source) > $timestamp || $reload) {
                         try {
                             $lessCompiler->parseFile($source, '/');
                             $css = $lessCompiler->getCss();
                             if ($css) {
                                 file_put_contents($output, $css);
                             }
                         } catch (Exception $e) {
                         }
                     }
                 }
             }
         }
     });
 }
开发者ID:zulfajuniadi,项目名称:laravel-watch-less,代码行数:47,代码来源:WatchLessServiceProvider.php

示例13: _initProcessor

 /**
  * @return Less_Parser
  */
 protected function _initProcessor()
 {
     // lazy load
     if (!class_exists('Less_Parser')) {
         require_once dirname(__FILE__) . '/class.less.gpeasy.php';
     }
     $options = array('compress' => true, 'strictUnits' => false, 'strictMath' => false, 'numPrecision' => 4, 'cache_method' => false);
     if ($this->_isDebug()) {
         $options['compress'] = false;
     }
     $less = new Less_Parser($options);
     // set paths
     $less->SetImportDirs(array($this->_tpl->lessFull => $this->_tpl->baseurl));
     // add custom vars
     $less->ModifyVars(array());
     return $less;
 }
开发者ID:nikoyar,项目名称:jblank,代码行数:20,代码来源:css.less.gpeasy.php

示例14: less

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

示例15: _initProcessor

 /**
  * @return Less_Parser
  */
 protected function _initProcessor()
 {
     // lazy load
     if (!class_exists('Less_Parser')) {
         require_once dirname(__FILE__) . '/class.less.gpeasy.php';
     }
     $options = array('compress' => 1, 'strictUnits' => 0, 'strictMath' => 0, 'relativeUrls' => 1, 'numPrecision' => 4, 'cache_method' => 0, 'sourceMap' => 0);
     if ($this->_isDebug()) {
         $options['compress'] = 0;
         $options['sourceMap'] = 1;
         $options['sourceMapRootpath'] = $this->_tpl->less;
         $options['sourceMapBasepath'] = $path = JPath::clean($this->_tpl->lessFull, '/');
     }
     $less = new Less_Parser($options);
     // set paths
     $less->SetImportDirs(array($this->_tpl->lessFull => $this->_tpl->less));
     // add custom vars
     $less->ModifyVars($this->_getCustomVars());
     return $less;
 }
开发者ID:Cheren,项目名称:JBlank,代码行数:23,代码来源:css.less.gpeasy.php


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