c3a9fa1ec04837b5f51c546421fb446634bb9f4b
[atutor.git] / mods / phpdoc / PHPDoc / renderer / html / PhpdocHTMLDocumentRenderer.php
1 <?php\r
2 /**\r
3 * Provides functioninality to render modules and classes.\r
4 *\r
5 * @version $Id: PhpdocHTMLDocumentRenderer.php,v 1.4 2000/12/03 22:37:37 uw Exp $\r
6 */\r
7 class PhpdocHTMLDocumentRenderer extends PhpdocHTMLRenderer {\r
8 \r
9         /**\r
10         * Message displayed if an object lacks documentation.\r
11         *\r
12         * @var  string  $undocumented\r
13         * @access       public\r
14         */\r
15         var $undocumented = "Warning: documentation is missing.";\r
16 \r
17         /**\r
18         * Array of functions found in the xml document.\r
19         *\r
20         * @var  array   $functions\r
21         */\r
22         var $functions = array();\r
23 \r
24         /**\r
25         * Array of included files.\r
26         *\r
27         * @var  array   $uses\r
28         */\r
29         var $uses = array();\r
30 \r
31         /**\r
32         * Array of constants.\r
33         *\r
34         * @var  array   $constants\r
35         */\r
36         var $constants = array();\r
37 \r
38         /**\r
39         * Array of access modifiers.\r
40         *\r
41         * @var  array   $accessModifiers\r
42         */\r
43         var $accessModifiers = array("public", "private");\r
44 \r
45         /**\r
46         * Array of doc container fields that get mapped directly to templateblocks.\r
47         *\r
48         * @var  array   $simpleDocfields\r
49         * @see  renderVariableDetail()\r
50         */      \r
51         var $simpleDocfields = array(\r
52                                                                                                                                 "VERSION"                       => "version", \r
53                                                                                                                                 "SINCE"                         => "since",\r
54                                                                                                                                 "DEPRECATED"    => "deprecated", \r
55                                                                                                                                 "COPYRIGHT"             => "copyright", \r
56                                                                                                                                 "MAGIC"                         => "magic" \r
57                                                                                                                         );\r
58 \r
59         /**\r
60         * Types of include statements.\r
61         *\r
62         * @var  array   $usesTypes\r
63         * @see  renderUses()\r
64         */                                                                                                                      \r
65         var $usesTypes = array( "include", "include_once", "require", "require_once" );\r
66 \r
67         /**\r
68         * Adds a summary and a detailed list of all constants to the template.\r
69         *\r
70         * @see  renderConstantSummary(), renderConstantDetail()\r
71         */                                                                                                                                                      \r
72         function renderConstants() {\r
73 \r
74                 $this->constants["public"]      = $this->accessor->getConstantsByAccess("public");\r
75                 $this->constants["private"] = $this->accessor->getConstantsByAccess("private");\r
76 \r
77                 if (0 == count($this->constants["public"]) && 0 == count($this->constants["private"]))\r
78                         return;\r
79 \r
80                 $this->renderConstantSummary();\r
81                 $this->renderConstantDetail();\r
82                 $this->constants = array();\r
83 \r
84         } // end func renderConstants\r
85 \r
86         /**\r
87         * Adds a summary of all constants to the template.\r
88         *\r
89         * The function assumes that there is a block called "constantssummary" and\r
90         * withing this block a bock called "constantssummary_loop" in the template.\r
91         * \r
92         * @see  renderConstantDetail()\r
93         */      \r
94         function renderConstantSummary() {\r
95 \r
96                 reset($this->accessModifiers);\r
97                 while (list($k, $access) = each($this->accessModifiers)) {\r
98                         if (0 == count($this->constants[$access])) \r
99                                 continue;\r
100 \r
101                         $this->tpl->setCurrentBlock("constantssummary_loop");\r
102 \r
103                         reset($this->constants[$access]);\r
104                         while (list($name, $const) = each($this->constants[$access])) {\r
105 \r
106                                 $this->tpl->setVariable("NAME", $name);\r
107                                 $this->tpl->setVariable("VALUE", htmlentities($const["value"]));                        \r
108                                 \r
109                                 if (isset($const["doc"]["shortdescription"]))\r
110                                         $this->tpl->setVariable("SHORTDESCRIPTION", $this->encode($const["doc"]["shortdescription"]["value"]));\r
111 \r
112                                 if ("true" == $const["undoc"])\r
113                                         $this->tpl->setVariable("UNDOC", $this->undocumented);\r
114 \r
115                                 $this->tpl->parseCurrentBlock();\r
116                         }\r
117 \r
118                         $this->tpl->setCurrentBlock("constantssummary");\r
119                         $this->tpl->setVariable("ACCESS", ucfirst($access));\r
120                         $this->tpl->parseCurrentBlock();\r
121 \r
122                 }\r
123 \r
124         } // end func renderConstantSummary\r
125 \r
126         /** \r
127         * Adds a detailed list of all constants to the template.\r
128         * \r
129         * The function assumes that there is a block named "constantdetails" and\r
130         * withing it another block named "constantdetails_loop". \r
131         *\r
132         * @see  renderConstantSummary()\r
133         */      \r
134         function renderConstantDetail() {\r
135 \r
136                 reset($this->accessModifiers);\r
137                 while (list($k, $access) = each($this->accessModifiers)) {\r
138                         if (0 == count($this->constants[$access]))\r
139                                 continue;\r
140 \r
141                         reset($this->constants[$access]);\r
142                         while (list($name, $constant) = each($this->constants[$access])) {\r
143 \r
144                                 $tplvars = array();\r
145                                 $tplvars["NAME"]        =       $name;\r
146                                 $tplvars["CASE"]        = $constant["case"];\r
147                                 $tplvars["VALUE"]       =       htmlentities($constant["value"]);\r
148 \r
149                                 if ("true" == $constant["undoc"])\r
150                                         $tplvars["UNDOC"] = $this->undocumented;\r
151 \r
152                                 if (isset($constant["doc"]["shortdescription"]))\r
153                                         $tplvars["SHORTDESCRIPTION"] = $this->encode($constant["doc"]["shortdescription"]["value"]);\r
154 \r
155                                 if (isset($constant["doc"]["description"]))\r
156                                         $tplvars["DESCRIPTION"] = $this->encode($constant["doc"]["description"]["value"]);\r
157 \r
158                                 $this->renderCommonDocfields("constantdetails_", $constant);\r
159 \r
160                                 $this->tpl->setCurrentBlock("constantdetails_loop");\r
161                                 $this->tpl->setVariable($tplvars);\r
162                                 $this->tpl->parseCurrentBlock();\r
163                         }\r
164 \r
165                         $this->tpl->setCurrentBlock("constantdetails");\r
166                         $this->tpl->setVariable("ACCESS", ucfirst($access));\r
167                         $this->tpl->parseCurrentBlock();\r
168                 }       \r
169 \r
170         } // end func renderConstantsDetail\r
171 \r
172         /**\r
173         * Adds a summary and a detailed list of included files to the template.\r
174         * @see  renderUsesSummary(), renderUsesDetail()\r
175         */              \r
176         function renderUses() {\r
177 \r
178                 $found = false;\r
179                 \r
180                 reset($this->usesTypes);\r
181                 while (list($k, $type) = each($this->usesTypes)) {\r
182 \r
183                         $this->uses[$type] = $this->accessor->getUsesByType($type);\r
184                         if (!$found && 0 != count($this->uses[$type]))\r
185                                 $found = true;\r
186 \r
187                 }\r
188 \r
189                 if (!$found)\r
190                         return;\r
191 \r
192                 $this->renderUsesSummary();\r
193                 $this->renderUsesDetail();\r
194 \r
195                 $this->uses = array();\r
196         } // end func renderUses                                                                                                                        \r
197 \r
198         /**\r
199         * Adds a detailed list of all included files to the template.\r
200         * \r
201         * The function assumes that there is a block names "usesdetail" and within the block \r
202         * a block names "usesdetail_loop" in the template.\r
203         *\r
204         * @see  renderUsesSummary()\r
205         */      \r
206         function renderUsesDetail() {\r
207 \r
208                 reset($this->usesTypes);\r
209                 while (list($k, $type) = each($this->usesTypes)) {\r
210                         if (0 == count($this->uses[$type]))\r
211                                 continue;\r
212 \r
213                         reset($this->uses[$type]);\r
214                         while (list($file, $uses) = each($this->uses[$type])) {\r
215 \r
216                                 $tplvars = array();\r
217                                 $tplvars["FILE"]        = $uses["file"];\r
218                                 $tplvars["TYPE"]        = $type;\r
219 \r
220                                 if ("true" == $uses["undoc"])\r
221                                         $tplvars["UNDOC"] = $this->undocumented;\r
222 \r
223                                 if (isset($uses["doc"]["shortdescription"]))\r
224                                         $tplvars["SHORTDESCRIPTION"] = $this->encode($uses["doc"]["shortdescription"]["value"]);\r
225 \r
226                                 if (isset($uses["doc"]["description"]))\r
227                                         $tplvars["DESCRIPTION"] = $this->encode($uses["doc"]["description"]["value"]);\r
228                                 \r
229                                 $this->renderCommonDocfields("usesdetails_", $uses);\r
230                                 $this->tpl->setCurrentBlock("usesdetails_loop");\r
231                                 $this->tpl->setVariable($tplvars);\r
232                                 $this->tpl->parseCurrentBlock();\r
233                         }\r
234 \r
235                         $this->tpl->setCurrentBlock("usesdetails");\r
236                         $this->tpl->setVariable("TYPE", $type);\r
237                         $this->tpl->parseCurrentBlock();\r
238                 }\r
239 \r
240         } // end func renderUsesDetail\r
241 \r
242         /** \r
243         * Adds a summary of all included files to the template.\r
244         * \r
245         * The function assumes that there is a block names "usessummary" and within\r
246         * the block another block names "usessummary_loop" in the template.\r
247         * \r
248         * @see  renderUsesDetail()\r
249         */      \r
250         function renderUsesSummary() {\r
251 \r
252                 reset($this->usesTypes);\r
253                 while (list($k, $type) = each($this->usesTypes)) {\r
254                         if (0 == count($this->uses[$type]))\r
255                                 continue;\r
256 \r
257                         $this->tpl->setCurrentBlock("usessummary_loop");\r
258 \r
259                         reset($this->uses[$type]);\r
260                         while (list($file, $uses) = each($this->uses[$type])) {\r
261 \r
262                                 $this->tpl->setVariable("FILE", $file);\r
263                                 if (isset($uses["doc"]["shortdescription"]))\r
264                                         $this->tpl->setVariable("SHORTDESCRIPTION", $this->encode($uses["doc"]["shortdescription"]["value"]));\r
265 \r
266                                 if ("true" == $uses["undoc"])\r
267                                         $this->tpl->setVariable("UNDOC", $this->undocumented);\r
268 \r
269                                 $this->tpl->parseCurrentBlock();\r
270                         }\r
271 \r
272                         $this->tpl->setCurrentBlock("usessummary");\r
273                         $this->tpl->setVariable("TYPE", $type);\r
274                         $this->tpl->parseCurrentBlock();\r
275                 }\r
276 \r
277         } // end func renderUsesSummary\r
278 \r
279         /**\r
280         * Adds a summary and a detailed list of all functions to the template.\r
281         *\r
282         * @see  renderFunctionSummary(), renderFunctionDetail(), $functions\r
283         */\r
284         function renderFunctions() {\r
285 \r
286                 $this->functions["private"] = $this->accessor->getFunctionsByAccess("private");\r
287                 $this->functions["public"]      = $this->accessor->getFunctionsByAccess("public");\r
288 \r
289                 if (0 == count($this->functions["private"]) && 0 == count($this->functions["public"]))\r
290                         return;\r
291 \r
292                 $this->renderFunctionSummary();\r
293                 $this->renderFunctionDetail();\r
294                 $this->functions = array();\r
295                 \r
296         } // end func renderFunctions\r
297 \r
298         /**\r
299         * Adds a function summary to the template.\r
300         * \r
301         * The function assumes that there is ablock names "functionsummary" and \r
302         * within it a block names "functionsummary_loop" in the template. \r
303         *\r
304         * @see  renderFunctionDetail(), renderFunctions(), $functions, $accessModifiers\r
305         */      \r
306         function renderFunctionSummary() {\r
307 \r
308                 reset($this->accessModifiers);\r
309                 while (list($k, $access) = each($this->accessModifiers)) {\r
310                         if (0 == count($this->functions[$access])) \r
311                                 continue;                       \r
312 \r
313                         $this->tpl->setCurrentBlock("functionsummary_loop");\r
314                         reset($this->functions[$access]);\r
315                         while (list($name, $function) = each($this->functions[$access])) {\r
316 \r
317                                 $this->tpl->setVariable("NAME", $name);\r
318                                 \r
319                                 if (isset($function["doc"]["parameter"]))\r
320                                         $this->tpl->setVariable("PARAMETER", $this->getParameter($function["doc"]["parameter"]));\r
321 \r
322                                 if (isset($function["doc"]["shortdescription"]))\r
323                                         $this->tpl->setVariable("SHORTDESCRIPTION", $this->encode($function["doc"]["shortdescription"]["value"]));\r
324 \r
325                                 if (isset($function["doc"]["return"]))\r
326                                         $this->tpl->setVariable("RETURNTYPE", $function["doc"]["return"]["type"]);\r
327                                 else\r
328                                         $this->tpl->setVariable("RETURNTYPE", "void");\r
329 \r
330                                 if ("true" == $function["undoc"])\r
331                                         $this->tpl->setVariable("UNDOC", $this->undocumented);\r
332 \r
333                                 $this->tpl->parseCurrentBlock();\r
334                         }\r
335 \r
336                         $this->tpl->setCurrentBlock("functionsummary");                         \r
337                         $this->tpl->setVariable("ACCESS", ucfirst($access) );\r
338                         $this->tpl->parseCurrentBlock();\r
339                 }\r
340 \r
341         } // end func renderFunctionSummary\r
342 \r
343         /**\r
344         * Adds a detailed list of functions to the template.\r
345         *\r
346         * The function assumes that there is a block named "functiondetails" and \r
347         * within it a bloc "functiondetails_loop" in the template.\r
348         *\r
349         * @see  renderFunctions(), renderFunctionSummary(), $functions, $accessModifiers\r
350         */\r
351         function renderFunctionDetail() {\r
352 \r
353                 reset($this->accessModifiers);\r
354                 while (list($k, $access) = each($this->accessModifiers)) {\r
355                         if (0 == count($this->functions[$access]))\r
356                                 continue;\r
357 \r
358                         reset($this->functions[$access]);\r
359                         while (list($name, $function) = each($this->functions[$access])) {\r
360 \r
361                                 $tplvars = array();\r
362                                 $tplvars["NAME"]                = $function["name"];\r
363                                 $tplvars["ACCESS"]      = $function["access"];\r
364 \r
365                                 if ("true" == $function["undoc"])\r
366                                         $tplvars["UNDOC"]  = $this->undocumented;\r
367 \r
368                                 if ("true" == $function["abstract"])\r
369                                         $tplvars["ABSTRACT"] = "abstract";\r
370 \r
371                                 if ("true" == $function["static"])\r
372                                         $tplvars["STATIC"] = "static";\r
373 \r
374                                 if (isset($function["doc"]["shortdescription"]))\r
375                                         $tplvars["SHORTDESCRIPTION"] = $this->encode($function["doc"]["shortdescription"]["value"]);\r
376 \r
377                                 if (isset($function["doc"]["description"]))\r
378                                         $tplvars["DESCRIPTION"] = $this->encode($function["doc"]["description"]["value"]);\r
379 \r
380                                 $this->renderCommonDocfields("functiondetails_", $function);\r
381                                 \r
382                                 if (isset($function["doc"]["parameter"])) {\r
383                                         $tplvars["PARAMETER"] = $this->getParameter($function["doc"]["parameter"]);\r
384                                         $this->renderParameterDetail($function["doc"]["parameter"]);\r
385                                 }\r
386                                 \r
387                                 if (isset($function["doc"]["throws"]))\r
388                                         $this->renderThrows($function["doc"]["throws"], "functiondetails_");\r
389 \r
390                                 if (isset($function["doc"]["global"])) \r
391                                         $this->renderGlobals($function["doc"]["global"], "functiondetails_");\r
392 \r
393                                 if (isset($function["doc"]["return"])) {\r
394 \r
395                                         $tplvars["RETURNTYPE"] = $function["doc"]["return"]["type"];                                    \r
396 \r
397                                         $this->tpl->setCurrentBlock("functiondetails_return");\r
398                                         $this->tpl->setVariable("TYPE", $function["doc"]["return"]["type"]);\r
399                                         $this->tpl->setVariable("DESCRIPTION", $this->encode($function["doc"]["return"]["value"]));\r
400 \r
401                                         if (isset($function["doc"]["return"]["name"]))\r
402                                                 $this->tpl->setVariable("NAME", $function["doc"]["return"]["name"]);\r
403 \r
404                                         $this->tpl->parseCurrentBlock();\r
405 \r
406                                 } else {\r
407 \r
408                                         $tplvars["RETURNTYPE"] = "void";\r
409 \r
410                                 }\r
411 \r
412                                 $this->tpl->setCurrentBlock("functiondetails_loop");    \r
413                                 $this->tpl->setVariable($tplvars);\r
414                                 $this->tpl->parseCurrentBlock();        \r
415                         }\r
416 \r
417                         $this->tpl->setCurrentBlock("functiondetails");\r
418                         $this->tpl->setVariable("ACCESS", ucfirst($access) );\r
419                         $this->tpl->parseCurrentBlock();\r
420                 }\r
421 \r
422         } // end func renderFunctionDetail\r
423 \r
424         /**\r
425         * Renders a detailed list of function parameters.\r
426         *\r
427         * The function assumes that there is a block named "functiondetails_parameter" in \r
428         * the template and within it a block named "functiondetails_parameter_loop".\r
429         *\r
430         * @param        array   Parameter\r
431         */\r
432         function renderParameterDetail($parameter) {\r
433 \r
434                 if (!isset($parameter[0]))\r
435                         $parameter = array($parameter);\r
436 \r
437                 $this->tpl->setCurrentBlock("functiondetails_parameter_loop");\r
438                 \r
439                 reset($parameter);\r
440                 while (list($k, $param) = each($parameter)) {\r
441 \r
442                         $this->tpl->setVariable("NAME", $param["name"]);\r
443                         $this->tpl->setVariable("DESCRIPTION", $this->encode($param["value"]));\r
444 \r
445                         if (isset($param["type"]))\r
446                                 $this->tpl->setVariable("TYPE", $param["type"]);\r
447 \r
448                         if (isset($param["default"]))\r
449                                 $this->tpl->setVariable("DEFAULT", "= >>".htmlentities($param["default"])."<<");\r
450 \r
451                         if ("true" == $param["undoc"])\r
452                                 $this->tpl->setVariable("UNDOC", $this->undocumented);\r
453 \r
454                         $this->tpl->parseCurrentBlock();                        \r
455                 }\r
456 \r
457         } // end func renderParameterDetail\r
458 \r
459         /**\r
460         * Converts the XML parameter array into formatted string.\r
461         *\r
462         * @param        array   XML parameter array\r
463         * @return       string  Formatted parameter string\r
464         */\r
465         function getParameter($parameter) {\r
466 \r
467                 if (!is_array($parameter))\r
468                         return "void";\r
469 \r
470                 $value = "";\r
471 \r
472                 if (!isset($parameter[0])) {\r
473 \r
474                         if (!isset($parameter["default"]))\r
475                                 $value .= $parameter["type"] . " " . $parameter["name"];\r
476                         else\r
477                                 $value .= "[ ".$parameter["type"] . " " . $parameter["name"]." ]";\r
478 \r
479                 } else {\r
480 \r
481                         $flag_optional = false;\r
482 \r
483                         reset($parameter);\r
484                         while (list($k, $param) = each($parameter)) {\r
485 \r
486                                 if (!isset($param["default"])) {\r
487                                         if ($flag_optional) {\r
488                                                 $value = substr($value, 0, -2)." ], ";\r
489                                                 $flag_optional = false;\r
490                                         }\r
491                                 } else {\r
492                                         if (!$flag_optional) {\r
493                                                 $value .= "[ ";\r
494                                                 $flag_optional = true;\r
495                                         }\r
496                                 }\r
497 \r
498                                 $value .= $param["type"] . " " . $param["name"].", ";\r
499                         }\r
500 \r
501                         $value = substr($value, 0, -2);\r
502                         if ($flag_optional)\r
503                                 $value .= " ]";\r
504 \r
505                 }\r
506 \r
507                 return $value;          \r
508         } // end func getParameter\r
509 \r
510         /**\r
511         * Renders a block with references to other source elements.\r
512         *\r
513         * @param        array           XML references array\r
514         * @param        string  optional template blockname prefix\r
515         */      \r
516         function renderSee($references, $prefix = "") {\r
517 \r
518                 $value = "";            \r
519                 if (!isset($references[0])) {\r
520 \r
521                         if (isset($references["group"]))\r
522                                 $value .= sprintf('<a href="%s#%s_%s">%s::%s</a>',\r
523                                                                                                                 $this->nameToUrl($references["group"]).$this->file_extension,\r
524                                                                                                                 $references["type"],\r
525                                                                                                                 $references["value"],\r
526                                                                                                                 $references["group"],\r
527                                                                                                                 $references["value"] \r
528                                                                                                 );\r
529                         else \r
530                                 $value .= sprintf('<a href="#%s_%s">%s</a>',\r
531                                                                                                                 $references["type"],\r
532                                                                                                                 $references["value"],\r
533                                                                                                                 $references["value"]\r
534                                                                                                         );\r
535 \r
536                 } else {\r
537                                 \r
538                         reset($references);\r
539                         while (list($k, $reference) = each($references)) {\r
540 \r
541                                 if (isset($reference["group"]))\r
542                                         $value .= sprintf('<a href="%s#%s_%s">%s::%s</a>, ',\r
543                                                                                                                         $this->nameToUrl($reference["group"]).$this->file_extension,\r
544                                                                                                                         $reference["type"],\r
545                                                                                                                         $reference["value"],\r
546                                                                                                                         $reference["group"],\r
547                                                                                                                         $reference["value"] \r
548                                                                                                         );\r
549                                 else \r
550                                         $value .= sprintf('<a href="#%s_%s">%s</a>, ',\r
551                                                                                                                         $reference["type"],\r
552                                                                                                                         $reference["value"],\r
553                                                                                                                         $reference["value"]\r
554                                                                                                                 );\r
555 \r
556                         }       \r
557 \r
558                         $value = substr($value, 0, -2);\r
559                 }\r
560 \r
561                 $this->tpl->setCurrentBlock(strtolower($prefix) . "see");\r
562                 $this->tpl->setVariable("SEE", $value);\r
563                 $this->tpl->parseCurrentBlock();\r
564                 \r
565         } // end func renderSee\r
566 \r
567         /**\r
568         * Renders an author list.\r
569         *\r
570         * @param        array           XML author array\r
571         * @param        string  optional template blockname prefix\r
572         */      \r
573         function renderAuthors($authors, $prefix = "") {\r
574 \r
575                 $value = "";\r
576 \r
577                 if (!isset($authors[0])) {\r
578 \r
579                         if (isset($authors["email"]))\r
580                                 $value .= sprintf('%s &lt;<a href="mailto:%s">%s</a>&gt;, ', $authors["value"], $authors["email"], $authors["email"]);\r
581                         else \r
582                                 $value .= $authors["email"] . ", ";\r
583 \r
584                 } else {\r
585 \r
586                         reset($authors);\r
587                         while (list($k, $author) = each($authors)) {\r
588 \r
589                                 if (isset($author["email"]))\r
590                                         $value .= sprintf('%s &lt;<a href="mailto:%s">%s</a>&gt;, ', $author["value"], $author["email"], $author["email"]);\r
591                                 else \r
592                                         $value .= $author["email"] . ", ";\r
593 \r
594                         }\r
595 \r
596                 }\r
597 \r
598                 $value = substr($value, 0, -2);\r
599                 $this->tpl->setCurrentBlock(strtolower($prefix) . "authors");\r
600                 $this->tpl->setVariable("AUTHOR", $value);\r
601                 $this->tpl->parseCurrentBlock();\r
602 \r
603         } // end func renderAuthors\r
604 \r
605         /**\r
606         * Renders a list of external links.\r
607         *\r
608         * @param        array           XML link array\r
609         * @param        string  optional template blockname prefix\r
610         */\r
611         function renderLinks($links, $prefix = "") {\r
612 \r
613                 $value = "";\r
614                 if (!isset($links[0])) {\r
615                         $value .= sprintf('<a href="%s">%s</a>%s, ', \r
616                                                                                                         $links["url"], \r
617                                                                                                         $links["url"], \r
618                                                                                                         ("" != $links["description"]) ? " - " . $links["description"] : ""\r
619                                                                                                 );\r
620                 } else {\r
621 \r
622                         reset($links);\r
623                         while (list($k, $link) = each($links)) {\r
624                                 $value .= sprintf('<a href="%s">%s</a>%s, ', \r
625                                                                                                                 $link["url"], \r
626                                                                                                                 $link["url"], \r
627                                                                                                                 ("" != $link["description"]) ? " - " . $links["description"] : ""\r
628                                                                                                         ); \r
629                         }\r
630 \r
631                 }\r
632 \r
633                 $value = substr($value, 0, 2);\r
634                 $this->tpl->setCurrentBlock(strtolower($prefix) . "links");\r
635                 $this->tpl->setVariable("LINK", $value);\r
636                 $this->tpl->parseCurrentBlock();\r
637 \r
638         } // end func renderLinks\r
639 \r
640         /**\r
641         * Renders a list of exceptions.\r
642         *\r
643         * @param        array           XML array \r
644         * @param        string  optional template blockname prefix\r
645         */\r
646         function renderThrows($throws, $prefix = "") {\r
647 \r
648                 $value = "";\r
649                 if (!isset($throws[0])) {\r
650                 \r
651                         $value = $throws["value"];\r
652                         \r
653                 }       else {\r
654 \r
655                         reset($throws);\r
656                         while (list($k, $exception) = each($throws)) \r
657                                 $value .= sprintf("%s, ", $exception["value"]);\r
658 \r
659                         $value = substr($value, 0, -2);\r
660 \r
661                 }       \r
662 \r
663                 $this->tpl->setCurrentBlock(strtolower($prefix) . "throws");\r
664                 $this->tpl->setVariable("EXCEPTIONS", $value);\r
665                 $this->tpl->parseCurrentBlock();\r
666 \r
667         } // end func renderThrows\r
668 \r
669         /**\r
670         * Renders a list of global elements.\r
671         *\r
672         * @param        array           XML globals array\r
673         * @param        string  optional template blockname prefix\r
674         */\r
675         function renderGlobals($globals, $prefix = "") {\r
676 \r
677                 $prefix = strtolower($prefix);\r
678                 $this->tpl->setCurrentBlock($prefix . "globals_loop");\r
679 \r
680                 if (!isset($globals[0])) {\r
681 \r
682                         $this->tpl->setVariable("NAME", $globals["name"]);\r
683                         $this->tpl->setVariable("DESCRIPTION", $this->encode($globals["value"]));\r
684 \r
685                         if (isset($globals["type"]))\r
686                                 $this->tpl->setVariable("TYPE", $globals["type"]);\r
687 \r
688                         $this->tpl->parseCurrentBlock();\r
689 \r
690                 } else {\r
691 \r
692                         reset($globals);\r
693                         while (list($k, $global) = each($globals)) {\r
694 \r
695                                 $this->tpl->setVariable("NAME", $global["name"]);\r
696                                 $this->tpl->setVariable("DESCRIPTION", $this->encode($global["value"]));\r
697 \r
698                                 if (isset($globals["type"]))\r
699                                         $this->tpl->setVariable("TYPE", $globals["type"]);\r
700 \r
701                                 $this->tpl->parseCurrentBlock();\r
702 \r
703                         }\r
704 \r
705                 }\r
706 \r
707         } // end func renderGlobals\r
708 \r
709         /**\r
710         * Adds some tags to the template that are allowed nearly everywhere.\r
711         *\r
712         * @param        string  template blockname prefixs\r
713         * @param        array           \r
714         * @see  $simpleDocfields, renderLinks(), renderAuthors(), renderSee()\r
715         */      \r
716         function renderCommonDocfields($block, &$data) {\r
717 \r
718                 reset($this->simpleDocfields);\r
719                 while (list($varname, $field) = each($this->simpleDocfields)) {\r
720 \r
721                         if (isset($data["doc"][$field])) {\r
722 \r
723                                 $this->tpl->setCurrentBlock($block.$field);\r
724                                 $this->tpl->setVariable($varname, htmlentities($data["doc"][$field]["value"]));\r
725                                 $this->tpl->parseCurrentBlock();\r
726 \r
727                         }\r
728 \r
729                 }\r
730 \r
731                 if (isset($data["doc"]["link"]))\r
732                         $this->renderLinks($data["doc"]["link"], $block);\r
733 \r
734                 if (isset($data["doc"]["author"])) \r
735                         $this->renderAuthors($data["doc"]["author"], $block);\r
736 \r
737                 if (isset($data["doc"]["see"]))\r
738                         $this->renderSee($data["doc"]["see"], $block);\r
739 \r
740         } // end func renderCommonDocfields\r
741 \r
742 } // end func PhpdocHTMLDocumentRenderer\r
743 ?>