3 * Base of the class and module exporter.
\r
5 * @version $Id: PhpdocXMLDocumentExporter.php,v 1.2 2000/12/03 22:37:38 uw Exp $
\r
7 class PhpdocXMLDocumentExporter extends PhpdocXMLExporter {
\r
10 * Mapping from internal result array index name to xml tag name.
\r
12 * @var array $docTags
\r
14 var $docTags = array(
\r
15 "desc" => "description",
\r
16 "sdesc" => "shortdescription",
\r
18 "version" => "version",
\r
20 "version" => "version",
\r
21 "deprec" => "deprecated",
\r
22 "copyright" => "copyright",
\r
23 "exclude" => "exclude",
\r
24 "brother" => "brother",
\r
29 * Attributes of the <see> container.
\r
31 * @var array $seeAttributes
\r
33 var $seeAttributes = array(
\r
39 * Attributes of the <link> container.
\r
41 * @var array $linkAttributes
\r
43 var $linkAttributes = array( "url" => "CDATA" );
\r
46 * Attributes of the <author> container.
\r
48 * @var array $authorAttributes
\r
50 var $authorAttributes = array( "email" => "CDATA" );
\r
53 * Attributes of <inherited> and <overriden> container.
\r
55 * @var array $inheritedOverridenAttributes
\r
57 var $inheritedOverridenAttributes = array(
\r
63 * Attributes of the <constant> container.
\r
65 * @var array $constAttributes
\r
67 var $constAttributes = array(
\r
69 "undoc" => "Boolean",
\r
70 "access" => "CDATA",
\r
75 * Attribues of the <uses> container.
\r
77 * @var array $usesAttributes
\r
79 var $usesAttributes = array(
\r
82 "undoc" => "Boolean"
\r
86 * Attribues of the <function> container.
\r
88 * @var array $functionAttributes
\r
90 var $functionAttributes = array(
\r
92 "undoc" => "Boolean",
\r
93 "access" => "CDATA",
\r
94 "abstract" => "Boolean",
\r
99 * Attributes of the <return> container.
\r
101 * @var array $returnAttributes
\r
103 var $returnAttributes = array(
\r
109 * Attributes of the <global> container.
\r
111 * @var array $globalAttributes
\r
113 var $globalAttributes = array(
\r
119 * Attributes of the <param> container.
\r
121 * @var array $paramAttributes
\r
123 var $paramAttributes = array(
\r
125 "default" => "CDATA",
\r
127 "undoc" => "Boolean"
\r
131 * Writes a <file> container.
\r
133 * @param string $file filename
\r
135 function filenameXML($file) {
\r
136 $this->xmlwriter->addElement("file", $file);
\r
137 } // end func filenameXML
\r
140 * Adds all constants (define(), const) to the xml document.
\r
142 * @param array Array of constants
\r
143 * @return boolean Returns false on failure otherwise true
\r
145 function constsXML($consts) {
\r
146 if (!is_array($consts) || 0 == count($consts))
\r
150 while (list($k, $data)=each($consts)) {
\r
152 $attribs = $this->getAttributes($data, $this->constAttributes);
\r
153 $this->xmlwriter->startElement("constant", (isset($data["value"])) ? $data["value"] : "", $attribs, false, true);
\r
154 $this->docXML($data);
\r
155 $this->xmlwriter->endElement("constant", true);
\r
160 } // end func constsXML
\r
163 * Adds a list of used files (include, require...) to the xml document.
\r
167 function usesXML($uses) {
\r
168 if (!is_array($uses)) {
\r
169 $this->err[] = new PhpdocError("No array given.", __FILE__, __LINE__);
\r
174 while (list($k, $data) = each($uses)) {
\r
176 $attribs = $this->getAttributes($data, $this->usesAttributes);
\r
177 $this->xmlwriter->startElement("uses", "", $attribs, false, true);
\r
178 $this->docXML($data);
\r
179 $this->xmlwriter->endElement("uses", true);
\r
184 } // end func usesXML
\r
187 * Adds a list of functions to the xml file.
\r
191 function functionsXML($functions) {
\r
192 if (!is_array($functions)) {
\r
193 $this->err[] = new PhpdocError("No array given.", __FILE__, __LINE__);
\r
198 while (list($k, $data) = each($functions)) {
\r
200 $attribs = $this->getAttributes($data, $this->functionAttributes);
\r
201 $this->xmlwriter->startElement("function", "", $attribs, false, true);
\r
202 $this->docXML($data);
\r
203 $this->xmlwriter->endElement("function", true);
\r
207 } // end functionsXML
\r
210 * Adds a documentation block (author, links, see, params...) to the xml document
\r
214 function docXML($data) {
\r
216 $this->xmlwriter->startElement("doc", "", "", false, true);
\r
218 if (isset($data["link"]))
\r
219 $this->linkXML($data["link"]);
\r
221 if (isset($data["author"]))
\r
222 $this->authorXML($data["author"]);
\r
224 if (isset($data["see"]))
\r
225 $this->seeXML($data["see"]);
\r
227 if (isset($data["params"]))
\r
228 $this->paramsXML($data["params"]);
\r
230 if (isset($data["return"]))
\r
231 $this->returnXML($data["return"]);
\r
233 if (isset($data["throws"]))
\r
234 $this->throwsXML($data["throws"]);
\r
236 if (isset($data["global"]))
\r
237 $this->globalsXML($data["global"]);
\r
239 if (isset($data["inherited"])) {
\r
244 "type" => $this->inheritedOverridenAttributes["src"],
\r
245 "value" => $data["inherited"]
\r
248 $this->xmlwriter->addElement("inherited", "", $attribs);
\r
251 if (isset($data["overrides"])) {
\r
254 "type" => $this->inheritedOverridenAttributes["src"],
\r
255 "value" => $data["overrides"]
\r
258 $this->xmlwriter->addElement("overriden", "", $attribs);
\r
261 reset($this->docTags);
\r
262 while (list($field, $tag) = each($this->docTags))
\r
263 if (isset($data[$field]))
\r
264 $this->xmlwriter->addElement($tag, $data[$field], "");
\r
266 $this->xmlwriter->endElement("doc", true);
\r
267 } // end func docXML
\r
270 * Adds <global> container to the xml document.
\r
274 function globalsXML($globals) {
\r
277 while (list($k, $data) = each($globals)) {
\r
278 $attribs = $this->getAttributes($data, $this->globalAttributes);
\r
279 $this->xmlwriter->addElement("global", (isset($data["desc"])) ? $data["desc"] : "", $attribs);
\r
282 } // end func globalsXML
\r
285 * Adds <throws> container to the xml document.
\r
289 function throwsXML($exceptions) {
\r
291 reset($exceptions);
\r
292 while (list($k, $exception) = each($exceptions))
\r
293 $this->xmlwriter->addElement("throws", $exception, "", true);
\r
295 } // end func throwsXML
\r
298 * Adds <return> container to the xml document.
\r
302 function returnXML($return) {
\r
306 if (is_array($return)) {
\r
308 if (isset($return["desc"])) {
\r
309 $desc = $return["desc"];
\r
310 unset($return["desc"]);
\r
312 $attribs = $this->getAttributes($return, $this->returnAttributes);
\r
316 $attribs["type"] = array( "type" => "CDATA", "value" => $return );
\r
320 $this->xmlwriter->addElement("return", $desc, $attribs);
\r
322 } // end func returnXML
\r
325 * Adds <parameter> container to the xml document.
\r
329 function paramsXML($params) {
\r
332 while (list($k, $data) = each($params)) {
\r
333 $attribs = $this->getAttributes($data, $this->paramAttributes);
\r
334 $this->xmlwriter->addElement("parameter", (isset($data["desc"])) ? $data["desc"] : "", $attribs);
\r
337 } // end func paramsXML
\r
340 * Adds <author> container to the xml document.
\r
344 function authorXML($authors) {
\r
347 while (list($k, $data) = each($authors)) {
\r
349 $attribs = array();
\r
351 if (isset($data["mail"]))
\r
354 "type" => $this->authorAttributes["email"],
\r
355 "value" => $data["mail"]
\r
358 $this->xmlwriter->addElement("author",$data["name"], $attribs);
\r
362 } // end func authorXML
\r
365 * Adds <link> container to the xml document.
\r
369 function linkXML($links) {
\r
372 while (list($k, $data) = each($links)) {
\r
376 "type" => $this->linkAttributes["url"],
\r
377 "value" => $data["url"]
\r
380 $this->xmlwriter->addElement("link", (isset($data["desc"])) ? $data["desc"] : "", $attribs);
\r
384 } // end func linkXML
\r
387 * Adds <see> container to the xml document.
\r
391 function seeXML($see) {
\r
394 while (list($type, $data) = each($see)) {
\r
397 while (list($k, $data2) = each($data)) {
\r
401 "type" => $this->seeAttributes["type"],
\r
402 "value" => strtolower($type)
\r
405 if (isset($data2["group"]))
\r
406 $attribs["group"] = array(
\r
407 "type" => $this->seeAttributes["group"],
\r
408 "value" => $data2["group"]
\r
411 $this->xmlwriter->addElement("see", $data2["name"], $attribs);
\r
417 } // end func SeeXML
\r
419 } // end class PhpdocXMLDocumentExporter
\r