New parameters 'reverse' and 'sortbyvalue' for Special:PagesWithProp
authorRicordisamoa <ricordisamoa@openmailbox.org>
Thu, 20 Aug 2015 09:23:38 +0000 (11:23 +0200)
committerAmir Sarabadani <ladsgroup@gmail.com>
Fri, 21 Jul 2017 13:32:43 +0000 (17:32 +0400)
Bug: T66950
Change-Id: Idc31289b1a9dd4746b2ecd502a23b182210384d8

includes/specials/SpecialPagesWithProp.php
languages/i18n/en.json
languages/i18n/qqq.json

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;
        }
 
        /**
index 929042f..c87a676 100644 (file)
        "pageswithprop-legend": "Pages with a page property",
        "pageswithprop-text": "This page lists pages that use a particular page property.",
        "pageswithprop-prop": "Property name:",
+       "pageswithprop-reverse": "Sort in reverse order",
+       "pageswithprop-sortbyvalue": "Sort by property value",
        "pageswithprop-submit": "Go",
        "pageswithprop-prophidden-long": "long text property value hidden ($1)",
        "pageswithprop-prophidden-binary": "binary property value hidden ($1)",
index 719f413..8937aec 100644 (file)
        "pageswithprop-legend": "Legend for the input form on [[Special:PagesWithProp]].\n{{Identical|Page with page property}}",
        "pageswithprop-text": "Introductory text for the input form on [[Special:PagesWithProp]]",
        "pageswithprop-prop": "Label for the property name input field on [[Special:PagesWithProp]].\n{{Identical|Property name}}",
+       "pageswithprop-reverse": "Label for the reverse checkmark field on [[Special:PagesWithProp]].",
+       "pageswithprop-sortbyvalue": "Label for the sort by value checkmark field on [[Special:PagesWithProp]].",
        "pageswithprop-submit": "Label for the submit button on [[Special:PagesWithProp]].\n{{Identical|Go}}",
        "pageswithprop-prophidden-long": "Information shown on [[Special:PagesWithProp]] when property value is longer than 1 kilobyte.\n\nParameters:\n* $1 - size of property value in kilobytes\nSee also:\n* {{msg-mw|pageswithprop-prophidden-binary}}",
        "pageswithprop-prophidden-binary": "Information shown on [[Special:PagesWithProp]] when property value contains binary data.\n\nParameters:\n* $1 - size of property value in kilobytes\nSee also:\n* {{msg-mw|pageswithprop-prophidden-long}}",