Addshore has uploaded a new change for review.
https://gerrit.wikimedia.org/r/230063
Change subject: Add paging to ListProperties
......................................................................
Add paging to ListProperties
Bug: T98437
Change-Id: Iee8af979efae7ad527096257545aedb88670f934
---
M repo/includes/specials/SpecialListProperties.php
1 file changed, 41 insertions(+), 24 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/63/230063/1
diff --git a/repo/includes/specials/SpecialListProperties.php
b/repo/includes/specials/SpecialListProperties.php
index 1c31a6f..2c6a994 100644
--- a/repo/includes/specials/SpecialListProperties.php
+++ b/repo/includes/specials/SpecialListProperties.php
@@ -6,6 +6,7 @@
use Html;
use Wikibase\DataModel\Entity\PropertyId;
use Wikibase\DataTypeSelector;
+use Wikibase\Lib\EntityIdFormatter;
use Wikibase\PropertyInfoStore;
use Wikibase\Repo\LanguageFallbackLabelDescriptionLookupFactory;
use Wikibase\Repo\WikibaseRepo;
@@ -51,6 +52,16 @@
* @var string
*/
private $dataType;
+
+ /**
+ * @var PropertyId[]
+ */
+ private $propertyIds = array();
+
+ /**
+ * @var EntityIdFormatter
+ */
+ private $entityIdFormatter;
public function __construct() {
parent::__construct( 'ListProperties' );
@@ -173,29 +184,29 @@
);
}
- protected function showQuery( array $query = array() ) {
- $propertyIds = $this->getResult();
+ /**
+ * Formats a row for display.
+ *
+ * @param PropertyId $propertyId
+ *
+ * @return string
+ */
+ protected function formatRow( $propertyId ) {
+ $entityIdFormatter = $this->getEntityIdFormater();
+ return $entityIdFormatter->formatEntityId( $propertyId );
+ }
- if ( empty( $propertyIds ) ) {
- $this->getOutput()->addWikiMsg( 'specialpage-empty' );
- return;
+ private function getEntityIdFormater() {
+ if ( !isset( $this->entityIdFormatter ) ) {
+ $labelDescriptionLookup =
$this->labelDescriptionLookupFactory->newLabelDescriptionLookup(
+ $this->getLanguage(),
+ $this->propertyIds
+ );
+ $this->entityIdFormatter =
$this->entityIdFormatterFactory->getEntityIdFormater(
+ $labelDescriptionLookup
+ );
}
-
- $labelDescriptionLookup =
$this->labelDescriptionLookupFactory->newLabelDescriptionLookup(
- $this->getLanguage(),
- $propertyIds
- );
-
- $formatter =
$this->entityIdFormatterFactory->getEntityIdFormater( $labelDescriptionLookup );
-
- $html = Html::openElement( 'ul' );
-
- foreach ( $propertyIds as $propertyId ) {
- $html .= Html::rawElement( 'li', array(),
$formatter->formatEntityId( $propertyId ) );
- }
-
- $html .= Html::closeElement( 'ul' );
- $this->getOutput()->addHTML( $html );
+ return $this->entityIdFormatter;
}
/**
@@ -206,17 +217,23 @@
*/
protected function getResult( $offset = 0, $limit = 0 ) {
if ( $this->dataType === '' ) {
- $propertyInfoForDataType =
$this->propertyInfoStore->getAllPropertyInfo();
+ $propertyInfo =
$this->propertyInfoStore->getAllPropertyInfo();
} else {
- $propertyInfoForDataType =
$this->propertyInfoStore->getPropertyInfoForDataType( $this->dataType );
+ $propertyInfo =
$this->propertyInfoStore->getPropertyInfoForDataType(
+ $this->dataType
+ );
}
+
+ $propertyInfo = array_slice( $propertyInfo, $offset, null, true
);
$propertyIds = array();
- foreach ( $propertyInfoForDataType as $numericId => $info ) {
+ foreach ( $propertyInfo as $numericId => $info ) {
$propertyIds[] = PropertyId::newFromNumber( $numericId
);
}
+ $this->propertyIds = $propertyIds;
+
return $propertyIds;
}
--
To view, visit https://gerrit.wikimedia.org/r/230063
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iee8af979efae7ad527096257545aedb88670f934
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Addshore <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits