X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialPagesWithProp.php;h=46ad31c4a8f53fb518288b904ada091c787aebf1;hb=a1ef77b2d80830fbcb617a83961d78cff9d6e384;hp=5878e1ffb178a1cb95c80a585892ca2b1d8323af;hpb=6b604178acc9beecd2abc638043c9067043efc12;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialPagesWithProp.php b/includes/specials/SpecialPagesWithProp.php index 5878e1ffb1..527b910fcf 100644 --- a/includes/specials/SpecialPagesWithProp.php +++ b/includes/specials/SpecialPagesWithProp.php @@ -28,9 +28,32 @@ * @since 1.21 */ class SpecialPagesWithProp extends QueryPage { + + /** + * @var string|null + */ private $propName = null; + + /** + * @var string[]|null + */ private $existingPropNames = null; + /** + * @var string|null + */ + private $ns; + + /** + * @var bool + */ + private $reverse = false; + + /** + * @var bool + */ + private $sortByValue = false; + function __construct( $name = 'PagesWithProp' ) { parent::__construct( $name ); } @@ -42,10 +65,12 @@ class SpecialPagesWithProp extends QueryPage { public function execute( $par ) { $this->setHeaders(); $this->outputHeader(); - $this->getOutput()->addModuleStyles( 'mediawiki.special.pagesWithProp' ); + $this->getOutput()->addModuleStyles( 'mediawiki.special' ); $request = $this->getRequest(); $propname = $request->getVal( 'propname', $par ); + $this->reverse = $request->getBool( 'reverse' ); + $this->sortByValue = $request->getBool( 'sortbyvalue' ); $propnames = $this->getExistingPropNames(); @@ -58,6 +83,27 @@ class SpecialPagesWithProp extends QueryPage { 'label-message' => 'pageswithprop-prop', 'required' => true, ], + 'namespace' => [ + 'type' => 'namespaceselect', + 'name' => 'namespace', + 'label-message' => 'namespace', + 'all' => null, + 'default' => null, + ], + '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' ] ); @@ -74,6 +120,7 @@ class SpecialPagesWithProp extends QueryPage { public function onSubmit( $data, $form ) { $this->propName = $data['propname']; + $this->ns = $data['namespace']; parent::execute( $data['propname'] ); } @@ -100,7 +147,7 @@ class SpecialPagesWithProp extends QueryPage { } public function getQueryInfo() { - return [ + $query = [ 'tables' => [ 'page_props', 'page' ], 'fields' => [ 'page_id' => 'pp_page', @@ -115,14 +162,31 @@ class SpecialPagesWithProp extends QueryPage { 'pp_propname' => $this->propName, ], 'join_conds' => [ - 'page' => [ 'INNER JOIN', 'page_id = pp_page' ] + 'page' => [ 'JOIN', 'page_id = pp_page' ] ], 'options' => [] ]; + + if ( $this->ns && isset( $this->ns ) ) { + $query['conds']['page_namespace'] = $this->ns; + } + + return $query; } 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; } /**