本文整理汇总了PHP中Less_Parser::allParsedFiles方法的典型用法代码示例。如果您正苦于以下问题:PHP Less_Parser::allParsedFiles方法的具体用法?PHP Less_Parser::allParsedFiles怎么用?PHP Less_Parser::allParsedFiles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Less_Parser
的用法示例。
在下文中一共展示了Less_Parser::allParsedFiles方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _compile
/**
* @param string $path
* @return string
*/
protected function _compile($path)
{
try {
$this->_processor->parseFile($path);
$resultCss = $this->_processor->getCss();
$this->_cacheMix = $this->_processor->allParsedFiles();
return $resultCss;
} catch (Exception $ex) {
die('<strong>Less Error (JBlank):</strong><br/><pre>' . $ex->getMessage() . '</pre>');
}
}
示例2: 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;
}
示例3: Cache
public static function Cache(&$less_files, $parser_options = array()) {
$file = dirname(__FILE__) . '/Less.php';
if (file_exists($file) && !class_exists('Less_Parser')) {
require_once($file);
}$parser_options['cache_dir'] = Less_Cache::$cache_dir;
$parser = new Less_Parser($parser_options);
foreach ($less_files as $file_path => $uri_or_less) {
if (strpos($uri_or_less, "\n") !== false) {
$parser->Parse($uri_or_less);
continue;
}$parser->ParseFile($file_path, $uri_or_less);
}$compiled = $parser->getCss();
$less_files = $parser->allParsedFiles();
return $compiled;
}
示例4: compile
/**
* Compiles the LESS code into a single CSS file.
*/
public function compile()
{
try {
$dest = $this->paths->get('css.compressed');
$compile = $this->params->get('compile_less', 1);
$changed = (bool) $this->isLessUpdated();
$generateSourceMap = $this->params->get('generate_css_sourcemap', false);
JLog::add('LESS cache changed: ' . ((bool) $changed ? 'true' : 'false'), JLog::DEBUG, $this->logger);
$force = (bool) ($compile == 2);
$changed = (bool) ($compile == 1 && $changed);
JLog::add('Force LESS compilation: ' . ((bool) $force ? 'true' : 'false'), JLog::DEBUG, $this->logger);
JLog::add('Compiling LESS: ' . ((bool) $changed ? 'true' : 'false'), JLog::DEBUG, $this->logger);
if (!JFile::exists($dest) || $changed || $force) {
JLog::add('Generate CSS sourcemap: ' . ((bool) $generateSourceMap ? 'true' : 'false'), JLog::DEBUG, $this->logger);
$options = array('compress' => true);
$cssSourceMapUri = str_replace(JPATH_ROOT, JURI::base(), $this->paths->get('css.sourcemap'));
// Build source map with minified code.
if ($this->params->get('generate_css_sourcemap', false)) {
$options['sourceMap'] = true;
$options['sourceMapWriteTo'] = $this->paths->get('css.sourcemap');
$options['sourceMapURL'] = $cssSourceMapUri;
$options['sourceMapBasepath'] = JPATH_ROOT;
$options['sourceMapRootpath'] = JUri::base();
} else {
JFile::delete($this->paths->get('css.sourcemap'));
}
$less = new Less_Parser($options);
$less->parseFile($this->paths->get('css.less'), JUri::base());
$css = $less->getCss();
JLog::add('Writing CSS to: ' . $dest, JLog::DEBUG, $this->logger);
JFile::write($dest, $css);
$files = $less->allParsedFiles();
// update cache.
$this->updateCache(self::CACHEKEY . '.files.less', $files);
}
} catch (Exception $e) {
JLog::add($e->getMessage(), JLog::ERROR, $this->logger);
return false;
}
}
示例5: Cache
public static function Cache(&$less_files, $parser_options = array())
{
// get less.php if it exists
$file = dirname(__FILE__) . '/Less.php';
if (file_exists($file) && !class_exists('Less_Parser')) {
require_once $file;
}
$parser_options['cache_dir'] = Less_Cache::$cache_dir;
$parser = new Less_Parser($parser_options);
// combine files
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();
$less_files = $parser->allParsedFiles();
return $compiled;
}
示例6: ParseLess
/**
* Handle the processing of multiple less files into css
*
* @return mixed Compiled css string or false
*
*/
static function ParseLess(&$less_files)
{
global $dataDir;
$compiled = false;
// don't use less if the memory limit is less than 64M
$limit = @ini_get('memory_limit');
if ($limit) {
$limit = \gp\tool::getByteValue($limit);
//if less than 64M, disable less compiler if we can't increase
if ($limit < 67108864 && @ini_set('memory_limit', '96M') === false) {
if (\gp\tool::LoggedIn()) {
msg('LESS compilation disabled. Please increase php\'s memory_limit');
}
return false;
//if less than 96M, try to increase
} elseif ($limit < 100663296) {
@ini_set('memory_limit', '96M');
}
}
//compiler options
$options = array();
//prepare the compiler
includeFile('thirdparty/less.php/Less.php');
$parser = new \Less_Parser($options);
$import_dirs[$dataDir] = \gp\tool::GetDir('/');
$parser->SetImportDirs($import_dirs);
$parser->cache_method = 'php';
$parser->SetCacheDir($dataDir . '/data/_cache');
// combine files
try {
foreach ($less_files as $less) {
//treat as less markup if there are newline characters
if (strpos($less, "\n") !== false) {
$parser->Parse($less);
continue;
}
// handle relative and absolute paths
if (!empty($dataDir) && strpos($less, $dataDir) === false) {
$relative = $less;
$less = $dataDir . '/' . ltrim($less, '/');
} else {
$relative = substr($less, strlen($dataDir));
}
$parser->ParseFile($less, \gp\tool::GetDir(dirname($relative)));
}
$compiled = $parser->getCss();
} catch (Exception $e) {
if (\gp\tool::LoggedIn()) {
msg('LESS Compile Failed: ' . $e->getMessage());
}
return false;
}
// significant difference in used memory 15,000,000 -> 6,000,000. Max still @ 15,000,000
if (function_exists('gc_collect_cycles')) {
gc_collect_cycles();
}
$less_files = $parser->allParsedFiles();
return $compiled;
}
示例7: 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;
}
示例8: substr
$dirLen = $index - $lastOffset + 1;
// include /
$dir = substr($paths[0], $lastOffset, $dirLen);
foreach ($paths as $path) {
if (substr($path, $lastOffset, $dirLen) != $dir) {
return $common;
}
}
$common .= $dir;
$lastOffset = $index + 1;
}
return substr($common, 0, -1);
}
if ($regenerate) {
// chop absolute path to a common denominator
$allIncluded = $parser->allParsedFiles();
$prefix = getCommonPath($allIncluded);
$allIncluded = array_map(function ($x) use($prefix) {
return substr($x, strlen($prefix));
}, $allIncluded);
$allIncluded = implode(' ', $allIncluded);
} else {
$allIncluded = 'Can only say when regenerating.';
}
if ($status_only) {
if ($regenerated) {
print "Regenerated CSS file.";
} else {
print "Did not regenerate CSS file. Would just output the cache file.";
}
exit;
示例9:
if ($custom_css == 1 && $compile_css == 1) {
$parser->ModifyVars(array('custom_css' => '"../../../../../../templates/' . $this->template . '/css/custom.css"'));
} else {
$parser->ModifyVars(array('custom_css' => '"custom.less"'));
}
if ($compile_css == 1) {
$parser->ModifyVars(array('loadall' => 'true', 'bootstrap' => '"../less/bootstrap.less"', 'yjsgless' => '"yjsg.less"', 'sitelinkcolor' => '#' . $valid_color, 'normalize' => '"../../../../../../plugins/system/yjsg' . $cssFolder . 'normalize.css"', 'yjsg_layout' => '"../../../../../../plugins/system/yjsg' . $cssFolder . 'yjsg_layout.css"', 'newsitems' => '"../../../../../../plugins/system/yjsg' . $cssFolder . 'newsitems.css"', 'typo' => '"../../../../../../plugins/system/yjsg' . $cssFolder . 'typo.css"', 'joomladefaults' => '"../../../../../../plugins/system/yjsg' . $cssFolder . 'joomladefaults.css"', 'template_css' => '"../../../../../../plugins/system/yjsg' . $cssFolder . 'template.css"', 'yjsg_responsive' => '"../../../../../../plugins/system/yjsg' . $cssFolder . 'yjresponsive.css"', 'menus_css' => $menus, 'layout_css' => '"../../../../../../templates/' . $this->template . '/css/layout.css"', 'custom_responsive' => '"../../../../../../templates/' . $this->template . '/css/custom_responsive.css"', 'template_style' => '"../../../../../../templates/' . $this->template . '/css/' . $css_file . '.css"'));
} else {
$parser->ModifyVars(array('loadall' => 'false', 'bootstrap' => '"../less/bootstrap.less"', 'yjsgless' => '"yjsg.less"', 'sitelinkcolor' => '#' . $valid_color));
}
$parser->parseFile($input_less, false);
if ($selectors_override == 1 && $selectors_override_type == 3 && $compile_css == 1) {
$parser->parseFile($fontfacekit, false);
}
$output_cssContents = $parser->getCss();
$imported_files = $parser->allParsedFiles();
$newCache = $yjsgLess->newCache($imported_files);
// replace all calls for assets folder with actual path and remove @imports generated by compiler if we are compiling everything
if ($compile_css == 1) {
$output_cssContents = str_replace('../../../../../plugins/system/yjsg/assets/', YJSG_ASSETS, $output_cssContents);
$output_cssContents = preg_replace('/(@import(.*?);)/s', '', $output_cssContents);
}
// replace @font-face kit font strings if the settings is on
if ($selectors_override == 1 && $selectors_override_type == 3 && $compile_css == 1) {
$output_cssContents = preg_replace("/(url\\('(?!\\.)(?!\\/))/s", "url('" . YJSGSITE_PATH . 'css/fontfacekits/' . $fontfacekit_font_family . '/', $output_cssContents);
}
// replace @font-face font strings for fontawesome
$getfontawesome = '';
if ($compile_css == 1) {
$getfontawesome = JFile::read($fontawesome);
$getfontawesome = str_replace('../../../../../plugins/system/yjsg/assets/', YJSG_ASSETS, $getfontawesome);