Tpt has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/50491


Change subject: Allows to restrict output in Special:EntitiesWithoutLabels to a 
specific entity type
......................................................................

Allows to restrict output in Special:EntitiesWithoutLabels to a specific
entity type

Change-Id: I1756f2bf26ec2e4682d0a8aa58b3d51794b20e54
---
M repo/Wikibase.i18n.php
M repo/includes/specials/SpecialEntitiesWithoutLabel.php
2 files changed, 55 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/91/50491/1

diff --git a/repo/Wikibase.i18n.php b/repo/Wikibase.i18n.php
index 4af7331..c1efcd2 100644
--- a/repo/Wikibase.i18n.php
+++ b/repo/Wikibase.i18n.php
@@ -175,8 +175,10 @@
        'special-entitieswithoutlabel' => 'Entities without label',
        'wikibase-entitieswithoutlabel-legend' => 'Get list of entities without 
label',
        'wikibase-entitieswithoutlabel-label-language' => 'Language:',
+       'wikibase-entitieswithoutlabel-label-type' => 'Type:',
        'wikibase-entitieswithoutlabel-submit' => 'Find',
        'wikibase-entitieswithoutlabel-invalid-language' => '"$1" is not a 
valid language code.',
+       'wikibase-entitieswithoutlabel-invalid-type' => '"$1" is not a valid 
entity type.',
        'special-itemswithoutsitelinks' => 'Items without sitelinks',
        'special-entitydata' => 'Entity data',
        'wikibase-entitydata-not-found' => "No entity with ID $1 was found.",
@@ -584,8 +586,10 @@
        'special-entitieswithoutlabel' => 'This special page returns a list of 
entities without label for a given language',
        'wikibase-entitieswithoutlabel-legend' => 'Legend of the form that 
allow to change the language.',
        'wikibase-entitieswithoutlabel-label-language' => 'Label for the input 
field to change the language.',
+       'wikibase-entitieswithoutlabel-label-type' => 'Label of the entity type 
selector that allows to restrict the request to one type.',
        'wikibase-entitieswithoutlabel-submit' => 'Label for the button that 
activate the action.',
-       'wikibase-entitieswithoutlabel-invalid-language' => 'Error message 
shown when the language code passed in parameter is invalid. $1 is invalid 
language code.',
+       'wikibase-entitieswithoutlabel-invalid-language' => 'Error message 
shown when the language code passed in parameter is invalid. $1 is the invalid 
language code.',
+       'wikibase-entitieswithoutlabel-invalid-language' => 'Error message 
shown when the entity type passed in parameter is invalid. $1 is the invalid 
type.',
        'special-itemswithoutsitelinks' => 'This special page returns a list of 
items without any site link',
        'special-entitydata' => 'Title for special page that provides a linked 
data interface and easy way to get the JSON data representation for an entity.',
        'wikibase-entitydata-not-found' => 'Error shown when no entity with the 
given ID could be found. Paramters:
diff --git a/repo/includes/specials/SpecialEntitiesWithoutLabel.php 
b/repo/includes/specials/SpecialEntitiesWithoutLabel.php
index db9eb91..22434be 100644
--- a/repo/includes/specials/SpecialEntitiesWithoutLabel.php
+++ b/repo/includes/specials/SpecialEntitiesWithoutLabel.php
@@ -63,13 +63,35 @@
                $output = $this->getOutput();
                $request = $this->getRequest();
 
-               $this->language = $request->getText( 'language', '' );
-               if ( $this->language === '' && $subPage !== null ) {
-                       $this->language = $subPage;
+               $this->language = '';
+               $this->type = null;
+               if ( $subPage !== null ) {
+                       $parts = explode( '/', $subPage );
+                       if ( count( $parts >= 2 ) ) {
+                               $this->type = $parts[1];
+                       }
+                       $this->language = $parts[0];
                }
+
+               $this->language = $request->getText( 'language', 
$this->language );
                if ( $this->language !== '' && !in_array( $this->language, 
\Wikibase\Utils::getLanguageCodes() ) ) {
                        $output->addWikiMsg( 
'wikibase-entitieswithoutlabel-invalid-language', $this->language );
                        $this->language = '';
+               }
+
+               $this->type = $request->getText( 'type', $this->type );
+               $possibleTypes = array( 'item', 'property', 'query' );
+               if ( $this->type === '' ) {
+                       $this->type = null;
+               }
+               if ( $this->type !== null && !in_array( $this->type, 
$possibleTypes ) ) {
+                       $output->addWikiMsg( 
'wikibase-entitieswithoutlabel-invalid-type', $this->type );
+                       $this->type = null;
+               }
+               $typeSelect = new XmlSelect( 'type', 
'wb-entitieswithoutlabel-type', $this->type );
+               $typeSelect->addOption( '', '' );
+               foreach( $possibleTypes as $possibleType ) {
+                       $typeSelect->addOption( $this->msg( 'wikibase-entity-' 
. $possibleType )->text(), $possibleType );
                }
 
                $output->addHTML(
@@ -82,17 +104,35 @@
                                )
                        ) .
                        Html::openElement( 'fieldset' ) .
-                       Html::element( 'legend', array(), $this->msg( 
'wikibase-entitieswithoutlabel-legend' )->text() ) .
+                       Html::element(
+                               'legend',
+                               array(),
+                               $this->msg( 
'wikibase-entitieswithoutlabel-legend' )->text()
+                       ) .
                        Html::openElement( 'p' ) .
-                       Html::element( 'label', array( 'for' => 'language' ), 
$this->msg( 'wikibase-entitieswithoutlabel-label-language' )->text() )  . ' ' .
+                       Html::element(
+                               'label',
+                               array(
+                                       'for' => 
'wb-entitieswithoutlabel-language'
+                               ),
+                               $this->msg( 
'wikibase-entitieswithoutlabel-label-language' )->text()
+                       ) . ' ' .
                        Html::input(
                                'language',
                                $this->language,
                                'text',
-                                       array(
-                                               'id' => 'language'
+                               array(
+                                       'id' => 
'wb-entitieswithoutlabel-language'
                                )
-                       ) .
+                       ) . ' ' .
+                       Html::element(
+                               'label',
+                               array(
+                                       'for' => 'wb-entitieswithoutlabel-type'
+                               ),
+                               $this->msg( 
'wikibase-entitieswithoutlabel-label-type' )->text()
+                       ) . ' ' .
+                       $typeSelect->getHTML() . ' ' .
                        Html::input(
                                'submit',
                                $this->msg( 
'wikibase-entitieswithoutlabel-submit' )->text(),
@@ -143,7 +183,7 @@
         */
        protected function getResult( $offset = 0, $limit = 0 ) {
                $entityPerPage = \Wikibase\StoreFactory::getStore( 'sqlstore' 
)->newEntityPerPage();
-               return $entityPerPage->getEntitiesWithoutTerm( 
\Wikibase\Term::TYPE_LABEL, $this->language, null, $limit, $offset );
+               return $entityPerPage->getEntitiesWithoutTerm( 
\Wikibase\Term::TYPE_LABEL, $this->language, $this->type, $limit, $offset );
        }
 
 
@@ -155,7 +195,7 @@
         * @return Title
         */
        protected function getTitleForNavigation() {
-               return $this->getTitle( $this->language );
+               return $this->getTitle( $this->language . '/' . $this->type );
        }
 
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/50491
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1756f2bf26ec2e4682d0a8aa58b3d51794b20e54
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Tpt <thoma...@hotmail.fr>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to