- /**
- * To make it harder for someone to slip a user a fake
- * user-JavaScript or user-CSS preview, a random token
- * is associated with the login session. If it's not
- * passed back with the preview request, we won't render
- * the code.
- *
- * @param $action String: 'edit', 'submit' etc.
- * @return bool
- */
- public function userCanPreview( $action ) {
- if ( $action != 'submit' ) {
- return false;
- }
- if ( !$this->getContext()->getRequest()->wasPosted() ) {
- return false;
- }
- if ( !$this->getTitle()->userCanEditCssSubpage() ) {
- return false;
- }
- if ( !$this->getTitle()->userCanEditJsSubpage() ) {
- return false;
- }
-
- return $this->getContext()->getUser()->matchEditToken(
- $this->getContext()->getRequest()->getVal( 'wpEditToken' ) );
- }
-
- /**
- * Generated JavaScript action=raw&gen=js
- * This used to load MediaWiki:Common.js and the skin-specific style
- * before the ResourceLoader.
- *
- * @deprecated since 1.18 Use the ResourceLoader instead. This may be removed at some
- * point.
- * @param $skinName String: If set, overrides the skin name
- * @return String
- */
- public function generateUserJs( $skinName = null ) {
- return '';
- }
-
- /**
- * Generate user stylesheet for action=raw&gen=css
- *
- * @deprecated since 1.18 Use the ResourceLoader instead. This may be removed at some
- * point.
- * @return String
- */
- public function generateUserStylesheet() {
- return '';
- }
-
- /**
- * @private
- * @todo document
- * @param $out OutputPage
- */
- function setupUserCss( OutputPage $out ) {
- global $wgUseSiteCss, $wgAllowUserCss, $wgAllowUserCssPrefs;
-
- wfProfileIn( __METHOD__ );
-
- $this->setupSkinUserCss( $out );
- // Add any extension CSS
- foreach ( $out->getExtStyle() as $url ) {
- $out->addStyle( $url );
- }
-
- // Per-site custom styles
- if ( $wgUseSiteCss ) {
- $out->addModuleStyles( array( 'site', 'noscript' ) );
- if( $this->getContext()->getUser()->isLoggedIn() ){
- $out->addModuleStyles( 'user.groups' );
- }
- }
-
- // Per-user custom styles
- if ( $wgAllowUserCss ) {
- if ( $this->getTitle()->isCssSubpage() && $this->userCanPreview( $this->getContext()->getRequest()->getVal( 'action' ) ) ) {
- // @todo FIXME: Properly escape the cdata!
- $out->addInlineStyle( $this->getContext()->getRequest()->getText( 'wpTextbox1' ) );
- } else {
- $out->addModuleStyles( 'user' );
- }
- }
-
- // Per-user preference styles
- if ( $wgAllowUserCssPrefs ) {
- $out->addModuleStyles( 'user.options' );
- }
-
- wfProfileOut( __METHOD__ );
- }
-