Annotate different parts of the contributions UI with classes
[lhc/web/wiklou.git] / includes / specials / pagers / ContribsPager.php
index 2bfc923..626fc48 100644 (file)
@@ -30,27 +30,79 @@ use Wikimedia\Rdbms\IDatabase;
 
 class ContribsPager extends RangeChronologicalPager {
 
-       public $mDefaultDirection = IndexPager::DIR_DESCENDING;
-       public $messages;
-       public $target;
-       public $namespace = '';
-       public $mDb;
-       public $preventClickjacking = false;
+       /**
+        * @var string[] Local cache for escaped messages
+        */
+       private $messages;
+
+       /**
+        * @var string User name, or a string describing an IP address range
+        */
+       private $target;
+
+       /**
+        * @var string Set to "newbie" to list contributions from the most recent 1% registered users.
+        *  $this->target is ignored then. Defaults to "users".
+        */
+       private $contribs;
+
+       /**
+        * @var string|int A single namespace number, or an empty string for all namespaces
+        */
+       private $namespace = '';
+
+       /**
+        * @var string|false Name of tag to filter, or false to ignore tags
+        */
+       private $tagFilter;
+
+       /**
+        * @var bool Set to true to invert the namespace selection
+        */
+       private $nsInvert;
+
+       /**
+        * @var bool Set to true to show both the subject and talk namespace, no matter which got
+        *  selected
+        */
+       private $associated;
+
+       /**
+        * @var bool Set to true to show only deleted revisions
+        */
+       private $deletedOnly;
+
+       /**
+        * @var bool Set to true to show only latest (a.k.a. current) revisions
+        */
+       private $topOnly;
+
+       /**
+        * @var bool Set to true to show only new pages
+        */
+       private $newOnly;
+
+       /**
+        * @var bool Set to true to hide edits marked as minor by the user
+        */
+       private $hideMinor;
+
+       private $preventClickjacking = false;
 
        /** @var IDatabase */
-       public $mDbSecondary;
+       private $mDbSecondary;
 
        /**
         * @var array
         */
-       protected $mParentLens;
+       private $mParentLens;
 
        /**
         * @var TemplateParser
         */
-       protected $templateParser;
+       private $templateParser;
 
-       function __construct( IContextSource $context, array $options ) {
+       public function __construct( IContextSource $context, array $options ) {
                parent::__construct( $context );
 
                $msgs = [
@@ -102,20 +154,33 @@ class ContribsPager extends RangeChronologicalPager {
                return $query;
        }
 
+       /**
+        * Wrap the navigation bar in a p element with identifying class.
+        * In future we may want to change the `p` tag to a `div` and upstream
+        * this to the parent class.
+        *
+        * @return string HTML
+        */
+       function getNavigationBar() {
+               return Html::rawElement( 'p', [ 'class' => 'mw-pager-navigation-bar' ],
+                       parent::getNavigationBar()
+               );
+       }
+
        /**
         * This method basically executes the exact same code as the parent class, though with
         * a hook added, to allow extensions to add additional queries.
         *
         * @param string $offset Index offset, inclusive
         * @param int $limit Exact query limit
-        * @param bool $descending Query direction, false for ascending, true for descending
+        * @param bool $order IndexPager::QUERY_ASCENDING or IndexPager::QUERY_DESCENDING
         * @return IResultWrapper
         */
-       function reallyDoQuery( $offset, $limit, $descending ) {
+       function reallyDoQuery( $offset, $limit, $order ) {
                list( $tables, $fields, $conds, $fname, $options, $join_conds ) = $this->buildQueryInfo(
                        $offset,
                        $limit,
-                       $descending
+                       $order
                );
 
                /*
@@ -141,7 +206,7 @@ class ContribsPager extends RangeChronologicalPager {
                ) ];
                Hooks::run(
                        'ContribsPager::reallyDoQuery',
-                       [ &$data, $this, $offset, $limit, $descending ]
+                       [ &$data, $this, $offset, $limit, $order ]
                );
 
                $result = [];
@@ -155,7 +220,7 @@ class ContribsPager extends RangeChronologicalPager {
                }
 
                // sort results
-               if ( $descending ) {
+               if ( $order === self::QUERY_ASCENDING ) {
                        ksort( $result );
                } else {
                        krsort( $result );
@@ -369,6 +434,41 @@ class ContribsPager extends RangeChronologicalPager {
                return 'rev_timestamp';
        }
 
+       /**
+        * @return false|string
+        */
+       public function getTagFilter() {
+               return $this->tagFilter;
+       }
+
+       /**
+        * @return string
+        */
+       public function getContribs() {
+               return $this->contribs;
+       }
+
+       /**
+        * @return string
+        */
+       public function getTarget() {
+               return $this->target;
+       }
+
+       /**
+        * @return bool
+        */
+       public function isNewOnly() {
+               return $this->newOnly;
+       }
+
+       /**
+        * @return int|string
+        */
+       public function getNamespace() {
+               return $this->namespace;
+       }
+
        /**
         * @return string[]
         */
@@ -377,7 +477,7 @@ class ContribsPager extends RangeChronologicalPager {
                return [ 'rev_id' ];
        }
 
-       function doBatchLookups() {
+       protected function doBatchLookups() {
                # Do a link batch query
                $this->mResult->seek( 0 );
                $parentRevIds = [];
@@ -413,14 +513,14 @@ class ContribsPager extends RangeChronologicalPager {
        /**
         * @return string
         */
-       function getStartBody() {
+       protected function getStartBody() {
                return "<ul class=\"mw-contributions-list\">\n";
        }
 
        /**
         * @return string
         */
-       function getEndBody() {
+       protected function getEndBody() {
                return "</ul>\n";
        }