".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();
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."
";
$description = webservice_lib::generate_webservice_description($file, $classname);
foreach ($description as $functionname => $functiondescription) {
$documentation .= <<{$functionname}(
EOF;
$arrayparams = array();
$comma="";
foreach($functiondescription['params'] as $param => $type) {
$documentation .= <<) :
EOF;
if (array_key_exists('return', $functiondescription)) {
foreach($functiondescription['return'] as $return => $type) {
$documentation .= <<
{$type}
EOF;
if (is_array($type)) {
$arraytype = "".print_r($type, true)."
";
$documentation .= << {$return} {$arraytype}
EOF;
}
}
}
foreach($functiondescription['params'] as $param => $type) {
if (is_array($type)) {
$arraytype = "".print_r($type, true)."
";
$documentation .= <<{$param} : {$arraytype}
EOF;
}
}
}
$documentation .= <<
EOF;
}
echo $documentation;
}
/**
* Retrieve all external.php from Moodle
* @param array $files
* @param string $directorypath
* @return boolean result true if n
*/
function setListApiFiles( &$files, $directorypath )
{
if(is_dir($directorypath)){ //check that we are browsing a folder not a file
if( $dh = opendir($directorypath))
{
while( false !== ($file = readdir($dh)))
{
if( $file == '.' || $file == '..') { // Skip '.' and '..'
continue;
}
$path = $directorypath . '/' . $file;
///browse the subfolder
if( is_dir($path) ) {
setListApiFiles($files, $path);
}
///retrieve api.php file
else if ($file == "external.php") {
$files[] = $path;
}
}
closedir($dh);
}
}
}
?>