New infrastructure for actions, as discussed on wikitech-l. Fairly huge commit.
[lhc/web/wiklou.git] / includes / OutputPage.php
index 67e31b4..34eac1e 100644 (file)
@@ -1933,53 +1933,10 @@ class OutputPage {
 
        /**
         * Produce a "user is blocked" page.
-        *
-        * @param $return Boolean: whether to have a "return to $wgTitle" message or not.
-        * @return nothing
+        * @deprecated since 1.18
         */
-       function blockedPage( $return = true ) {
-               global $wgContLang;
-
-               $this->setPageTitle( wfMsg( 'blockedtitle' ) );
-               $this->setRobotPolicy( 'noindex,nofollow' );
-               $this->setArticleRelated( false );
-
-               $name = $this->getUser()->blockedBy();
-               $reason = $this->getUser()->blockedFor();
-               if( $reason == '' ) {
-                       $reason = wfMsg( 'blockednoreason' );
-               }
-               $blockTimestamp = $this->getContext()->getLang()->timeanddate(
-                       wfTimestamp( TS_MW, $this->getUser()->mBlock->mTimestamp ), true
-               );
-               $ip = wfGetIP();
-
-               $link = '[[' . $wgContLang->getNsText( NS_USER ) . ":{$name}|{$name}]]";
-
-               $blockid = $this->getUser()->mBlock->getId();
-
-               $blockExpiry = $this->getContext()->getLang()->formatExpiry( $this->getUser()->mBlock->mExpiry );
-
-               if ( $this->getUser()->mBlock->mAuto ) {
-                       $msg = 'autoblockedtext';
-               } else {
-                       $msg = 'blockedtext';
-               }
-
-               /* $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 = $this->getUser()->mBlock->getTarget();
-
-               $this->addWikiMsg(
-                       $msg, $link, $reason, $ip, $name, $blockid, $blockExpiry,
-                       $intended, $blockTimestamp
-               );
-
-               # Don't auto-return to special pages
-               if( $return ) {
-                       $return = $this->getTitle()->getNamespace() > -1 ? $this->getTitle() : null;
-                       $this->returnToMain( null, $return );
-               }
+       function blockedPage() {
+               throw new UserBlockedError( $this->getUser()->mBlock );
        }
 
        /**
@@ -2044,28 +2001,11 @@ class OutputPage {
 
        /**
         * Display an error page noting that a given permission bit is required.
-        *
+        * @deprecated since 1.18, just throw the exception directly
         * @param $permission String: key required
         */
        public function permissionRequired( $permission ) {
-               $this->setPageTitle( wfMsg( 'badaccess' ) );
-               $this->setHTMLTitle( wfMsg( 'errorpagetitle' ) );
-               $this->setRobotPolicy( 'noindex,nofollow' );
-               $this->setArticleRelated( false );
-               $this->mBodytext = '';
-
-               $groups = array_map( array( 'User', 'makeGroupLinkWiki' ),
-                       User::getGroupsWithPermission( $permission ) );
-               if( $groups ) {
-                       $this->addWikiMsg(
-                               'badaccess-groups',
-                               $this->getContext()->getLang()->commaList( $groups ),
-                               count( $groups )
-                       );
-               } else {
-                       $this->addWikiMsg( 'badaccess-group0' );
-               }
-               $this->returnToMain();
+               throw new PermissionsError( $permission );
        }
 
        /**
@@ -2073,8 +2013,7 @@ class OutputPage {
         */
        public function loginToUse() {
                if( $this->getUser()->isLoggedIn() ) {
-                       $this->permissionRequired( 'read' );
-                       return;
+                       throw new PermissionsError( 'read' );
                }
 
                $this->setPageTitle( wfMsg( 'loginreqtitle' ) );
@@ -2181,9 +2120,7 @@ class OutputPage {
                        $this->addWikiText( $this->formatPermissionsErrorMessage( $reasons, $action ) );
                } else {
                        // Wiki is read only
-                       $this->setPageTitle( wfMsg( 'readonly' ) );
-                       $reason = wfReadOnlyReason();
-                       $this->wrapWikiMsg( "<div class='mw-readonly-error'>\n$1\n</div>", array( 'readonlytext', $reason ) );
+                       throw new ReadOnlyError;
                }
 
                // Show source, if supplied
@@ -2358,8 +2295,7 @@ class OutputPage {
         * @return String: The doctype, opening <html>, and head element.
         */
        public function headElement( Skin $sk, $includeStyle = true ) {
-               global $wgOutputEncoding, $wgMimeType;
-               global $wgUseTrackbacks, $wgHtml5;
+               global $wgUseTrackbacks;
 
                if ( $sk->commonPrintStylesheet() ) {
                        $this->addModuleStyles( 'mediawiki.legacy.wikiprintable' );