Jhernandez has uploaded a new change for review.

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

Change subject: WIP: Add Special:Collections page to menu
......................................................................

WIP: Add Special:Collections page to menu

** Just an empty page. More work on following patches

Change-Id: I6bbfc5f0438ec0925039e11edfd0c5d491de7623
---
M MobileFrontend.alias.php
M MobileFrontend.php
M i18n/en.json
M i18n/qqq.json
M includes/skins/SkinMinervaAlpha.php
A includes/specials/SpecialCollections.php
A includes/views/MobileCollectionView.php
A includes/views/MobileView.php
8 files changed, 125 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/96/187396/1

diff --git a/MobileFrontend.alias.php b/MobileFrontend.alias.php
index 9d1dc0d..80459c2 100644
--- a/MobileFrontend.alias.php
+++ b/MobileFrontend.alias.php
@@ -11,6 +11,7 @@
 
 /** English (English) */
 $specialPageAliases['en'] = array(
+       'Collections' => array( 'Collections' ),
        'History' => array( 'History' ),
        'MobileOptions' => array( 'MobileOptions' ),
        'Uploads' => array( 'Uploads' ),
diff --git a/MobileFrontend.php b/MobileFrontend.php
index e8b8dce..6196e56 100644
--- a/MobileFrontend.php
+++ b/MobileFrontend.php
@@ -64,6 +64,9 @@
        'MobileWatchlistCollection' => 'models/MobileWatchlistCollection',
        'MobilePage' => 'models/MobilePage',
 
+       'MobileView' => 'views/MobileView',
+       'MobileCollectionView' => 'views/MobileCollectionView',
+
        'MobileUI' => 'MobileUI',
        'MobileUserInfo' => 'MobileUserInfo',
 
@@ -79,6 +82,7 @@
        'SpecialUploads' => 'specials/SpecialUploads',
        'SpecialUserProfile' => 'specials/SpecialUserProfile',
        'SpecialMobileHistory' => 'specials/SpecialMobileHistory',
+       'SpecialCollections' => 'specials/SpecialCollections',
        'SpecialMobileDiff' => 'specials/SpecialMobileDiff',
        'SpecialMobileEditor' => 'specials/SpecialMobileEditor',
        'SpecialMobileOptions' => 'specials/SpecialMobileOptions',
@@ -159,6 +163,7 @@
 
 // use array_merge to ensure we do not override existing values set by core
 $wgSpecialPages = array_merge( $wgSpecialPages, array(
+       'Collections' => 'SpecialCollections',
        'History' => 'SpecialMobileHistory',
        'MobileDiff' => 'SpecialMobileDiff',
        'MobileEditor' => 'SpecialMobileEditor',
diff --git a/i18n/en.json b/i18n/en.json
index 9268874..92ae872 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -399,5 +399,6 @@
        "mobile-frontend-time-precision-BCE-0annum": "$1 BCE",
        "mobile-frontend-days-ago": "$1 {{PLURAL:$1|day|days}} ago",
        "mobile-frontend-months-ago": "$1 {{PLURAL:$1|month|months}} ago",
-       "mobile-frontend-years-ago": "$1 {{PLURAL:$1|year|years}} ago"
+       "mobile-frontend-years-ago": "$1 {{PLURAL:$1|year|years}} ago",
+       "mobile-frontend-main-menu-collections": "Collections"
 }
diff --git a/i18n/qqq.json b/i18n/qqq.json
index ab911d8..f010f04 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -427,5 +427,6 @@
        "mobile-frontend-time-precision-BCE-0annum": "Used to present a point 
in time BCE (before current era) with the precision of a year",
        "mobile-frontend-days-ago": "Expression of duration of time passed in 
days.\nParameter:\n* $1 - number of days that have passed.",
        "mobile-frontend-months-ago": "Expression of duration of time passed in 
months.\nParameter:\n * $1 - number of months that have passed.",
-       "mobile-frontend-years-ago": "Expression of duration of time passed in 
years.\nParameter:\n * $1 - number of years that have passed."
+       "mobile-frontend-years-ago": "Expression of duration of time passed in 
years.\nParameter:\n * $1 - number of years that have passed.",
+       "mobile-frontend-main-menu-collections": "Experimental feature on 
mobile."
 }
diff --git a/includes/skins/SkinMinervaAlpha.php 
b/includes/skins/SkinMinervaAlpha.php
index 103e95e..bd0986c 100644
--- a/includes/skins/SkinMinervaAlpha.php
+++ b/includes/skins/SkinMinervaAlpha.php
@@ -90,6 +90,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( 'Collections' ) ),
+                                               'class' => MobileUI::iconClass( 
'watchlist', 'before' ),
+                                       ),
+                               ),
+                       ),
+               );
+               return array_merge( $items, parent::getPersonalTools() );
+       }
+
+       /**
+        * {@inheritdoc}
+        */
        protected function getDiscoveryTools() {
                global $wgMFEnableWikiGrok, $wgMFEnableWikiGrokInSidebar, 
$wgMFEnableWikiGrokForAnons;
 
diff --git a/includes/specials/SpecialCollections.php 
b/includes/specials/SpecialCollections.php
new file mode 100644
index 0000000..c920f41
--- /dev/null
+++ b/includes/specials/SpecialCollections.php
@@ -0,0 +1,49 @@
+<?php
+/**
+ * SpecialCollections.php
+ */
+
+/**
+ * Render a collection of articles.
+ */
+class SpecialCollections extends MobileSpecialPage {
+       protected $mode = 'alpha';
+
+       /**
+        * Construct function
+        */
+       public function __construct() {
+               parent::__construct( 'Collections' );
+       }
+
+       /**
+        * 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 = new MobileWatchlistCollection( 
$this->getUser() );
+                       }
+               } else {
+                       $collection = new MobileWatchlistCollection( 
$this->getUser() );
+               }
+
+               $collection->load();
+               $this->render( $collection );
+       }
+
+       public function render( $collection ) {
+               $out = $this->getOutput();
+               $this->setHeaders();
+               $title = $collection->getTitle();
+               $out->setPageTitle( $title );
+               $view = new MobileCollectionView( $collection );
+               $view->render( $out );
+       }
+}
diff --git a/includes/views/MobileCollectionView.php 
b/includes/views/MobileCollectionView.php
new file mode 100644
index 0000000..6e00869
--- /dev/null
+++ b/includes/views/MobileCollectionView.php
@@ -0,0 +1,27 @@
+<?php
+/**
+ * MobileCard.php
+ */
+
+/**
+ * Render a mobile card.
+ */
+class MobileCollectionView extends MobileView {
+       /**
+        * Constructor
+        * @param Collection $collection
+        */
+       public function __construct( $collection ) {
+               $this->collection = $collection;
+       }
+
+       /**
+        * Returns the html for a collection
+        *
+        * @protected
+        * @return string Html
+        */
+       public function getHtml() {
+               return 'Collections';
+       }
+}
diff --git a/includes/views/MobileView.php b/includes/views/MobileView.php
new file mode 100644
index 0000000..fbd77b0
--- /dev/null
+++ b/includes/views/MobileView.php
@@ -0,0 +1,21 @@
+<?php
+/**
+ * MobileCard.php
+ */
+
+/**
+ * Render a mobile card.
+ */
+abstract class MobileView {
+       /**
+        * Returns the html for the view
+        *
+        * @private
+        * @return string Html
+        */
+       abstract public function getHtml();
+
+       public function render( OutputPage $out ) {
+               $out->addHTML( $this->getHtml() );
+       }
+}

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6bbfc5f0438ec0925039e11edfd0c5d491de7623
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jhernandez <jhernan...@wikimedia.org>

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

Reply via email to