Jhernandez has uploaded a new change for review.

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

Change subject: WIP: Gather moderation page
......................................................................

WIP: Gather moderation page

TODO:
- Get the owner of the collections from the api (See bug:T92782 in the comments)
         - Without the owner there is no way to link to a collection

Visit Special:GatherModeration to see the page.

Bug: T92782
Change-Id: I342f4cdfa43ea70d1427072b011fc90e29906855
---
M Gather.php
M extension.json
A includes/specials/SpecialGatherModeration.php
M resources/Resources.php
A resources/ext.gather.styles/moderation.less
5 files changed, 176 insertions(+), 1 deletion(-)


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

diff --git a/Gather.php b/Gather.php
index 50556d2..9fdd8d4 100644
--- a/Gather.php
+++ b/Gather.php
@@ -54,6 +54,7 @@
        'Gather\views\helpers\CSS' => 'views/helpers/CSS',
 
        'Gather\SpecialGather' => 'specials/SpecialGather',
+       'Gather\SpecialGatherModeration' => 'specials/SpecialGatherModeration',
 
        'Gather\api\ApiEditList' => 'api/ApiEditList',
        'Gather\api\ApiQueryLists' => 'api/ApiQueryLists',
@@ -67,6 +68,7 @@
 
 
 $wgSpecialPages['Gather'] = 'Gather\SpecialGather';
+$wgSpecialPages['GatherModeration'] = 'Gather\SpecialGatherModeration';
 
 // Hooks
 $wgExtensionFunctions[] = 'Gather\Hooks::onExtensionSetup';
diff --git a/extension.json b/extension.json
index f112a51..a03b140 100644
--- a/extension.json
+++ b/extension.json
@@ -13,7 +13,8 @@
                "Gather\\Hooks::onExtensionSetup"
        ],
        "SpecialPages": {
-               "Gather": "Gather\\SpecialGather"
+               "Gather": "Gather\\SpecialGather",
+               "GatherModeration": "Gather\\SpecialGatherModeration"
        },
        "MessagesDirs": {
                "Gather": [
@@ -43,6 +44,7 @@
                "Gather\\views\\CollectionsListItemCard": 
"includes/views/CollectionsListItemCard.php",
                "Gather\\views\\helpers\\CSS": "includes/views/helpers/CSS.php",
                "Gather\\SpecialGather": "includes/specials/SpecialGather.php",
+               "Gather\\SpecialGatherModeration": 
"includes/specials/SpecialGatherModeration.php",
                "Gather\\api\\ApiEditList": "includes/api/ApiEditList.php",
                "Gather\\api\\ApiQueryLists": "includes/api/ApiQueryLists.php",
                "Gather\\api\\ApiQueryListPages": 
"includes/api/ApiQueryListPages.php"
@@ -226,6 +228,15 @@
                        "scripts": [
                                "ext.gather.special/init.js"
                        ]
+               },
+               "ext.gather.moderation": {
+                       "targets": [
+                               "mobile",
+                               "desktop"
+                       ],
+                       "styles": [
+                               "ext.gather.styles/moderation.less"
+                       ]
                }
        },
        "ResourceFileModulePaths": {
diff --git a/includes/specials/SpecialGatherModeration.php 
b/includes/specials/SpecialGatherModeration.php
new file mode 100644
index 0000000..5d6a977
--- /dev/null
+++ b/includes/specials/SpecialGatherModeration.php
@@ -0,0 +1,106 @@
+<?php
+/**
+ * SpecialGatherModeration.php
+ */
+
+namespace Gather;
+
+use User;
+use SpecialPage;
+use ApiMain;
+use FauxRequest;
+use Html;
+
+/**
+ * Render a collection of articles.
+ */
+class SpecialGatherModeration extends SpecialPage {
+
+       public function __construct() {
+               parent::__construct( 'GatherModeration' );
+               $out = $this->getOutput();
+               $out->addModules( array(
+                       'ext.gather.moderation'
+               ) );
+               $out->addModuleStyles( array(
+                       'mediawiki.ui.anchor',
+                       'mediawiki.ui.icon',
+                       'ext.gather.icons',
+                       'ext.gather.styles',
+               ) );
+       }
+
+       /**
+        * Render the special page
+        */
+       public function execute() {
+               $api = new ApiMain( new FauxRequest( array(
+                       'action' => 'query',
+                       'list' => 'lists',
+                       'lstmode' => 'allpublic',
+                       // FIXME: Need owner to link to collection
+                       'lstprop' => 'label|description|image|count',
+                       // TODO: Pagination
+                       'continue' => '',
+               ) ) );
+               $api->execute();
+               $data = $api->getResultData();
+               if ( isset( $data['query']['lists'] ) ) {
+                       $lists = $data['query']['lists'];
+                       $this->render( $lists );
+               }
+       }
+
+       /**
+        * Render the special page
+        *
+        * @param array $lists
+        */
+       public function render( $lists ) {
+               $out = $this->getOutput();
+               $this->setHeaders();
+               $out->setProperty( 'unstyledContent', true );
+               $out->setPageTitle( 'Gather Moderation' );
+
+               $html = '';
+               $html .= Html::openElement( 'div', array( 'class' => 'content 
gather-moderation' ) );
+               $html .= Html::openElement( 'ul', array() );
+               $html .= Html::openElement( 'li', array( 'class' => 'heading' ) 
)
+               . Html::element( 'span', array(), 'Owner' )
+               . Html::element( 'span', array(), 'Id' )
+               . Html::element( 'span', array(), 'Label' )
+               . Html::element( 'span', array(), 'Description' )
+               . Html::element( 'span', array(), 'Count' )
+               . Html::closeElement( 'li' );
+               foreach ( $lists as $list ) {
+                       $html .= $this->row( $list );
+               }
+               $html .= Html::closeElement( 'ul' );
+               $html .= Html::closeElement( 'div' );
+
+               $out->addHTML( $html );
+       }
+
+       private function row( $data ) {
+               return Html::openElement( 'li', array( 'class' => 
$additionalClasses ) )
+                       . $this->userLink( $data['owner'] )
+                       . $this->collectionLink( $data['id'], $data['owner'], 
$data['id'] )
+                       . $this->collectionLink( $data['label'], 
$data['owner'], $data['id'] )
+                       . Html::element( 'span', array(), $data['description'] )
+                       . Html::element( 'span', array(), $data['count'] )
+                       . Html::closeElement( 'li' );
+       }
+
+       private function userLink( $user ) {
+               return Html::element( 'a', array(
+                       'href' => SpecialPage::getTitleFor( 'Gather', $user 
)->getLocalUrl()
+               ), $user );
+       }
+
+       private function collectionLink( $text, $user, $id ) {
+               return Html::element( 'a', array(
+                       'href' => SpecialPage::getTitleFor( 'Gather', 
$user.'/'.$id )->getLocalUrl()
+               ), $text );
+       }
+}
+
diff --git a/resources/Resources.php b/resources/Resources.php
index 2f25098..9a8afa4 100644
--- a/resources/Resources.php
+++ b/resources/Resources.php
@@ -194,6 +194,12 @@
                ),
        ),
 
+       'ext.gather.moderation' => 
$wgGatherMobileSpecialPageResourceBoilerplate + array(
+               'styles' => array(
+                       'ext.gather.styles/moderation.less',
+               ),
+       )
+
 );
 
 $wgResourceModuleSkinStyles['vector'] = 
$wgGatherMobileSpecialPageResourceBoilerplate + array(
diff --git a/resources/ext.gather.styles/moderation.less 
b/resources/ext.gather.styles/moderation.less
new file mode 100644
index 0000000..78c5f59
--- /dev/null
+++ b/resources/ext.gather.styles/moderation.less
@@ -0,0 +1,50 @@
+@import "minerva.variables";
+@import "minerva.mixins";
+
+.gather-moderation {
+       padding-top: 1em;
+
+       ul {
+               display: table;
+               width: 100%;
+
+               li {
+                       display: table-row;
+
+                       &.heading {
+                               font-weight: bold;
+
+                               >* {
+                                       border-width: 0px;
+                                       border-bottom: 2px solid #444;
+                                       text-align: center;
+                               }
+                       }
+
+                       >* {
+                               display: table-cell;
+                               padding: 0.4em 1em;
+                               border-style: solid;
+                               border-width: 0px 1px 1px 0;
+                               border-color: @grayLightest;
+                               border-bottom-color: @grayLight;
+                       }
+
+                       &:not(.heading) {
+                               >* {
+                                       &:first-child {
+                                               border-left-width: 1px;
+                                       }
+                               }
+                       }
+
+                       &:nth-child(2n) {
+                               background-color: @grayLightest;
+
+                               >* {
+                                       border-right-color: @grayLight;
+                               }
+                       }
+               }
+       }
+}

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I342f4cdfa43ea70d1427072b011fc90e29906855
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