本文整理汇总了PHP中ResourceLoader::makeComment方法的典型用法代码示例。如果您正苦于以下问题:PHP ResourceLoader::makeComment方法的具体用法?PHP ResourceLoader::makeComment怎么用?PHP ResourceLoader::makeComment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ResourceLoader
的用法示例。
在下文中一共展示了ResourceLoader::makeComment方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getStyles
/**
* @param ResourceLoaderContext $context
* @return array
*/
public function getStyles(ResourceLoaderContext $context)
{
$geshi = SyntaxHighlight_GeSHi::prepare('', $this->lang);
if (!$geshi->error) {
$css = SyntaxHighlight_GeSHi::getCSS($geshi);
} else {
$css = ResourceLoader::makeComment($geshi->error());
}
return array('all' => $css);
}
示例2: getStyles
/**
* @param ResourceLoaderContext $context
* @return array
*/
public function getStyles(ResourceLoaderContext $context)
{
$styles = [];
foreach ($this->getPages($context) as $titleText => $options) {
if ($options['type'] !== 'style') {
continue;
}
$media = isset($options['media']) ? $options['media'] : 'all';
$style = $this->getContent($titleText);
if (strval($style) === '') {
continue;
}
if ($this->getFlip($context)) {
$style = CSSJanus::transform($style, true, false);
}
$style = MemoizedCallable::call('CSSMin::remap', [$style, false, $this->getConfig()->get('ScriptPath'), true]);
if (!isset($styles[$media])) {
$styles[$media] = [];
}
$style = ResourceLoader::makeComment($titleText) . $style;
$styles[$media][] = $style;
}
return $styles;
}
示例3: getStyles
/**
* @param ResourceLoaderContext $context
* @return array
*/
public function getStyles(ResourceLoaderContext $context)
{
$styles = array();
foreach ($this->getPages($context) as $titleText => $options) {
if ($options['type'] !== 'style') {
continue;
}
$title = Title::newFromText($titleText);
if (!$title || $title->isRedirect()) {
continue;
}
$media = isset($options['media']) ? $options['media'] : 'all';
$style = $this->getContent($title);
if (strval($style) === '') {
continue;
}
if ($this->getFlip($context)) {
$style = CSSJanus::transform($style, true, false);
}
$style = CSSMin::remap($style, false, $this->getConfig()->get('ScriptPath'), true);
if (!isset($styles[$media])) {
$styles[$media] = array();
}
$style = ResourceLoader::makeComment($titleText) . $style;
$styles[$media][] = $style;
}
return $styles;
}
示例4: getCSS
/**
* Get the raw vector CSS, flipping if needed
*
* @todo Possibly get rid of this function and use ResourceLoader in the manner it was
* designed to be used in, rather than just grabbing a list of filenames from it,
* and not properly handling such details as media types in module definitions.
*
* @param string $dir 'ltr' or 'rtl'
* @return String
*/
public function getCSS($dir)
{
// All CSS files these modules reference will be concatenated in sequence
// and loaded as one file.
$moduleNames = array('mediawiki.legacy.shared', 'skins.common.interface', 'skins.vector.styles', 'mediawiki.legacy.config');
$prepend = '';
$css = '';
$resourceLoader = new ResourceLoader();
foreach ($moduleNames as $moduleName) {
/** @var ResourceLoaderFileModule $module */
$module = $resourceLoader->getModule($moduleName);
$cssFileNames = $module->getAllStyleFiles();
wfSuppressWarnings();
foreach ($cssFileNames as $cssFileName) {
if (!file_exists($cssFileName)) {
$prepend .= ResourceLoader::makeComment("Unable to find {$cssFileName}.");
continue;
}
if (!is_readable($cssFileName)) {
$prepend .= ResourceLoader::makeComment("Unable to read {$cssFileName}. " . "Please check file permissions.");
continue;
}
try {
if (preg_match('/\\.less$/', $cssFileName)) {
// Run the LESS compiler for *.less files (bug 55589)
$compiler = ResourceLoader::getLessCompiler();
$cssFileContents = $compiler->compileFile($cssFileName);
} else {
// Regular CSS file
$cssFileContents = file_get_contents($cssFileName);
}
if ($cssFileContents) {
// Rewrite URLs, though don't bother embedding images. While static image
// files may be cached, CSS returned by this function is definitely not.
$cssDirName = dirname($cssFileName);
$css .= CSSMin::remap($cssFileContents, $cssDirName, '..' . str_replace(array($GLOBALS['IP'], DIRECTORY_SEPARATOR), array('', '/'), $cssDirName), false);
} else {
$prepend .= ResourceLoader::makeComment("Unable to read {$cssFileName}.");
}
} catch (Exception $e) {
$prepend .= ResourceLoader::formatException($e);
}
$css .= "\n";
}
wfRestoreWarnings();
}
$css = $prepend . $css;
if ($dir == 'rtl') {
$css = CSSJanus::transform($css, true);
}
return $css;
}