Rewrite ajaxwatch.js to use the API watch action, and JQuery. Allows it to be used...
[lhc/web/wiklou.git] / includes / Article.php
index 5695905..7915e80 100644 (file)
@@ -11,6 +11,7 @@
  * Note: edit user interface and cache support functions have been
  * moved to separate EditPage and HTMLFileCache classes.
  *
+ * @internal documentation reviewed 15 Mar 2010
  */
 class Article {
        /**@{{
@@ -33,15 +34,15 @@ class Article {
        var $mRedirectTarget = null;      // !< Title object if set
        var $mRedirectUrl = false;        // !<
        var $mRevIdFetched = 0;           // !<
-       var $mRevision;                   // !<
+       var $mRevision;                   // !< Revision object if set
        var $mTimestamp = '';             // !<
-       var $mTitle;                      // !<
+       var $mTitle;                      // !< Title object
        var $mTotalAdjustment = 0;        // !<
        var $mTouched = '19700101000000'; // !<
        var $mUser = -1;                  // !< Not loaded
-       var $mUserText = '';              // !<
-       var $mParserOptions;              // !<
-       var $mParserOutput;               // !<
+       var $mUserText = '';              // !< username from Revision if set
+       var $mParserOptions;              // !< ParserOptions object
+       var $mParserOutput;               // !< ParserCache object if set
        /**@}}*/
 
        /**
@@ -804,8 +805,6 @@ class Article {
                        }
                }
 
-               $sk = $wgUser->getSkin();
-
                # getOldID may want us to redirect somewhere else
                if ( $this->mRedirectUrl ) {
                        $wgOut->redirect( $this->mRedirectUrl );
@@ -833,15 +832,6 @@ class Article {
                        wfIncrStats( 'pcache_miss_stub' );
                }
 
-               # For the main page, overwrite the <title> element with the con-
-               # tents of 'pagetitle-view-mainpage' instead of the default (if
-               # that's not empty).
-               if ( $this->mTitle->equals( Title::newMainPage() )
-                       && ( $m = wfMsgForContent( 'pagetitle-view-mainpage' ) ) !== '' )
-               {
-                       $wgOut->setHTMLTitle( $m );
-               }
-
                $wasRedirected = $this->showRedirectedFromHeader();
                $this->showNamespaceHeader();
 
@@ -849,6 +839,7 @@ class Article {
                # Keep going until $outputDone is set, or we run out of things to do.
                $pass = 0;
                $outputDone = false;
+               $this->mParserOutput = false;
                while ( !$outputDone && ++$pass ) {
                        switch( $pass ) {
                                case 1:
@@ -957,6 +948,23 @@ class Article {
                        }
                }
 
+               # Adjust the title if it was set by displaytitle, -{T|}- or language conversion
+               if ( $this->mParserOutput ) {
+                       $titleText = $this->mParserOutput->getTitleText();
+                       if ( strval( $titleText ) !== '' ) {
+                               $wgOut->setPageTitle( $titleText );
+                       }
+               }
+
+               # For the main page, overwrite the <title> element with the con-
+               # tents of 'pagetitle-view-mainpage' instead of the default (if
+               # that's not empty).
+               if ( $this->mTitle->equals( Title::newMainPage() )
+                       && ( $m = wfMsgForContent( 'pagetitle-view-mainpage' ) ) !== '' )
+               {
+                       $wgOut->setHTMLTitle( $m );
+               }
+
                # Now that we've filled $this->mParserOutput, we know whether
                # there are any __NOINDEX__ tags on the page
                $policy = $this->getRobotPolicy( 'view' );
@@ -1023,7 +1031,7 @@ class Article {
         *    array
         */
        public function getRobotPolicyForView() {
-               wfDeprecated( __FUNC__ );
+               wfDeprecated( __METHOD__ );
                $policy = $this->getRobotPolicy( 'view' );
                return $policy['index'] . ',' . $policy['follow'];
        }
@@ -1506,7 +1514,6 @@ class Article {
                                        $rmvtxt );
                }
                $wgOut->wrapWikiMsg( "<div id='mw_trackbacks'>$1</div>\n", array( 'trackbackbox', $tbtext ) );
-               $this->mTitle->invalidateCache();
        }
 
        /**
@@ -1755,6 +1762,9 @@ class Article {
 
        /**
         * @param $section empty/null/false or a section number (0, 1, 2, T1, T2...)
+        * @param $text String: new text of the section
+        * @param $summary String: new section's subject, only if $section is 'new'
+        * @param $edittime String: revision timestamp or null to use the current revision
         * @return string Complete article text, or null if error
         */
        public function replaceSection( $section, $text, $summary = '', $edittime = null ) {
@@ -2544,13 +2554,17 @@ class Article {
 
                $hasHistory = ( $res->numRows() > 1 );
                $row = $dbw->fetchObject( $res );
-               $onlyAuthor = $row->rev_user_text;
-               // Try to find a second contributor
-               foreach ( $res as $row ) {
-                       if ( $row->rev_user_text != $onlyAuthor ) {
-                               $onlyAuthor = false;
-                               break;
+               if ( $row ) { // $row is false if the only contributor is hidden
+                       $onlyAuthor = $row->rev_user_text;
+                       // Try to find a second contributor
+                       foreach ( $res as $row ) {
+                               if ( $row->rev_user_text != $onlyAuthor ) { // Bug 22999
+                                       $onlyAuthor = false;
+                                       break;
+                               }
                        }
+               } else {
+                       $onlyAuthor = false;
                }
                $dbw->freeResult( $res );
 
@@ -4134,7 +4148,7 @@ class Article {
        /**
         * Updates cascading protections
         *
-        * @param $parserOutput mixed ParseerOptions object, or boolean false
+        * @param $parserOutput mixed ParserOptions object, or boolean false
         **/
 
        protected function doCascadeProtectionUpdates( $parserOutput ) {