[MediaWiki-commits] [Gerrit] Add pagination to Special:GatherList - change (mediawiki...Gather)

2015-04-01 Thread jenkins-bot (Code Review)
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 
john."
+   "apihelp-gather-example-1": "List the collections for user 
john.",
+   "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 .= 

[MediaWiki-commits] [Gerrit] Add pagination to Special:GatherList - change (mediawiki...Gather)

2015-03-31 Thread Jdlrobson (Code Review)
Jdlrobson has uploaded a new change for review.

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

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 includes/specials/SpecialGatherLists.php
1 file changed, 27 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Gather 
refs/changes/43/200943/1

diff --git a/includes/specials/SpecialGatherLists.php 
b/includes/specials/SpecialGatherLists.php
index bb7769e..8220221 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,40 @@
} elseif ( $this->canHideLists() ) {
$out->addSubtitle( $this->getSubTitle( true ) );
}
+   $req = $this->getRequest();
+   $limit = 100;
+   $offset = $req->getVal( 'offset', '' );
+
// FIXME: Make method on CollectionsList
$api = new ApiMain( new FauxRequest( 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' => '',
+   'continue' => $req->getVal( 'continue', '' ),
+   'lstcontinue' => $req->getVal( 'lstcontinue', '' ),
) ) );
-   $api->execute();
-   $data = $api->getResultData();
-   if ( isset( $data['query']['lists'] ) ) {
-   $lists = $data['query']['lists'];
-   $this->render( $lists, $subPage === 'hidden' ? 'show' : 
'hide' );
+   try {
+   $api->execute();
+   $data = $api->getResultData();
+   $continue = isset( $data['continue'] ) ? 
$data['continue'] : false;
+   if ( isset( $data['query']['lists'] ) ) {
+   $lists = $data['query']['lists'];
+   $this->render( $lists, $subPage === 'hidden' ? 
'show' : 'hide' );
+   }
+   } catch ( Exception $e ) {
+   $continue = false;
+   }
+
+   if ( $continue ) {
+   $nextPageUrl = $this->getTitle()->getLocalUrl( 
$continue );
+   $out->addHTML(
+   Html::element( 'a', array(
+   'href' => $nextPageUrl,
+   ), 'older' )
+   );
}
}
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I87ff376afc20f5779a6fe5205bf66d8b4f60d9ad
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Gather
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson 

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