jenkins-bot has submitted this change and it was merged.

Change subject: Add pagination to Special:GatherList
......................................................................


Add pagination to Special:GatherList

Infinite scroll and pagination for other things will come in a later
patch.

Bug: T94515
Change-Id: I87ff376afc20f5779a6fe5205bf66d8b4f60d9ad
---
M i18n/en.json
M i18n/qqq.json
M includes/specials/SpecialGatherLists.php
M resources/ext.gather.styles/lists.less
4 files changed, 35 insertions(+), 12 deletions(-)

Approvals:
  Jhernandez: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/i18n/en.json b/i18n/en.json
index a9b9a06..b9f00a9 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -76,5 +76,6 @@
        "apihelp-gather-description": "List and edit gather collections.",
        "apihelp-gather-param-gather": "Action to perform on collections.",
        "apihelp-gather-param-owner": "Owner of the collections to search for. 
If omitted, defaults to current user.",
-       "apihelp-gather-example-1": "List the collections for user 
<kbd>john</kbd>."
+       "apihelp-gather-example-1": "List the collections for user 
<kbd>john</kbd>.",
+       "gather-lists-collection-more-link-label": "View more public 
collections."
 }
diff --git a/i18n/qqq.json b/i18n/qqq.json
index a38cbb7..d0d452e 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -79,5 +79,6 @@
        "apihelp-gather-description": "{{doc-apihelp-description|gather}}",
        "apihelp-gather-param-gather": "{{doc-apihelp-param|gather|gather}}",
        "apihelp-gather-param-owner": "{{doc-apihelp-param|gather|owner}}",
-       "apihelp-gather-example-1": "{{doc-apihelp-example|gather}}"
+       "apihelp-gather-example-1": "{{doc-apihelp-example|gather}}",
+       "gather-lists-collection-more-link-label": "Link label for a more type 
link on the Special:GatherLists page."
 }
diff --git a/includes/specials/SpecialGatherLists.php 
b/includes/specials/SpecialGatherLists.php
index bb7769e..c3a346b 100644
--- a/includes/specials/SpecialGatherLists.php
+++ b/includes/specials/SpecialGatherLists.php
@@ -13,6 +13,7 @@
 use Linker;
 use Gather\views\helpers\CSS;
 use MWTimestamp;
+use Exception;
 
 /**
  * Render a collection of articles.
@@ -57,21 +58,32 @@
                } elseif ( $this->canHideLists() ) {
                        $out->addSubtitle( $this->getSubTitle( true ) );
                }
+               $req = $this->getRequest();
+               $limit = 100;
+
                // FIXME: Make method on CollectionsList
-               $api = new ApiMain( new FauxRequest( array(
+               $api = new ApiMain( new FauxRequest( array_merge( array(
                        'action' => 'query',
                        'list' => 'lists',
                        'lstmode' => $subPage === 'hidden' ? 'allhidden' : 
'allpublic',
+                       'lstlimit' => $limit,
                        // FIXME: Need owner to link to collection
                        'lstprop' => 
'label|description|image|count|updated|owner',
-                       // TODO: Pagination
                        'continue' => '',
-               ) ) );
-               $api->execute();
-               $data = $api->getResultData();
-               if ( isset( $data['query']['lists'] ) ) {
-                       $lists = $data['query']['lists'];
-                       $this->render( $lists, $subPage === 'hidden' ? 'show' : 
'hide' );
+               ), $req->getValues() ) ) );
+               try {
+                       $api->execute();
+                       $data = $api->getResultData();
+                       if ( isset( $data['query']['lists'] ) ) {
+                               $lists = $data['query']['lists'];
+                               if ( isset( $data['continue'] ) ) {
+                                       $nextPageUrl = 
$this->getTitle()->getLocalUrl( $data['continue'] );
+                               } else {
+                                       $nextPageUrl = '';
+                               }
+                               $this->render( $lists, $subPage === 'hidden' ? 
'show' : 'hide', $nextPageUrl );
+                       }
+               } catch ( Exception $e ) {
                }
        }
 
@@ -91,9 +103,10 @@
         * Render the special page
         *
         * @param array $lists
-        * @param string [$action] hide or show - action to associate with the 
row.
+        * @param string $action hide or show - action to associate with the 
row.
+        * @param string $nextPageUrl url to access the next page of results.
         */
-       public function render( $lists, $action ) {
+       public function render( $lists, $action, $nextPageUrl = '' ) {
                $out = $this->getOutput();
                $this->setHeaders();
                $out->setProperty( 'unstyledContent', true );
@@ -117,6 +130,12 @@
                        $html .= $this->row( $list, $action );
                }
                $html .= Html::closeElement( 'ul' );
+               if ( $nextPageUrl ) {
+                       $html .= Html::element( 'a', array(
+                                       'href' => $nextPageUrl,
+                                       'class' => CSS::buttonClass( 
'progressive', 'more-collections' ),
+                               ), wfMessage( 
'gather-lists-collection-more-link-label' ) );
+               }
                $html .= Html::closeElement( 'div' );
 
                $out->addHTML( $html );
diff --git a/resources/ext.gather.styles/lists.less 
b/resources/ext.gather.styles/lists.less
index b362968..9fce8de 100644
--- a/resources/ext.gather.styles/lists.less
+++ b/resources/ext.gather.styles/lists.less
@@ -7,6 +7,7 @@
        ul {
                display: table;
                width: 100%;
+               margin-bottom: 1em;
 
                li {
                        display: table-row;
@@ -18,6 +19,7 @@
                                        border-width: 0px;
                                        border-bottom: 2px solid #444;
                                        text-align: center;
+                                       vertical-align: bottom;
                                }
                        }
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I87ff376afc20f5779a6fe5205bf66d8b4f60d9ad
Gerrit-PatchSet: 3
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: Yurik <yu...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to