From 70557e34898ba42f1b1c4398f107cc43003b7f87 Mon Sep 17 00:00:00 2001 From: Ricordisamoa Date: Thu, 20 Aug 2015 11:23:38 +0200 Subject: [PATCH] New parameters 'reverse' and 'sortbyvalue' for Special:PagesWithProp Bug: T66950 Change-Id: Idc31289b1a9dd4746b2ecd502a23b182210384d8 --- includes/specials/SpecialPagesWithProp.php | 47 +++++++++++++++++++++- languages/i18n/en.json | 2 + languages/i18n/qqq.json | 2 + 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/includes/specials/SpecialPagesWithProp.php b/includes/specials/SpecialPagesWithProp.php index 5878e1ffb1..34fcc78c7e 100644 --- a/includes/specials/SpecialPagesWithProp.php +++ b/includes/specials/SpecialPagesWithProp.php @@ -28,9 +28,27 @@ * @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; } /** diff --git a/languages/i18n/en.json b/languages/i18n/en.json index 929042f216..c87a676432 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -1851,6 +1851,8 @@ "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)", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index 719f413b25..8937aec0aa 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -2041,6 +2041,8 @@ "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}}", -- 2.20.1