jenkins-bot has submitted this change and it was merged.

Change subject: Add ApiFlowViewPost
......................................................................


Add ApiFlowViewPost

Adds a new API module, similar to the existing ones, to request a
specific post.

Change-Id: Ia661db49e06e8b5eaa6fb8f43f56b44fc3a2feb0
---
M Flow.php
M includes/Block/Topic.php
M includes/api/ApiFlow.php
A includes/api/ApiFlowViewPost.php
4 files changed, 59 insertions(+), 1 deletion(-)

Approvals:
  Legoktm: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/Flow.php b/Flow.php
index e34187d..adba0f4 100755
--- a/Flow.php
+++ b/Flow.php
@@ -233,6 +233,7 @@
 $wgAutoloadClasses['ApiFlowModerateTopic'] = 
"$dir/includes/api/ApiFlowModerateTopic.php";
 $wgAutoloadClasses['ApiFlowNewTopic'] = 
"$dir/includes/api/ApiFlowNewTopic.php";
 $wgAutoloadClasses['ApiFlowReply'] = "$dir/includes/api/ApiFlowReply.php";
+$wgAutoloadClasses['ApiFlowViewPost'] = 
"$dir/includes/api/ApiFlowViewPost.php";
 $wgAutoloadClasses['ApiFlowViewHeader'] = 
"$dir/includes/api/ApiFlowViewHeader.php";
 $wgAutoloadClasses['ApiFlowViewTopicSummary'] = 
"$dir/includes/api/ApiFlowViewTopicSummary.php";
 $wgAutoloadClasses['ApiQueryPropFlowInfo'] = 
"$dir/includes/api/ApiQueryPropFlowInfo.php";
diff --git a/includes/Block/Topic.php b/includes/Block/Topic.php
index 0bc2993..8b46a22 100644
--- a/includes/Block/Topic.php
+++ b/includes/Block/Topic.php
@@ -696,7 +696,7 @@
                        $output['user'] = $templating->getCreatorText( $post );
                }
 
-               if ( ! isset( $options['no-children'] ) ) {
+               if ( !isset( $options['no-children'] ) || 
!$options['no-children'] ) {
                        $children = array( 'element' => 'post' );
 
                        foreach( $post->getChildren() as $child ) {
diff --git a/includes/api/ApiFlow.php b/includes/api/ApiFlow.php
index c95f586..2458bdb 100644
--- a/includes/api/ApiFlow.php
+++ b/includes/api/ApiFlow.php
@@ -21,6 +21,7 @@
                'close-open-topic' => 'ApiFlowCloseOpenTopic',
 
                // GET
+               'view' => 'ApiFlowViewPost', // @todo: 'view' is also for 
topiclist
                'header-view' => 'ApiFlowViewHeader',
                'topic-summary-view' => 'ApiFlowViewTopicSummary',
        );
diff --git a/includes/api/ApiFlowViewPost.php b/includes/api/ApiFlowViewPost.php
new file mode 100644
index 0000000..d73c099
--- /dev/null
+++ b/includes/api/ApiFlowViewPost.php
@@ -0,0 +1,56 @@
+<?php
+
+class ApiFlowViewPost extends ApiFlowBaseGet {
+       public function __construct( $api, $modName ) {
+               parent::__construct( $api, $modName, 'vp' );
+       }
+
+       /**
+        * Taken from ext.flow.base.js
+        *
+        * @return array
+        */
+       protected function getBlockNames() {
+               return array( 'topic' );
+       }
+
+       protected function getAction() {
+               return 'view';
+       }
+
+       public function getAllowedParams() {
+               global $wgFlowContentFormat;
+
+               return array(
+                       'postId' => array(
+                               ApiBase::PARAM_REQUIRED => true,
+                       ),
+                       'contentFormat' => array(
+                               ApiBase::PARAM_TYPE => array( 'html', 
'wikitext' ),
+                               ApiBase::PARAM_DFLT => $wgFlowContentFormat,
+                       ),
+                       'no-children' => array(
+                               ApiBase::PARAM_TYPE => 'boolean',
+                               ApiBase::PARAM_DFLT => false,
+                       ),
+               );
+       }
+
+       public function getParamDescription() {
+               return array(
+                       'postId' => 'Id of the post to view',
+                       'contentFormat' => 'Format to return the content in',
+                       'no-children' => 'If set, this won\'t render replies to 
the requested post',
+               );
+       }
+
+       public function getDescription() {
+               return 'View a post';
+       }
+
+       public function getExamples() {
+               return array(
+                       
'api.php?action=flow&submodule=view&vppostId=???&vpcontentFormat=wikitext&workflow=',
+               );
+       }
+}

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ia661db49e06e8b5eaa6fb8f43f56b44fc3a2feb0
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Matthias Mullie <mmul...@wikimedia.org>
Gerrit-Reviewer: Jdlrobson <jrob...@wikimedia.org>
Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com>
Gerrit-Reviewer: Matthias Mullie <mmul...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to