* Display the anon talk page info message on anon talk pages again (moved outside...
[lhc/web/wiklou.git] / includes / Article.php
index 2d5dabc..4ede20f 100644 (file)
@@ -175,32 +175,23 @@ class Article {
                        return "<div class='noarticletext'>$ret</div>";
                } else {
                        $this->loadContent();
-                       # check if we're displaying a [[User talk:x.x.x.x]] anonymous talk page
-                       if ( $this->mTitle->getNamespace() == NS_USER_TALK &&
-                         $wgUser->isIP($this->mTitle->getText()) &&
-                         $action=='view'
-                       ) {
-                               wfProfileOut( $fname );
-                               return $this->mContent . "\n" .wfMsg('anontalkpagetext');
-                       } else {
-                               if($action=='edit') {
-                                       if($section!='') {
-                                               if($section=='new') {
-                                                       wfProfileOut( $fname );
-                                                       $text=$this->getPreloadedText($preload);
-                                                       return $text;
-                                               }
-
-                                               # strip NOWIKI etc. to avoid confusion (true-parameter causes HTML
-                                               # comments to be stripped as well)
-                                               $rv=$this->getSection($this->mContent,$section);
+                       if($action=='edit') {
+                               if($section!='') {
+                                       if($section=='new') {
                                                wfProfileOut( $fname );
-                                               return $rv;
+                                               $text=$this->getPreloadedText($preload);
+                                               return $text;
                                        }
+
+                                       # strip NOWIKI etc. to avoid confusion (true-parameter causes HTML
+                                       # comments to be stripped as well)
+                                       $rv=$this->getSection($this->mContent,$section);
+                                       wfProfileOut( $fname );
+                                       return $rv;
                                }
-                               wfProfileOut( $fname );
-                               return $this->mContent;
                        }
+                       wfProfileOut( $fname );
+                       return $this->mContent;
                }
        }
 
@@ -923,6 +914,12 @@ class Article {
                if( empty( $t ) ) {
                        $wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
                }
+               
+               # check if we're displaying a [[User talk:x.x.x.x]] anonymous talk page
+               if( $this->mTitle->getNamespace() == NS_USER_TALK &&
+                       User::isIP( $this->mTitle->getText() ) ) {
+                       $wgOut->addWikiText( wfMsg('anontalkpagetext') );
+               }
 
                # If we have been passed an &rcid= parameter, we want to give the user a
                # chance to mark this new article as patrolled.
@@ -1690,7 +1687,7 @@ class Article {
         * @return bool true on success
         */
        function updateRestrictions( $limit = array(), $reason = '' ) {
-               global $wgUser, $wgRestrictionTypes;
+               global $wgUser, $wgRestrictionTypes, $wgContLang;
                
                $id = $this->mTitle->getArticleID();
                if( !$wgUser->isAllowed( 'protect' ) || wfReadOnly() || $id == 0 ) {
@@ -1712,12 +1709,24 @@ class Article {
                # If nothing's changed, do nothing
                if( $changed ) {
                        if( wfRunHooks( 'ArticleProtect', array( &$this, &$wgUser, $limit, $reason ) ) ) {
-                               # Update page record
+
                                $dbw =& wfGetDB( DB_MASTER );
+                               
+                               # Prepare a null revision to be added to the history
+                               $comment = $wgContLang->ucfirst( wfMsgForContent( $protect ? 'protectedarticle' : 'unprotectedarticle', $this->mTitle->getPrefixedText() ) );
+                               if( $reason )
+                                       $comment .= ": $reason";
+                               if( $protect )
+                                       $comment .= " [$updated]";
+                               $nullRevision = Revision::newNullRevision( $dbw, $id, $comment, true );
+                               $nullRevId = $nullRevision->insertOn( $dbw );
+                       
+                               # Update page record
                                $dbw->update( 'page',
                                        array( /* SET */
                                                'page_touched' => $dbw->timestamp(),
-                                               'page_restrictions' => $updated
+                                               'page_restrictions' => $updated,
+                                               'page_latest' => $nullRevId
                                        ), array( /* WHERE */
                                                'page_id' => $id
                                        ), 'Article::protect'
@@ -1810,8 +1819,7 @@ class Article {
                
                if( count( $authors ) > 1 && !$confirm ) {
                        $skin=$wgUser->getSkin();
-                       $wgOut->addHTML('<b>'.wfMsg('historywarning'));
-                       $wgOut->addHTML( $skin->historyLink() .'</b>');
+                       $wgOut->addHTML( '<strong>' . wfMsg( 'historywarning' ) . ' ' . $skin->historyLink() . '</strong>' );
                }
 
                # If a single user is responsible for all revisions, find out who they are
@@ -2506,7 +2514,7 @@ class Article {
                        $old_user_abort = ignore_user_abort( true );
 
                        $dbw->query("LOCK TABLES $hitcounterTable WRITE");
-                       $dbw->query("CREATE TEMPORARY TABLE $acchitsTable ENGINE=HEAP ".
+                       $dbw->query("CREATE TEMPORARY TABLE $acchitsTable TYPE=HEAP ".
                                "SELECT hc_id,COUNT(*) AS hc_n FROM $hitcounterTable ".
                                'GROUP BY hc_id');
                        $dbw->query("DELETE FROM $hitcounterTable");