本文整理汇总了PHP中Less_Parser::AddParsedFile方法的典型用法代码示例。如果您正苦于以下问题:PHP Less_Parser::AddParsedFile方法的具体用法?PHP Less_Parser::AddParsedFile怎么用?PHP Less_Parser::AddParsedFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Less_Parser
的用法示例。
在下文中一共展示了Less_Parser::AddParsedFile方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: compile
public function compile($env)
{
$evald = $this->compileForImport($env);
//get path & uri
$path_and_uri = null;
if (is_callable(Less_Parser::$options['import_callback'])) {
$path_and_uri = call_user_func(Less_Parser::$options['import_callback'], $evald);
}
if (!$path_and_uri) {
$path_and_uri = $evald->PathAndUri();
}
if ($path_and_uri) {
list($full_path, $uri) = $path_and_uri;
} else {
$full_path = $uri = $evald->getPath();
}
//import once
if ($evald->skip($full_path, $env)) {
return array();
}
if ($this->options['inline']) {
//todo needs to reference css file not import
//$contents = new Less_Tree_Anonymous($this->root, 0, array('filename'=>$this->importedFilename), true );
Less_Parser::AddParsedFile($full_path);
$contents = new Less_Tree_Anonymous(file_get_contents($full_path), 0, array(), true);
if ($this->features) {
return new Less_Tree_Media(array($contents), $this->features->value);
}
return array($contents);
}
// css ?
if ($evald->css) {
$features = $evald->features ? $evald->features->compile($env) : null;
return new Less_Tree_Import($this->compilePath($env), $features, $this->options, $this->index);
}
return $this->ParseImport($full_path, $uri, $env);
}
示例2: compileCss
//.........这里部分代码省略.........
$importcontent = preg_replace($rimportvars, '', $importcontent);
}
// remember this path when lookup for import
if (preg_match($rimport, $importcontent)) {
$importdirs[dirname(JPATH_ROOT . '/' . $rtl_url)] = self::relativePath($todir, dirname($rtl_url));
}
$rtlcontent .= "\n{$importcontent}\n\n";
// rtl theme overwrite
if ($theme && strpos($url, 'themes/') === false) {
$rtlthemepath = preg_replace($rswitchrtl, '/less/rtl/' . $theme . '/', $url);
if (is_file(JPATH_ROOT . '/' . $rtlthemepath)) {
// process import file
$importcontent = JFile::read(JPATH_ROOT . '/' . $rtlthemepath);
$rtlcontent .= "\n{$importcontent}\n\n";
$importdirs[dirname(JPATH_ROOT . '/' . $rtlthemepath)] = self::relativePath($todir, dirname($rtlthemepath));
}
}
} else {
$import = true;
}
}
// override in template for this file
$rtlpath = preg_replace($rswitchrtl, '/less/rtl/', $path);
if (is_file(JPATH_ROOT . '/' . $rtlpath)) {
// process import file
$importcontent = JFile::read(JPATH_ROOT . '/' . $rtlpath);
$rtlcontent .= "\n{$importcontent}\n\n";
$importdirs[dirname(JPATH_ROOT . '/' . $rtlpath)] = self::relativePath($todir, dirname($rtlpath));
}
// rtl theme
if ($theme) {
$rtlthemepath = preg_replace($rswitchrtl, '/less/rtl/' . $theme . '/', $path);
if (is_file(JPATH_ROOT . '/' . $rtlthemepath)) {
// process import file
$importcontent = JFile::read(JPATH_ROOT . '/' . $rtlthemepath);
$rtlcontent .= "\n{$importcontent}\n\n";
$importdirs[dirname(JPATH_ROOT . '/' . $rtlthemepath)] = self::relativePath($todir, dirname($rtlthemepath));
}
}
if ($rtlcontent) {
$output = $output . "\n#{$krtlsep}{content: \"separator\";}\n\n{$rtlcontent}\n\n";
}
}
// common place
$importdirs[T3_TEMPLATE_PATH . '/less'] = self::relativePath($todir, T3_TEMPLATE_URL);
// myself
$importdirs[dirname(JPATH_ROOT . '/' . $path)] = self::relativePath($todir, dirname($path));
// ignore all these files
foreach (array(T3_PATH, T3_PATH . '/bootstrap', T3_TEMPLATE_PATH) as $know_path) {
foreach (array('vars', 'variables', 'mixins') as $know_file) {
$realfile = realpath($know_path . '/less/' . $know_file . '.less');
if (is_file($realfile) && !Less_Parser::FileParsed($realfile)) {
Less_Parser::AddParsedFile($realfile);
}
}
}
// compile less to css using lessphp
$parser->SetImportDirs($importdirs);
$parser->SetFileInfo(JPATH_ROOT . '/' . $path, self::relativePath($todir, dirname($path)));
$source = $vars . "\n#{$kvarsep}{content: \"separator\";}\n" . $output;
$parser->parse($source);
$output = $parser->getCss();
// remove the duplicate clearfix at the beginning if not bootstrap.css file
if (strpos($path, $tpl . '/less/bootstrap.less') === false) {
$arr = preg_split($rsplitbegin . $kvarsep . $rsplitend, $output);
// ignore first one, it's clearfix
if (is_array($arr)) {
array_shift($arr);
}
$output = implode("\n", $arr);
} else {
$output = preg_replace($rsplitbegin . $kvarsep . $rsplitend, '', $output);
}
//update url if needed
if (defined('T3_DEV_MODE') && T3_DEV_MODE) {
$output = T3Path::updateUrl($output, $topath ? T3Path::relativePath(dirname($topath), dirname($path)) : T3_TEMPLATE_URL . '/css/');
}
if ($is_rtl) {
if ($rtlcontent) {
$output = preg_split($rsplitbegin . $krtlsep . $rsplitend, $output, -1, PREG_SPLIT_DELIM_CAPTURE);
$rtlcontent = isset($output[2]) ? $output[2] : false;
$output = $output[0];
}
T3::import('jacssjanus/ja.cssjanus');
$output = JACSSJanus::transform($output, true);
//join again
if ($rtlcontent) {
$output = $output . "\n" . $rtlcontent;
}
}
//remove comments and clean up
$output = preg_replace($rcomment, '', $output);
$output = preg_replace($rspace, "\n\n", $output);
if ($tofile) {
$ret = JFile::write($tofile, $output);
@chmod($tofile, 0644);
return $ret;
}
return $output;
}
示例3: compile
public function compile($env) {
$evald = $this->compileForImport($env);
$path_and_uri = null;
if (is_callable(Less_Parser::$options['import_callback'])) {
$path_and_uri = call_user_func(Less_Parser::$options['import_callback'], $evald);
}if (!$path_and_uri) {
$path_and_uri = $evald->PathAndUri();
}if ($path_and_uri) {
list($full_path, $uri) = $path_and_uri;
} else {
$full_path = $uri = $evald->getPath();
}if ($evald->skip($full_path, $env)) {
return array();
}if ($this->options['inline']) {
Less_Parser::AddParsedFile($full_path);
$contents = new Less_Tree_Anonymous(file_get_contents($full_path), 0, array(), true);
if ($this->features) {
return new Less_Tree_Media(array($contents), $this->features->value);
}return array($contents);
}if ($evald->css) {
$features = ($evald->features ? $evald->features->compile($env) : null);
return new Less_Tree_Import($this->compilePath($env), $features, $this->options, $this->index);
}return $this->ParseImport($full_path, $uri, $env);
}
示例4: compile
public function compile($env)
{
$evald = $this->compileForImport($env);
//get path & uri
$path_and_uri = null;
if (is_callable(Less_Parser::$options['import_callback'])) {
$path_and_uri = call_user_func(Less_Parser::$options['import_callback'], $evald);
}
if (!$path_and_uri) {
$path_and_uri = $evald->PathAndUri();
}
if ($path_and_uri) {
list($full_path, $uri) = $path_and_uri;
} else {
$full_path = $uri = $evald->getPath();
}
//import once
if ($evald->skip($full_path, $env)) {
return array();
}
if ($this->options['inline']) {
require_once ABSPATH . 'wp-admin/includes/file.php';
WP_Filesystem();
global $wp_filesystem;
Less_Parser::AddParsedFile($full_path);
$contents = new Less_Tree_Anonymous($wp_filesystem->get_contents($full_path), 0, array(), true);
if ($this->features) {
return new Less_Tree_Media(array($contents), $this->features->value);
}
return array($contents);
}
// css ?
if ($evald->css) {
$features = $evald->features ? $evald->features->compile($env) : null;
return new Less_Tree_Import($this->compilePath($env), $features, $this->options, $this->index);
}
return $this->ParseImport($full_path, $uri, $env);
}