Add BeforePageRedirect hook to OutputPage, allowing extensions to override redirect...
[lhc/web/wiklou.git] / includes / RevisionList.php
index cf0c32a..814e2df 100644 (file)
@@ -2,15 +2,11 @@
 /**
  * List for revision table items for a single page
  */
-abstract class RevisionListBase {
+abstract class RevisionListBase extends ContextSource {
        /**
         * @var Title
         */
        var $title;
-       /**
-        * @var IContextSource
-        */
-       var $context;
 
        var $ids, $res, $current;
 
@@ -20,7 +16,7 @@ abstract class RevisionListBase {
         * @param $title Title
         */
        function __construct( IContextSource $context, Title $title ) {
-               $this->context = $context;
+               $this->setContext( $context );
                $this->title = $title;
        }
 
@@ -104,24 +100,6 @@ abstract class RevisionListBase {
         * @param $row stdclass
         */
        abstract public function newItem( $row );
-
-       /**
-        * Get the language of the user doing the action
-        *
-        * @return Language object
-        */
-       public function getLang() {
-               return $this->context->getLang();
-       }
-
-       /**
-        * Get the user doing the action
-        *
-        * @return User object
-        */
-       public function getUser() {
-               return $this->context->getUser();
-       }
 }
 
 /**
@@ -184,19 +162,19 @@ abstract class RevisionItemBase {
        }
 
        /**
-        * Get the date, formatted with $wgLang
+        * Get the date, formatted in user's languae
         */
        public function formatDate() {
-               global $wgLang;
-               return $wgLang->date( $this->getTimestamp() );
+               return $this->list->getLanguage()->userDate( $this->getTimestamp(),
+                       $this->list->getUser() );
        }
 
        /**
-        * Get the time, formatted with $wgLang
+        * Get the time, formatted in user's languae
         */
        public function formatTime() {
-               global $wgLang;
-               return $wgLang->time( $this->getTimestamp() );
+               return $this->list->getLanguage()->userTime( $this->getTimestamp(),
+                       $this->list->getUser() );
        }
 
        /**
@@ -250,19 +228,19 @@ class RevisionList extends RevisionListBase {
         * @return mixed
         */
        public function doQuery( $db ) {
-               $conds = array(
-                       'rev_page' => $this->title->getArticleID(),
-                       'rev_page = page_id'
-               );
+               $conds = array( 'rev_page' => $this->title->getArticleID() );
                if ( $this->ids !== null ) {
                        $conds['rev_id'] = array_map( 'intval', $this->ids );
                }
                return $db->select(
-                       array( 'revision', 'page' ),
-                       '*',
+                       array( 'revision', 'page', 'user' ),
+                       array_merge( Revision::selectFields(), Revision::selectUserFields() ),
                        $conds,
                        __METHOD__,
-                       array( 'ORDER BY' => 'rev_id DESC' )
+                       array( 'ORDER BY' => 'rev_id DESC' ),
+                       array(
+                               'page' => Revision::pageJoinCond(),
+                               'user' => Revision::userJoinCond() )
                );
        }
 
@@ -296,7 +274,7 @@ class RevisionItem extends RevisionItemBase {
        }
 
        public function getAuthorNameField() {
-               return 'rev_user_text';
+               return 'user_name'; // see Revision::selectUserFields()
        }
 
        public function canView() {
@@ -316,7 +294,7 @@ class RevisionItem extends RevisionItemBase {
         * Overridden by RevDel_ArchiveItem.
         */
        protected function getRevisionLink() {
-               $date = $this->list->getLang()->timeanddate( $this->revision->getTimestamp(), true );
+               $date = $this->list->getLanguage()->timeanddate( $this->revision->getTimestamp(), true );
                if ( $this->isDeleted() && !$this->canViewContent() ) {
                        return $date;
                }