Kill some trailing whitespace
[lhc/web/wiklou.git] / includes / Article.php
index 3debb17..9e12611 100644 (file)
@@ -718,9 +718,9 @@ class Article {
                }
 
                $outputDone = false;
+               wfRunHooks( 'ArticleViewHeader', array( &$this ) );
                if ( $pcache ) {
                        if ( $wgOut->tryParserCache( $this, $wgUser ) ) {
-                               wfRunHooks( 'ArticleViewHeader', array( &$this ) );
                                $outputDone = true;
                        }
                }
@@ -767,11 +767,6 @@ class Article {
                        }
                }
                if( !$outputDone ) {
-                       /**
-                        * @fixme: this hook doesn't work most of the time, as it doesn't
-                        * trigger when the parser cache is used.
-                        */
-                       wfRunHooks( 'ArticleViewHeader', array( &$this ) ) ;
                        $wgOut->setRevisionId( $this->getRevIdFetched() );
                        # wrap user css and user js in pre and don't parse
                        # XXX: use $this->mTitle->usCssJsSubpage() when php is fixed/ a workaround is found
@@ -1652,7 +1647,7 @@ class Article {
         * @return bool true on success
         */
        function updateRestrictions( $limit = array(), $reason = '', $cascade = 0, $expiry = null ) {
-               global $wgUser, $wgRestrictionTypes, $wgContLang, $wgGroupPermissions;
+               global $wgUser, $wgRestrictionTypes, $wgContLang;
 
                $id = $this->mTitle->getArticleID();
                if( !$wgUser->isAllowed( 'protect' ) || wfReadOnly() || $id == 0 ) {
@@ -1707,11 +1702,6 @@ class Article {
                                $nullRevision = Revision::newNullRevision( $dbw, $id, $comment, true );
                                $nullRevId = $nullRevision->insertOn( $dbw );
 
-                               foreach( $limit as $action => $restrictions ) {
-                                       # Check if the group level required to edit also can protect pages
-                                       # Otherwise, people who cannot normally protect can "protect" pages via transclusion
-                                       $cascade = ( $cascade && isset($wgGroupPermissions[$restrictions]['protect']) && $wgGroupPermissions[$restrictions]['protect'] );       
-                               }
                                # Update restrictions table
                                foreach( $limit as $action => $restrictions ) {
                                        if ($restrictions != '' ) {
@@ -1787,8 +1777,6 @@ class Article {
                $confirm = $wgRequest->wasPosted() &&
                        $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) );
                $reason = $wgRequest->getText( 'wpReason' );
-               # Flag to hide all contents of the archived revisions
-               $suppress = $wgRequest->getVal( 'wpSuppress' ) && $wgUser->isAllowed('deleterevision');
 
                # This code desperately needs to be totally rewritten
 
@@ -1820,7 +1808,7 @@ class Article {
                }
 
                if( $confirm ) {
-                       $this->doDelete( $reason, $suppress );
+                       $this->doDelete( $reason );
                        if( $wgRequest->getCheck( 'wpWatch' ) ) {
                                $this->doWatch();
                        } elseif( $this->mTitle->userIsWatching() ) {
@@ -1966,14 +1954,7 @@ class Article {
                $delcom = htmlspecialchars( wfMsg( 'deletecomment' ) );
                $token = htmlspecialchars( $wgUser->editToken() );
                $watch = Xml::checkLabel( wfMsg( 'watchthis' ), 'wpWatch', 'wpWatch', $wgUser->getBoolOption( 'watchdeletion' ) || $this->mTitle->userIsWatching(), array( 'tabindex' => '2' ) );
-               if ( $wgUser->isAllowed( 'deleterevision' ) ) {
-                       $supress = "<tr><td>&nbsp;</td><td>";
-                       $supress .= Xml::checkLabel( wfMsg( 'revdelete-suppress' ), 'wpSuppress', 'wpSuppress', false, array( 'tabindex' => '2' ) );
-                       $supress .= "</td></tr>";
-               } else {
-                       $supress = '';
-               }
-               
+
                $wgOut->addHTML( "
 <form id='deleteconfirm' method='post' action=\"{$formaction}\">
        <table border='0'>
@@ -1985,7 +1966,6 @@ class Article {
                                <input type='text' size='60' name='wpReason' id='wpReason' value=\"" . htmlspecialchars( $reason ) . "\" tabindex=\"1\" />
                        </td>
                </tr>
-               $supress
                <tr>
                        <td>&nbsp;</td>
                        <td>$watch</td>
@@ -2024,12 +2004,12 @@ class Article {
        /**
         * Perform a deletion and output success or failure messages
         */
-       function doDelete( $reason, $suppress = false ) {
+       function doDelete( $reason ) {
                global $wgOut, $wgUser;
                wfDebug( __METHOD__."\n" );
 
                if (wfRunHooks('ArticleDelete', array(&$this, &$wgUser, &$reason))) {
-                       if ( $this->doDeleteArticle( $reason, $suppress ) ) {
+                       if ( $this->doDeleteArticle( $reason ) ) {
                                $deleted = wfEscapeWikiText( $this->mTitle->getPrefixedText() );
 
                                $wgOut->setPagetitle( wfMsg( 'actioncomplete' ) );
@@ -2052,7 +2032,7 @@ class Article {
         * Deletes the article with database consistency, writes logs, purges caches
         * Returns success
         */
-       function doDeleteArticle( $reason, $suppress = false ) {
+       function doDeleteArticle( $reason ) {
                global $wgUseSquid, $wgDeferredUpdateList;
                global $wgUseTrackbacks;
 
@@ -2070,17 +2050,6 @@ class Article {
                $u = new SiteStatsUpdate( 0, 1, -(int)$this->isCountable( $this->getContent() ), -1 );
                array_push( $wgDeferredUpdateList, $u );
 
-               // Bitfields to further supress the content
-               if ( $suppress ) {
-                       $bitfield = 0;
-                       $bitfield |= Revision::DELETED_TEXT;
-                       $bitfield |= Revision::DELETED_COMMENT;
-                       $bitfield |= Revision::DELETED_USER;
-                       $bitfield |= Revision::DELETED_RESTRICTED;
-               } else {
-                       $bitfield = 'rev_deleted';
-               }
-               
                // For now, shunt the revision data into the archive table.
                // Text is *not* removed from the text table; bulk storage
                // is left intact to avoid breaking block-compression or
@@ -2104,7 +2073,7 @@ class Article {
                                'ar_text_id'    => 'rev_text_id',
                                'ar_text'       => '\'\'', // Be explicit to appease
                                'ar_flags'      => '\'\'', // MySQL's "strict mode"...
-                               'ar_deleted'    => $bitfield
+                               'ar_len'                => 'rev_len'
                        ), array(
                                'page_id' => $id,
                                'page_id = rev_page'
@@ -2145,9 +2114,8 @@ class Article {
                # Clear caches
                Article::onArticleDelete( $this->mTitle );
 
-               # Log the deletion, if the page was suppressed, log it at Oversight instead
-               $logtype = ($suppress) ? 'oversight' : 'delete';
-               $log = new LogPage( $logtype );
+               # Log the deletion
+               $log = new LogPage( 'delete' );
                $log->addEntry( 'delete', $this->mTitle, $reason );
 
                # Clear the cached article id so the interface doesn't act like we exist
@@ -2208,7 +2176,7 @@ class Article {
                        if( $current->getComment() != '') {
                                $wgOut->addHTML(
                                        wfMsg( 'editcomment',
-                                       htmlspecialchars( $current->getComment() ) ) );
+                                       $wgUser->getSkin()->formatComment( $current->getComment() ) ) );
                        }
                        return;
                }
@@ -2253,13 +2221,8 @@ class Article {
                        );
                }
 
-               $target = Revision::newFromId( $s->rev_id );
-               # Revision *must* be public and we don't well handle deleted edits on top
-               if ( $target->isDeleted(REVISION::DELETED_TEXT) ) {
-                       $wgOut->setPageTitle( wfMsg('rollbackfailed') );
-                       $wgOut->addHTML( wfMsg( 'missingarticle' ) );
-               }
                # Get the edit summary
+               $target = Revision::newFromId( $s->rev_id );
                $newComment = wfMsgForContent( 'revertpage', $target->getUserText(), $from );
                $newComment = $wgRequest->getText( 'summary', $newComment );
 
@@ -2385,7 +2348,7 @@ class Article {
         *
         * @param Revision $rev
         *
-        * @fixme This is a shitty interface function. Kill it and replace the
+        * @todo This is a shitty interface function. Kill it and replace the
         * other shitty functions like editUpdates and such so it's not needed
         * anymore.
         */
@@ -2437,30 +2400,10 @@ class Article {
                        ? wfMsg( 'diff' )
                        : $sk->makeKnownLinkObj( $this->mTitle, wfMsg( 'diff' ), 'diff=next&oldid='.$oldid );
 
-               $cdel='';
-               if( $wgUser->isAllowed( 'deleterevision' ) ) {          
-                       $revdel = SpecialPage::getTitleFor( 'Revisiondelete' );
-                       if( $revision->isCurrent() ) {
-                       // We don't handle top deleted edits too well
-                               $cdel = wfMsgHtml('rev-delundel');      
-                       } else if( !$revision->userCan( Revision::DELETED_RESTRICTED ) ) {
-                       // If revision was hidden from sysops
-                               $cdel = wfMsgHtml('rev-delundel');      
-                       } else {
-                               $cdel = $sk->makeKnownLinkObj( $revdel,
-                                       wfMsgHtml('rev-delundel'),
-                                       'target=' . urlencode( $this->mTitle->getPrefixedDbkey() ) .
-                                       '&oldid=' . urlencode( $oldid ) );
-                               // Bolden oversighted content
-                               if( $revision->isDeleted( Revision::DELETED_RESTRICTED ) )
-                                       $cdel = "<strong>$cdel</strong>";
-                       }
-                       $cdel = "(<small>$cdel</small>)";
-               }
-
-               $userlinks = $sk->revUserTools( $revision, true );
+               $userlinks = $sk->userLink( $revision->getUser(), $revision->getUserText() )
+                                               . $sk->userToolLinks( $revision->getUser(), $revision->getUserText() );
 
-               $r = "\n\t\t\t\t<div id=\"mw-revision-info\">" . "<tt>$cdel</tt>" . wfMsg( 'revision-info', $td, $userlinks ) . "</div>\n" .
+               $r = "\n\t\t\t\t<div id=\"mw-revision-info\">" . wfMsg( 'revision-info', $td, $userlinks ) . "</div>\n" .
                     "\n\t\t\t\t<div id=\"mw-revision-nav\">" . wfMsg( 'revision-nav', $prevdiff, $prevlink, $lnk, $curdiff, $nextlink, $nextdiff ) . "</div>\n\t\t\t";
                $wgOut->setSubtitle( $r );
        }