r97233 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97232‎ | r97233 | r97234 >
Date:05:29, 16 September 2011
Author:werdna
Status:deferred (Comments)
Tags:
Comment:
Since I accidentally committed most of it in r97232, commit my formatter API module
Modified paths:
  • /branches/lqt-updates/extensions/LiquidThreads/api/ApiLqtFormatter.php (added) (history)

Diff [purge]

Index: branches/lqt-updates/extensions/LiquidThreads/api/ApiLqtFormatter.php
@@ -0,0 +1,89 @@
 2+<?php
 3+
 4+class ApiLqtFormatter extends ApiBase {
 5+
 6+ public function execute() {
 7+ $params = $this->extractRequestParams();
 8+ $result = $this->getResult();
 9+
 10+ $formatter = $this->getFormatter( $params );
 11+
 12+ $ctxClass = $formatter->getContextClass();
 13+ $context = new $ctxClass;
 14+
 15+ $contextParams = array(
 16+ 'base-url',
 17+ 'nesting-level',
 18+ 'single',
 19+ 'timestamp',
 20+ );
 21+
 22+ foreach( $contextParams as $param ) {
 23+ if ( $params[$param] !== null ) {
 24+ $context->set($param, $params[$param]);
 25+ }
 26+ }
 27+
 28+ $object = LiquidThreadsObject::retrieve( $params['object'] );
 29+
 30+ $output = array(
 31+ 'html' => $formatter->getHTML($object, $context),
 32+ );
 33+
 34+ $result->addValue( null, 'form', $output );
 35+ }
 36+
 37+ /**
 38+ * Get an array of valid forms and their corresponding classes.
 39+ */
 40+ public function getFormatters() {
 41+ return array(
 42+ 'post' => 'LiquidThreadsPostFormatter',
 43+ 'topic' => 'LiquidThreadsTopicFormatter',
 44+ );
 45+ }
 46+
 47+ /**
 48+ * Creates the appropriate LiquidThreadsEditForm object
 49+ * @param $params Array: The parameters passed to the API module.
 50+ */
 51+ public function getFormatter( $params ) {
 52+ global $wgUser;
 53+
 54+ $formName = $params['formatter'];
 55+
 56+ if ( $formName == 'post' ) {
 57+ $formatter = LiquidThreadsPostFormatter::singleton();
 58+ } elseif ( $formName == 'topic' ) {
 59+ $formatter = LiquidThreadsTopicFormatter::singleton();
 60+ } else {
 61+ $this->dieUsage( "Not yet implemented", 'not-implemented' );
 62+ }
 63+
 64+ return $formatter;
 65+ }
 66+
 67+ public function getAllowedParams() {
 68+ return array(
 69+ 'formatter' => array(
 70+ ApiBase::PARAM_REQUIRED => true,
 71+ ApiBase::PARAM_TYPE => array_keys( $this->getFormatters() ),
 72+ ),
 73+
 74+ ## Params for post
 75+ 'base-url' => null,
 76+ 'nesting-level' => null,
 77+ 'single' => null,
 78+
 79+ ## Shared params
 80+ 'object' => array(
 81+ ApiBase::PARAM_REQUIRED => true,
 82+ ),
 83+ 'timestamp' => null,
 84+ );
 85+ }
 86+
 87+ public function getVersion() {
 88+ return __CLASS__ . ': $Id: ApiLqtForm.php 79941 2011-01-10 17:18:57Z hartman $';
 89+ }
 90+}

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r97232Add some misisng svn add-swerdna05:28, 16 September 2011

Comments

#Comment by Nikerabbit (talk | contribs)   05:45, 16 September 2011

svn:keywords?

#Comment by Werdna (talk | contribs)   05:46, 16 September 2011

What does that mean?

#Comment by P858snake (talk | contribs)   05:55, 16 September 2011

svn:eol-style maybe?

#Comment by Nikerabbit (talk | contribs)   06:04, 16 September 2011

for

return __CLASS__ . ': $Id: ApiLqtForm.php 79941 2011-01-10 17:18:57Z hartman $';
svn pg svn:keywords includes/api/ApiQueryBase.php 
Id
#Comment by Catrope (talk | contribs)   09:30, 16 September 2011

It means you need to do svn propset svn:keywords Id ApiLqtFormatter.php in order for $Id$ to work.

Status & tagging log