* Instead a new RequestContext should be created and it will implicitly create
* a OutputPage tied to that context.
*/
- function __construct( RequestContext $context = null ) {
+ function __construct( IContextSource $context = null ) {
if ( $context === null ) {
# Extensions should use `new RequestContext` instead of `new OutputPage` now.
wfDeprecated( __METHOD__ );
* @return Array (dbKey => array('time' => MW timestamp or null, 'sha1' => sha1 or ''))
* @since 1.18
*/
- public function getImageTimeKeys() {
+ public function getFileSearchOptions() {
return $this->mImageTimeKeys;
}
}
}
// File versioning...
- foreach ( (array)$parserOutput->getImageTimeKeys() as $dbk => $data ) {
+ foreach ( (array)$parserOutput->getFileSearchOptions() as $dbk => $data ) {
$this->mImageTimeKeys[$dbk] = $data;
}
* /w/index.php?title=Main_page&variant=zh-cn should never be served.
*/
function addAcceptLanguage() {
- $lang = $this->getTitle()->getPageLanguage();
- if( !$this->getRequest()->getCheck( 'variant' ) && $lang->hasVariants() ) {
- $variants = $lang->getVariants();
+ global $wgContLang;
+ if( !$this->getRequest()->getCheck( 'variant' ) && $wgContLang->hasVariants() ) {
+ $variants = $wgContLang->getVariants();
$aloption = array();
foreach ( $variants as $variant ) {
- if( $variant === $lang->getCode() ) {
+ if( $variant === $wgContLang->getCode() ) {
continue;
} else {
$aloption[] = 'string-contains=' . $variant;
protected function makeResourceLoaderLink( $modules, $only, $useESI = false, array $extraQuery = array() ) {
global $wgLoadScript, $wgResourceLoaderUseESI,
$wgResourceLoaderInlinePrivateModules;
- $baseQuery = array(
- 'lang' => $this->getContext()->getLang()->getCode(),
- 'debug' => ResourceLoader::inDebugMode() ? 'true' : 'false',
- 'skin' => $this->getSkin()->getSkinName(),
- ) + $extraQuery;
- if ( $only !== ResourceLoaderModule::TYPE_COMBINED ) {
- $baseQuery['only'] = $only;
- }
- // Propagate printable and handheld parameters if present
- if ( $this->isPrintable() ) {
- $baseQuery['printable'] = 1;
- }
- if ( $this->getRequest()->getBool( 'handheld' ) ) {
- $baseQuery['handheld'] = 1;
- }
if ( !count( $modules ) ) {
return '';
$links = '';
foreach ( $groups as $group => $modules ) {
- $query = $baseQuery;
// Special handling for user-specific groups
+ $user = null;
if ( ( $group === 'user' || $group === 'private' ) && $this->getUser()->isLoggedIn() ) {
- $query['user'] = $this->getUser()->getName();
+ $user = $this->getUser()->getName();
}
// Create a fake request based on the one we are about to make so modules return
// correct timestamp and emptiness data
+ $query = ResourceLoader::makeLoaderQuery(
+ array(), // modules; not determined yet
+ $this->getContext()->getLang()->getCode(),
+ $this->getSkin()->getSkinName(),
+ $user,
+ null, // version; not determined yet
+ ResourceLoader::inDebugMode(),
+ $only === ResourceLoaderModule::TYPE_COMBINED ? null : $only,
+ $this->isPrintable(),
+ $this->getRequest()->getBool( 'handheld' ),
+ $extraQuery
+ );
$context = new ResourceLoaderContext( $resourceLoader, new FauxRequest( $query ) );
// Drop modules that know they're empty
foreach ( $modules as $key => $module ) {
continue;
}
- $query['modules'] = ResourceLoader::makePackedModulesString( array_keys( $modules ) );
-
// Support inlining of private modules if configured as such
if ( $group === 'private' && $wgResourceLoaderInlinePrivateModules ) {
if ( $only == ResourceLoaderModule::TYPE_STYLES ) {
// timestamp of these user-changable modules so we can ensure cache misses on change
// This should NOT be done for the site group (bug 27564) because anons get that too
// and we shouldn't be putting timestamps in Squid-cached HTML
+ $version = null;
if ( $group === 'user' ) {
// Get the maximum timestamp
$timestamp = 1;
$timestamp = max( $timestamp, $module->getModifiedTime( $context ) );
}
// Add a version parameter so cache will break when things change
- $query['version'] = wfTimestamp( TS_ISO_8601_BASIC, $timestamp );
+ $version = wfTimestamp( TS_ISO_8601_BASIC, $timestamp );
}
- // Make queries uniform in order
- ksort( $query );
-
- $url = wfAppendQuery( $wgLoadScript, $query );
- // Prevent the IE6 extension check from being triggered (bug 28840)
- // by appending a character that's invalid in Windows extensions ('*')
- $url .= '&*';
+
+ $url = ResourceLoader::makeLoaderURL(
+ array_keys( $modules ),
+ $this->getContext()->getLang()->getCode(),
+ $this->getSkin()->getSkinName(),
+ $user,
+ $version,
+ ResourceLoader::inDebugMode(),
+ $only === ResourceLoaderModule::TYPE_COMBINED ? null : $only,
+ $this->isPrintable(),
+ $this->getRequest()->getBool( 'handheld' ),
+ $extraQuery
+ );
if ( $useESI && $wgResourceLoaderUseESI ) {
$esi = Xml::element( 'esi:include', array( 'src' => $url ) );
if ( $only == ResourceLoaderModule::TYPE_STYLES ) {
* have to be purged on configuration changes.
*/
protected function getJSVars() {
- global $wgUseAjax, $wgEnableMWSuggest;
+ global $wgUseAjax, $wgEnableMWSuggest, $wgContLang;
$title = $this->getTitle();
$ns = $title->getNamespace();
'wgCategories' => $this->getCategories(),
'wgBreakFrames' => $this->getFrameOptions() == 'DENY',
);
- $lang = $this->getTitle()->getPageLanguage();
- if ( $lang->hasVariants() ) {
- $vars['wgUserVariant'] = $lang->getPreferredVariant();
+ if ( $wgContLang->hasVariants() ) {
+ $vars['wgUserVariant'] = $wgContLang->getPreferredVariant();
}
foreach ( $title->getRestrictionTypes() as $type ) {
$vars['wgRestriction' . ucfirst( $type )] = $title->getRestrictions( $type );
global $wgUniversalEditButton, $wgFavicon, $wgAppleTouchIcon, $wgEnableAPI,
$wgSitename, $wgVersion, $wgHtml5, $wgMimeType,
$wgFeed, $wgOverrideSiteFeed, $wgAdvertisedFeedTypes,
- $wgDisableLangConversion, $wgCanonicalLanguageLinks,
+ $wgDisableLangConversion, $wgCanonicalLanguageLinks, $wgContLang,
$wgRightsPage, $wgRightsUrl;
$tags = array();
) );
}
- $lang = $this->getTitle()->getPageLanguage();
-
# Language variants
if ( !$wgDisableLangConversion && $wgCanonicalLanguageLinks
- && $lang->hasVariants() ) {
+ && $wgContLang->hasVariants() ) {
- $urlvar = $lang->getURLVariant();
+ $urlvar = $wgContLang->getURLVariant();
if ( !$urlvar ) {
- $variants = $lang->getVariants();
+ $variants = $wgContLang->getVariants();
foreach ( $variants as $_v ) {
$tags[] = Html::element( 'link', array(
'rel' => 'alternate',