Jdlrobson has uploaded a new change for review.
https://gerrit.wikimedia.org/r/95561
Change subject: Story 1360: Add paging to Special:History and enable link
......................................................................
Story 1360: Add paging to Special:History and enable link
* Add more button to bottom of page to allow going back in time when
there is more history to show
* Add error message when no history is returned.
* Link to it from the last modified link
Change-Id: I8ed1607259d3babb21c29d6256379fc89dc99204
---
M MobileFrontend.i18n.php
M includes/MobileContext.php
M includes/skins/SkinMobileBeta.php
M includes/specials/SpecialHistory.php
4 files changed, 52 insertions(+), 25 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend
refs/changes/61/95561/1
diff --git a/MobileFrontend.i18n.php b/MobileFrontend.i18n.php
index bfcf1b3..05fb7f9 100644
--- a/MobileFrontend.i18n.php
+++ b/MobileFrontend.i18n.php
@@ -81,7 +81,7 @@
'mobile-frontend-password-placeholder' => 'Password',
'mobile-frontend-login' => 'Sign in',
'mobile-frontend-history' => 'View edit history of this page.',
- 'mobile-frontend-history-404-title' => 'Bad title given',
+ 'mobile-frontend-history-no-results' => 'No history matches the filter
provided.',
'mobile-frontend-history-404-desc' => "Cannot look at history for a
page that doesn't exist. It may have been deleted or you may have followed a
bad link.",
'mobile-frontend-history-summary' => 'Page history for [[:$1]]',
'mobile-frontend-last-modified-date' => 'Last modified on $1, at $2',
@@ -497,6 +497,7 @@
If not the Main Page, the following message is used:
* {{msg-mw|Mobile-frontend-last-modified-date}}',
+ 'mobile-frontend-history-no-results' => 'Error shown when there are no
history entires for a given/invalid filter.',
'mobile-frontend-history-404-title' => 'Title of the 404 error page
shown when navigate to [[Special:History/Title of page that does not exist]]',
'mobile-frontend-history-404-desc' => 'Explain the reasons why the user
may have arrived on {{msg-mw|mobile-frontend-history-404-title}}',
'mobile-frontend-history-summary' => 'Summary text that appears at the
top of the mobile history page for a given page.
diff --git a/includes/MobileContext.php b/includes/MobileContext.php
index 58a8219..0e2d033 100644
--- a/includes/MobileContext.php
+++ b/includes/MobileContext.php
@@ -293,10 +293,10 @@
*/
private function shouldDisplayMobileViewInternal() {
global $wgMobileUrlTemplate;
- // always display non-mobile view for edit/history/diff
+ $ctx = MobileContext::singleton();
$action = $this->getAction();
- if ( $action === 'history' ) {
+ if ( $action === 'history' && !$ctx->isBetaGroupMember() ) {
return false;
}
diff --git a/includes/skins/SkinMobileBeta.php
b/includes/skins/SkinMobileBeta.php
index a4862a5..06b7d3c 100644
--- a/includes/skins/SkinMobileBeta.php
+++ b/includes/skins/SkinMobileBeta.php
@@ -35,6 +35,7 @@
if ( !$title->isMainPage() ) {
$link['class'] = 'top-bar';
}
+ $link['href'] = SpecialPage::getTitleFor( 'History', $title
)->getLocalURL();
return $link;
}
diff --git a/includes/specials/SpecialHistory.php
b/includes/specials/SpecialHistory.php
index 7fc0224..795f53c 100644
--- a/includes/specials/SpecialHistory.php
+++ b/includes/specials/SpecialHistory.php
@@ -3,6 +3,8 @@
class SpecialHistory extends MobileSpecialPageFeed {
const LIMIT = 50;
protected $mode = 'beta';
+ /** @var String|null timestamp to offset results from */
+ protected $offset;
/** @var Title|null if no title passed */
protected $title;
@@ -16,6 +18,7 @@
$out = $this->getOutput();
$out->setPageTitle( $this->msg( 'history' ) );
+ $this->offset = $this->getRequest()->getVal( 'offset', false );
if ( $par ) {
// enter article history view
$this->title = Title::newFromText( $par );
@@ -41,12 +44,13 @@
protected function doQuery() {
wfProfileIn( __METHOD__ );
$table = 'revision';
+ $dbr = wfGetDB( DB_SLAVE, $table );
+ $conds = array();
+ if ( $this->offset ) {
+ $conds[] = 'rev_timestamp <= ' . $dbr->addQuotes(
$this->offset );
+ }
if ( $this->title ) {
- $conds = array(
- 'rev_page' => $this->title->getArticleID(),
- );
- } else {
- $conds = array();
+ $conds['rev_page'] = $this->title->getArticleID();
}
$options = array(
'ORDER BY' => 'rev_timestamp DESC',
@@ -56,7 +60,6 @@
$options['LIMIT'] = self::LIMIT + 1;
$tables = array( $table );
- $dbr = wfGetDB( DB_SLAVE, $table );
$fields = array( '*' );
wfProfileIn( __METHOD__ . '-query' );
@@ -112,28 +115,50 @@
wfProfileOut( __METHOD__ );
}
+ protected function getMoreButton( $ts ) {
+ $attrs = array(
+ 'href' => $this->getContext()->getTitle()->
+ getLocalUrl(
+ array(
+ 'offset' => $ts,
+ )
+ ),
+ 'class' => 'more',
+ );
+ return Html::element( 'a', $attrs, 'more' );
+ }
+
protected function showHistory( ResultWrapper $res ) {
+ $numRows = $res->numRows();
$rev1 = $rev2 = null;
$out = $this->getOutput();
- $out->addHtml(
- Html::openElement( 'ul',
- array(
- 'class' => 'page-list'
+ if ( $numRows > 0 ) {
+ $out->addHtml(
+ Html::openElement( 'ul',
+ array(
+ 'class' => 'page-list'
+ )
)
- )
- );
+ );
- foreach ( $res as $row ) {
- $rev1 = new Revision( $row );
- if ( $rev2 ) {
- $this->showRow( $rev2, $rev1 );
+ foreach ( $res as $row ) {
+ $rev1 = new Revision( $row );
+ if ( $rev2 ) {
+ $this->showRow( $rev2, $rev1 );
+ }
+ $rev2 = $rev1;
}
- $rev2 = $rev1;
+ if ( $rev1 && $numRows < self::LIMIT + 1 ) {
+ $this->showRow( $rev1, null );
+ }
+ $out->addHtml( '</ul>' );
+ // Captured 1 more than we should have done so if the
number of results is greater than the limit there are more to show
+ if ( $numRows > self::LIMIT ) {
+ $out->addHtml( $this->getMoreButton(
$rev1->getTimestamp() ) );
+ }
+ } else {
+ $out->addHtml( Html::element( 'div', array( 'class' =>
'error alert' ),
+ $this->msg(
'mobile-frontend-history-no-results' ) ) );
}
- if ( $rev1 && $res->numRows() < self::LIMIT + 1 ) {
- $this->showRow( $rev1, null );
- }
- $out->addHtml( '</ul>' );
- // @todo: paging
}
}
--
To view, visit https://gerrit.wikimedia.org/r/95561
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8ed1607259d3babb21c29d6256379fc89dc99204
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits