*
* 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() {
$this->mResourceLoader = new ResourceLoader();
}
return $this->mResourceLoader;
- }
+ }
/**
* TODO: Document
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 ) );
-
+
// 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 );
)
);
}
-
+
// 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
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;
}
// 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
$this->title = Title::makeTitle( NS_MAIN, "Main Page" );
if ( !isset( $this->userUser ) || !( $this->userUser instanceOf User ) ) {
$this->userUser = User::newFromName( $this->userName );
-
+
if ( !$this->userUser->getID() ) {
$this->userUser = User::createNew( $this->userName, array(
"email" => "test@example.com",
"real_name" => "Test User" ) );
$this->userUser->load();
}
-
+
$this->altUser = User::newFromName( $this->altUserName );
if ( !$this->altUser->getID() ) {
$this->altUser = User::createNew( $this->altUserName, array(
$prefix = $wgContLang->getFormattedNsText( NS_PROJECT );
$this->setTitle( NS_SPECIAL );
-
+
$this->assertEquals( array( array( 'badaccess-group0' ), array( 'ns-specialprotected' ) ),
$this->title->getUserPermissionsErrors( 'bogus', $this->user ) );
$this->assertEquals( array( array( 'badaccess-group0' ) ),