本文整理汇总了PHP中CSSMin::getLocalFileReferences方法的典型用法代码示例。如果您正苦于以下问题:PHP CSSMin::getLocalFileReferences方法的具体用法?PHP CSSMin::getLocalFileReferences怎么用?PHP CSSMin::getLocalFileReferences使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSSMin
的用法示例。
在下文中一共展示了CSSMin::getLocalFileReferences方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: 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);
}
示例4: testCommentedLocalFileReferences
/**
* CSSMin::getLocalFileReferences should ignore url(...) expressions
* that have been commented out.
*/
public function testCommentedLocalFileReferences()
{
$basepath = __DIR__ . '/../data/css/';
$css = file_get_contents($basepath . 'comments.css');
$files = CSSMin::getLocalFileReferences($css, $basepath);
$expected = [$basepath . 'not-commented.gif'];
$this->assertArrayEquals($expected, $files, 'Url(...) expression in comment should be omitted.');
}
示例5: 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
$this->localFileRefs = array_merge($this->localFileRefs, CSSMin::getLocalFileReferences($style, $localDir));
return CSSMin::remap($style, $localDir, $remoteDir, true);
}
示例6: 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);
}