Jdlrobson has uploaded a new change for review.
https://gerrit.wikimedia.org/r/182984
Change subject: WIP: Add Special:MobileCollections to alpha left nav
......................................................................
WIP: Add Special:MobileCollections to alpha left nav
Change-Id: I4220deeb1051b1b21de333752fb3a5afa8d257ea
---
M MobileFrontend.alias.php
M MobileFrontend.php
M i18n/en.json
M i18n/qqq.json
M includes/skins/SkinMinervaAlpha.php
A includes/specials/SpecialMobileCollections.php
6 files changed, 112 insertions(+), 2 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend
refs/changes/84/182984/1
diff --git a/MobileFrontend.alias.php b/MobileFrontend.alias.php
index 0782994..29552bb 100644
--- a/MobileFrontend.alias.php
+++ b/MobileFrontend.alias.php
@@ -11,6 +11,7 @@
/** English (English) */
$specialPageAliases['en'] = array(
+ 'Collections' => array( 'MobileCollections' ),
'History' => array( 'History' ),
'MobileOptions' => array( 'MobileOptions' ),
'Uploads' => array( 'Uploads' ),
diff --git a/MobileFrontend.php b/MobileFrontend.php
index 16c1872..ea5af0b 100644
--- a/MobileFrontend.php
+++ b/MobileFrontend.php
@@ -74,6 +74,7 @@
'SpecialUploads' => 'specials/SpecialUploads',
'SpecialUserProfile' => 'specials/SpecialUserProfile',
'SpecialMobileHistory' => 'specials/SpecialMobileHistory',
+ 'SpecialMobileCollections' => 'specials/SpecialMobileCollections',
'SpecialMobileDiff' => 'specials/SpecialMobileDiff',
'SpecialMobileEditor' => 'specials/SpecialMobileEditor',
'SpecialMobileOptions' => 'specials/SpecialMobileOptions',
@@ -152,6 +153,7 @@
// use array_merge to ensure we do not override existing values set by core
$wgSpecialPages = array_merge( $wgSpecialPages, array(
+ 'Collections' => 'SpecialMobileCollections',
'History' => 'SpecialMobileHistory',
'MobileDiff' => 'SpecialMobileDiff',
'MobileEditor' => 'SpecialMobileEditor',
diff --git a/i18n/en.json b/i18n/en.json
index b6f4697..066b6b6 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -371,5 +371,6 @@
"apihelp-parse-param-mainpage": "Apply mobile main page
transformations.",
"mobile-frontend-donate-button-label": "Donate",
"mobile-frontend-wikidata-editor-description-label": "Describe ''$1''
in a single sentence:",
- "mobile-frontend-meta-data-issues-categories": "About this category"
+ "mobile-frontend-meta-data-issues-categories": "About this category",
+ "mobile-frontend-main-menu-collections": "Collections"
}
diff --git a/i18n/qqq.json b/i18n/qqq.json
index c31d6a3..928fe5e 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -398,5 +398,6 @@
"apihelp-parse-param-mainpage": "{{doc-apihelp-param|parse|mainpage}}",
"mobile-frontend-donate-button-label": "Message for donation button in
mobile interface at bottom of page.\n{{Identical|Donate}}",
"mobile-frontend-wikidata-editor-description-label": "Appears above an
editable input field for wikidata description\n* $1 - Title of page for which
description is being edited.",
- "mobile-frontend-meta-data-issues-categories": "Label to appear in
button that opens issue overlay on categories."
+ "mobile-frontend-meta-data-issues-categories": "Label to appear in
button that opens issue overlay on categories.",
+ "mobile-frontend-main-menu-collections": "Experimental feature on
mobile."
}
diff --git a/includes/skins/SkinMinervaAlpha.php
b/includes/skins/SkinMinervaAlpha.php
index 9b79713..8e80315 100644
--- a/includes/skins/SkinMinervaAlpha.php
+++ b/includes/skins/SkinMinervaAlpha.php
@@ -116,6 +116,24 @@
/**
* {@inheritdoc}
*/
+ protected function getPersonalTools() {
+ $items = array(
+ 'collections' => array(
+ 'links' => array(
+ array(
+ 'text' => wfMessage(
'mobile-frontend-main-menu-collections' )->escaped(),
+ 'href' =>
$this->getPersonalUrl( SpecialPage::getTitleFor( 'MobileCollections' ) ),
+ 'class' => MobileUI::iconClass(
'watchlist', 'before' ),
+ ),
+ ),
+ ),
+ );
+ return array_merge( $items, parent::getPersonalTools() );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
protected function getDiscoveryTools() {
global $wgMFEnableWikiGrok, $wgMFEnableWikiGrokInSidebar,
$wgMFEnableWikiGrokForAnons;
diff --git a/includes/specials/SpecialMobileCollections.php
b/includes/specials/SpecialMobileCollections.php
new file mode 100644
index 0000000..3ed4b01
--- /dev/null
+++ b/includes/specials/SpecialMobileCollections.php
@@ -0,0 +1,87 @@
+<?php
+/**
+ * SpecialMobileCollections.php
+ */
+
+/**
+ * Render a collection of articles.
+ */
+class SpecialMobileCollections extends MobileSpecialPage {
+ /**
+ * Construct function
+ */
+ public function __construct() {
+ parent::__construct( 'MobileCollections' );
+ }
+
+ /**
+ * Render the special page and redirect the user to the editor (if page
exists)
+ * @param string $subpage The name of the page to edit
+ */
+ public function executeWhenAvailable( $subpage ) {
+ if ( $subpage ) {
+ $args = explode( '/', $subpage );
+ $user = User::newFromName( $args[0] );
+ if ( isset( $args[1] ) ) {
+ // check permissions
+ // getCollection( id )
+ } else {
+ $collection = $this->getWatchlistCollection();
+ }
+ } else {
+ $collection = $this->getWatchlistCollection();
+ $user = $this->getUser();
+ }
+
+ // FIXME: i18n
+ $title = $user->getName() . ' collections';
+ $this->render( $title, $collection );
+ }
+
+ public function render( $title, $collection ) {
+ $this->getOutput()->setPageTitle( $title );
+ foreach ( $collection as $mobilePage ) {
+ $html = Html::openElement( 'div' ) .
+ Html::element( 'h2', array(),
$mobilePage->getTitle()->getText() ) .
+ $mobilePage->getMediumThumbnailHtml() .
+ '<p>Lorem ipsum dolor sit amet, consectetur
adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi
ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in
voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim
id est laborum.</p>' .
+ Html::closeElement( 'div' );
+ $this->getOutput()->addHTML( $html );
+ }
+ }
+
+ // FIXME: Copy and pasted from core. yuk. why isn't this abstracted?
+ private function getWatchlistCollection() {
+ $collection = new MobileCollection();
+ $list = array();
+ $dbr = wfGetDB( DB_MASTER );
+
+ $res = $dbr->select(
+ 'watchlist',
+ array(
+ 'wl_namespace', 'wl_title'
+ ), array(
+ 'wl_user' => $this->getUser()->getId(),
+ 'wl_namespace' => 0,
+ ),
+ __METHOD__
+ );
+
+ if ( $res->numRows() > 0 ) {
+ $titles = array();
+ foreach ( $res as $row ) {
+ $title = Title::makeTitleSafe(
$row->wl_namespace, $row->wl_title );
+ $titles[] = $title;
+ }
+ $res->free();
+
+ GenderCache::singleton()->doTitlesArray( $titles );
+
+ foreach ( $titles as $title ) {
+ // FIXME: Page image.
+ $collection->add( new MobilePage( $title ) );
+ }
+ }
+ return $collection;
+ }
+}
--
To view, visit https://gerrit.wikimedia.org/r/182984
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4220deeb1051b1b21de333752fb3a5afa8d257ea
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