Methods\n"; } if ($typeList) { $buf .= "Types\n"; } $buf .= "

Methods

"; foreach($methodList as $method) { $name = $method[name]; $author = $method[author] ? $method[author] : $unknown; $version = $method[version] ? $method[version] : $unknown; $desc = $method[purpose] ? $method[purpose] : $unknown; $sigs = $method[signatures]; $buf .= ""; $buf .= "" . field("Signature(s)", get_sigs($method), 3) . ""; $buf .= "" . field("Author", $author, 2) . field("Version", $version) . ""; $buf .= "" . field("Purpose", $desc, 3) . ""; $exclude_list = array( "see", "signatures", "purpose", "version", "author", "name" ); foreach($method as $key => $val) { if (!in_array($key, $exclude_list)) { if (is_array($val)) { $buf .= ""; foreach($val as $key2 => $desc) { if (gettype($desc) === "string") { if (gettype($key2) !== "string") { $key2 = false; } $buf .= "" . field(ucfirst($key2), $desc, 3) . ""; } } } else { $buf .= "" . field(ucfirst($key), $val, 3) . ""; } } } if ($sigs) { $bmultiple = count($sigs) > 1; foreach($sigs as $sig) { if ($bmultiple) { $count ++; $buf .= ""; } if ($sig[params]) { $buf .= ""; $buf .= ""; } if ($sig[returns]) { $buf .= ""; $buf .= ""; } } } if ($method[see]) { $buf .= ""; foreach($method[see] as $name => $desc) { if ($method_hash[$name]) { $name = "$name"; } $buf .= "" . field($name, $desc, 3) . ""; } } } $buf .= "
$name
" . ucfirst($key) . "
Signature $count: " . get_sig($name, $sig) . "
Parameters
"; $buf .= do_params($sig[params], false, false); $buf .= "
Return Value(s)
"; $buf .= do_params($sig[returns], false, false); $buf .= "
See Also

Types

"; $buf .= ""; $buf .= "
"; $buf .= do_params($typeList, true); $buf .= "
"; return $buf; } /********************************************************************* * The following functions are non-public and may change at any time. * *********************************************************************/ /* non public - format key/val pair in a */ function field($title, $text, $columns=false, $width=false) { if ($columns) { $colspan = " colspan='$columns'"; } if ($width) { $width = " width='$width' "; } $colon = $title && $text ? ":" : ""; return "$title$colon $text"; } function is_xmlrpc_type($type) { static $types = array("array", "struct", "mixed", "string", "int", "i4", "datetime", "base64", "boolean"); return in_array($type, $types); } function user_type($type) { global $xi_type_hash; return $xi_type_hash[$type] ? true : false; } function do_param($param, $bNewType=false, $bLinkUserTypes=true, $depth=0) { /* guard against serious craziness */ if (++ $depth >= 24) { return "
max depth reached. bailing out...
"; } $name = $param[name]; $type = $param[type]; $desc = $param[description]; $member = $param[member]; $opt = $param[optional]; $def = $param['default']; $type_def = $param[type_def]; if ($type_def) { $type_def = "$type_def "; } else { $type_def = ""; } $buf = "
"; if ($bNewType) { $anchor = ""; } if (user_type($type)) { if ($bLinkUserTypes) { $type = "$type"; } else { /* hack to display user values inline. max depth check above. */ global $xi_type_hash; $newtype = $xi_type_hash[$type]; $newtype[name] = $param[name]; $newtype[optional] = $param[optional]; if ($param[description]) { $newtype[description] = $param[description]; } $newtype[type_def] = $type; $buf .= do_param($newtype, $bNewType, $bLinkUserTypes, $depth); return $buf; } } $buf .= "$type_def$type $anchor$name"; if ($opt || $def) { $buf .= " ("; if ($opt) { $buf .= "optional" . ($def ? ", " : ""); } if ($def) { $buf .= "default=$def"; } $buf .= ")"; } if ($desc) { $buf .= " -- $desc"; } if ($member) { $buf .= do_params($member, $bNewType, $bLinkUserTypes, $depth); } $buf .= "
\n"; return $buf; } /* non public - format params list recursively */ function do_params($params, $bNewType=false, $bLinkUserTypes=true, $depth=0) { if ($params) { $br = $bNewType ? "
" : ""; $buf = "\n
\n"; foreach($params as $param) { $buf .= do_param($param, $bNewType, $bLinkUserTypes, $depth); } $buf .= "
$br\n"; } return $buf; } function get_sig($method_name, $sig) { $buf = ""; if ($method_name && $sig) { $return = $sig[returns][0][type]; if (!$return) { $return = "void"; } $buf .= "$return "; $buf .= "$method_name( "; $first = true; if ($sig[params]) { foreach($sig[params] as $param) { $type = $param[type]; $opt = $param[optional]; $def = $param["default"]; $name = $param["name"]; if (user_type($type)) { $type = "$type"; } if ($opt) { $buf .= $first ? '[' : ' ['; } if (!$first) { $buf .= ', '; } $buf .= "$type"; if (name) { $buf .= " $name"; } if ($def) { $buf .= " = $def"; } if ($opt) { $buf .= ']'; } $first = false; } } $buf .= " )"; } return $buf; } /* non public. generate method signature from method description */ function get_sigs($method) { $method_name = $method[name]; $buf = ""; if ($method[signatures]) { foreach($method[signatures] as $sig) { $buf .= "
  • " . get_sig($method_name, $sig); } } return $buf; } function name_cmp($a, $b) { return strcmp($a[name], $b[name]); } /************************************* * END system.describeMethods Support * *************************************/