Robert Vogel has submitted this change and it was merged.

Change subject: BSF: New API base class for use with ExtJS stores
......................................................................


BSF: New API base class for use with ExtJS stores

I've added a new base class for API modules that should make it easier to
implement a backend for ExtJS data stores. It incorporates most ExtJS
parameters.

This may be merged with or derived from 
https://gerrit.wikimedia.org/r/#/c/149845

Change-Id: I08719d3300822d2e15618b1874f4e6f6fd300328
---
A includes/api/ApiExtJSBase.php
1 file changed, 69 insertions(+), 0 deletions(-)

Approvals:
  Robert Vogel: Verified; Looks good to me, approved
  Swidmann: Checked; Looks good to me, but someone else must approve



diff --git a/includes/api/ApiExtJSBase.php b/includes/api/ApiExtJSBase.php
new file mode 100644
index 0000000..90546f7
--- /dev/null
+++ b/includes/api/ApiExtJSBase.php
@@ -0,0 +1,69 @@
+<?php
+
+abstract class ApiExtJSBase extends ApiBase {
+
+       public function getAllowedParams() {
+               return array(
+                       'sort' => array(
+                               ApiBase::PARAM_TYPE => 'string',
+                               ApiBase::PARAM_REQUIRED => false
+                       ),
+                       'page' => array(
+                               ApiBase::PARAM_TYPE => 'integer',
+                               ApiBase::PARAM_REQUIRED => false
+                       ),
+                       'limit' => array(
+                               ApiBase::PARAM_TYPE => 'integer',
+                               ApiBase::PARAM_REQUIRED => false
+                       ),
+                       'start' => array(
+                               ApiBase::PARAM_TYPE => 'integer',
+                               ApiBase::PARAM_REQUIRED => false
+                       ),
+                       '_dc' => array(
+                               ApiBase::PARAM_TYPE => 'integer',
+                               ApiBase::PARAM_REQUIRED => false
+                       ),
+                       'format' => array(
+                               ApiBase::PARAM_DFLT => 'json',
+                               ApiBase::PARAM_TYPE => array( 'json', 'jsonfm' 
),
+                       )
+               );
+       }
+
+       public function getParamDescription() {
+               return array(
+                       'sort' => 'JSON string with sorting info',
+                       'page' => 'Allows server side calculation of 
start/limit',
+                       'limit' => 'Number of results to return',
+                       'start' => 'The offset to start the result list from',
+                       '_dc' => '"Disable cache" flag',
+                       'format' => 'The format of the output'
+               );
+       }
+
+       public function getResultProperties() {
+               return array(
+                       '' => array(
+                               'success' => 'boolean',
+                               'results' => array(
+                                       ApiBase::PROP_TYPE => 'integer',
+                                       ApiBase::PROP_NULLABLE => false
+                               ),
+                               'rows' => array(
+                                       ApiBase::PROP_TYPE => 'array',
+                                       ApiBase::PROP_NULLABLE => false
+                               )
+                       )
+               );
+       }
+
+       protected function getParameterFromSettings($paramName, $paramSettings, 
$parseLimit) {
+               $value = parent::getParameterFromSettings($paramName, 
$paramSettings, $parseLimit);
+               //Unfortunately there is no way to register custom types for 
parameters
+               if( $paramName === 'sort' ) {
+                       $value = FormatJson::decode($value);
+               }
+               return $value;
+       }
+}
\ No newline at end of file

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I08719d3300822d2e15618b1874f4e6f6fd300328
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BlueSpiceFoundation
Gerrit-Branch: master
Gerrit-Owner: Robert Vogel <vo...@hallowelt.biz>
Gerrit-Reviewer: Mglaser <gla...@hallowelt.biz>
Gerrit-Reviewer: Pigpen <reym...@hallowelt.biz>
Gerrit-Reviewer: Robert Vogel <vo...@hallowelt.biz>
Gerrit-Reviewer: Smuggli <mug...@hallowelt.biz>
Gerrit-Reviewer: Swidmann <widm...@hallowelt.biz>

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

Reply via email to