Merge "Allow ORMTable to access a foreign wiki."
[lhc/web/wiklou.git] / includes / api / ApiParamInfo.php
index f226347..343a262 100644 (file)
@@ -4,7 +4,7 @@
  *
  * Created on Dec 01, 2007
  *
- * Copyright © 2008 Roan Kattouw <Firstname>.<Lastname>@gmail.com
+ * Copyright © 2008 Roan Kattouw "<Firstname>.<Lastname>@gmail.com"
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -251,6 +251,62 @@ class ApiParamInfo extends ApiBase {
                }
                $result->setIndexedTagName( $retval['parameters'], 'param' );
 
+               $props = $obj->getFinalResultProperties();
+               $listResult = null;
+               if ( $props !== false ) {
+                       $retval['props'] = array();
+
+                       foreach ( $props as $prop => $properties ) {
+                               $propResult = array();
+                               if ( $prop == ApiBase::PROP_LIST ) {
+                                       $listResult = $properties;
+                                       continue;
+                               }
+                               if ( $prop != ApiBase::PROP_ROOT ) {
+                                       $propResult['name'] = $prop;
+                               }
+                               $propResult['properties'] = array();
+
+                               foreach ( $properties as $name => $p ) {
+                                       $propertyResult = array();
+
+                                       $propertyResult['name'] = $name;
+
+                                       if ( !is_array( $p ) ) {
+                                               $p = array( ApiBase::PROP_TYPE => $p );
+                                       }
+
+                                       $propertyResult['type'] = $p[ApiBase::PROP_TYPE];
+
+                                       if ( is_array( $propertyResult['type'] ) ) {
+                                               $propertyResult['type'] = array_values( $propertyResult['type'] );
+                                               $result->setIndexedTagName( $propertyResult['type'], 't' );
+                                       }
+
+                                       $nullable = null;
+                                       if ( isset( $p[ApiBase::PROP_NULLABLE] ) ) {
+                                               $nullable = $p[ApiBase::PROP_NULLABLE];
+                                       }
+
+                                       if ( $nullable === true ) {
+                                               $propertyResult['nullable'] = '';
+                                       }
+
+                                       $propResult['properties'][] = $propertyResult;
+                               }
+
+                               $result->setIndexedTagName( $propResult['properties'], 'property' );
+                               $retval['props'][] = $propResult;
+                       }
+
+                       // default is true for query modules, false for other modules, overriden by ApiBase::PROP_LIST
+                       if ( $listResult === true || ( $listResult !== false && $obj instanceof ApiQueryBase ) ) {
+                               $retval['listresult'] = '';
+                       }
+
+                       $result->setIndexedTagName( $retval['props'], 'prop' );
+               }
+
                // Errors
                $retval['errors'] = $this->parseErrors( $obj->getPossibleErrors() );
                $result->setIndexedTagName( $retval['errors'], 'error' );