本文整理汇总了PHP中Less_Parser::SetFileInfo方法的典型用法代码示例。如果您正苦于以下问题:PHP Less_Parser::SetFileInfo方法的具体用法?PHP Less_Parser::SetFileInfo怎么用?PHP Less_Parser::SetFileInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Less_Parser
的用法示例。
在下文中一共展示了Less_Parser::SetFileInfo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: divide
//.........这里部分代码省略.........
}
// remember this path when lookup for import
if (preg_match($rimport, $importcontent)) {
$importdirs[dirname(JPATH_ROOT . '/' . $rtl_url)] = $root . '/' . 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)] = $root . '/' . 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)] = $root . '/' . 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)] = $root . '/' . dirname($rtlthemepath) . '/';
}
}
if ($rtlcontent) {
//rtl content will be treat as a new file
$rtlfile = str_replace('.less', '-rtl.less', $path);
$output = $output . "\n#{$kfilepath}{content: \"{$rtlfile}\";}\n\n#{$krtlsep}{content: \"separator\";}\n\n{$rtlcontent}\n\n";
}
}
// common place
$importdirs[T3_TEMPLATE_PATH . '/less'] = T3_TEMPLATE_URL . '/less/';
// myself
$importdirs[dirname(JPATH_ROOT . '/' . $path)] = $root . '/' . dirname($path) . '/';
// compile less to css using lessphp
$parser->SetImportDirs($importdirs);
$parser->SetFileInfo(JPATH_ROOT . '/' . $path, $root . '/' . dirname($path) . '/');
$source = $vars . "\n#{$kvarsep}{content: \"separator\";}\n" . $output;
$parser->parse($source);
$output = $parser->getCss();
//use cssjanus to transform the content
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);
if ($rtlcontent) {
$output = $output . "\n" . $rtlcontent;
}
}
//update path and store to files
$split_contents = preg_split($rsplitbegin . $kfilepath . $rsplitend, $output, -1, PREG_SPLIT_DELIM_CAPTURE);
$file_contents = array();
$file = $path;
//default
$relpath = JURI::base(true) . '/' . dirname($file);
$isfile = false;
foreach ($split_contents as $chunk) {
if ($isfile) {
$isfile = false;
$file = $chunk;
$relpath = $topath ? T3Path::relativePath($topath, dirname($file)) : JURI::base(true) . '/' . dirname($file);
} else {
$file_contents[$file] = (isset($file_contents[$file]) ? $file_contents[$file] : '') . "\n" . ($file ? T3Path::updateUrl($chunk, $relpath) : $chunk) . "\n\n";
$isfile = true;
}
}
if (!empty($file_contents)) {
// remove the duplicate clearfix at the beginning
$split_contents = preg_split($rsplitbegin . $kvarsep . $rsplitend, reset($file_contents));
// ignore first one, it's clearfix
if (is_array($split_contents)) {
array_shift($split_contents);
}
$file_contents[key($file_contents)] = implode("\n", $split_contents);
//output the file to content and add to document
foreach ($file_contents as $file => $content) {
$cssfile = $topath . str_replace('/', '.', $file) . '.css';
JFile::write(JPATH_ROOT . '/' . $cssfile, $content);
$doc->addStylesheet($root . '/' . $cssfile);
}
}
}