Documentation is available at RSDEngineSmartyClass.php
1 <?php
2 // RSDEngine: The Rapid and Secure Development Engine
3 // Copyright (C) 2003 Lukas Feiler
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19 /**Contains just the class RSDEngineSmartyClass.
20 *
21 * @package RSDEngine
22 * @author Lukas Feiler <lukas.feiler@chello.at>
23 * @copyright Lukas Feiler 2003
24 * @filesource
25 */
26
27 /**RSDEngineSmartyClass extends RSDEngineClass.
28 */
29 require_once('RSDEngine/RSDEngineClass.php');
30
31
32 /**Generates a class extending the class Smarty.
33 *
34 * @author Lukas Feiler <lukas.feiler@chello.at>
35 * @version 0.1.9
36 * @copyright Lukas Feiler 2003
37 * @package RSDEngine
38 */
39 class RSDEngineSmartyClass extends RSDEngineClass {
40
41 /**Whether to overwrite an existing file. The default for this class is not to do so!
42 * @var boolean
43 */
44 var $overwriteExisting = false;
45
46 /**Returns the class name.
47 *
48 * In fact ucfirst($this->config['projectName']) . 'Smarty' is returned.
49 * @see config
50 *
51 * @return String The class name.
52 */
53 function getClassName()
54 {
55 return ucfirst($this->config['projectName']) . 'Smarty';
56 }
57
58 function getBaseClassName()
59 {
60 return ucfirst($this->config['projectName']) . 'SmartyBase';
61 }
62
63 /**Returns the name for an instance created from this class.
64 *
65 * In fact strtolower($this->config['projectName']) . 'Smarty' is returned.
66 * @see config
67 *
68 * @return String The instance name.
69 */
70 function getInstanceName()
71 {
72 return strtolower($this->config['projectName']) . 'Smarty';
73 }
74
75 /**Returns the code for this class.
76 *
77 * The generated class will be extending Smarty.
78 * Note that this method requires $this->config to be correctly
79 * filled with all configuration options of the RSDEngine.
80 * @see config
81 * @see RSDApplication
82 *
83 * @return String The code of the smarty child class.
84 */
85 function getCode()
86 {
87 extract($this->config);
88 $className = $this->getClassName();
89 $baseClassName = $this->getBaseClassName();
90 $projectNameUC = strtoupper($projectName);
91 $authors = RSArrayUtil::toString(split("\n",$authors),"\n",'* @author %val');
92
93 $write = $this->config['writeSmartyChildClass'];
94 $this->setWrite($write);
95
96 $data = "";
97 $data.= '/' . "**Contains just the class $className.\n" .
98 "*\n" .
99 $authors . "\n" .
100 '* @copyright ' . $copyright . "\n" .
101 '* @package ' . $projectName . "\n" .
102 '* @filesource' . "\n" .
103 '*/' . "\n" .
104 "\n" .
105 '/' . '**' . $className . " extends $baseClassName.\n" .
106 "*/\n" .
107 "require_once('$baseClassName.php');\n\n" .
108 '/' . '**' . $className . ' is the SMARTY class for this application that handles templates.' . "\n" .
109 '*' . "\n" .
110 $authors . "\n" .
111 '* @copyright ' . $copyright . "\n" .
112 '* @package ' . $projectName . "\n" .
113 '* @version 0.1' . "\n" .
114 '*/' . "\n" .
115 "class $className extends $baseClassName {\n" .
116 ' /' . '**Initializes SMARTY.' . "\n" .
117 ' */' . "\n" .
118 ' function ' . $className . '()' . "\n" .
119 " {\n" .
120 " \$this->$baseClassName();\n" .
121 " \n" .
122 " //change this to true when switching to production!\n" .
123 ' //$this->caching = true;' . "\n" .
124 ' }' . "\n" .
125 '}';
126 return $data;
127 }
128 }
129 ?>
Documentation generated on Mon, 8 Dec 2003 13:12:49 +0100 by phpDocumentor 1.2.3