5 class PhpdocHTMLIndexRenderer extends PhpdocHTMLRenderer {
8 * Some container in the package list.
11 * @see renderPackagelist()
13 var $packageFields = array("class", "module");
16 * Packagelist from the PhpdocIndexAccessor
20 var $packages = array();
23 * Array with classtree informations
27 var $classtree = array();
30 * IntegratedTemplate Object used be renderClasstree()
32 * @var object IntegratedTemplate
33 * @see renderClasstree()
38 * IntegratedTemplateObject used by renderModulegroup()
40 * @var object IntegratedTemplate
41 * @see renderModulegroup()
46 * Sets the xml and template root directory.
48 * @param string XML file path
49 * @param string Template file path
50 * @param string Name of the application
51 * @param string Filename extension
52 * @see setPath(), setTemplateRoot()
54 function PhpdocHTMLIndexRenderer($path, $templateRoot, $application, $extension = ".html") {
56 $this->setPath($path);
57 $this->setTemplateRoot($templateRoot);
58 $this->application = $application;
59 $this->file_extension = $extension;
61 $this->accessor = new PhpdocIndexAccessor;
62 $this->tpl = new IntegratedTemplate($this->templateRoot);
63 $this->fileHandler = new PhpdocFileHandler;
68 * Builds all index files phpdoc needs assuming that the xml files have default names
71 * @see renderElementlist(), renderPackagelist(), renderFramelementlist(), renderFramePackageSummary()
75 $this->renderElementlist("elementlist.xml");
76 $this->renderFrameElementlist("elementlist.xml");
77 $this->renderPackagelist("packagelist.xml");
78 $this->renderFramePackageSummary("packagelist.xml");
79 $this->renderFrameElementlist("packagelist.xml");
81 } // end function generate
84 * Saves the generated classtree summary to disk.
86 * @see renderClasstree()
89 function finishClasstree() {
91 if (!is_object($this->treeTpl))
94 $this->treeTpl->setVariable("APPNAME", $this->application);
95 $this->fileHandler->createFile($this->path."phpdoc_classtree".$this->file_extension, $this->treeTpl->get() );
98 } // end func finishClasstree
101 * Adds a classtree to the classtree summary template.
103 * @param string XML Classtree file
104 * @see finishClasstree()
107 function addClasstree($xmlfile) {
109 $this->accessor->loadXMLFile($this->path.$xmlfile);
111 if (!is_object($this->treeTpl)) {
112 $this->treeTpl = new IntegratedTemplate($this->templateRoot);
113 $this->treeTpl->loadTemplatefile("classtree.html");
116 $this->classtree = $this->accessor->getClasstree();
117 $this->treeTpl->setCurrentBlock("classtree");
118 $this->treeTpl->setVariable("BASECLASS", $this->classtree["baseclass"]);
119 $this->treeTpl->setVariable("TREE", "<ul>".$this->buildClasstreeHTML($this->classtree["baseclass"])."</ul>");
120 $this->treeTpl->parseCurrentBlock();
123 } // end func addClasstree
125 function finishModulegroup() {
127 if (!is_object($this->moduleTpl))
130 $this->moduleTpl->setVariable("APPNAME", $this->application);
131 $this->fileHandler->createFile($this->path."phpdoc_modulegroup".$this->file_extension, $this->moduleTpl->get() );
132 $this->moduleTpl = "";
133 } // end func finishModulegroups
136 * Renders a modulegroup xml file.
138 * @param string XML File
140 function addModulegroup($xmlfile) {
142 $this->accessor->loadXMLFile($this->path.$xmlfile);
144 if (!is_object($this->moduleTpl)) {
145 $this->moduleTpl = new IntegratedTemplate($this->templateRoot);
146 $this->moduleTpl->loadTemplateFile("modulegroup.html");
149 $modulegroup = $this->accessor->getModulegroup();
152 reset($modulegroup["modules"]);
153 while (list($k, $module) = each($modulegroup["modules"]))
154 $modules .= sprintf('<li><a href="%s">%s</a>', $this->nameToUrl($module) . $this->file_extension, $module);
158 $this->moduleTpl->setCurrentBlock("modulegroup");
159 $this->moduleTpl->setVariable("MODULEGROUP", $modulegroup["group"]);
160 $this->moduleTpl->setVariable("MODULES", $modules);
161 $this->moduleTpl->parseCurrentBlock();
163 } // end func addModulegroup
166 * Renders the element index list.
168 * @param string XML file
172 function renderElementlist($xmlfile) {
174 $this->accessor->loadXMLFile($this->path.$xmlfile);
175 $this->tpl->loadTemplatefile("elementlist.html");
177 $chapters = $this->accessor->getChapternames();
178 if (0 != count($chapters)) {
180 $this->tpl->setCurrentBlock("chaptersummary_loop");
183 while (list($k, $chapter) = each($chapters)) {
184 $this->tpl->setVariable("CHAPTER", $chapter);
185 $this->tpl->parseCurrentBlock();
188 $chapters = $this->accessor->getChapters();
190 while (list($name, $elements) = each($chapters)) {
192 if (!isset($elements["element"][0]))
193 $elements["element"] = array($elements["element"]);
195 $this->tpl->setCurrentBlock("chapter_loop");
197 reset($elements["element"]);
198 while (list($k, $element) = each($elements["element"])) {
200 switch($element["type"]) {
206 $desc = sprintf('Class <a href="%s">%s</a>.',
207 $this->nameToUrl($element["name"]) . $this->file_extension,
213 $desc = sprintf('Module <a href="%s">%s</a>.',
214 $this->nameToUrl($element["name"]) . $this->file_extension,
220 $desc = sprintf('Function in %s <a href="%s">%s</a>',
221 $element["sourcetype"],
222 $this->nameToUrl($element["source"]) . $this->file_extension,
228 $desc = sprintf('Variable in Class <a href="%s">%s</a>',
229 $this->nameToUrl($element["source"]) . $this->file_extension,
235 $desc = sprintf('Included file in %s <a href="%s">%s</a>',
236 $element["sourcetype"],
237 $this->nameToUrl($element["source"]) . $this->file_extension,
243 $desc = sprintf('Constant defined in %s <a href="%s">%s</a>',
244 $element["sourcetype"],
245 $this->nameToUrl($element["source"]) . $this->file_extension,
252 $this->tpl->setVariable("ELEMENTNAME", $element["name"]);
253 $this->tpl->setVariable("ELEMENT", $desc);
254 $this->tpl->setVariable("SHORTDESCRIPTION", $element["value"]);
255 $this->tpl->parseCurrentBlock();
259 $this->tpl->setCurrentBlock("chapter");
260 $this->tpl->setVariable("CHAPTER", $name);
261 $this->tpl->parseCurrentBlock();
267 $this->tpl->setVariable("APPNAME", $this->application);
268 $this->fileHandler->createFile($this->path . "phpdoc_elementlist" . $this->file_extension, $this->tpl->get() );
271 } // end func renderElementlist
274 * Renders a complete packagelist.
276 * @param string XML file
278 * @see renderFrameElementlist(), renderFramePackagesummary()
280 function renderPackagelist($xmlfile) {
282 $this->loadPackagelist($xmlfile);
283 $this->tpl->loadTemplatefile("packagelist.html");
285 reset($this->packages);
286 while (list($packagename, $package) = each($this->packages)) {
288 reset($this->packageFields);
289 while (list($k, $field) = each($this->packageFields)) {
290 if (!isset($package[$field]))
293 $this->tpl->setCurrentBlock("package_".$field."_loop");
295 reset($package[$field]);
296 while (list($k, $element) = each($package[$field])) {
298 $this->tpl->setVariable("ELEMENT", sprintf('<a href="%s">%s</a>',
299 $this->nameToUrl($element) . $this->file_extension,
304 $this->tpl->parseCurrentBlock();
307 $this->tpl->setCurrentBlock("package_" . $field);
308 $this->tpl->setVariable("EMPTY", "");
309 $this->tpl->parseCurrentBlock();
313 $this->tpl->setCurrentBlock("package");
314 $this->tpl->setVariable("PACKAGE_NAME", $packagename);
315 $this->tpl->parseCurrentBlock();
319 $this->tpl->setVariable("APPNAME", $this->application);
320 $this->fileHandler->createFile($this->path . "phpdoc_packagelist" . $this->file_extension, $this->tpl->get() );
323 } // end func renderPackagelist
326 * Renders files for the lower left frame with the elements of a certain file.
328 * @param string This function needs the packagelist.xml to work!
330 * @see renderFramePackagesummary(), renderPackagelist()
332 function renderFrameElementlist($xmlfile) {
334 $this->loadPackagelist($xmlfile);
336 reset($this->packages);
337 while (list($packagename, $package) = each($this->packages)) {
339 $this->tpl->loadTemplatefile("frame_packageelementlist.html");
341 reset($this->packageFields);
342 while (list($k, $field) = each($this->packageFields)) {
344 if (!isset($package[$field]))
347 $this->tpl->setCurrentBlock("package_".$field."_loop");
349 reset($package[$field]);
350 while (list($k, $element) = each($package[$field])) {
352 $this->tpl->setVariable("ELEMENT", sprintf('<a href="%s" target="main">%s</a>',
353 $this->nameToUrl($element) . $this->file_extension,
357 $this->tpl->parseCurrentBlock();
360 $this->tpl->setCurrentBlock("package_" . $field);
361 $this->tpl->setVariable("EMPTY", "");
362 $this->tpl->parseCurrentBlock();
366 $this->tpl->setCurrentBlock("package");
367 $this->tpl->setVariable("PACKAGE_NAME", $packagename);
368 $this->tpl->parseCurrentBlock();
370 $this->tpl->setVariable("APPNAME", $this->application);
371 $packagename = $this->nameToUrl($packagename);
372 $this->fileHandler->createFile($this->path . "packageelementlist_" . $packagename . $this->file_extension, $this->tpl->get() );
378 } // end func renderFrameElementlist
381 * Renders a Packagesummary for the frameset.
383 * @param string XML file.
385 * @see renderPackagelist(), renderFrameElementlist()
387 function renderFramePackagesummary($xmlfile) {
389 $this->loadPackagelist($xmlfile);
391 $this->tpl->loadTemplatefile("frame_packagelist.html");
392 $this->tpl->setCurrentBlock("package");
394 reset($this->packages);
395 while (list($packagename, $v) = each($this->packages)) {
397 $this->tpl->setVariable("PACKAGE", sprintf('<a href="packageelementlist_%s" target="packageelements">%s</a>',
398 $this->nameToUrl($packagename) . $this->file_extension,
401 $this->tpl->parseCurrentBlock();
405 $this->tpl->setVariable("APPNAME", $this->application);
406 $this->fileHandler->createFile($this->path . "frame_packagelist" . $this->file_extension, $this->tpl->get() );
409 } // end func renderFramePackagesummary
412 * Imports the packagelist from the PhpdocIndexAccessor if not done previously.
414 * @param string XMl file.
417 function loadPackagelist($xmlfile) {
419 if (0 == count($this->packages)) {
420 $this->accessor->loadXMLFile($this->path . $xmlfile);
421 $this->packages = $this->accessor->getPackagelist();
424 } // end func loadPackagelist
427 * Recursivly builds an HTML class tree using <ul><li></ul>.
429 * @param string Name of the class the recursive loop starts with
430 * @see renderClasstree()
432 function buildClasstreeHTML($class) {
436 if (0 == count($this->classtree["classes"][$class])) {
438 $html .= sprintf('<li><a href="%s">%s</a>', $this->nameToUrl($class) . $this->file_extension, $class);
442 $html .= sprintf('<li><a href="%s">%s</a>', $this->nameToUrl($class) . $this->file_extension, $class);
445 reset($this->classtree["classes"][$class]);
446 while (list($k, $subclass) = each($this->classtree["classes"][$class]))
447 $html .= $this->buildClasstreeHTML($subclass);
454 } // end func buildClasstreeHTML
456 } // end class PhpdocHTMLIndexRenderer