本文整理汇总了PHP中CSSMin::remap方法的典型用法代码示例。如果您正苦于以下问题:PHP CSSMin::remap方法的具体用法?PHP CSSMin::remap怎么用?PHP CSSMin::remap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSSMin
的用法示例。
在下文中一共展示了CSSMin::remap方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRemapRemapping
/**
* This tests basic functionality of CSSMin::remap. testRemapRemapping tests funky parameters.
*
* @dataProvider provideRemapRemappingCases
* @covers CSSMin::remap
*/
public function testRemapRemapping($message, $input, $expectedOutput)
{
$localPath = __DIR__ . '/../../data/cssmin/';
$remotePath = 'http://localhost/w/';
$realOutput = CSSMin::remap($input, $localPath, $remotePath);
$this->assertEquals($expectedOutput, $realOutput, "CSSMin::remap: {$message}");
}
示例2: testRemapRemapping
/**
* This tests basic functionality of CSSMin::remap. testRemapRemapping tests funky parameters.
*
* @dataProvider provideRemapRemappingCases
* @covers CSSMin::remap
*/
public function testRemapRemapping($message, $input, $expectedOutput)
{
$localPath = __DIR__ . '/../../data/cssmin/';
$remotePath = 'http://localhost/w/';
$realOutput = CSSMin::remap($input, $localPath, $remotePath);
$this->assertEquals($expectedOutput, preg_replace('/\\d+-\\d+-\\d+T\\d+:\\d+:\\d+Z/', 'timestamp', $realOutput), "CSSMin::remap: {$message}");
}
示例3: minimizeFiles
public function minimizeFiles($files)
{
$css_out = '';
$webroot = (string) OC::$WEBROOT;
foreach ($files as $file_info) {
$file = $file_info[0] . '/' . $file_info[2];
$css_out .= '/* ' . $file . ' */' . "\n";
$css = file_get_contents($file);
$in_root = false;
foreach (OC::$APPSROOTS as $app_root) {
if (strpos($file, $app_root['path'] . '/') === 0) {
$in_root = rtrim($webroot . $app_root['url'], '/');
break;
}
}
if ($in_root !== false) {
$css = str_replace('%appswebroot%', $in_root, $css);
$css = str_replace('%webroot%', $webroot, $css);
}
$remote = $file_info[1];
$remote .= '/';
$remote .= dirname($file_info[2]);
$css_out .= CSSMin::remap($css, dirname($file), $remote, true);
}
if (!defined('DEBUG') || !DEBUG) {
$css_out = CSSMin::minify($css_out);
}
return $css_out;
}
示例4: getStyles
/**
* @param $context ResourceLoaderContext
* @return array
*/
public function getStyles(ResourceLoaderContext $context)
{
global $wgScriptPath;
$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, $wgScriptPath, true);
if (!isset($styles[$media])) {
$styles[$media] = array();
}
if (strpos($titleText, '*/') === false) {
$style = "/* {$titleText} */\n" . $style;
}
$styles[$media][] = $style;
}
return $styles;
}
示例5: readStyleFile
/**
* Reads a style file.
*
* This method can be used as a callback for array_map()
*
* @param $path String: File path of style file to read
* @param $flip bool
*
* @return String: CSS data in script file
* @throws MWException if the file doesn't exist
*/
protected function readStyleFile($path, $flip)
{
$localPath = $this->getLocalPath($path);
if (!file_exists($localPath)) {
$msg = __METHOD__ . ": style file not found: \"{$localPath}\"";
wfDebugLog('resourceloader', $msg);
throw new MWException($msg);
}
$style = file_get_contents($localPath);
if ($flip) {
$style = CSSJanus::transform($style, true, false);
}
$dirname = dirname($path);
if ($dirname == '.') {
// If $path doesn't have a directory component, don't prepend a dot
$dirname = '';
}
$dir = $this->getLocalPath($dirname);
$remoteDir = $this->getRemotePath($dirname);
// Get and register local file references
$this->localFileRefs = array_merge($this->localFileRefs, CSSMin::getLocalFileReferences($style, $dir));
return CSSMin::remap($style, $dir, $remoteDir, true);
}
示例6: readStyleFile
/**
* Reads a style file.
*
* This method can be used as a callback for array_map()
*
* @param string $path File path of style file to read
* @param bool $flip
* @param ResourceLoaderContext $context
*
* @return string CSS data in script file
* @throws MWException If the file doesn't exist
*/
protected function readStyleFile($path, $flip, $context)
{
$localPath = $this->getLocalPath($path);
$remotePath = $this->getRemotePath($path);
if (!file_exists($localPath)) {
$msg = __METHOD__ . ": style file not found: \"{$localPath}\"";
wfDebugLog('resourceloader', $msg);
throw new MWException($msg);
}
if ($this->getStyleSheetLang($localPath) === 'less') {
$style = $this->compileLessFile($localPath, $context);
$this->hasGeneratedStyles = true;
} else {
$style = file_get_contents($localPath);
}
if ($flip) {
$style = CSSJanus::transform($style, true, false);
}
$localDir = dirname($localPath);
$remoteDir = dirname($remotePath);
// Get and register local file references
$localFileRefs = CSSMin::getLocalFileReferences($style, $localDir);
foreach ($localFileRefs as $file) {
if (file_exists($file)) {
$this->localFileRefs[] = $file;
} else {
$this->missingLocalFileRefs[] = $file;
}
}
// Don't cache this call. remap() ensures data URIs embeds are up to date,
// and urls contain correct content hashes in their query string. (T128668)
return CSSMin::remap($style, $localDir, $remoteDir, true);
}
示例7: readStyleFile
/**
* Reads a style file.
*
* This method can be used as a callback for array_map()
*
* @param $path String: File path of style file to read
* @param $flip bool
*
* @return String: CSS data in script file
* @throws MWException if the file doesn't exist
*/
protected function readStyleFile($path, $flip, ResourceLoaderContext $context)
{
$localPath = $this->getLocalPath($path);
if (!file_exists($localPath)) {
throw new MWException(__METHOD__ . ": style file not found: \"{$localPath}\"");
}
// Wikia - change begin - @author: wladek
$style = self::getFileContents($localPath, $context);
// Wikia - change end
if ($flip) {
$style = CSSJanus::transform($style, true, false);
}
$dirname = dirname($path);
if ($dirname == '.') {
// If $path doesn't have a directory component, don't prepend a dot
$dirname = '';
}
$dir = $this->getLocalPath($dirname);
$remoteDir = $this->getRemotePath($dirname, $context);
// Get and register local file references
$this->localFileRefs = array_merge($this->localFileRefs, CSSMin::getLocalFileReferences($style, $dir));
return CSSMin::remap($style, $dir, $remoteDir, true, $this->localBasePath);
}
示例8: readStyleFile
/**
* Reads a style file.
*
* This method can be used as a callback for array_map()
*
* @param string $path File path of style file to read
* @param bool $flip
* @param ResourceLoaderContext $context (optional)
*
* @return string CSS data in script file
* @throws MWException If the file doesn't exist
*/
protected function readStyleFile($path, $flip, $context = null)
{
$localPath = $this->getLocalPath($path);
$remotePath = $this->getRemotePath($path);
if (!file_exists($localPath)) {
$msg = __METHOD__ . ": style file not found: \"{$localPath}\"";
wfDebugLog('resourceloader', $msg);
throw new MWException($msg);
}
if ($this->getStyleSheetLang($localPath) === 'less') {
$compiler = $this->getLessCompiler($context);
$style = $this->compileLessFile($localPath, $compiler);
$this->hasGeneratedStyles = true;
} else {
$style = file_get_contents($localPath);
}
if ($flip) {
$style = CSSJanus::transform($style, true, false);
}
$localDir = dirname($localPath);
$remoteDir = dirname($remotePath);
// Get and register local file references
$localFileRefs = CSSMin::getAllLocalFileReferences($style, $localDir);
foreach ($localFileRefs as $file) {
if (file_exists($file)) {
$this->localFileRefs[] = $file;
} else {
$this->missingLocalFileRefs[] = $file;
}
}
return CSSMin::remap($style, $localDir, $remoteDir, true);
}
示例9: 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;
}
$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 = 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;
}
示例10: 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;
}
示例11: readStyleFile
/**
* Reads a style file.
*
* This method can be used as a callback for array_map()
*
* @param $path String: File path of script file to read
* @return String: CSS data in script file
*/
protected function readStyleFile($path, $flip)
{
$localPath = $this->getLocalPath($path);
$style = file_get_contents($localPath);
if ($style === false) {
throw new MWException(__METHOD__ . ": style file not found: \"{$localPath}\"");
}
if ($flip) {
$style = CSSJanus::transform($style, true, false);
}
$dir = $this->getLocalPath(dirname($path));
$remoteDir = $this->getRemotePath(dirname($path));
// Get and register local file references
$this->localFileRefs = array_merge($this->localFileRefs, CSSMin::getLocalFileReferences($style, $dir));
return CSSMin::remap($style, $dir, $remoteDir, true);
}