'Cookie' => null
);
+ /**
+ * If the current page was reached through a redirect, $mRedirectedFrom contains the Title
+ * of the redirect.
+ *
+ * @var Title
+ */
+ private $mRedirectedFrom = null;
+
/**
* Constructor for OutputPage. This should not be called directly.
* Instead a new RequestContext should be created and it will implicitly create
return $this->mHTMLtitle;
}
+ /**
+ * Set $mRedirectedFrom, the Title of the page which redirected us to the current page.
+ *
+ * param @t Title
+ */
+ public function setRedirectedFrom( $t ) {
+ $this->mRedirectedFrom = $t;
+ }
+
/**
* "Page title" means the contents of \<h1\>. It is stored as a valid HTML fragment.
* This function allows good tags like \<sup\> in the \<h1\> tag, but not bad tags like \<script\>.
|| ( isset( $wgGroupPermissions['autoconfirmed'][$action] ) && $wgGroupPermissions['autoconfirmed'][$action] ) )
) {
$displayReturnto = null;
- $returnto = $this->getTitle();
+
+ # Due to bug 32276, if a user does not have read permissions,
+ # $this->getTitle() will just give Special:Badtitle, which is
+ # not especially useful as a returnto parameter. Use the title
+ # from the request instead, if there was one.
+ $request = $this->getRequest();
+ $returnto = Title::newFromURL( $request->getVal( 'title', '' ) );
if ( $action == 'edit' ) {
$msg = 'whitelistedittext';
$displayReturnto = $returnto;
}
$query = array();
+
if ( $returnto ) {
$query['returnto'] = $returnto->getPrefixedText();
- $request = $this->getRequest();
+
if ( !$request->wasPosted() ) {
$returntoquery = $request->getValues();
unset( $returntoquery['title'] );
* @return String: The doctype, opening <html>, and head element.
*/
public function headElement( Skin $sk, $includeStyle = true ) {
- global $wgContLang, $wgUseTrackbacks;
+ global $wgContLang;
$userdir = $this->getLanguage()->getDir();
$sitedir = $wgContLang->getDir();
$this->getHeadItems()
) );
- if ( $wgUseTrackbacks && $this->isArticleRelated() ) {
- $ret .= $this->getTitle()->trackbackRDF();
- }
-
$closeHead = Html::closeElement( 'head' );
if ( $closeHead ) {
$ret .= "$closeHead\n";
foreach ( (array) $modules as $name ) {
$module = $resourceLoader->getModule( $name );
# Check that we're allowed to include this module on this page
- if ( ( $module->getOrigin() > $this->getAllowedModules( ResourceLoaderModule::TYPE_SCRIPTS )
+ if ( !$module
+ || ( $module->getOrigin() > $this->getAllowedModules( ResourceLoaderModule::TYPE_SCRIPTS )
&& $only == ResourceLoaderModule::TYPE_SCRIPTS )
|| ( $module->getOrigin() > $this->getAllowedModules( ResourceLoaderModule::TYPE_STYLES )
&& $only == ResourceLoaderModule::TYPE_STYLES )
* - in other words, page-independent/site-wide variables (without state).
* You will only be adding bloat to the html page and causing page caches to
* have to be purged on configuration changes.
+ * @return array
*/
protected function getJSVars() {
global $wgUseAjax, $wgEnableMWSuggest;
$canonicalName = false; # bug 21115
}
+ $lang = $title->getPageLanguage();
+
+ // Pre-process information
+ $separatorTransTable = $lang->separatorTransformTable();
+ $separatorTransTable = $separatorTransTable ? $separatorTransTable : array();
+ $compactSeparatorTransTable = array(
+ implode( "\t", array_keys( $separatorTransTable ) ),
+ implode( "\t", $separatorTransTable ),
+ );
+ $digitTransTable = $lang->digitTransformTable();
+ $digitTransTable = $digitTransTable ? $digitTransTable : array();
+ $compactDigitTransTable = array(
+ implode( "\t", array_keys( $digitTransTable ) ),
+ implode( "\t", $digitTransTable ),
+ );
+
$vars = array(
'wgCanonicalNamespace' => $nsname,
'wgCanonicalSpecialPageName' => $canonicalName,
'wgUserGroups' => $this->getUser()->getEffectiveGroups(),
'wgCategories' => $this->getCategories(),
'wgBreakFrames' => $this->getFrameOptions() == 'DENY',
+ 'wgPageContentLanguage' => $lang->getCode(),
+ 'wgSeparatorTransformTable' => $compactSeparatorTransTable,
+ 'wgDigitTransformTable' => $compactDigitTransTable,
);
- $lang = $this->getTitle()->getPageLanguage();
if ( $lang->hasVariants() ) {
$vars['wgUserVariant'] = $lang->getPreferredVariant();
}
if ( $title->isMainPage() ) {
$vars['wgIsMainPage'] = true;
}
+ if ( $this->mRedirectedFrom ) {
+ $vars['wgRedirectedFrom'] = $this->mRedirectedFrom->getPrefixedDBKey();
+ }
// Allow extensions to add their custom variables to the mw.config map.
// Use the 'ResourceLoaderGetConfigVars' hook if the variable is not
}
foreach ( $moduleStyles as $name ) {
- $group = $resourceLoader->getModule( $name )->getGroup();
+ $module = $resourceLoader->getModule( $name );
+ if ( !$module ) {
+ continue;
+ }
+ $group = $module->getGroup();
// Modules in groups named "other" or anything different than "user", "site" or "private"
// will be placed in the "other" group
$styles[isset( $styles[$group] ) ? $group : 'other'][] = $name;