Mglaser has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/267219

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

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


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BlueSpiceFoundation 
refs/changes/19/267219/1

diff --git a/includes/api/BSApiExtJSStoreBase.php 
b/includes/api/BSApiExtJSStoreBase.php
index deb6460..fa4152a 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,29 @@
        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
         */
-       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( $this->hasMeta() ) {
+                       $result->addValue( null, $this->metaData, $aMetaData );
+               }
        }
 
        /**
@@ -446,4 +467,7 @@
                return $aProcessedData;
        }
 
-}
+       public function hasMeta() {
+               return false;
+       }
+}
\ 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: newchange
Gerrit-Change-Id: I183cf773880b1ff9ea3a6f33d8ad214bcd075dbe
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BlueSpiceFoundation
Gerrit-Branch: master
Gerrit-Owner: Mglaser <[email protected]>

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

Reply via email to