removed mods directory from the ATutor codebase
[atutor.git] / mods / phpdoc / PHPDoc / xmlreader / PhpdocXMLReader.php
diff --git a/mods/phpdoc/PHPDoc/xmlreader/PhpdocXMLReader.php b/mods/phpdoc/PHPDoc/xmlreader/PhpdocXMLReader.php
deleted file mode 100644 (file)
index 88f3fc9..0000000
+++ /dev/null
@@ -1,225 +0,0 @@
-<?php\r
-/**\r
-* Reads XML documents into a multi dimensional Array.\r
-*\r
-* @version $Id: PhpdocXMLReader.php,v 1.2 2000/12/03 22:37:38 uw Exp $\r
-*/\r
-class PhpdocXMLReader extends PhpdocObject {\r
-       \r
-       /**\r
-       * PHPDocFileHandler object.\r
-       *\r
-       * @var  object PhpdocFileHandler\r
-       * @see  createFileHandler()\r
-       */\r
-       var $filehandler; \r
-\r
-       /**\r
-       * Values array from xml_parse_into_struct().\r
-       *\r
-       * @var  array\r
-       * @see  parse(), stripCloseFromStructvalues(), importXML()\r
-       */\r
-       var $structvalues = array();\r
-       \r
-       /**\r
-       * Parses a given XML file and returns the data as a hash.\r
-       * \r
-       * Please do not ask me for a in detail explanation of how it is done,\r
-       * the documentation is in the source...\r
-       *\r
-       * @param        string  $filename Name of the xml document\r
-       * @access       public\r
-       * @throws PhpdocError\r
-       * @see  importXML()\r
-       */      \r
-       function parse($filename) {\r
-       \r
-               if (""==$filename) {\r
-                       $this->err[] = new PhpdocError("No filename given.", __FILE__, __LINE__);\r
-                       return array();\r
-               }\r
-               \r
-               $parser = @xml_parser_create();\r
-               if (!$parser) {\r
-                       $this->err = PhpdocError("Can't create a XML Parser.", __FILE__, __LINE__);\r
-                       return array();\r
-               }\r
-               xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);\r
-               \r
-               $this->createFileHandler();\r
-               $xml = $this->filehandler->getFile($filename);\r
-\r
-               $values = array();\r
-               $index  = array();\r
-               xml_parse_into_struct($parser, $xml, &$values, &$index);\r
-               \r
-               xml_parser_free($parser);\r
-\r
-               $this->structvalues = $values;\r
-               $this->stripCloseFromStructvalues();\r
-               list($data, $last) = $this->importXML();\r
-               $this->structvalues = array();\r
-               \r
-               return $data;\r
-       } // end func parse\r
-\r
-       /**\r
-       * Creates a PhpdocFileHandler object and saves it to $filehandler if it does not already exist.\r
-       *\r
-       * @see  $filehandler\r
-       */      \r
-       function createFilehandler() {\r
-       \r
-               if (!isset($this->filehandler))\r
-                       $this->filehandler = new PhpdocFileHandler;\r
-                       \r
-       } // end func createFilehandler\r
-       \r
-       /**\r
-       * Strips all values out of the xml_parse_intro_struct() values array with the type "open".\r
-       *\r
-       * @see  $structvalues \r
-       */\r
-       function stripCloseFromStructvalues() {\r
-               \r
-               $values = array();\r
-               \r
-               reset($this->structvalues);\r
-               while (list($k, $v) = each($this->structvalues))\r
-                       if ("close" != $v["type"])\r
-                               $values[] = $v;\r
-                               \r
-               $this->structvalues = $values;\r
-       } // end func stripCloseFromStructvalues\r
-        \r
-       /**\r
-       * Converts an xml_parse_into_struct value array to an array that's simmilar to phpdocs internal arrays.\r
-       *\r
-       * Well, don't ask me to explain this hack. Just take it as it. For those who want to unterstand and optimize\r
-       * it:\r
-       *  - PHP3 compatibility is a must\r
-       *  - no XML DOM\r
-       *  - no eval(), this can't be optimized by the compiler\r
-       *\r
-       * @param        integer \r
-       * @param        integer\r
-       * @return       array   $data[0] = daten, $data[1] = some index value used for the recursion\r
-       * @see          addToArray()\r
-       */\r
-       function importXML($start = 0, $allowed_level = 1) {\r
-               \r
-               $data = array();\r
-               $last = 0;\r
-               \r
-               for ($i=$start; $i<count($this->structvalues); $i++) {\r
-                       if ($allowed_level != $this->structvalues[$i]["level"]) \r
-                               break;\r
-                       \r
-                       $value          = (isset($this->structvalues[$i]["value"])) ? $this->structvalues[$i]["value"] : "";\r
-                       $attribs        = (isset($this->structvalues[$i]["attributes"])) ? $this->structvalues[$i]["attributes"] : "";\r
-                       $tag                    = $this->structvalues[$i]["tag"];\r
-\r
-                       if ("open" == $this->structvalues[$i]["type"]) {\r
-\r
-                               list($inner, $next) = $this->importXML($i+1, $this->structvalues[$i]["level"]+1);\r
-                               \r
-                               // append the inner data to the current one\r
-                               $data                           = $this->addToArray($data, $tag, $value, $attribs, $inner);\r
-                               \r
-                               // skip some entries in $this->structvalues\r
-                               $i = $next;\r
-                               \r
-                       } else {\r
-                       \r
-                               // same level, append to the array\r
-                               $data = $this->addToArray($data, $tag, $value, $attribs);\r
-                               \r
-                       }\r
-                       \r
-                       // remember the last index in $this->structvalues we've worked on\r
-                       $last = $i;\r
-               }\r
-               \r
-               return array($data, $last);\r
-       } // end func importXML\r
-       \r
-       /**\r
-       * Appends some values to an array\r
-       * Well, don't ask me; just improve it with the remarks on buildXMLResult()\r
-       * @param        array\r
-       * @param        string\r
-       * @param        string  \r
-       * @param        array\r
-       * @param        array\r
-       * @return       array $target\r
-       */\r
-       function addToArray($target, $key, $value="", $attributes = "", $inner = "") {\r
-\r
-               if (!isset($target[$key]["value"]) && !isset($target[$key][0])) {\r
-       \r
-                       if (""!=$inner)\r
-                               $target[$key] = $inner;\r
-\r
-                       if (""!=$attributes) {\r
-                               reset($attributes);\r
-                               while (list($k, $v) = each($attributes))\r
-                                       $target[$key][$k] = $this->xmldecode($v);\r
-                       }\r
-                               \r
-                       $target[$key]["value"] = $this->xmldecode($value);\r
-               \r
-               } else {\r
-       \r
-                       if (!isset($target[$key][0])) {\r
-               \r
-                               $oldvalue = $target[$key];\r
-                               $target[$key] = array();\r
-                               $target[$key][0] = $oldvalue;\r
-                       \r
-                               if ("" != $inner)\r
-                                       $target[$key][1] = $inner;\r
-\r
-                               if ("" != $attributes) {\r
-                                       reset($attributes);\r
-                                       while (list($k, $v)=each($attributes))\r
-                                               $target[$key][1][$k] = $this->xmldecode($v);\r
-                               }\r
-                               \r
-                               $target[$key][1]["value"] = $this->xmldecode($value);\r
-                               \r
-                       } else {\r
-                               \r
-                               $index = count($target[$key]);\r
-                               \r
-                               if ("" != $inner)\r
-                                       $target[$key][$index] = $inner;\r
-\r
-                               if (""!=$attributes) {\r
-                                       reset($attributes);\r
-                                       while (list($k, $v) = each($attributes))\r
-                                               $target[$key][$index][$k] = $this->xmldecode($v);\r
-                               }\r
-                               \r
-                               $target[$key][$index]["value"] = $this->xmldecode($value);\r
-\r
-                       }\r
-\r
-               }\r
-       \r
-               return $target;\r
-       } // end func addToArray\r
-       \r
-       /**\r
-       * Replaces some basic entities with their character counterparts.\r
-       * \r
-       * @param        string  String to decode\r
-       * @return       string  Decoded string\r
-       */\r
-       function xmldecode($value) {\r
-               #return preg_replace( array("@&lt;@", "@&gt;@", "@&apos;@", "@&quot;@", "@&amp;@"), array("<", ">", "'", '"', "&"), $value);\r
-               return utf8_decode(preg_replace( array("@&lt;@", "@&gt;@", "@&apos;@", "@&quot;@", "@&amp;@"), array("<", ">", "'", '"', "&"), $value));\r
-       } // end func xmldecode\r
-\r
-} // end class PhpdocXMLReader\r
-?>
\ No newline at end of file