1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14:
15: class Horde_Reflection_Wiki extends Horde_Reflection {
16:
17: 18: 19: 20: 21:
22: private function _getSignature()
23: {
24: $name = $this->_name;
25: $returnType = $this->_returns;
26:
27: $title = substr($this->_name, strpos($name, '_', 2) + 1);
28: $desc = substr($this->_help, 0, 20) . '...';
29:
30: $result = "++$title - $desc\n";
31: $result .= "##gray|($returnType)## ";
32: $result .= "##660000|$title##";
33: $result .= "(";
34: $first = true;
35: $nbr = 0;
36: while (list($name, $parameter) = each($this->_parameters)) {
37: $nbr++;
38: if ($nbr == $this->_numberOfRequiredParameters + 1) {
39: $result .= " [ ";
40: }
41: if ($first) {
42: $first = false;
43: } else {
44: $result .= ', ';
45: }
46: $type = $parameter['type'];
47: $result .= "##gray|($type) ##";
48: $result .= "##336600|$name##";
49: }
50: reset($this->_parameters);
51: if ($nbr > $this->_numberOfRequiredParameters) {
52: $result .= " ] ";
53: }
54: $result .= ")";
55: return $result;
56: }
57:
58: 59: 60: 61: 62:
63: public function autoDocument()
64: {
65: $signature = $this->_getSignature();
66: $id = md5($this->_name);
67: $help = trim(strip_tags($this->_help));
68:
69: $html = "$signature\n";
70: if ($help) {
71: $html .= "\nDescription : \n<code>\n$help\n</code>\n";
72: }
73:
74: if (count($this->_parameters)>0) {
75: $html .= "Parameters: \n";
76: if (count($this->_parameters)>0) {
77:
78: $html .= "||~ Type||~ Name||~ Documentation||\n";
79: while (list($name, $parameter) = each($this->_parameters)) {
80: $type = $parameter['type'];
81: if (is_array($type)) {
82: $type = implode(' | ', $type);
83: }
84: if (isset($parameter['doc'])) {
85: $doc = htmlentities($parameter['doc']);
86: } else {
87: $doc = '';
88: echo 'Missing doc for ' . $this->_name . '<br />';
89: }
90: $html .= "||$type||$name||$doc||\n";
91: }
92: reset($this->_parameters);
93: }
94: }
95:
96: return $html;
97: }
98:
99: }
100: