Jhernandez has uploaded a new change for review.

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

Change subject: Fix namespace references and errors
......................................................................

Fix namespace references and errors

Since we are using "namespace Gather;" in our php files, then:
* Classes from the Gather namespace are properly resolved, no need to do
  Gather\Collection on the code.
* Global class names try to be resolved from the Gather namespace (and fail,
  because global). In each file, I'm declaring with "use" the global classes
  used on such file.

Also:
* Fix a missnamed variable "CollectionList --> CollectionsList"

Change-Id: I6b2f75d569ce72fe20f9b0273f34f661c5aa3748
---
M includes/models/Collection.php
M includes/models/CollectionsList.php
M includes/specials/SpecialGather.php
M includes/stores/WatchlistCollectionStore.php
M includes/views/CollectionItemCardView.php
M includes/views/CollectionView.php
M includes/views/CollectionsListItemCardView.php
M includes/views/CollectionsListView.php
M includes/views/UserNotFoundView.php
M includes/views/View.php
10 files changed, 67 insertions(+), 32 deletions(-)


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

diff --git a/includes/models/Collection.php b/includes/models/Collection.php
index 2114b90..4128009 100644
--- a/includes/models/Collection.php
+++ b/includes/models/Collection.php
@@ -6,6 +6,13 @@
 
 namespace Gather;
 
+use \User as User;
+use \Title as Title;
+use \IteratorAggregate as IteratorAggregate;
+use \ArrayIterator as ArrayIterator;
+use \MobilePage as MobilePage;
+use \SpecialPage as SpecialPage;
+
 /**
  * A collection of pages, which are represented by the MobilePage class.
  */
diff --git a/includes/models/CollectionsList.php 
b/includes/models/CollectionsList.php
index 4e20490..d81c5fe 100644
--- a/includes/models/CollectionsList.php
+++ b/includes/models/CollectionsList.php
@@ -6,12 +6,16 @@
 
 namespace Gather;
 
+use \User as User;
+use \IteratorAggregate as IteratorAggregate;
+use \ArrayIterator as ArrayIterator;
+
 /**
  * A list of collections, which are represented by the Collection class.
  */
 class CollectionsList implements IteratorAggregate {
        /**
-        * @var Gather\Collection[] Internal list of collections.
+        * @var Collection[] Internal list of collections.
         */
        protected $lists = array();
 
@@ -32,7 +36,7 @@
                // Get watchlist collection (private)
                // Directly avoid adding if not owner
                if ( $includePrivate ) {
-                       $watchlist = new Gather\Collection(
+                       $watchlist = new Collection(
                                $user,
                                wfMessage( 'gather-watchlist-title' ),
                                wfMessage( 'gather-watchlist-description' ),
@@ -51,9 +55,9 @@
         * If the collection to add is private, and this collection list does 
not include
         * private items, the collection won't be added
         *
-        * @param Gather\Collection $collection
+        * @param Collection $collection
         */
-       public function add( Gather\Collection $collection ) {
+       public function add( Collection $collection ) {
                if ( $this->includePrivate ||
                        ( !$this->includePrivate && $collection->isPublic() ) ) 
{
                        $this->lists[] = $collection;
diff --git a/includes/specials/SpecialGather.php 
b/includes/specials/SpecialGather.php
index 3af1499..abf59f3 100644
--- a/includes/specials/SpecialGather.php
+++ b/includes/specials/SpecialGather.php
@@ -5,6 +5,9 @@
 
 namespace Gather;
 
+use \User as User;
+use \SpecialPage as SpecialPage;
+
 /**
  * Render a collection of articles.
  */
@@ -54,7 +57,7 @@
         * Render an error when the user was not found
         */
        public function renderUserNotFoundError() {
-               $this->render( new Gather\UserNotFoundView() );
+               $this->render( new UserNotFoundView() );
        }
 
        /**
@@ -64,7 +67,7 @@
         * @param int $id collection id
         */
        public function renderUserCollection( User $user, $id ) {
-               $collection = new Gather\Collection(
+               $collection = new Collection(
                        $user,
                        $this->msg( 'gather-watchlist-title' ),
                        $this->msg( 'gather-watchlist-description' )
@@ -79,7 +82,7 @@
                }
                // FIXME: For empty-collection and not-allowed-to-see-this we 
are doing the
                // same thing right now.
-               $this->render( new Gather\CollectionView( $collection ) );
+               $this->render( new CollectionView( $collection ) );
        }
 
        /**
@@ -88,8 +91,8 @@
         * @param User $user owner of collections
         */
        public function renderUserCollectionsList( User $user ) {
-               $collectionsList = new Gather\CollectionsList( $user, 
$this->isOwner( $user ) );
-               $this->render( new Gather\CollectionsListView( $collectionsList 
) );
+               $collectionsList = new CollectionsList( $user, $this->isOwner( 
$user ) );
+               $this->render( new CollectionsListView( $collectionsList ) );
        }
 
        /**
diff --git a/includes/stores/WatchlistCollectionStore.php 
b/includes/stores/WatchlistCollectionStore.php
index 0936a0d..17a7a14 100644
--- a/includes/stores/WatchlistCollectionStore.php
+++ b/includes/stores/WatchlistCollectionStore.php
@@ -1,5 +1,11 @@
 <?php
 
+namespace Gather;
+
+use \User as User;
+use \Title as Title;
+use \GenderCache as GenderCache;
+
 /**
  * Abstraction for watchlist storage.
  * FIXME: This should live in core and power Special:EditWatchlist
diff --git a/includes/views/CollectionItemCardView.php 
b/includes/views/CollectionItemCardView.php
index a1c3100..7629a14 100644
--- a/includes/views/CollectionItemCardView.php
+++ b/includes/views/CollectionItemCardView.php
@@ -5,10 +5,14 @@
 
 namespace Gather;
 
+use \MobilePage as MobilePage;
+use \MobileUI as MobileUI;
+use \Html as Html;
+
 /**
  * View for an item card in a mobile collection.
  */
-class CollectionItemCardView extends Gather\View {
+class CollectionItemCardView extends View {
        protected $item;
 
        /**
diff --git a/includes/views/CollectionView.php 
b/includes/views/CollectionView.php
index 509cdcb..5549a20 100644
--- a/includes/views/CollectionView.php
+++ b/includes/views/CollectionView.php
@@ -5,29 +5,33 @@
 
 namespace Gather;
 
+use \Html as Html;
+use \User as User;
+use \SpecialPage as SpecialPage;
+
 /**
  * Render a mobile card.
  */
-class CollectionView extends Gather\View {
+class CollectionView extends View {
        /**
-        * @var Gather\Collection
+        * @var Collection
         */
        protected $collection;
 
        /**
-        * @param Gather\Collection $collection
+        * @param Collection $collection
         */
-       public function __construct( Gather\Collection $collection ) {
+       public function __construct( Collection $collection ) {
                $this->collection = $collection;
        }
 
        /**
         * Returns the rendered html for the collection header
-        * @param Gather\Collection $collection
+        * @param Collection $collection
         *
         * @return string Html
         */
-       private function getHeaderHtml( Gather\Collection $collection ) {
+       private function getHeaderHtml( Collection $collection ) {
                $collection = $this->collection;
                $description = $collection->getDescription();
                $owner = $collection->getOwner();
@@ -81,11 +85,11 @@
        /**
         * Returns the html for the items of a collection
         *
-        * @param Gather\Collection
+        * @param Collection
         *
         * @return string HTML
         */
-       public function getCollectionItems( Gather\Collection $collection ) {
+       public function getCollectionItems( Collection $collection ) {
                $html = Html::openElement( 'div', array( 'class' => 
'collection-items' ) );
                foreach ( $collection as $item ) {
                        if ( $item->getTitle()->getNamespace() === NS_MAIN ) {
diff --git a/includes/views/CollectionsListItemCardView.php 
b/includes/views/CollectionsListItemCardView.php
index 9649cfa..5353eea 100644
--- a/includes/views/CollectionsListItemCardView.php
+++ b/includes/views/CollectionsListItemCardView.php
@@ -5,15 +5,17 @@
 
 namespace Gather;
 
+use \Html as Html;
+
 /**
  * View for an item card in a mobile collection.
  */
-class CollectionsListItemCardView extends Gather\View {
+class CollectionsListItemCardView extends View {
 
        /**
-        * @param Gather\Collection $collection
+        * @param Collection $collection
         */
-       public function __construct( Gather\Collection $collection ) {
+       public function __construct( Collection $collection ) {
                $this->collection = $collection;
        }
 
diff --git a/includes/views/CollectionsListView.php 
b/includes/views/CollectionsListView.php
index d8f9c60..9400466 100644
--- a/includes/views/CollectionsListView.php
+++ b/includes/views/CollectionsListView.php
@@ -5,28 +5,30 @@
 
 namespace Gather;
 
+use \Html as Html;
+
 /**
  * Renders a mobile collection card list
  */
-class CollectionsListView extends Gather\View {
+class CollectionsListView extends View {
        /**
-        * @param Gather\Collection $collection
+        * @param Collection $collection
         */
-       public function __construct( Gather\CollectionList $collectionList ) {
-               $this->collectionList = $collectionList;
+       public function __construct( CollectionsList $collectionsList ) {
+               $this->collectionsList = $collectionsList;
        }
 
        /**
         * Returns the html for the items of a collection
         *
-        * @param Gather\CollectionList
+        * @param CollectionsList
         *
         * @return string Html
         */
-       public static function getListItemsHtml( Gather\CollectionList 
$collectionList ) {
+       public static function getListItemsHtml( CollectionsList 
$collectionsList ) {
                $html = Html::openElement( 'div', array( 'class' => 
'collection-cards' ) );
-               foreach ( $collectionList as $item ) {
-                       $view = new Gather\CollectionsListItemCardView( $item );
+               foreach ( $collectionsList as $item ) {
+                       $view = new CollectionsListItemCardView( $item );
                        $html .= $view->getHtml();
                }
                // FIXME: Pagination
@@ -49,7 +51,7 @@
        public function getHtml() {
                $html = Html::openElement( 'div', array( 'class' => 'collection 
content' ) );
                // Get items
-               $html .= $this->getListItemsHtml( $this->collectionList );
+               $html .= $this->getListItemsHtml( $this->collectionsList );
                $html .= Html::closeElement( 'div' );
                return $html;
        }
diff --git a/includes/views/UserNotFoundView.php 
b/includes/views/UserNotFoundView.php
index f99e085..4f10f7f 100644
--- a/includes/views/UserNotFoundView.php
+++ b/includes/views/UserNotFoundView.php
@@ -1,4 +1,3 @@
-
 <?php
 /**
  * UserNotFoundView.php
@@ -6,10 +5,12 @@
 
 namespace Gather;
 
+use \View as View;
+
 /**
  * Renders an error when the user wasn't found
  */
-class UserNotFoundView extends Gather\View {
+class UserNotFoundView extends View {
 
        /**
         * @inheritdoc
diff --git a/includes/views/View.php b/includes/views/View.php
index 9f0bb85..2101393 100644
--- a/includes/views/View.php
+++ b/includes/views/View.php
@@ -5,6 +5,8 @@
 
 namespace Gather;
 
+use \OutputPage as OutputPage;
+
 /**
  * Render a view.
  */

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6b2f75d569ce72fe20f9b0273f34f661c5aa3748
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Gather
Gerrit-Branch: master
Gerrit-Owner: Jhernandez <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to