John Erling Blad has submitted this change and it was merged.

Change subject: Add Special:ItemsWithoutSitelinks that list all items without 
any site link
......................................................................


Add Special:ItemsWithoutSitelinks that list all items without any site link

Edits also the label of Special:EntitiesWithoutLabel to be consistent with
the others special page names.

Change-Id: I032208726699d104c8ee76ef97e3f61b5f78f334
---
M repo/Wikibase.i18n.alias.php
M repo/Wikibase.i18n.php
M repo/Wikibase.php
M repo/includes/specials/SpecialEntitiesWithoutLabel.php
A repo/includes/specials/SpecialItemsWithoutSitelinks.php
M repo/includes/store/EntityPerPage.php
M repo/includes/store/sql/EntityPerPageTable.php
7 files changed, 158 insertions(+), 6 deletions(-)

Approvals:
  John Erling Blad: Verified; Looks good to me, approved



diff --git a/repo/Wikibase.i18n.alias.php b/repo/Wikibase.i18n.alias.php
index 3e652a7..ab4fc8d 100644
--- a/repo/Wikibase.i18n.alias.php
+++ b/repo/Wikibase.i18n.alias.php
@@ -26,6 +26,7 @@
        'SetDescription' => array( 'SetDescription' ),
        'SetAliases' => array( 'SetAliases' ),
        'EntitiesWithoutLabel' => array( 'EntitiesWithoutLabel' ),
+       'ItemsWithoutSitelinks' => array( 'ItemsWithoutSitelinks' ),
 );
 
 /** Arabic (العربية) */
@@ -195,4 +196,4 @@
        'ItemDisambiguation' => array( '项目消歧义' ),
        'ListDatatypes' => array( '列出数据类型' ),
        'SetLabel' => array( '设置标签' ),
-);
\ No newline at end of file
+);
diff --git a/repo/Wikibase.i18n.php b/repo/Wikibase.i18n.php
index a98c028..224f97c 100644
--- a/repo/Wikibase.i18n.php
+++ b/repo/Wikibase.i18n.php
@@ -172,11 +172,12 @@
        'wikibase-listdatatypes-intro' => 'This is a list of all datatypes 
currently in use on this installation:',
        'wikibase-history-title-with-label' => 'Revision history of "$2" ($1)',
        'wikibase-history-title-without-label' => 'Revision history of ($1)',
-       'special-entitieswithoutlabel' => 'List of entities without label',
+       'special-entitieswithoutlabel' => 'Entities without label',
        'wikibase-entitieswithoutlabel-legend' => 'Get list of entities without 
label',
        'wikibase-entitieswithoutlabel-label-language' => 'Language:',
        'wikibase-entitieswithoutlabel-submit' => 'Find',
        'wikibase-entitieswithoutlabel-invalid-language' => '"$1" is not a 
valid language code.',
+       'special-itemswithoutsitelinks' => 'Items without sitelinks',
        'special-entitydata' => 'Entity data',
        'wikibase-entitydata-not-found' => "No entity with ID $1 was found.",
        'wikibase-entitydata-bad-revision' => "Can't show revision $2 of entity 
$1.",
@@ -585,6 +586,7 @@
        'wikibase-entitieswithoutlabel-label-language' => 'Label for the input 
field to change the language.',
        '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.',
+       '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:
 * $1 is the given ID',
diff --git a/repo/Wikibase.php b/repo/Wikibase.php
index cb3eae7..2111cee 100644
--- a/repo/Wikibase.php
+++ b/repo/Wikibase.php
@@ -157,6 +157,8 @@
 $wgAutoloadClasses['Wikibase\ItemHandler']                             = $dir 
. 'includes/content/ItemHandler.php';
 $wgAutoloadClasses['Wikibase\PropertyContent']                         = $dir 
. 'includes/content/PropertyContent.php';
 $wgAutoloadClasses['Wikibase\PropertyHandler']                         = $dir 
. 'includes/content/PropertyHandler.php';
+$wgAutoloadClasses['Wikibase\QueryContent']                    = $dir . 
'includes/content/QueryContent.php';
+$wgAutoloadClasses['Wikibase\QueryHandler']                    = $dir . 
'includes/content/QueryHandler.php';
 
 // includes/specials
 $wgAutoloadClasses['SpecialCreateEntity']                              = $dir 
. 'includes/specials/SpecialCreateEntity.php';
@@ -170,6 +172,7 @@
 $wgAutoloadClasses['SpecialSetDescription']                    = $dir . 
'includes/specials/SpecialSetDescription.php';
 $wgAutoloadClasses['SpecialSetAliases']                                = $dir 
. 'includes/specials/SpecialSetAliases.php';
 $wgAutoloadClasses['SpecialEntitiesWithoutLabel']          = $dir . 
'includes/specials/SpecialEntitiesWithoutLabel.php';
+$wgAutoloadClasses['SpecialItemsWithoutSitelinks']         = $dir . 
'includes/specials/SpecialItemsWithoutSitelinks.php';
 $wgAutoloadClasses['SpecialListDatatypes']                             = $dir 
. 'includes/specials/SpecialListDatatypes.php';
 
 // includes/store
@@ -231,6 +234,7 @@
 $wgSpecialPages['SetDescription']                                      = 
'SpecialSetDescription';
 $wgSpecialPages['SetAliases']                                          = 
'SpecialSetAliases';
 $wgSpecialPages['EntitiesWithoutLabel']                        = 
'SpecialEntitiesWithoutLabel';
+$wgSpecialPages['ItemsWithoutSitelinks']               = 
'SpecialItemsWithoutSitelinks';
 $wgSpecialPages['NewProperty']                                                 
= 'SpecialNewProperty';
 $wgSpecialPages['ListDatatypes']                                       = 
'SpecialListDatatypes';
 
@@ -245,11 +249,12 @@
 $wgSpecialPageGroups['SetAliases']                                     = 
'wikibaserepo';
 $wgSpecialPageGroups['EntitiesWithoutLabel']           = 'wikibaserepo';
 $wgSpecialPageGroups['EntityData']                                     = 
'wikibaserepo';
+$wgSpecialPageGroups['ItemsWithoutSitelinks']          = 'wikibaserepo';
 $wgSpecialPageGroups['ListDatatypes']                          = 
'wikibaserepo';
 
 
 // Hooks
-$wgHooks['BeforePageDisplay'][]                                                
= 'Wikibase\RepoHooks::onBeforePageDisplay';
+$wgHooks['WikibaseDefaultSettings'][]                      = 
'Wikibase\RepoHooks::onWikibaseDefaultSettings';
 $wgHooks['LoadExtensionSchemaUpdates'][]                       = 
'Wikibase\RepoHooks::onSchemaUpdate';
 $wgHooks['UnitTestsList'][]                                            = 
'Wikibase\RepoHooks::registerUnitTests';
 $wgHooks['NamespaceIsMovable'][]                                       = 
'Wikibase\RepoHooks::onNamespaceIsMovable';
@@ -279,6 +284,7 @@
 // register hooks and handlers
 $wgContentHandlers[CONTENT_MODEL_WIKIBASE_ITEM] = '\Wikibase\ItemHandler';
 $wgContentHandlers[CONTENT_MODEL_WIKIBASE_PROPERTY] = 
'\Wikibase\PropertyHandler';
+$wgContentHandlers[CONTENT_MODEL_WIKIBASE_QUERY] = '\Wikibase\QueryHandler';
 
 $wgWBStores = array();
 
@@ -291,3 +297,5 @@
 if ( defined( 'WB_EXPERIMENTAL_FEATURES' ) && WB_EXPERIMENTAL_FEATURES ) {
        include_once( __DIR__ . '/config/Wikibase.experimental.php' );
 }
+
+unset( $dir );
diff --git a/repo/includes/specials/SpecialEntitiesWithoutLabel.php 
b/repo/includes/specials/SpecialEntitiesWithoutLabel.php
index 1d71715..db9eb91 100644
--- a/repo/includes/specials/SpecialEntitiesWithoutLabel.php
+++ b/repo/includes/specials/SpecialEntitiesWithoutLabel.php
@@ -118,7 +118,6 @@
         * @since 0.3
         *
         * @param $entry The entry is for this call an EntityId
-        * TODO: just getting an ID here is odd
         *
         * @return string|null
         */
@@ -141,7 +140,6 @@
         * @param integer $limit
         *
         * @return EntityId[]
-        * TODO: it's a bit odd that this returns an array of EntityId
         */
        protected function getResult( $offset = 0, $limit = 0 ) {
                $entityPerPage = \Wikibase\StoreFactory::getStore( 'sqlstore' 
)->newEntityPerPage();
diff --git a/repo/includes/specials/SpecialItemsWithoutSitelinks.php 
b/repo/includes/specials/SpecialItemsWithoutSitelinks.php
new file mode 100644
index 0000000..97f0c13
--- /dev/null
+++ b/repo/includes/specials/SpecialItemsWithoutSitelinks.php
@@ -0,0 +1,87 @@
+<?php
+
+use Wikibase\EntityId;
+
+/**
+ * Page for listing entities without label.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @since 0.4
+ *
+ * @file
+ * @ingroup WikibaseRepo
+ *
+ * @licence GNU GPL v2+
+ * @author Thomas Pellissier Tanon
+ */
+class SpecialItemsWithoutSitelinks extends SpecialWikibaseQueryPage {
+
+       public function __construct() {
+               parent::__construct( 'ItemsWithoutSitelinks' );
+       }
+
+       /**
+        * @see SpecialWikibasePage::execute
+        *
+        * @since 0.4
+        *
+        * @param string $subPage
+        * @return boolean
+        */
+       public function execute( $subPage ) {
+               if ( !parent::execute( $subPage ) ) {
+                       return false;
+               }
+
+               $this->showQuery();
+       }
+
+       /**
+        * @see SpecialWikibaseQueryPage::formatRow
+        *
+        * @since 0.4
+        *
+        * @param $entry The entry is for this call an EntityId
+        *
+        * @return string|null
+        */
+       protected function formatRow( $entry ) {
+               try {
+                       $title = 
\Wikibase\EntityContentFactory::singleton()->getTitleForId( $entry );
+                       return Linker::linkKnown( $title );
+               } catch ( MWException $e ) {
+                       wfWarn( "Error formatting result row: " . 
$e->getMessage() );
+                       return false;
+               }
+       }
+
+       /**
+        * @see SpecialWikibaseQueryPage::getResult
+        *
+        * @since 0.4
+        *
+        * @param integer $offset
+        * @param integer $limit
+        *
+        * @return EntityId[]
+        */
+       protected function getResult( $offset = 0, $limit = 0 ) {
+               $entityPerPage = \Wikibase\StoreFactory::getStore( 'sqlstore' 
)->newEntityPerPage();
+               return $entityPerPage->getItemsWithoutSitelinks( null, $limit, 
$offset );
+       }
+
+}
diff --git a/repo/includes/store/EntityPerPage.php 
b/repo/includes/store/EntityPerPage.php
index 95890bd..4961724 100644
--- a/repo/includes/store/EntityPerPage.php
+++ b/repo/includes/store/EntityPerPage.php
@@ -70,7 +70,6 @@
         */
        public function rebuild();
 
-
        /**
         * Return all entities without a specify term
         *
@@ -84,4 +83,17 @@
         * @return EntityId[]
         */
        public function getEntitiesWithoutTerm( $termType, $language = null, 
$entityType = null, $limit = 50, $offset = 0 );
+
+
+       /**
+        * Return all items without sitelinks
+        *
+        * @since 0.4
+        *
+        * @param string|null $siteId Restrict the request to a specific site.
+        * @param integer $limit Limit of the query.
+        * @param integer $offset Offset of the query.
+        * @return EntityId[]
+        */
+       public function getItemsWithoutSitelinks( $siteId = null, $limit = 50, 
$offset = 0 );
 }
diff --git a/repo/includes/store/sql/EntityPerPageTable.php 
b/repo/includes/store/sql/EntityPerPageTable.php
index 6389894..dd19eeb 100644
--- a/repo/includes/store/sql/EntityPerPageTable.php
+++ b/repo/includes/store/sql/EntityPerPageTable.php
@@ -183,4 +183,48 @@
                }
                return $entities;
        }
+
+       /**
+        * Return all items without sitelinks
+        *
+        * @since 0.4
+        *
+        * @param string|null $siteId Restrict the request to a specific site.
+        * @param integer $limit Limit of the query.
+        * @param integer $offset Offset of the query.
+        * @return EntityId[]
+        */
+       public function getItemsWithoutSitelinks( $siteId = null, $limit = 50, 
$offset = 0 ) {
+               $dbr = wfGetDB( DB_SLAVE );
+               $conditions = array(
+                       'ips_site_page IS NULL'
+               );
+               $conditions['epp_entity_type'] = Item::ENTITY_TYPE;
+               $joinConditions = 'ips_item_id = epp_entity_id';
+
+               if ( $siteId !== null ) {
+                       $joinConditions .= ' AND ips_site_id = ' . 
$dbr->addQuotes( $siteId );
+               }
+
+               $rows = $dbr->select(
+                       array( 'wb_entity_per_page', 'wb_items_per_site' ),
+                       array(
+                               'entity_id' => 'epp_entity_id'
+                       ),
+                       $conditions,
+                       __METHOD__,
+                       array(
+                               'OFFSET' => $offset,
+                               'LIMIT' => $limit,
+                               'ORDER BY' => 'epp_page_id DESC'
+                       ),
+                       array( 'wb_items_per_site' => array( 'LEFT JOIN', 
$joinConditions ) )
+               );
+
+               $entities = array();
+               foreach ( $rows as $row ) {
+                       $entities[] = new EntityId( Item::ENTITY_TYPE, 
(int)$row->entity_id );
+               }
+               return $entities;
+       }
 }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I032208726699d104c8ee76ef97e3f61b5f78f334
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Tpt <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: Denny Vrandecic <[email protected]>
Gerrit-Reviewer: Jeroen De Dauw <[email protected]>
Gerrit-Reviewer: John Erling Blad <[email protected]>
Gerrit-Reviewer: Lydia Pintscher <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: Tpt <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to