$string['requiredcapability'] = 'Required capability';
$string['response'] = 'Response';
$string['restcode'] = 'REST';
+$string['restparam'] = 'REST (POST parameters)';
$string['restrictedusers'] = 'Authorised users only';
$string['selectedcapabilitydoesntexit'] = 'The currently set required capability ($a) doesn\'t exist anymore. Please change it and save the changes.';
$string['selectedcapability'] = 'Selected';
$string['validuntil'] = 'Valid until';
$string['webservices'] = 'Web services';
$string['wsdocumentation'] = 'Web service documentation';
-$string['wsdocumentationintro'] = 'Following a listing of web service functions available for the username <b>$a</b>.<br/>In order to create a client we advice you to read the <a href=\"http://docs.moodle.org/en/Development:Creating_a_web_service_and_a_web_service_function#Create_your_own_client\">Moodle documentation</a>
- <br/><br/>For REST parameters convert the XML-RPC structures into POST.';
+$string['wsdocumentationintro'] = 'Following a listing of web service functions available for the username <b>$a</b>.<br/>In order to create a client we advice you to read the <a href=\"http://docs.moodle.org/en/Development:Creating_a_web_service_and_a_web_service_function#Create_your_own_client\">Moodle documentation</a>';
$string['wsdocumentationlogin'] = 'Enter your web service username and password.';
$string['wspassword'] = 'Web service password';
$string['wsusername'] = 'Web service username';
return $restresponsehtml;
}
+
+ /**
+ * Create indented REST param description
+ * @param object $paramdescription
+ * @param string $indentation composed by space only
+ * @return string the html to diplay
+ */
+ public function rest_param_description_html($paramdescription, $paramstring) {
+ $brakeline = <<<EOF
+
+
+EOF;
+ if ($paramdescription instanceof external_multiple_structure) {
+ $paramstring = $paramstring.'[0]';
+ $return = $this->rest_param_description_html($paramdescription->content, $paramstring);
+ return $return;
+ } else if ($paramdescription instanceof external_single_structure) {
+ $singlestructuredesc = "";
+ foreach ($paramdescription->keys as $attributname => $attribut) {
+ $paramstring = $paramstring.'['.$attributname.']';
+ $singlestructuredesc .= $this->rest_param_description_html($paramdescription->keys[$attributname], $paramstring);
+ }
+ return $singlestructuredesc;
+ } else {
+ $paramstring = $paramstring.'=';
+ switch($paramdescription->type) {
+ case PARAM_BOOL: // 0 or 1 only for now
+ case PARAM_INT:
+ $type = 'int';
+ break;
+ case PARAM_FLOAT;
+ $type = 'double';
+ break;
+ default:
+ $type = 'string';
+ }
+ return $paramstring." ".$type.$brakeline;
+ }
+ }
+
+
/**
* This display all the documentation
* @param array $functions contains all decription objects
$documentationhtml .= "<div style=\"border:solid 1px #DEDEDE;background:#DFEEE7;color:#222222;padding:4px;\">";
$documentationhtml .= '<b>'.get_string('phpparam', 'webservice').'</b><br/>';
$documentationhtml .= $brakeline.'['.$paramname.'] =>'.htmlentities($this->xmlrpc_param_description_html($paramdesc)). $brakeline. $brakeline;
+ $documentationhtml .= "</div><br/>";
+ $documentationhtml .= "</pre>";
+ $documentationhtml .= "<pre>";
+ $documentationhtml .= "<div style=\"border:solid 1px #DEDEDE;background:#FEEBE5;color:#222222;padding:4px;\">";
+ $documentationhtml .= '<b>'.get_string('restparam', 'webservice').'</b><br/>';
+ $documentationhtml .= $brakeline.htmlentities($this->rest_param_description_html($paramdesc,$paramname)). $brakeline. $brakeline;
$documentationhtml .= "</div>";
$documentationhtml .= "</pre>";
$documentationhtml .= "</span>";