EBernhardson (WMF) has uploaded a new change for review.

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


Change subject: Allow wikitext in the summary block
......................................................................

Allow wikitext in the summary block

Change-Id: I0c2a8cb1bf2154eacd9ad268371184e28ff7777f
---
M includes/Block/Summary.php
M templates/edit-summary.html.php
M templates/summary.html.php
3 files changed, 16 insertions(+), 9 deletions(-)


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

diff --git a/includes/Block/Summary.php b/includes/Block/Summary.php
index 41fb3de..fbc66e2 100644
--- a/includes/Block/Summary.php
+++ b/includes/Block/Summary.php
@@ -7,6 +7,7 @@
 use Flow\Model\Workflow;
 use Flow\Model\Summary;
 use Flow\Repository\SummaryRepository;
+use Flow\ParsoidUtils;
 use Flow\Templating;
 use User;
 
@@ -35,6 +36,13 @@
        }
 
        protected function validate() {
+               if ( empty( $this->submitted['content'] ) ) {
+                       $this->errors['content'] = wfMessage( 
'flow-missing-summary-content' );
+                       $content = '';
+               } else {
+                       $content = ParsoidUtils::convertWikitextToHtml5( 
$this->submitted['content'], $this->workflow->getArticleTitle() );
+               }
+
                if ( $this->summary ) {
                        if ( empty( $this->submitted['prev_revision'] ) ) {
                                $this->errors['prev_revision'] = wfMessage( 
'flow-missing-prev-revision-identifier' );
@@ -47,19 +55,16 @@
                                $this->errors['prev_revision'] = wfMessage( 
'flow-prev-revision-mismatch' )->params( $this->submitted['prev_revision'], 
$this->summary->getRevisionId()->getHex() );
                        }
                        // this isnt really part of validate, but we want the 
error-rendering template to see the users edited summary
-                       $this->summary = $this->summary->newNextRevision( 
$this->user, $this->submitted['content'], 'flow-edit-summary' );
+                       $this->summary = $this->summary->newNextRevision( 
$this->user, $content, 'flow-edit-summary' );
                } else {
                        if ( empty( $this->submitted['prev_revision'] ) ) {
                                // this isnt really part of validate either, 
should validate be renamed or should this logic be redone?
-                               $this->summary = Summary::create( 
$this->workflow, $this->user, $this->submitted['content'] );
+                               $this->summary = Summary::create( 
$this->workflow, $this->user, $content );
                        } else {
                                // User submitted a previous revision, but we 
couldn't find one.  This is likely
                                // an internal error and not a user error, 
consider better handling
                                $this->errors['prev_revision'] = wfMessage( 
'flow-prev-revision-does-not-exist' );
                        }
-               }
-               if ( empty( $this->submitted['content'] ) ) {
-                       $this->errors['content'] = wfMessage( 
'flow-missing-summary-content' );
                }
        }
 
@@ -83,7 +88,7 @@
        }
 
        public function render( Templating $templating, array $options ) {
-               $templateName = ($this->action == 'edit-summary') ? 
'edit-summary' : 'summary';
+               $templateName = ( $this->action == 'edit-summary' ) ? 
'edit-summary' : 'summary';
                $templating->render( "flow:$templateName.html.php", array(
                        'block' => $this,
                        'workflow' => $this->workflow,
diff --git a/templates/edit-summary.html.php b/templates/edit-summary.html.php
index d52b791..476bb7f 100644
--- a/templates/edit-summary.html.php
+++ b/templates/edit-summary.html.php
@@ -20,7 +20,8 @@
 if ( $block->hasErrors( 'content' ) ) {
        echo '<p>' . $block->getError( 'content' )->escaped() . '</p>';
 }
-echo Html::textarea( $block->getName() . '[content]', $summary ? 
$summary->getContent() : '' );
+$content = $summary ? \Flow\ParsoidUtils::convertHTML5ToWikitext( 
$summary->getContent() ) : '';
+echo Html::textarea( $block->getName() . '[content]', $content );
 echo Html::element( 'input', array(
        'type' => 'submit',
        'class' => 'mw-ui-button mw-ui-constructive',
diff --git a/templates/summary.html.php b/templates/summary.html.php
index f694d24..66f052c 100644
--- a/templates/summary.html.php
+++ b/templates/summary.html.php
@@ -4,9 +4,10 @@
        echo '<p>' . $block->getError( 'content' )->escaped() . '</p>';
 }
 if ( $summary ) {
-       echo htmlspecialchars( $summary->getContent() );
+       // contains HTML5+RDFa content
+       echo $summary->getContent();
 }
 
 $editLink = $this->generateUrl( $workflow, 'edit-summary' );
 ?>
-<div class="flow-summary-edit-link"><a href="<?php echo 
htmlspecialchars($editLink);?>"><?php echo wfMessage( 'flow-edit-summary-link' 
)->escaped()?></a></div>
\ No newline at end of file
+<div class="flow-summary-edit-link"><a href="<?php echo 
htmlspecialchars($editLink);?>"><?php echo wfMessage( 'flow-edit-summary-link' 
)->escaped()?></a></div>

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0c2a8cb1bf2154eacd9ad268371184e28ff7777f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: EBernhardson (WMF) <[email protected]>

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

Reply via email to