. // // // /////////////////////////////////////////////////////////////////////////// /** * This file generate a web service documentation in HTML * This documentation describe how to call a Moodle Web Service */ require_once('../config.php'); require_once('lib.php'); $protocol = optional_param('protocol',"soap",PARAM_ALPHA); /// PAGE settings $PAGE->set_course($COURSE); $PAGE->set_url('webservice/wsdoc.php'); $PAGE->set_title(get_string('wspagetitle', 'webservice')); $PAGE->set_heading(get_string('wspagetitle', 'webservice')); $PAGE->set_generaltype("form"); echo $OUTPUT->header(); webservice_lib::display_webservices_availability($protocol); generate_documentation($protocol); generate_functionlist(); echo $OUTPUT->footer(); /** * Generate documentation specific to a protocol * @param string $protocol */ function generate_documentation($protocol) { switch ($protocol) { case "soap": $documentation = get_string('soapdocumentation','webservice'); break; case "xmlrpc": $documentation = get_string('xmlrpcdocumentation','webservice'); break; default: break; } echo $documentation; echo "".get_string('wsuserreminder','webservice').""; } /** * Generate web service function list * @global object $CFG */ function generate_functionlist () { global $CFG; $documentation = "

".get_string('functionlist','webservice')."

"; //retrieve all external file $externalfiles = array(); $externalfunctions = array(); webservice_lib::setListApiFiles($externalfiles, $CFG->dirroot); foreach ($externalfiles as $file) { require($file); $classpath = substr($file,strlen($CFG->dirroot)+1); //remove the dir root + / from the file path $classpath = substr($classpath,0,strlen($classpath) - 13); //remove /external.php from the classpath $classpath = str_replace('/','_',$classpath); //convert all / into _ $classname = $classpath."_external"; $api = new $classname(); $documentation .= "

".get_string('moodlepath','webservice').": ".$classpath."