var $mInlineMsg = array();
var $mTemplateIds = array();
+ var $mImageTimeKeys = array();
# What level of 'untrustworthiness' is allowed in CSS/JS modules loaded on this page?
# @see ResourceLoaderModule::$origin
}
/**
- * Filter an array of modules to remove insufficiently trustworthy members
+ * Filter an array of modules to remove insufficiently trustworthy members, and modules
+ * which are no longer registered (eg a page is cached before an extension is disabled)
* @param $modules Array
* @return Array
*/
$filteredModules = array();
foreach( $modules as $val ){
$module = $resourceLoader->getModule( $val );
- if( $module->getOrigin() <= $this->getAllowedModules( $type ) ) {
+ if( $module instanceof ResourceLoaderModule
+ && $module->getOrigin() <= $this->getAllowedModules( $type ) )
+ {
$filteredModules[] = $val;
}
}
/**
* Return whether user JavaScript is allowed for this page
- * @deprecated @since 1.18 Load modules with ResourceLoader, and origin and
+ * @deprecated since 1.18 Load modules with ResourceLoader, and origin and
* trustworthiness is identified and enforced automagically.
* @return Boolean
*/
$this->mNoGallery = $parserOutput->getNoGallery();
$this->mHeadItems = array_merge( $this->mHeadItems, $parserOutput->getHeadItems() );
$this->addModules( $parserOutput->getModules() );
- // Versioning...
- foreach ( (array)$parserOutput->mTemplateIds as $ns => $dbks ) {
+
+ // Template versioning...
+ foreach ( (array)$parserOutput->getTemplateIds() as $ns => $dbks ) {
if ( isset( $this->mTemplateIds[$ns] ) ) {
$this->mTemplateIds[$ns] = $dbks + $this->mTemplateIds[$ns];
} else {
$this->mTemplateIds[$ns] = $dbks;
}
}
+ // File versioning...
+ foreach ( (array)$parserOutput->getImageTimeKeys() as $dbk => $data ) {
+ $this->mImageTimeKeys[$dbk] = $data;
+ }
// Hooks registered in the object
global $wgParserOutputHooks;
}
}
- $sk = $wgUser->getSkin();
-
// Add base resources
- $this->addModules( array( 'mediawiki.legacy.wikibits', 'mediawiki.util' ) );
+ $this->addModules( 'mediawiki.util' );
+ global $wgIncludeLegacyJavaScript;
+ if( $wgIncludeLegacyJavaScript ){
+ $this->addModules( 'mediawiki.legacy.wikibits' );
+ }
// Add various resources if required
if ( $wgUseAjax ) {
if ( $this->mArticleBodyOnly ) {
$this->out( $this->mBodytext );
} else {
+ $sk = $wgUser->getSkin( $this->getTitle() );
+
// Hook that allows last minute changes to the output page, e.g.
// adding of CSS or Javascript by extensions.
wfRunHooks( 'BeforePageDisplay', array( &$this, &$sk ) );
$this->setRobotPolicy( 'noindex,nofollow' );
$this->setArticleRelated( false );
- $name = User::whoIs( $wgUser->blockedBy() );
+ $name = $wgUser->blockedBy();
$reason = $wgUser->blockedFor();
if( $reason == '' ) {
$reason = wfMsg( 'blockednoreason' );
$link = '[[' . $wgContLang->getNsText( NS_USER ) . ":{$name}|{$name}]]";
- $blockid = $wgUser->mBlock->mId;
+ $blockid = $wgUser->mBlock->getId();
- $blockExpiry = $wgUser->mBlock->mExpiry;
- if ( $blockExpiry == 'infinity' ) {
- // Entry in database (table ipblocks) is 'infinity' but 'ipboptions' uses 'infinite' or 'indefinite'
- // Search for localization in 'ipboptions'
- $scBlockExpiryOptions = wfMsg( 'ipboptions' );
- foreach ( explode( ',', $scBlockExpiryOptions ) as $option ) {
- if ( strpos( $option, ':' ) === false ) {
- continue;
- }
- list( $show, $value ) = explode( ':', $option );
- if ( $value == 'infinite' || $value == 'indefinite' ) {
- $blockExpiry = $show;
- break;
- }
- }
- } else {
- $blockExpiry = $wgLang->timeanddate(
- wfTimestamp( TS_MW, $blockExpiry ),
- true
- );
- }
+ $blockExpiry = $wgLang->formatExpiry( $wgUser->mBlock->mExpiry );
if ( $wgUser->mBlock->mAuto ) {
$msg = 'autoblockedtext';
/* $ip returns who *is* being blocked, $intended contains who was meant to be blocked.
* This could be a username, an IP range, or a single IP. */
- $intended = $wgUser->mBlock->mAddress;
+ $intended = $wgUser->mBlock->getTarget();
$this->addWikiMsg(
$msg, $link, $reason, $ip, $name, $blockid, $blockExpiry,
}
continue;
}
- // Special handling for user and site groups; because users might change their stuff
- // on-wiki like site or user pages, or user preferences; we need to find the highest
+ // Special handling for the user group; because users might change their stuff
+ // on-wiki like user pages, or user preferences; we need to find the highest
// timestamp of these user-changable modules so we can ensure cache misses on change
- if ( $group === 'user' || $group === 'site' ) {
+ // 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
+ if ( $group === 'user' ) {
// Get the maximum timestamp
$timestamp = 1;
foreach ( $modules as $module ) {
if ( $useESI && $wgResourceLoaderUseESI ) {
$esi = Xml::element( 'esi:include', array( 'src' => $url ) );
if ( $only == ResourceLoaderModule::TYPE_STYLES ) {
- $links .= Html::inlineStyle( $esi );
+ $link = Html::inlineStyle( $esi );
} else {
- $links .= Html::inlineScript( $esi );
+ $link = Html::inlineScript( $esi );
}
} else {
// Automatically select style/script elements
if ( $only === ResourceLoaderModule::TYPE_STYLES ) {
- $links .= Html::linkedStyle( wfAppendQuery( $wgLoadScript, $query ) ) . "\n";
+ $link = Html::linkedStyle( wfAppendQuery( $wgLoadScript, $query ) );
} else {
- $links .= Html::linkedScript( wfAppendQuery( $wgLoadScript, $query ) ) . "\n";
+ $link = Html::linkedScript( wfAppendQuery( $wgLoadScript, $query ) );
}
}
+
+ if( $group == 'noscript' ){
+ $links .= Html::rawElement( 'noscript', array(), $link ) . "\n";
+ } else {
+ $links .= $link . "\n";
+ }
}
return $links;
}
$ret = '';
// Add ResourceLoader styles
// Split the styles into four groups
- $styles = array( 'other' => array(), 'user' => array(), 'site' => array(), 'private' => array() );
+ $styles = array( 'other' => array(), 'user' => array(), 'site' => array(), 'private' => array(), 'noscript' => array() );
$resourceLoader = $this->getResourceLoader();
foreach ( $this->getModuleStyles() as $name ) {
$group = $resourceLoader->getModule( $name )->getGroup();
$ret .= implode( "\n", $this->buildCssLinksArray() ) . $this->mInlineStyles;
// Add marker tag to mark the place where the client-side loader should inject dynamic styles
// We use a <meta> tag with a made-up name for this because that's valid HTML
- $ret .= Html::element( 'meta', array( 'name' => 'ResourceLoaderDynamicStyles', 'content' => '' ) );
+ $ret .= Html::element( 'meta', array( 'name' => 'ResourceLoaderDynamicStyles', 'content' => '' ) ) . "\n";
// Add site, private and user styles
// 'private' at present only contains user.options, so put that before 'user'
// Any future private modules will likely have a similar user-specific character
- foreach ( array( 'site', 'private', 'user' ) as $group ) {
+ foreach ( array( 'site', 'noscript', 'private', 'user' ) as $group ) {
$ret .= $this->makeResourceLoaderLink( $sk, $styles[$group],
ResourceLoaderModule::TYPE_STYLES
);
* @param $modules Array: list of jQuery modules which should be loaded
* @return Array: the list of modules which were not loaded.
* @since 1.16
- * @deprecated @since 1.17
+ * @deprecated since 1.17
*/
public function includeJQuery( $modules = array() ) {
return array();