New date formatter
[lhc/web/wiklou.git] / includes / Article.php
index 51d27dc..703b3ed 100644 (file)
@@ -150,7 +150,7 @@ class Article {
                                        $rid = $rt->getArticleID();
                                        if ( 0 != $rid ) {
                                                $sql = "SELECT cur_text,cur_timestamp,cur_user," .
-                                                 "cur_counter,cur_touched FROM cur WHERE cur_id={$rid}";
+                                                 "cur_counter,cur_restrictions,cur_touched FROM cur WHERE cur_id={$rid}";
                                                $res = wfQuery( $sql, DB_READ, $fname );
 
                                                if ( 0 != wfNumRows( $res ) ) {
@@ -282,7 +282,6 @@ class Article {
                # diff page instead of the article.
 
                if ( isset( $diff ) ) {
-                       include_once( "$IP/DifferenceEngine.php" );
                        $wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
                        $de = new DifferenceEngine( $oldid, $diff );
                        $de->showDiffPage();
@@ -312,7 +311,7 @@ class Article {
                        $sk = $wgUser->getSkin();
                        $redir = $sk->makeKnownLink( $this->mRedirectedFrom, "",
                          "redirect=no" );
-                       $s = str_replace( "$1", $redir, wfMsg( "redirectedfrom" ) );
+                       $s = wfMsg( "redirectedfrom", $redir );
                        $wgOut->setSubtitle( $s );
                }
                $wgOut->checkLastModified( $this->mTouched );
@@ -472,8 +471,7 @@ class Article {
                $wgOut->setArticleFlag( false );
 
                if ( $isConflict ) {
-                       $s = str_replace( "$1", $this->mTitle->getPrefixedText(),
-                         wfMsg( "editconflict" ) );
+                       $s = wfMsg( "editconflict", $this->mTitle->getPrefixedText() );
                        $wgOut->setPageTitle( $s );
                        $wgOut->addHTML( wfMsg( "explainconflict" ) );
 
@@ -481,8 +479,7 @@ class Article {
                        $wpTextbox1 = $this->getContent(true);
                        $wpEdittime = $this->getTimestamp();
                } else {
-                       $s = str_replace( "$1", $this->mTitle->getPrefixedText(),
-                         wfMsg( "editing" ) );
+                       $s = wfMsg( "editing", $this->mTitle->getPrefixedText() );
 
                        if($section!="") { 
                                if($section=="new") {
@@ -511,7 +508,7 @@ class Article {
                $kblength = (int)(strlen( $wpTextbox1 ) / 1024);
                if( $kblength > 29 ) {
                        $wgOut->addHTML( "<strong>" . 
-                               str_replace( '$1', $kblength , wfMsg( "longpagewarning" ) )
+                               wfMsg( "longpagewarning", $kblength )
                                . "</strong>" );
                }
                
@@ -537,8 +534,8 @@ class Article {
                  wfMsg( "cancel" ) );
                $edithelp = $sk->makeKnownLink( wfMsg( "edithelppage" ),
                  wfMsg( "edithelp" ) );
-               $copywarn = str_replace( "$1", $sk->makeKnownLink(
-                 wfMsg( "copyrightpage" ) ), wfMsg( "copyrightwarning" ) );
+               $copywarn = wfMsg( "copyrightwarning", $sk->makeKnownLink(
+                 wfMsg( "copyrightpage" ) ) );
 
                $wpTextbox1 = wfEscapeHTML( $wpTextbox1 );
                $wpTextbox2 = wfEscapeHTML( $wpTextbox2 );
@@ -686,6 +683,11 @@ $wgLang->recodeForEdit( $wpTextbox1 ) .
                        }
                }
                
+               # The talk page isn't in the regular link tables, so we need to update manually:
+               $talkns = $ns ^ 1; # talk -> normal; normal -> talk
+               $sql = "UPDATE cur set cur_touched='$now' WHERE cur_namespace=$talkns AND cur_title='" . wfStrencode( $ttl ) . "'";
+               wfQuery( $sql, DB_WRITE );
+               
                $this->showArticle( $text, wfMsg( "newarticle" ) );
        }
 
@@ -980,6 +982,12 @@ $wgLang->recodeForEdit( $wpTextbox1 ) .
                        "cur_restrictions='{$limit}' WHERE cur_id={$id}";
                wfQuery( $sql, DB_WRITE, "Article::protect" );
 
+               $log = new LogPage( wfMsg( "protectlogpage" ), wfMsg( "protectlogtext" ) );
+               if ( $limit === "" ) {
+                       $log->addEntry( wfMsg( "unprotectedarticle", $this->mTitle->getPrefixedText() ), "" );          
+               } else {
+                       $log->addEntry( wfMsg( "protectedarticle", $this->mTitle->getPrefixedText() ), "" );
+               }
                $wgOut->redirect( wfLocalUrl( $this->mTitle->getPrefixedURL() ) );
        }
 
@@ -1012,6 +1020,11 @@ $wgLang->recodeForEdit( $wpTextbox1 ) .
                        return;
                }
 
+               if ( $wpConfirm ) {
+                       $this->doDelete();
+                       return;
+               }
+
                # determine whether this page has earlier revisions
                # and insert a warning if it does
                # we select the text because it might be useful below
@@ -1073,6 +1086,8 @@ $wgLang->recodeForEdit( $wpTextbox1 ) .
        function confirmDelete( $par = "" )
        {
                global $wgOut;
+
+               wfDebug( "Article::confirmDelete\n" );
                
                $sub = htmlspecialchars( $this->mTitle->getPrefixedText() );
                $wgOut->setSubtitle( wfMsg( "deletesub", $sub ) );
@@ -1107,6 +1122,7 @@ $wgLang->recodeForEdit( $wpTextbox1 ) .
                global $wgOut, $wgUser, $wgLang;
                global $wpReason;
                $fname = "Article::doDelete";
+               wfDebug( "$fname\n" );
 
                $this->doDeleteArticle( $this->mTitle );
                $deleted = $this->mTitle->getPrefixedText();
@@ -1119,8 +1135,7 @@ $wgLang->recodeForEdit( $wpTextbox1 ) .
                  Namespace::getWikipedia() ) .
                  ":" . wfMsg( "dellogpage" ), wfMsg( "deletionlog" ) );
 
-               $text = str_replace( "$1" , $deleted, wfMsg( "deletedtext" ) );
-               $text = str_replace( "$2", $loglink, $text );
+               $text = wfMsg( "deletedtext", $deleted, $loglink );
 
                $wgOut->addHTML( "<p>" . $text );
                $wgOut->returnToMain( false );
@@ -1131,6 +1146,8 @@ $wgLang->recodeForEdit( $wpTextbox1 ) .
                global $wgUser, $wgOut, $wgLang, $wpReason, $wgDeferredUpdateList;
 
                $fname = "Article::doDeleteArticle";
+               wfDebug( "$fname\n" );
+
                $ns = $title->getNamespace();
                $t = wfStrencode( $title->getDBkey() );
                $id = $title->getArticleID();
@@ -1225,7 +1242,7 @@ $wgLang->recodeForEdit( $wpTextbox1 ) .
                $log = new LogPage( wfMsg( "dellogpage" ), wfMsg( "dellogpagetext" ) );
                $art = $title->getPrefixedText();
                $wpReason = wfCleanQueryVar( $wpReason );
-               $log->addEntry( str_replace( "$1", $art, wfMsg( "deletedarticle" ) ), $wpReason );
+               $log->addEntry( wfMsg( "deletedarticle", $art ), $wpReason );
 
                # Clear the cached article id so the interface doesn't act like we exist
                $this->mTitle->resetArticleID( 0 );
@@ -1289,7 +1306,7 @@ $wgLang->recodeForEdit( $wpTextbox1 ) .
                $s = wfFetchObject( $res );
        
                # Save it!
-               $newcomment = str_replace( "$1", $s->old_user_text, wfMsg( "revertpage" ) );
+               $newcomment = wfMsg( "revertpage", $s->old_user_text );
                $wgOut->setPagetitle( wfMsg( "actioncomplete" ) );
                $wgOut->setRobotpolicy( "noindex,nofollow" );
                $wgOut->addHTML( "<h2>" . $newcomment . "</h2>\n<hr>\n" );
@@ -1364,7 +1381,7 @@ $wgLang->recodeForEdit( $wpTextbox1 ) .
                global $wgLang, $wgOut;
 
                $td = $wgLang->timeanddate( $this->mTimestamp, true );
-               $r = str_replace( "$1", "{$td}", wfMsg( "revisionasof" ) );
+               $r = wfMsg( "revisionasof", $td );
                $wgOut->setSubtitle( "({$r})" );
        }
 
@@ -1383,9 +1400,7 @@ $wgLang->recodeForEdit( $wpTextbox1 ) .
                $link = "[[" . $wgLang->getNsText( Namespace::getUser() ) .
                  ":{$name}|{$name}]]";
 
-               $text = str_replace( "$1", $link, wfMsg( "blockedtext" ) );
-               $text = str_replace( "$2", $reason, $text );
-               $text = str_replace( "$3", getenv( "REMOTE_ADDR" ), $text );
+               $text = wfMsg( "blockedtext", $link, $reason, getenv( "REMOTE_ADDR" ) );
                $wgOut->addWikiText( $text );
                $wgOut->returnToMain( false );
        }
@@ -1436,12 +1451,13 @@ $wgLang->recodeForEdit( $wpTextbox1 ) .
                #
                $tc = "[&;%\\-,.\\(\\)' _0-9A-Za-z\\/:\\x80-\\xff]";
                $np = "[&;%\\-,.' _0-9A-Za-z\\/:\\x80-\\xff]"; # No parens
+               $namespacechar = '[ _0-9A-Za-z\x80-\xff]'; # Namespaces can use non-ascii!
                $conpat = "/^({$np}+) \\(({$tc}+)\\)$/";
 
                $p1 = "/\[\[({$np}+) \\(({$np}+)\\)\\|]]/";             # [[page (context)|]]
                $p2 = "/\[\[\\|({$tc}+)]]/";                                    # [[|page]]
-               $p3 = "/\[\[([A-Za-z _]+):({$np}+)\\|]]/";              # [[namespace:page|]]
-               $p4 = "/\[\[([A-Aa-z _]+):({$np}+) \\(({$np}+)\\)\\|]]/";
+               $p3 = "/\[\[($namespacechar+):({$np}+)\\|]]/";          # [[namespace:page|]]
+               $p4 = "/\[\[($namespacechar+):({$np}+) \\(({$np}+)\\)\\|]]/";
                                                                                                                # [[ns:page (cont)|]]
                $context = "";
                $t = $this->mTitle->getText();