3 * Provides a API to access Index xml documents.
5 class PhpdocIndexAccessor extends PhpdocAccessor {
8 * Ordered list of all chapternames.
12 var $chapternames = array();
15 * Ordered list of all chapters.
19 var $chapters = array();
22 * List of all packages.
26 var $packages = array();
33 var $classtree = array();
36 * Data of a modulegroup
40 var $modulegroup = array();
43 * Some container withing the packagelist.
46 * @see buildPackagelist()
48 var $packageFields = array("class", "module");
51 * Flag indicating that certain internal datafield have been filled.
55 var $flagBuild = array(
62 * Returns a modulegroup
66 function getModulegroup() {
68 $this->buildModulegroup();
70 if ($this->freeOnGet) {
72 $data = $this->modulegroup;
73 $this->modulegroup = array();
78 return $this->modulegroup;
81 } // end func getModulegroup
84 * Returns a classtree.
89 function getClasstree() {
91 $this->buildClasstree();
93 if ($this->freeOnGet) {
95 $data = $this->classtree;
96 $this->classtree = array();
101 return $this->classtree;
105 } // end func getClasstree
108 * Returns an ordered list of all chapternames.
114 function getChapternames() {
116 $this->buildChapterlist();
118 if ($this->freeOnGet) {
120 $data = $this->chapternames;
121 $this->chapternames = array();
126 return $this->chapternames;
130 } // end func getChapternames
133 * Returns an ordered list of all chapters.
137 * @see getChapternames()
139 function getChapters() {
141 $this->buildChapterlist();
143 if ($this->freeOnGet) {
145 $data = $this->chapters;
146 $this->chapters = array();
151 return $this->chapters;
155 } // end func getChapters
158 * Returns a list of all packages
163 function getPackagelist() {
165 $this->buildPackagelist();
167 if ($this->freeOnGet) {
169 $data = $this->packages;
170 $this->packages = array();
175 return $this->packages;
179 } // end func getPackagelist
183 * Builds the internal packagelist.
185 function buildPackagelist() {
187 if ($this->flagBuild["package"])
190 $data = $this->xml["packagelist"];
191 $this->xml = array();
192 $this->flagBuild["package"] = true;
194 $this->packages = array();
196 if (!isset($data["package"][0]))
197 $data["package"] = array($data["package"]);
199 reset($data["package"]);
200 while (list($k, $package)=each($data["package"])) {
202 $packagename = $package["name"];
204 reset($this->packageFields);
205 while (list($k, $field)=each($this->packageFields)) {
207 if (isset($package[$field][0])) {
209 reset($package[$field]);
210 while (list($k, $element)=each($package[$field]))
211 $this->packages[$packagename][$field][] = $element["name"];
213 } else if (isset($package[$field])) {
215 $this->packages[$packagename][$field][] = $package[$field]["name"];
222 } // end func buildPackagelist
225 * Builds the internal chapterlists.
227 function buildChapterlist() {
229 if ($this->flagBuild["chapter"])
232 $data = $this->xml["index"];
233 $this->xml = array();
234 $this->flagBuild["chapter"] = true;
236 $this->chapternames = array();
237 $this->chapters = array();
239 if (isset($data["chapter"][0])) {
241 $chapterlist = array();
242 reset($data["chapter"]);
243 while (list($k, $chapter)=each($data["chapter"]))
244 $chapterlist[strtoupper($chapter["char"])][$chapter["char"]] = $k;
246 ksort($chapterlist, SORT_STRING);
249 while (list($k, $chapters)=each($chapterlist)) {
252 while (list($chapter, $index)=each($chapters)) {
253 $this->chapternames[] = $chapter;
254 $this->chapters[$chapter] = $data["chapter"][$index];
261 $this->chapternames[] = $data["chapter"]["char"];
262 $this->chapters[$data["chapter"]["char"]] = $data["chapter"]["char"];
266 } // end func buildChapterlist
269 * Extracts the modulegroup data of the xml file.
271 * @see getModulegroup()
273 function buildModulegroup() {
275 if ($this->flagBuild["modulegroup"])
278 $this->flagBuild["modulegroup"] = true;
279 $data = $this->xml["modulegroup"];
282 $this->modulegroup = array(
283 "group" => $data["name"],
287 if (!isset($data["module"][0]))
288 $data["module"] = array( $data["module"] );
290 reset($data["module"]);
291 while (list($k, $module)=each($data["module"]))
292 $this->modulegroup["modules"][] = $module["name"];
294 } // end func buildModulegroup
297 * Extracts the classtree data of the xml file.
299 * @see getClasstree()
301 function buildClasstree() {
303 if ($this->flagBuild["classtree"])
306 $this->flagBuild["classtree"] = true;
307 $data = $this->xml["classtree"];
310 $this->classtree = array(
311 "baseclass" => $data["baseclass"],
315 if (!isset($data["class"][0]))
316 $data["class"] = array( $data["class"] );
318 reset($data["class"]);
319 while (list($k, $class)=each($data["class"])) {
321 if (!isset($class["subclass"])) {
323 $this->classtree["classes"][$class["name"]] = array();
327 if (!isset($class["subclass"][0])) {
329 $this->classtree["classes"][$class["name"]][] = $class["subclass"]["value"];
333 reset($class["subclass"]);
334 while (list($k, $subclass)=each($class["subclass"]))
335 $this->classtree["classes"][$class["name"]][] = $subclass["value"];
343 } // end func buildClasstree
346 * Resets the build flags.
351 reset($this->flagBuild);
352 while (list($k, $v)=each($this->flagBuild))
353 $this->flagBuild[$k] = false;
358 } // end class PhpdocIndexAccessor