本文整理汇总了PHP中OutputPage::transformCssMedia方法的典型用法代码示例。如果您正苦于以下问题:PHP OutputPage::transformCssMedia方法的具体用法?PHP OutputPage::transformCssMedia怎么用?PHP OutputPage::transformCssMedia使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OutputPage
的用法示例。
在下文中一共展示了OutputPage::transformCssMedia方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: assertTransformCssMediaCase
/**
* Tests a particular case of transformCssMedia, using the given input, globals,
* expected return, and message
*
* Asserts that $expectedReturn is returned.
*
* options['printableQuery'] - value of query string for printable, or omitted for none
* options['handheldQuery'] - value of query string for handheld, or omitted for none
* options['handheldForIPhone'] - value of the $wgHandheldForIPhone global
* options['media'] - passed into the method under the same name
* options['expectedReturn'] - expected return value
* options['message'] - PHPUnit message for assertion
*
* @param array $args key-value array of arguments as shown above
*/
protected function assertTransformCssMediaCase($args)
{
$queryData = array();
if (isset($args['printableQuery'])) {
$queryData['printable'] = $args['printableQuery'];
}
if (isset($args['handheldQuery'])) {
$queryData['handheld'] = $args['handheldQuery'];
}
$fauxRequest = new FauxRequest($queryData, false);
$this->setMWGlobals(array('wgRequest' => $fauxRequest, 'wgHandheldForIPhone' => $args['handheldForIPhone']));
$actualReturn = OutputPage::transformCssMedia($args['media']);
$this->assertSame($args['expectedReturn'], $actualReturn, $args['message']);
}
示例2: makeCombinedStyles
/**
* Combines an associative array mapping media type to CSS into a
* single stylesheet with "@media" blocks.
*
* @param array $stylePairs Array keyed by media type containing (arrays of) CSS strings
* @return array
*/
public static function makeCombinedStyles(array $stylePairs)
{
$out = array();
foreach ($stylePairs as $media => $styles) {
// ResourceLoaderFileModule::getStyle can return the styles
// as a string or an array of strings. This is to allow separation in
// the front-end.
$styles = (array) $styles;
foreach ($styles as $style) {
$style = trim($style);
// Don't output an empty "@media print { }" block (bug 40498)
if ($style !== '') {
// Transform the media type based on request params and config
// The way that this relies on $wgRequest to propagate request params is slightly evil
$media = OutputPage::transformCssMedia($media);
if ($media === '' || $media == 'all') {
$out[] = $style;
} elseif (is_string($media)) {
$out[] = "@media {$media} {\n" . str_replace("\n", "\n\t", "\t" . $style) . "}";
}
// else: skip
}
}
}
return $out;
}
示例3: makeCombinedStyles
/**
* Combines an associative array mapping media type to CSS into a
* single stylesheet with @media blocks.
*
* @param $styles Array: List of CSS strings keyed by media type
*
* @return string
*/
public static function makeCombinedStyles(array $styles)
{
$out = '';
foreach ($styles as $media => $style) {
// Transform the media type based on request params and config
// The way that this relies on $wgRequest to propagate request params is slightly evil
$media = OutputPage::transformCssMedia($media);
if ($media === null) {
// Skip
} elseif ($media === '' || $media == 'all') {
// Don't output invalid or frivolous @media statements
$out .= "{$style}\n";
} else {
$out .= "@media {$media} {\n" . str_replace("\n", "\n\t", "\t" . $style) . "\n}\n";
}
}
return $out;
}