File: PhpdocHTMLModuleRenderer.php

package info (click to toggle)
php4 4.0.3pl1-0potato3
  • links: PTS
  • area: main
  • in suites: potato
  • size: 15,168 kB
  • ctags: 20,556
  • sloc: ansic: 155,237; php: 10,827; sh: 9,608; yacc: 1,874; lex: 1,742; makefile: 788; java: 424; awk: 359; cpp: 335; perl: 181; xml: 57
file content (91 lines) | stat: -rw-r--r-- 2,761 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
/**
* Renders modules.
*/
class PhpdocHTMLModuleRenderer extends PhpdocHTMLDocumentRenderer {

	/**
	* Sets the xml and template root directory.
	* 
	* @param	string	XML file path
	* @param	string	Template file path
	* @param	string	Name of the current application
	* @see	setPath(), setTemplateRoot()
	*/
	function PhpdocHTMLModuleRenderer($path, $templateRoot, $application) {
	
		$this->setPath($path);
		$this->setTemplateRoot($templateRoot);
		$this->application = $application;
		
		$this->accessor = new PhpdocModuleAccessor;
		$this->tpl = new IntegratedTemplate($this->templateRoot);
		$this->fileHandler = new PhpdocFileHandler;
		
	} // end constructor

	/**
	* Renders a module
	* @param	string	XML source file
	* @param	string	Name of the HTML target file.
	* @access	public
	*/	
	function renderModule($xmlfile, $htmlfile="") {

		$this->tpl->loadTemplatefile("module.html");	
		
		if (""==$htmlfile)
			$htmlfile = substr($xmlfile, 7, -4).".html";
			
		$this->accessor->loadXMLFile($this->path.$xmlfile);
		$module = $this->accessor->getModuledata();		
			
		$this->renderFunctions();
		$this->renderUses();
		$this->renderConstants();

		$tplvars = array();
		
		$tplvars["MODULE_FILE"] 		= $module["file"]["value"];
		$tplvars["MODULE_NAME"] 		= $module["name"];
		$tplvars["MODULE_GROUP"] = $module["group"];
		$tplvars["MODULE_ACCESS"]	= $module["access"];
		$tplvars["MODULE_PACKAGE"]	= $module["package"];
		$tplvars["MODULE_UNDOC"] 	= ("true" == $module["undoc"]) ? $this->undocumented : "";
		
		if (isset($module["doc"]["link"]))
			$this->renderLinks($module["doc"]["link"], "class_");
			
		if (isset($module["doc"]["author"]))
			$this->renderAuthors($module["doc"]["author"], "class_");
			
		if (isset($module["doc"]["see"]))
			$this->renderSee($module["doc"]["see"], "class_");
		
		$fields = array( 	"version", "deprecated", "copyright"	,
											"since", "magic");
		reset($fields);
		while (list($k, $field)=each($fields)) 
			if (isset($module["doc"][$field])) {
				$this->tpl->setCurrentBlock("module_".strtolower($field));
				$this->tpl->setVariable(strtoupper($field), $module["doc"][$field]["value"]);
				$this->tpl->parseCurrentBlock();
			}

		$fields = array( "description", "shortdescription" );
		reset($fields);
		while (list($k, $field)=each($fields)) 
			if (isset($module["doc"][$field]))
				$tplvars["MODULE_".strtoupper($field)] = $this->encode($module["doc"][$field]["value"]);

		$this->tpl->setCurrentBlock("__global__");
		$this->tpl->setVariable($tplvars);
		$this->tpl->setVariable("APPNAME", $this->application);
		
		$this->fileHandler->createFile($this->path.$htmlfile, $this->tpl->get() );
		$this->tpl->free();	
		
	} // end func renderModule

} // end class PhpdocHTMLModuleRenderer
?>