*
* This class is used to prepare the final rendering. A skin is then
* applied to the output parameters (links, javascript, html, categories ...).
- *
+ *
* Another class (fixme) handles sending the whole page to the client.
- *
+ *
* Some comments comes from a pairing session between Zak Greant and Ashar Voultoiz
* in November 2010.
*
/**
* Return whether user JavaScript is allowed for this page
* @deprecated since 1.18 Load modules with ResourceLoader, and origin and
- * trustworthiness is identified and enforced automagically.
+ * trustworthiness is identified and enforced automagically.
* @return Boolean
*/
public function isUserJsAllowed() {
}
/**
- * Set a flag which will cause an X-Frame-Options header appropriate for
- * edit pages to be sent. The header value is controlled by
+ * Set a flag which will cause an X-Frame-Options header appropriate for
+ * edit pages to be sent. The header value is controlled by
* $wgEditPageFrameOptions.
*
- * This is the default for special pages. If you display a CSRF-protected
+ * This is the default for special pages. If you display a CSRF-protected
* form on an ordinary view page, then you need to call this function.
*/
public function preventClickjacking( $enable = true ) {
}
/**
- * Get the X-Frame-Options header value (without the name part), or false
- * if there isn't one. This is used by Skin to determine whether to enable
+ * Get the X-Frame-Options header value (without the name part), or false
+ * if there isn't one. This is used by Skin to determine whether to enable
* JavaScript frame-breaking, for clients that don't support X-Frame-Options.
*/
public function getFrameOptions() {
* the object, let's actually output it:
*/
public function output() {
- global $wgOutputEncoding;
global $wgLanguageCode, $wgDebugRedirects, $wgMimeType;
if( $this->mDoNothing ) {
# Buffer output; final headers may depend on later processing
ob_start();
- $response->header( "Content-type: $wgMimeType; charset={$wgOutputEncoding}" );
+ $response->header( "Content-type: $wgMimeType; charset=UTF-8" );
$response->header( 'Content-language: ' . $wgLanguageCode );
// Prevent framing, if requested
}
/**
- * Actually output something with print(). Performs an iconv to the
- * output encoding, if needed.
+ * Actually output something with print().
*
* @param $ins String: the string to output
*/
public function out( $ins ) {
- global $wgInputEncoding, $wgOutputEncoding, $wgContLang;
- if ( 0 == strcmp( $wgInputEncoding, $wgOutputEncoding ) ) {
- $outs = $ins;
- } else {
- $outs = $wgContLang->iconv( $wgInputEncoding, $wgOutputEncoding, $ins );
- if ( false === $outs ) {
- $outs = $ins;
- }
- }
- print $outs;
+ print $ins;
}
/**
* for when rate limiting has triggered.
*/
public function rateLimited() {
- $this->setPageTitle( wfMsg( 'actionthrottled' ) );
- $this->setRobotPolicy( 'noindex,follow' );
- $this->setArticleRelated( false );
- $this->enableClientCache( false );
- $this->mRedirect = '';
- $this->clearHTML();
- $this->setStatusCode( 503 );
- $this->addWikiMsg( 'actionthrottledtext' );
-
- $this->returnToMain( null, $this->getTitle() );
+ throw new ThrottledError;
}
/**
if( $this->getUser()->getBoolOption( 'editsectiononrightclick' ) ) {
$this->addModules( 'mediawiki.action.view.rightClickEdit' );
}
+ $this->addModules( 'mediawiki.action.view.tablesorting' );
}
/**
$this->mResourceLoader = new ResourceLoader();
}
return $this->mResourceLoader;
- }
+ }
/**
* TODO: Document
$wgResourceLoaderInlinePrivateModules;
// Lazy-load ResourceLoader
// TODO: Should this be a static function of ResourceLoader instead?
- // TODO: Divide off modules starting with "user", and add the user parameter to them
$baseQuery = array(
'lang' => $this->getContext()->getLang()->getCode(),
'debug' => ResourceLoader::inDebugMode() ? 'true' : 'false',
if ( ( $group === 'user' || $group === 'private' ) && $this->getUser()->isLoggedIn() ) {
$query['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
$context = new ResourceLoaderContext( $resourceLoader, new FauxRequest( $query ) );
if ( $modules === array() ) {
continue;
}
-
- $query['modules'] = implode( '|', array_keys( $modules ) );
-
+
+ $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 ) {
function getHeadScripts( Skin $sk ) {
// Startup - this will immediately load jquery and mediawiki modules
$scripts = $this->makeResourceLoaderLink( $sk, 'startup', ResourceLoaderModule::TYPE_SCRIPTS, true );
-
+
// Load config before anything else
$scripts .= Html::inlineScript(
ResourceLoader::makeLoaderConditionalScript(
ResourceLoader::makeConfigSetScript( $this->getJSVars() )
)
);
-
+
// Script and Messages "only" requests marked for top inclusion
// Messages should go first
$scripts .= $this->makeResourceLoaderLink( $sk, $this->getModuleMessages( true, 'top' ), ResourceLoaderModule::TYPE_MESSAGES );
return $scripts;
}
-
+
/**
* JS stuff to put at the bottom of the <body>: modules marked with position 'bottom',
* legacy scripts ($this->mScripts), user preferences, site JS and user JS
*/
function getBottomScripts( Skin $sk ) {
global $wgUseSiteJs, $wgAllowUserJs;
-
+
// Script and Messages "only" requests marked for bottom inclusion
// Messages should go first
$scripts = $this->makeResourceLoaderLink( $sk, $this->getModuleMessages( true, 'bottom' ), ResourceLoaderModule::TYPE_MESSAGES );
if ( $modules ) {
$scripts .= Html::inlineScript(
ResourceLoader::makeLoaderConditionalScript(
- Xml::encodeJsCall( 'mw.loader.load', array( $modules ) ) .
- // the go() call is unnecessary if we inserted top modules, but we don't know for sure that we did
- Xml::encodeJsCall( 'mw.loader.go', array() )
+ Xml::encodeJsCall( 'mw.loader.load', array( $modules ) )
)
);
}
-
+
// Legacy Scripts
$scripts .= "\n" . $this->mScripts;
}
}
$scripts .= $this->makeResourceLoaderLink( $sk, $userScripts, ResourceLoaderModule::TYPE_SCRIPTS );
-
+
return $scripts;
}
/**
* Get an array containing global JS variables
- *
+ *
* Do not add things here which can be evaluated in
* ResourceLoaderStartupScript - in other words, without state.
* You will only be adding bloat to the page and causing page caches to
'wgUserGroups' => $this->getUser()->getEffectiveGroups(),
'wgCategories' => $this->getCategories(),
'wgBreakFrames' => $this->getFrameOptions() == 'DENY',
+ 'wgIsMainPage' => $title->isMainPage(),
);
if ( $wgContLang->hasVariants() ) {
$vars['wgUserVariant'] = $wgContLang->getPreferredVariant();
if ( $wgUseAjax && $wgEnableMWSuggest && !$this->getUser()->getOption( 'disablesuggest', false ) ) {
$vars['wgSearchNamespaces'] = SearchEngine::userNamespaces( $this->getUser() );
}
-
+
// Allow extensions to add their custom variables to the global JS variables
wfRunHooks( 'MakeGlobalVariablesScript', array( &$vars ) );
-
+
return $vars;
}
*/
public function getHeadLinks( Skin $sk, $addContentType = false ) {
global $wgUniversalEditButton, $wgFavicon, $wgAppleTouchIcon, $wgEnableAPI,
- $wgSitename, $wgVersion, $wgHtml5, $wgMimeType, $wgOutputEncoding,
+ $wgSitename, $wgVersion, $wgHtml5, $wgMimeType,
$wgFeed, $wgOverrideSiteFeed, $wgAdvertisedFeedTypes,
$wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf,
$wgDisableLangConversion, $wgCanonicalLanguageLinks, $wgContLang,
if ( $wgHtml5 ) {
# More succinct than <meta http-equiv=Content-Type>, has the
# same effect
- $tags[] = Html::element( 'meta', array( 'charset' => $wgOutputEncoding ) );
+ $tags[] = Html::element( 'meta', array( 'charset' => 'UTF-8' ) );
} else {
$tags[] = Html::element( 'meta', array(
'http-equiv' => 'Content-Type',
- 'content' => "$wgMimeType; charset=$wgOutputEncoding"
+ 'content' => "$wgMimeType; charset=UTF-8"
) );
$tags[] = Html::element( 'meta', array( // bug 15835
'http-equiv' => 'Content-Style-Type',
// 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' => '' ) ) . "\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