ServerDocumentor
in package
Table of Contents
Properties
- $templateEngine : TemplateEngineInterface
- $templates : mixed
Methods
- __construct() : mixed
- generateDocs() : string
- Generate the documentation about methods exposed by a given server.
- setTemplate() : void
- templates() : array<string|int, string>
- render() : string
Properties
$templateEngine
protected
TemplateEngineInterface
$templateEngine
$templates
protected
static mixed
$templates
= array(
//'httpheaders' => array(),
'docheader' => '<!DOCTYPE html>
<html lang="{$lang}">
<head>
<meta name="generator" content="{$xmlrpc_name}" />
<link rel="stylesheet" type="text/css" href="docxmlrpcs.css" />
{$extras}
<title>{$title}</title>
</head>
<body>',
'docfooter' => '
<div class="footer">Generated using PHPXMLRPC {$xmlrpc_version}</div>
</body></html>',
'extrahtmlheader' => '',
'apiheader' => '
<h1>API index</h1>
<p>This server defines the following API specification:</p>
<table class="apilist">
<tr><th>Method</th><th>Description</th></tr>',
'apimethod' => '
<tr><td><a href="?methodName={$method}">{$method}</a></td><td>{$desc}</td></tr>',
'apifooter' => '
</table>',
'methodheader' => '
<h1>Method <em>{$method}</em></h1>
<div>{$desc}</div>',
'methodnotfound' => '
<h3>The method {$method} is not part of the API of this server</h3>
',
'sigheader' => '
<h2>Signature {$signum}</h2>
<blockquote>
<h3>Input parameters</h3>
<table class="inputparameters">
<tr><th>Type</th><th>Description</th></tr>',
'sigparam' => '
<tr><td>{$paramtype}</td><td>{$paramdesc}</td></tr>',
'sigfooter' => '
</table>
<h3>Output parameter</h3>
<table class="inputparameters">
<tr><th>Type</th><th>Description</th></tr>
<tr><td>{$outtype}</td><td>{$outdesc}</td></tr>
</table>
</blockquote>',
'formparam' => '<param><value></value></param>
',
'methodfooter' => '
<h2>Test method call</h2>
<p>Complete by hand the form below inserting the needed parameters to call this method.<br/>
For a string param use e.g. <pre><param><value><string>Hello</string></value></param></pre></p>
<form action="" method="post"><p>
<textarea id="methodCall" name="methodCall" rows="5" cols="80">
<methodCall><methodName>{$method}</methodName>
<params>
{$params}</params>
</methodCall>
</textarea><br/>
{$extras}
<input type="submit" value="Test"/>
</p></form>',
'editorheaders' => '<script type="module">
import {base64_decode} from "{$liburl}xmlrpc_lib.js";
window.base64_decode = base64_decode;
</script>
<script type="text/javascript">
<!--
function runeditor()
{
//var url = "{$editorurl}visualeditor.html?params={$param_payload}";
var url = "{$editorurl}visualeditor.html";
//if (document.frmaction.wstype.value == "1")
// url += "&type=jsonrpc";
var wnd = window.open(url, "_blank", "width=750, height=400, location=0, resizable=1, menubar=0, scrollbars=1");
}
// if javascript version of the lib is found, allow it to send us params
function buildparams(base64data)
{
if (typeof base64_decode == "function")
{
if (base64data == "0") // workaround for bug in base64_encode...
document.getElementById("methodCall").value = "{$methodcallstart}{$methodcallend}";
else
document.getElementById("methodCall").value = "{$methodcallstart}"+base64_decode(base64data)+"{$methodcallend}";
}
}
//-->
</script>
',
'editorlink' => '<input type="submit" value="Edit" onclick="runeditor(); return false;"/>',
'xmlrpcmethodstart' => '<methodCall><methodName>{$method}</methodName>\n<params>\n',
'xmlrpcmethodend' => '</params>\n</methodCall>',
)
Methods
__construct()
public
__construct(mixed $templateEngine) : mixed
Parameters
- $templateEngine : mixed
generateDocs()
Generate the documentation about methods exposed by a given server.
public
generateDocs(Server $server[, string $doctype = 'html' ][, string $lang = 'en' ][, string $editorPath = '' ][, string $displayExecutionForm = true ]) : string
Note that it will NOT html-escape the user provided documentation (ie. risky).
Parameters
- $server : Server
- $doctype : string = 'html'
-
type of documentation to generate: html (default), wsdl, etc...
- $lang : string = 'en'
-
language for docs
- $editorPath : string = ''
-
path to the visualeditor.html file, part of the jsxmlrpc lib. NB: when setting this, make sure that both that file and the xmlrpc_lib.js are present, with the same relative paths as in the original lib
- $displayExecutionForm : string = true
Tags
Return values
stringsetTemplate()
public
setTemplate(string $name, string $contents) : void
Parameters
- $name : string
- $contents : string
templates()
public
static templates() : array<string|int, string>
Return values
array<string|int, string>render()
protected
render(string $templateName[, array<string|int, mixed> $params = array() ]) : string
Parameters
- $templateName : string
- $params : array<string|int, mixed> = array()