Matthias Mullie has uploaded a new change for review. https://gerrit.wikimedia.org/r/133233
Change subject: Add ApiFlowViewTopicList ...................................................................... Add ApiFlowViewTopicList Adds a new API module, similar to the existing ones, to request a a list of topics. Note that I'm including 'render' as submodule-parameter. The better way would be to make use of the 'render' param in ApiFlow.php, but this server-side rendering will go away anyway. Figure it's better to keep it as-is for now, and just get rid of it altogether once client-side rendering is in place. Change-Id: I659687cbd1563ced0a5e9d7ae9514a62b0b43474 --- M Flow.php M includes/Block/TopicList.php M includes/api/ApiFlow.php A includes/api/ApiFlowViewTopicList.php 4 files changed, 71 insertions(+), 5 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow refs/changes/33/133233/1 diff --git a/Flow.php b/Flow.php index a8d2208..a65c44a 100755 --- a/Flow.php +++ b/Flow.php @@ -229,6 +229,7 @@ $wgAutoloadClasses['ApiFlowModerateTopic'] = "$dir/includes/api/ApiFlowModerateTopic.php"; $wgAutoloadClasses['ApiFlowNewTopic'] = "$dir/includes/api/ApiFlowNewTopic.php"; $wgAutoloadClasses['ApiFlowReply'] = "$dir/includes/api/ApiFlowReply.php"; +$wgAutoloadClasses['ApiFlowViewTopicList'] = "$dir/includes/api/ApiFlowViewTopicList.php"; $wgAutoloadClasses['ApiFlowViewPost'] = "$dir/includes/api/ApiFlowViewPost.php"; $wgAutoloadClasses['ApiFlowViewTopic'] = "$dir/includes/api/ApiFlowViewTopic.php"; $wgAutoloadClasses['ApiFlowViewHeader'] = "$dir/includes/api/ApiFlowViewHeader.php"; diff --git a/includes/Block/TopicList.php b/includes/Block/TopicList.php index bebdb7a..8d73106 100644 --- a/includes/Block/TopicList.php +++ b/includes/Block/TopicList.php @@ -27,7 +27,7 @@ /** * @var array */ - protected $supportedGetActions = array( 'view' ); + protected $supportedGetActions = array( 'view', 'topiclist-view' ); /** * @var Workflow|null @@ -255,17 +255,17 @@ // Compute offset/limit $limit = $this->getLimit( $requestOptions ); - if ( isset( $requestOptions['offset-id'] ) ) { + if ( isset( $requestOptions['offset-id'] ) && $requestOptions['offset-id'] ) { $findOptions['pager-offset'] = UUID::create( $requestOptions['offset-id'] ); - } elseif ( isset( $requestOptions['offset'] ) ) { + } elseif ( isset( $requestOptions['offset'] ) && $requestOptions['offset'] ) { $findOptions['pager-offset'] = intval( $requestOptions['offset'] ); } - if ( isset( $requestOptions['offset-dir'] ) ) { + if ( isset( $requestOptions['offset-dir'] ) && $requestOptions['offset-dir'] ) { $findOptions['pager-dir'] = $requestOptions['offset-dir']; } - if ( isset( $requestOptions['api'] ) ) { + if ( isset( $requestOptions['api'] ) && $requestOptions['api'] ) { $findOptions['offset-elastic'] = false; } diff --git a/includes/api/ApiFlow.php b/includes/api/ApiFlow.php index e8bf2ea..8a116f2 100644 --- a/includes/api/ApiFlow.php +++ b/includes/api/ApiFlow.php @@ -23,6 +23,7 @@ // GET // action 'view' exists in Topic.php & TopicList.php, for topic, post & // topiclist - we'll want to know topic-/post- or topiclist-view ;) + 'topiclist-view' => 'ApiFlowViewTopicList', 'post-view' => 'ApiFlowViewPost', 'topic-view' => 'ApiFlowViewTopic', 'header-view' => 'ApiFlowViewHeader', diff --git a/includes/api/ApiFlowViewTopicList.php b/includes/api/ApiFlowViewTopicList.php new file mode 100644 index 0000000..6542d45 --- /dev/null +++ b/includes/api/ApiFlowViewTopicList.php @@ -0,0 +1,64 @@ +<?php + +class ApiFlowViewTopicList extends ApiFlowBaseGet { + public function __construct( $api, $modName ) { + parent::__construct( $api, $modName, 'vtl' ); + } + + /** + * Taken from ext.flow.base.js + * + * @return array + */ + protected function getBlockNames() { + return array( 'topiclist' ); + } + + protected function getAction() { + return 'topiclist-view'; + } + + public function getAllowedParams() { + global $wgFlowDefaultLimit; + + return array( + 'offset-dir' => array( + ApiBase::PARAM_TYPE => array( 'fwd', 'rev' ), + ApiBase::PARAM_DFLT => 'fwd', + ), + 'offset-id' => array( + ApiBase::PARAM_TYPE => 'string', + ApiBase::PARAM_REQUIRED => false, + ), + 'limit' => array( + ApiBase::PARAM_TYPE => 'integer', + ApiBase::PARAM_DFLT => $wgFlowDefaultLimit, + ), + // @todo: I assume render parameter will soon be removed, after + // frontend rewrite + 'render' => array( + ApiBase::PARAM_TYPE => 'boolean', + ApiBase::PARAM_DFLT => false, + ), + ); + } + + public function getParamDescription() { + return array( + 'offset-dir' => 'Direction to get topics for', + 'offset-id' => 'Offset value (in UUID format) to start fetching topics at', + 'limit' => 'Amount of topics to fetch', + 'render' => 'Renders (in HTML) the topics, if set', + ); + } + + public function getDescription() { + return 'View a list of topics'; + } + + public function getExamples() { + return array( + 'api.php?action=flow&submodule=topiclist-view&workflow=', + ); + } +} -- To view, visit https://gerrit.wikimedia.org/r/133233 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I659687cbd1563ced0a5e9d7ae9514a62b0b43474 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Flow Gerrit-Branch: master Gerrit-Owner: Matthias Mullie <mmul...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits