Merge "Perform a permission check on the title when changing the page language"
[lhc/web/wiklou.git] / includes / specials / SpecialPagesWithProp.php
index 5878e1f..34fcc78 100644 (file)
  * @since 1.21
  */
 class SpecialPagesWithProp extends QueryPage {
+
+       /**
+        * @var string|null
+        */
        private $propName = null;
+
+       /**
+        * @var string[]|null
+        */
        private $existingPropNames = null;
 
+       /**
+        * @var bool
+        */
+       private $reverse = false;
+
+       /**
+        * @var bool
+        */
+       private $sortByValue = false;
+
        function __construct( $name = 'PagesWithProp' ) {
                parent::__construct( $name );
        }
@@ -46,6 +64,8 @@ class SpecialPagesWithProp extends QueryPage {
 
                $request = $this->getRequest();
                $propname = $request->getVal( 'propname', $par );
+               $this->reverse = $request->getBool( 'reverse' );
+               $this->sortByValue = $request->getBool( 'sortbyvalue' );
 
                $propnames = $this->getExistingPropNames();
 
@@ -58,6 +78,20 @@ class SpecialPagesWithProp extends QueryPage {
                                'label-message' => 'pageswithprop-prop',
                                'required' => true,
                        ],
+                       'reverse' => [
+                               'type' => 'check',
+                               'name' => 'reverse',
+                               'default' => $this->reverse,
+                               'label-message' => 'pageswithprop-reverse',
+                               'required' => false,
+                       ],
+                       'sortbyvalue' => [
+                               'type' => 'check',
+                               'name' => 'sortbyvalue',
+                               'default' => $this->sortByValue,
+                               'label-message' => 'pageswithprop-sortbyvalue',
+                               'required' => false,
+                       ]
                ], $this->getContext() );
                $form->setMethod( 'get' );
                $form->setSubmitCallback( [ $this, 'onSubmit' ] );
@@ -122,7 +156,18 @@ class SpecialPagesWithProp extends QueryPage {
        }
 
        function getOrderFields() {
-               return [ 'page_id' ];
+               $sort = [ 'page_id' ];
+               if ( $this->sortByValue ) {
+                       array_unshift( $sort, 'pp_sortkey' );
+               }
+               return $sort;
+       }
+
+       /**
+        * @return bool
+        */
+       public function sortDescending() {
+               return !$this->reverse;
        }
 
        /**