changed git call from https to git readonly
[atutor.git] / mods / phpdoc / PHPDoc / renderer / html / PhpdocHTMLModuleRenderer.php
1 <?php\r
2 /**\r
3 * Renders modules.\r
4 *\r
5 * @version      $Id: PhpdocHTMLModuleRenderer.php,v 1.4 2000/12/03 22:37:37 uw Exp $\r
6 */\r
7 class PhpdocHTMLModuleRenderer extends PhpdocHTMLDocumentRenderer {\r
8 \r
9         /**\r
10         * Sets the xml and template root directory.\r
11         * \r
12         * @param        string  XML file path\r
13         * @param        string  Template file path\r
14         * @param        string  Name of the current application\r
15         * @param        string  Filename extension\r
16         * @see  setPath(), setTemplateRoot()\r
17         */\r
18         function PhpdocHTMLModuleRenderer($path, $templateRoot, $application, $extension = ".html") {\r
19 \r
20                 $this->setPath($path);\r
21                 $this->setTemplateRoot($templateRoot);\r
22                 $this->application = $application;\r
23                 $this->file_extension = $extension;\r
24 \r
25                 $this->accessor = new PhpdocModuleAccessor;\r
26                 $this->tpl = new IntegratedTemplate($this->templateRoot);\r
27                 $this->fileHandler = new PhpdocFileHandler;\r
28 \r
29         } // end constructor\r
30 \r
31         /**\r
32         * Renders a module\r
33         *\r
34         * @param        string  XML source file\r
35         * @param        string  Name of the HTML target file.\r
36         * @access       public\r
37         */      \r
38         function renderModule($xmlfile, $htmlfile = "") {\r
39 \r
40                 $this->tpl->loadTemplatefile("module.html");    \r
41                 if ("" == $htmlfile)\r
42                         $htmlfile = substr($xmlfile, 7, -4) . $this->file_extension;\r
43 \r
44                 $this->accessor->loadXMLFile($this->path . $xmlfile);\r
45                 $module = $this->accessor->getModuledata();             \r
46 \r
47                 $this->renderFunctions();\r
48                 $this->renderUses();\r
49                 $this->renderConstants();\r
50 \r
51                 $tplvars = array();\r
52                 $tplvars["MODULE_FILE"]                 = $module["file"]["value"];\r
53                 $tplvars["MODULE_NAME"]                 = $module["name"];\r
54                 $tplvars["MODULE_GROUP"]                = $module["group"];\r
55                 $tplvars["MODULE_ACCESS"]               = $module["access"];\r
56                 $tplvars["MODULE_PACKAGE"]      = $module["package"];\r
57                 $tplvars["MODULE_UNDOC"]                = ("true" == $module["undoc"]) ? $this->undocumented : "";\r
58 \r
59                 if (isset($module["doc"]["link"]))\r
60                         $this->renderLinks($module["doc"]["link"], "class_");\r
61 \r
62                 if (isset($module["doc"]["author"]))\r
63                         $this->renderAuthors($module["doc"]["author"], "class_");\r
64 \r
65                 if (isset($module["doc"]["see"]))\r
66                         $this->renderSee($module["doc"]["see"], "class_");\r
67 \r
68                 $fields = array(        "version", "deprecated", "copyright", "since", "magic");\r
69                 reset($fields);\r
70                 while (list($k, $field) = each($fields)) \r
71 \r
72                         if (isset($module["doc"][$field])) {\r
73                                 $this->tpl->setCurrentBlock("module_" . strtolower($field));\r
74                                 $this->tpl->setVariable(strtoupper($field), $module["doc"][$field]["value"]);\r
75                                 $this->tpl->parseCurrentBlock();\r
76                         }\r
77 \r
78                 $fields = array( "description", "shortdescription" );\r
79                 reset($fields);\r
80                 while (list($k, $field) = each($fields)) \r
81 \r
82                         if (isset($module["doc"][$field]))\r
83                                 $tplvars["MODULE_" . strtoupper($field)] = $this->encode($module["doc"][$field]["value"]);\r
84 \r
85                 $this->tpl->setCurrentBlock("__global__");\r
86                 $this->tpl->setVariable($tplvars);\r
87                 $this->tpl->setVariable("APPNAME", $this->application);\r
88 \r
89                 $this->fileHandler->createFile($this->path . $htmlfile, $this->tpl->get() );\r
90                 $this->tpl->free();     \r
91 \r
92         } // end func renderModule\r
93 \r
94 } // end class PhpdocHTMLModuleRenderer\r
95 ?>