jenkins-bot has submitted this change and it was merged. Change subject: Special:Gather and collections overlay should use API ......................................................................
Special:Gather and collections overlay should use API Breaking changes: * Temporarily this prevents viewing of lists other than your own. For example: Currently http://127.0.0.1:8080/wiki/Special:Gather/Max is showing the collections that belong to http://127.0.0.1:8080/wiki/Special:Gather/Jdlrobson * Sets number of articles on list to -1 rather than true value Change-Id: Icca5cf432f8de6aef461c7d59947340a1056c553 --- M includes/Gather.hooks.php M includes/models/CollectionsList.php M includes/specials/SpecialGather.php 3 files changed, 37 insertions(+), 3 deletions(-) Approvals: Robmoen: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/Gather.hooks.php b/includes/Gather.hooks.php index 584cf14..0cba4b5 100644 --- a/includes/Gather.hooks.php +++ b/includes/Gather.hooks.php @@ -7,6 +7,7 @@ use \SpecialPage; use Gather\stores; +use Gather\models; use Gather\views\helpers\CSS; use \MobileContext; @@ -130,7 +131,7 @@ public static function onMakeGlobalVariablesScript( &$vars, $out ) { $user = $out->getUser(); if ( !$user->isAnon() ) { - $collectionsList = stores\UserPageCollectionsList::newFromUser( $user, true ); + $collectionsList = models\CollectionsList::newFromApi( $user, true ); $gatherCollections = array(); foreach ( $collectionsList as $collectionInfo ) { $id = $collectionInfo->getId(); diff --git a/includes/models/CollectionsList.php b/includes/models/CollectionsList.php index 38dbe20..c87c4e4 100644 --- a/includes/models/CollectionsList.php +++ b/includes/models/CollectionsList.php @@ -6,8 +6,11 @@ namespace Gather\models; +use \User; use Gather\models; use \ArrayIterator; +use \ApiMain; +use \FauxRequest; class CollectionsList implements \IteratorAggregate, ArraySerializable { @@ -75,5 +78,34 @@ return $arr; } + /** + * Generate UserPageCollectionsList from api result + * FIXME: $user parameter currently ignored + * @param User $user collection list owner (currently ignored) + * @param boolean $includePrivate if the list should show private collections or not + * @return models\CollectionsList List of collections. + */ + public static function newFromApi( User $user, $includePrivate = false ) { + $collectionsList = new CollectionsList( $includePrivate ); + $api = new ApiMain( new FauxRequest( array( + 'action' => 'query', + 'list' => 'lists', + ) ) ); + $api->execute(); + $data = $api->getResultData(); + if ( isset( $data['query']['lists'] ) ) { + $lists = $data['query']['lists']; + foreach ( $lists as $list ) { + if ( $list['isPublic'] || $includePrivate ) { + $info = new models\CollectionInfo( $list['id'], $user, + $list['label'], $list['description'], $list['isPublic'] ); + // FIXME: API should return the number of items in each list + $info->setCount( -1 ); + $collectionsList->add( $info ); + } + } + } + return $collectionsList; + } } diff --git a/includes/specials/SpecialGather.php b/includes/specials/SpecialGather.php index 1d48ebc..dfdd0c4 100644 --- a/includes/specials/SpecialGather.php +++ b/includes/specials/SpecialGather.php @@ -100,8 +100,9 @@ * @param User $user owner of collections */ public function renderUserCollectionsList( User $user ) { - $collectionsList = stores\UserPageCollectionsList::newFromUser( $user, $this->isOwner( $user ) ); - if ( $collectionsList->getCount() > 0 ) { + $collectionsList = models\CollectionsList::newFromApi( $user, $this->isOwner( $user ) ); + // FIXME: Remove when CollectionsList::newFromApi supports access of other peoples lists + if ( $this->isOwner( $user ) && $collectionsList->getCount() > 0 ) { $this->render( new views\CollectionsList( $collectionsList ) ); } else { $this->renderError( new views\NoPublic() ); -- To view, visit https://gerrit.wikimedia.org/r/195621 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Icca5cf432f8de6aef461c7d59947340a1056c553 Gerrit-PatchSet: 7 Gerrit-Project: mediawiki/extensions/Gather Gerrit-Branch: master Gerrit-Owner: Jdlrobson <jrob...@wikimedia.org> Gerrit-Reviewer: Jdlrobson <jrob...@wikimedia.org> Gerrit-Reviewer: Jhernandez <jhernan...@wikimedia.org> Gerrit-Reviewer: Robmoen <rm...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits