Only use one if, not 2
[lhc/web/wiklou.git] / includes / api / ApiParamInfo.php
index 4b2a263..f286fe2 100644 (file)
@@ -93,7 +93,8 @@ class ApiParamInfo extends ApiBase {
        {
                $result = $this->getResult();
                $retval['classname'] = get_class($obj);
-               $retval['description'] = (is_array($obj->getDescription()) ? implode("\n", $obj->getDescription()) : $obj->getDescription());
+               $retval['description'] = implode("\n", (array)$obj->getDescription());
+               $retval['version'] = implode("\n", (array)$obj->getVersion());
                $retval['prefix'] = $obj->getModulePrefix();
                if($obj->isReadMode())
                        $retval['readrights'] = '';
@@ -101,6 +102,8 @@ class ApiParamInfo extends ApiBase {
                        $retval['writerights'] = '';
                if($obj->mustBePosted())
                        $retval['mustbeposted'] = '';
+               if($obj instanceof ApiQueryGeneratorBase)
+                       $retval['generator'] = '';
                $allowedParams = $obj->getFinalParams();
                if(!is_array($allowedParams))
                        return $retval;
@@ -109,6 +112,10 @@ class ApiParamInfo extends ApiBase {
                foreach($allowedParams as $n => $p)
                {
                        $a = array('name' => $n);
+                       if(isset($paramDesc[$n]))
+                               $a['description'] = implode("\n", (array)$paramDesc[$n]);
+                       if(isset($p[ApiBase::PARAM_DEPRECATED]) && $p[ApiBase::PARAM_DEPRECATED])
+                               $a['deprecated'] = '';
                        if(!is_array($p))
                        {
                                if(is_bool($p))
@@ -116,8 +123,16 @@ class ApiParamInfo extends ApiBase {
                                        $a['type'] = 'bool';
                                        $a['default'] = ($p ? 'true' : 'false');
                                }
-                               if(is_string($p))
-                                       $a['default'] = $p;
+                               else if(is_string($p) || is_null($p))
+                               {
+                                       $a['type'] = 'string';
+                                       $a['default'] = strval($p);
+                               }
+                               else if(is_int($p))
+                               {
+                                       $a['type'] = 'integer';
+                                       $a['default'] = intval($p);
+                               }
                                $retval['parameters'][] = $a;
                                continue;
                        }
@@ -147,8 +162,6 @@ class ApiParamInfo extends ApiBase {
                                $a['highmax'] = $p[ApiBase::PARAM_MAX2];
                        if(isset($p[ApiBase::PARAM_MIN]))
                                $a['min'] = $p[ApiBase::PARAM_MIN];
-                       if(isset($paramDesc[$n]))
-                               $a['description'] = (is_array($paramDesc[$n]) ? implode("\n", $paramDesc[$n]) : $paramDesc[$n]);
                        $retval['parameters'][] = $a;
                }
                $result->setIndexedTagName($retval['parameters'], 'param');