3 // $Id: Function.php,v 1.3 2004/10/08 17:46:47 pmjones Exp $
5 class Text_Wiki_Render_Xhtml_Function
extends Text_Wiki_Render
{
8 // list separator for params and throws
11 // the "main" format string
12 'format_main' => '%access %return <b>%name</b> ( %params ) %throws',
14 // the looped format string for required params
15 'format_param' => '%type <i>%descr</i>',
17 // the looped format string for params with default values
18 'format_paramd' => '[%type <i>%descr</i> default %default]',
20 // the looped format string for throws
21 'format_throws' => '<b>throws</b> %type <i>%descr</i>'
26 * Renders a token into text matching the requested format.
30 * @param array $options The "options" portion of the token (second
33 * @return string The text rendered from the token options.
37 function token($options)
39 extract($options); // name, access, return, params, throws
41 // build the baseline output
42 $output = $this->conf
['format_main'];
43 $output = str_replace('%access', htmlspecialchars($access), $output);
44 $output = str_replace('%return', htmlspecialchars($return), $output);
45 $output = str_replace('%name', htmlspecialchars($name), $output);
47 // build the set of params
49 foreach ($params as $key => $val) {
51 // is there a default value?
52 if ($val['default']) {
53 $tmp = $this->conf
['format_paramd'];
55 $tmp = $this->conf
['format_param'];
58 // add the param elements
59 $tmp = str_replace('%type', htmlspecialchars($val['type']), $tmp);
60 $tmp = str_replace('%descr', htmlspecialchars($val['descr']), $tmp);
61 $tmp = str_replace('%default', htmlspecialchars($val['default']), $tmp);
65 // insert params into output
66 $tmp = implode($this->conf
['list_sep'], $list);
67 $output = str_replace('%params', $tmp, $output);
69 // build the set of throws
71 foreach ($throws as $key => $val) {
72 $tmp = $this->conf
['format_throws'];
73 $tmp = str_replace('%type', htmlspecialchars($val['type']), $tmp);
74 $tmp = str_replace('%descr', htmlspecialchars($val['descr']), $tmp);
78 // insert throws into output
79 $tmp = implode($this->conf
['list_sep'], $list);
80 $output = str_replace('%throws', $tmp, $output);
82 // close the div and return the output
84 return "\n$output\n\n";