2280b28958ab0fdf14eab2ac2805acc01b5172aa
[atutor.git] / mods / phpdoc / PHPDoc / renderer / html / PhpdocHTMLWarningRenderer.php
1 <?php
2 /**
3 * Renders files with warnings.
4 */
5 class PhpdocHTMLWarningRenderer extends PhpdocHTMLRenderer {
6
7         /**
8         * Sets the xml and template root directory.
9         * 
10         * @param        string  XML file path
11         * @param        string  Template file path
12         * @param        string  Name of the application
13         * @param        string  Filename        extension
14         * @see  setPath(), setTemplateRoot()
15         */
16         function PhpdocHTMLWarningRenderer($path, $templateRoot, $application, $extension = ".html") {
17
18                 $this->setPath($path);
19                 $this->setTemplateRoot($templateRoot);
20                 $this->application = $application;
21     $this->file_extension = $extension;
22
23                 $this->accessor = new PhpdocWarningAccessor;
24                 $this->fileHandler = new PhpdocFileHandler;
25
26         } // end constructor
27
28         /**
29         * Saves the generated report.
30         * 
31         * @see          addWarnings()
32         * @access       public
33         */
34         function finishWarnings() {
35
36                 if (!is_object($this->tpl)) 
37                         return;
38
39                 $this->tpl->setVariable("APPNAME", $this->application);
40                 $this->fileHandler->createFile($this->path."phpdoc_warnings" . $this->file_extension, $this->tpl->get() );
41
42                 $this->tpl = "";
43                 
44         }       // end func finishWarnings
45
46         /**
47         * Adds file with warnings to the warning list.
48         * 
49         * @param        string  XML file
50         * @see          finishWarnings()
51         * @access       public
52         */
53         function addWarnings($xmlfile) {
54
55                 $data = $this->accessor->getWarnings($this->path . $xmlfile);
56                 if (!is_object($this->tpl)) {
57                         $this->tpl = new IntegratedTemplate($this->templateRoot);
58                         $this->tpl->loadTemplateFile("warnings.html");
59                 }
60
61                 reset($data);
62                 while (list($file, $warnings) = each($data)) {
63
64                         $this->tpl->setCurrentBlock("warning_loop");                    
65                         
66                         reset($warnings);
67                         while (list($k, $warning) = each($warnings)) {
68
69                                 $this->tpl->setVariable("WARNINGTYPE", $warning["type"]);
70                                 $this->tpl->setVariable("WARNING", $this->encode($warning["value"]));
71                                 $this->tpl->setVariable("ELEMENT", htmlentities($warning["name"]));
72                                 $this->tpl->setVariable("ELEMENTTYPE", $warning["elementtype"]);
73                                 $this->tpl->parseCurrentBlock();
74
75                         }
76
77                         $this->tpl->setCurrentBlock("warning");
78                         $this->tpl->setVariable("FILE", $file);
79                         $this->tpl->setVariable("NUMWARNINGS", count($warnings));
80                         $this->tpl->parseCurrentBlock();
81
82                 }
83
84                 return true;
85         } // end func addWarnings
86
87 } // end class PhpdocHTMLIndexRenderer
88 ?>