Robert Vogel has submitted this change and it was merged.

Change subject: API: Metadata node and data in ExtJSStoreBase
......................................................................


API: Metadata node and data in ExtJSStoreBase

Adding the option to include metadata, which is used by the ExtJS store
to define the grid layout. Metadata is included only if the method hasMeta
returns true

* PatchSet 2: autodetection of metadata

Change-Id: I183cf773880b1ff9ea3a6f33d8ad214bcd075dbe
---
M includes/api/BSApiExtJSStoreBase.php
1 file changed, 26 insertions(+), 5 deletions(-)

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



diff --git a/includes/api/BSApiExtJSStoreBase.php 
b/includes/api/BSApiExtJSStoreBase.php
index deb6460..49ed47a 100644
--- a/includes/api/BSApiExtJSStoreBase.php
+++ b/includes/api/BSApiExtJSStoreBase.php
@@ -81,11 +81,18 @@
         */
        protected $totalProperty = 'total';
 
+       /**
+        * May be overwritten by subclass
+        * @var string
+        */
+       protected $metaData = 'metadata';
+
        public function execute() {
                $sQuery = $this->getParameter( 'query' );
                $aData = $this->makeData( $sQuery );
+               $aMetaData = $this->makeMetaData( $sQuery );
                $FinalData = $this->postProcessData( $aData );
-               $this->returnData( $FinalData );
+               $this->returnData( $FinalData, $aMetaData );
        }
 
        /**
@@ -98,15 +105,30 @@
        protected abstract function makeData( $sQuery = '' );
 
        /**
+        * @param string $sQuery Potential query provided by ExtJS component.
+        * This is some kind of preliminary filtering. Subclass has to decide if
+        * and how to process it
+        * @return array - Full list of of data objects. Filters, paging, 
sorting
+        * will be done by the base class
+        */
+       protected function makeMetaData( $sQuery = '' ) {
+               return array();
+       }
+
+       /**
         * Creates a proper output format based on the classes properties
         * @param array $aData An array of plain old data objects
+        * @param array $aMetaData An array of meta data items
         */
-       public function returnData($aData) {
-               wfRunHooks( 'BSApiExtJSStoreBaseBeforeReturnData', array( 
$this, &$aData ) );
+       public function returnData( $aData, $aMetaData = array() ) {
+               wfRunHooks( 'BSApiExtJSStoreBaseBeforeReturnData', array( 
$this, &$aData, &$aMetaData ) );
                $result = $this->getResult();
                $result->setIndexedTagName( $aData, $this->root );
                $result->addValue( null, $this->root, $aData );
                $result->addValue( null, $this->totalProperty, 
$this->iFinalDataSetCount );
+               if( !empty( $aMetaData ) ) {
+                       $result->addValue( null, $this->metaData, $aMetaData );
+               }
        }
 
        /**
@@ -445,5 +467,4 @@
                call_user_func_array( 'array_multisort', $aParams );
                return $aProcessedData;
        }
-
-}
+}
\ No newline at end of file

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I183cf773880b1ff9ea3a6f33d8ad214bcd075dbe
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/BlueSpiceFoundation
Gerrit-Branch: master
Gerrit-Owner: Mglaser <[email protected]>
Gerrit-Reviewer: Dvogel hallowelt <[email protected]>
Gerrit-Reviewer: Ljonka <[email protected]>
Gerrit-Reviewer: Pwirth <[email protected]>
Gerrit-Reviewer: Robert Vogel <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to