Bsitu has uploaded a new change for review.

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

Change subject: edit topic summary no javascript support
......................................................................

edit topic summary no javascript support

Change-Id: If389d58f711737f48f76e42bd84a31f2ebdb377d
---
M includes/Block/TopicSummary.php
A templates/edit-topic-summary.html.php
2 files changed, 98 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow 
refs/changes/85/120485/1

diff --git a/includes/Block/TopicSummary.php b/includes/Block/TopicSummary.php
index 0bf9a26..e5b6e84 100644
--- a/includes/Block/TopicSummary.php
+++ b/includes/Block/TopicSummary.php
@@ -40,6 +40,11 @@
         */
        protected $supportedPostActions = array( 'edit-topic-summary', 
'moderate-topic' );
 
+       /**
+        * Supported Get actions
+        */
+       protected $supportedGetActions = array( 'edit-topic-summary' );
+
        public function init( $action, $user ) {
                parent::init( $action, $user );
                $this->permissions = new RevisionActionPermissions( 
Container::get( 'flow_actions' ), $user );
@@ -179,12 +184,18 @@
                }
        }
 
-       /**
-        * @Todo - Add edit-topic-summary get action for no js support in UI 
patch
-        */
-       public function render( Templating $templating, array $options ) {
-
-       }
+       public function render( Templating $templating, array $options, $return 
= false ) {
+               switch ( $this->action ) {
+                       case 'edit-topic-summary':
+                               return $templating->render( 
'flow:edit-topic-summary.html.php', array(
+                                       'block' => $this,
+                                       'workflow' => $this->getWorkflow(),
+                                       'topicSummary' => $this->topicSummary,
+                                       'user' => $user,
+                               ), $return );
+                               break;
+               }
+        }
 
        public function renderAPI( Templating $templating, array $options ) {
                $output = array( 'type' => 'topicsummary' );
diff --git a/templates/edit-topic-summary.html.php 
b/templates/edit-topic-summary.html.php
new file mode 100644
index 0000000..8e7b521
--- /dev/null
+++ b/templates/edit-topic-summary.html.php
@@ -0,0 +1,81 @@
+<?php
+
+$revisionId = '';
+if ( $topicSummary ) {
+       // if summary already exists, propagate it's revisions id
+       $revisionId = $topicSummary->getRevisionId()->getAlphadecimal();
+
+       if ( $block->hasErrors( 'prev_revision' ) ) {
+               $error = $block->getErrorExtra( 'prev_revision' );
+               $revisionId = $error['revision_id'];
+       }
+}
+
+// owning workflow
+echo Html::openElement( 'div', array(
+       'id' => 'flow-topic-summary-' . $revisionId,
+) );
+echo Html::openElement( 'div', array(
+       'class' => 'flow-edit-topic-summary-form flow-element-container'
+) );
+echo Html::openElement( 'form', array(
+       'method' => 'POST',
+       'action' => $this->generateUrl( $workflow, 'edit-topic-summary' ),
+       'class' => 'flow-topic-summary-form',
+) );
+if ( $block->hasErrors() ) {
+       echo '<ul>';
+       foreach ( $block->getErrors() as $error ) {
+               echo '<li>', $block->getErrorMessage( $error )->parse() . 
'</li>';
+       }
+       echo '</ul>';
+}
+
+echo Html::element( 'input', array(
+       'type' => 'hidden',
+       'name' => 'wpEditToken',
+       'value' => $editToken
+) );
+
+if ( $topicSummary ) {
+       echo Html::element( 'input', array(
+               'type' => 'hidden',
+               'name' => $block->getName()."_prev_revision",
+               'value' => $revisionId
+       ) );
+}
+
+echo Html::textarea(
+       $block->getName() . '_content',
+       $topicSummary ? $this->getContent( $topicSummary, 'wikitext' ) : '',
+       array(
+               'class' => 'mw-ui-input',
+               'rows' => '10',
+               'data-topic-summary-id' => $revisionId
+       )
+);
+echo Html::openElement( 'div', array(
+       'class' => 'flow-edit-topic-summary-controls',
+) );
+echo Html::rawElement( 'div', array(
+       'class' => 'flow-terms-of-use plainlinks',
+), Flow\TermsOfUse::getAddTopicTerms() );
+
+// submit button text will be different if there's a more recent change already
+$submitMessage = 'flow-summarize-topic-submit';
+$submitClass = 'mw-ui-button mw-ui-constructive';
+if ( $block->hasErrors( 'prev_revision' ) ) {
+       $submitMessage = 'flow-summarize-topic-submit-overwrite';
+       $submitClass = 'mw-ui-button mw-ui-destructive';
+}
+echo Html::element( 'input', array(
+       'type' => 'submit',
+       'class' => $submitClass,
+       'value' => wfMessage( $submitMessage )->plain(),
+) );
+echo Html::element( 'div', array( 'class' => 'clear' ) );
+
+echo Html::closeElement( 'div' );
+echo Html::closeElement( 'form' );
+echo Html::closeElement( 'div' );
+echo Html::closeElement( 'div' );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If389d58f711737f48f76e42bd84a31f2ebdb377d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Bsitu <[email protected]>

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

Reply via email to