dc57514630c1d2ce9934e3bdef1ba27abc523cea
[atutor.git] / mods / phpdoc / PHPDoc / accessor / PhpdocAccessor.php
1 <?php\r
2 /**\r
3 * Provides an API to access PHPDoc XML files.\r
4\r
5 * It's up to you eigther to use this class to access \r
6 * the phpdoc xml files or to write your own parser.\r
7 */\r
8 class PhpdocAccessor extends PhpdocObject {\r
9 \r
10         /**\r
11         * Instance of PhpdocXMLReader\r
12         * @var  object  PhpdocXMLReader $xmlreader\r
13         */      \r
14         var $xmlreader;\r
15         \r
16         /**\r
17         * Result of the PhpdocXMLReader\r
18         * @var  array   $xml\r
19         */\r
20         var $xml = array();\r
21         \r
22         /**\r
23         * Free xml resources on calling a getXY() function?\r
24         * \r
25         * One of the design goals was to minimize the memory consumption of PHPdoc.\r
26         * So PHPdoc tries to save data as soon as possible to the disk, reuse objects\r
27         * and free resources of an object when they are no longer needed. The default \r
28         * value of true will cause the object to free the memory used by the \r
29         * xml data as soon as possible.\r
30         * \r
31         * @var  boolean\r
32         */      \r
33         var $freeOnGet = true;\r
34 \r
35         /**\r
36         * Reformatted PhpdocXMLReader result array\r
37         * @var  array\r
38         */\r
39         var $data = array();\r
40         \r
41         /**\r
42         * Loads the specified xml file. \r
43         *\r
44         * @param        string  Name of the xml file\r
45         * @return       boolean False if the given xml file was not \r
46         *                                                                       found or is empty otherwise true.\r
47         * @access       public\r
48         * @see          init()\r
49         */\r
50         function loadXMLFile($filename) {\r
51         \r
52                 $this->xmlreader = new PhpdocXMLReader;\r
53                 \r
54                 $this->xml = $this->xmlreader->parse($filename);\r
55                 $this->xml = $this->xml["phpdoc"];\r
56                 $ok = (!is_array($this->xml) || 0==count($this->xml)) ? false : true;\r
57                 \r
58                 $this->init();\r
59                 \r
60                 return $ok;             \r
61         } // end func loadXMLFile\r
62                 \r
63         /**\r
64         * Reformats the xml result array from the PhpdocXMLReader.\r
65         * \r
66         * Every derived class must override this function to call the functions\r
67         * it needs to reorganize the data from the PhpdocXMLReader in a \r
68         * way that it needs. \r
69         *\r
70         * @abstract\r
71         * @see  $xml, $data\r
72         */\r
73         function init() {\r
74         } // end func init\r
75 \r
76 } // end class PhpdocAccessor\r
77 ?>