+++ /dev/null
-<?php\r
-/**\r
-* Exporter used to export phpdoc internals data structures as xml documents.\r
-*\r
-* @version $Id: PhpdocXMLExporter.php,v 1.2 2000/12/03 22:37:38 uw Exp $\r
-*/\r
-class PhpdocXMLExporter extends PhpdocObject {\r
- \r
- /**\r
- * Filename prefix for the generated xml document.\r
- * \r
- * This class variable must be overriden by all derived classes.\r
- * PHPDoc uses the filename prefix to detect the content of \r
- * the file.\r
- * \r
- * @var string $fileprefix\r
- */\r
- var $fileprefix = "";\r
-\r
- /**\r
- * Target directory where the xml documents get saved.\r
- * @var string $path\r
- * @see setPath()\r
- */ \r
- var $path = "";\r
- \r
- /**\r
- * Data to save as a xml document.\r
- * @var array $result\r
- * @see setResult(), export()\r
- */\r
- var $result = array();\r
- \r
- /**\r
- * Instance of PhpdocXMLWriter used to generate the xml document.\r
- * @var object PhpdocXMLWriter\r
- * @see PhpdocXMLExporter()\r
- */\r
- var $xmlwriter;\r
- \r
- /**\r
- * Creates a PhpdocXMLWriter object.\r
- *\r
- * Make sure that all derived classes call this constructor.\r
- * \r
- * @see $xmlwriter\r
- */ \r
- function PhpdocXMLExporter() {\r
- \r
- $this->xmlwriter = new PhpdocXMLWriter;\r
- \r
- } // end constructor \r
-\r
- /**\r
- * Sets the target path for the generated xml documents.\r
- * \r
- * @param string\r
- * @see $path\r
- * @access public\r
- */ \r
- function setPath($path) {\r
- $this->path = $path;\r
- } // end func setPath\r
- \r
- /**\r
- * Exports the given result array as xml document.\r
- *\r
- * @param array \r
- * @param string name of the target xml file\r
- * @access public\r
- * @see create(), $result\r
- */\r
- function export($result, $xmlfile="") {\r
- \r
- if (0 == count($result))\r
- return;\r
-\r
- $this->result = $result;\r
- \r
- $this->xmlwriter->addXML('<?xml version="1.0"?>');\r
- $this->xmlwriter->startElement("phpdoc", "", "", false, true);\r
-\r
- $this->create();\r
-\r
- $this->xmlwriter->endElement("phpdoc", true);\r
- \r
- if ("" == $xmlfile)\r
- $xmlfile = $this->result["name"];\r
- \r
- /*\r
- if (file_exists($this->path.$xmlfile)) {\r
- $i = 1;\r
- while (file_exists($this->path.$name."_".$i.".xml"))\r
- $i++;\r
- \r
- $xmlfile = $name."_".$i.".xml";\r
- }\r
- */\r
- \r
- $xmlfile = $this->nameToURL($xmlfile);\r
- $xmlfile = $this->path.$this->fileprefix.$xmlfile.".xml";\r
- \r
- $this->xmlwriter->export($xmlfile);\r
- $this->xmlwriter->free();\r
- \r
- } // end func export\r
- \r
- /**\r
- * @param array\r
- */\r
- function setResult($result) {\r
- $this->result = $result;\r
- $this->create();\r
- } // end func setResult\r
- \r
- /**\r
- * Kind of array_intersect for xml attributes.\r
- * \r
- * This functions takes a data array and a list of allowed fields in the data\r
- * array. All of the allowed fields that exists in the data array will be \r
- * copied to returned array which looks like:\r
- * $attribs[name] = array ( type => allowed[name], value => data[name] ). \r
- * This structure is used by PhpdocXMLWriter->addElement().\r
- *\r
- * @param array data array\r
- * @param array array of allowed fields and their attribute type \r
- * @return array $attribs\r
- */\r
- function getAttributes($data, $allowed) {\r
- \r
- $attribs = array();\r
- \r
- reset($allowed);\r
- while (list($tag, $type)=each($allowed)) \r
- if (isset($data[$tag])) \r
- $attribs[$tag] = array( "type" => $type, "value" => $data[$tag] );\r
- \r
- return $attribs;\r
- } // end func getAttributes\r
-\r
-} // end PhpdocXMLExporter\r
-?>
\ No newline at end of file