Source for file RSDEngineSmartyBaseClass.php

Documentation is available at RSDEngineSmartyBaseClass.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 RSDEngineSmartyBaseClass.
20 *
21 * @package RSDEngine
22 * @author Lukas Feiler <lukas.feiler@chello.at>
23 * @copyright Lukas Feiler 2003
24 * @filesource
25 */
26
27 /**RSDEngineSmartyBaseClass 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 RSDEngineSmartyBaseClass extends RSDEngineClass {
40
41 /**Whether to overwrite an existing file. The default for this class is to do so!
42 * @var boolean
43 */
44 var $overwriteExisting = true;
45
46 /**Returns the class name.
47 *
48 * In fact ucfirst($this->config['projectName']) . 'SmartyBase' is returned.
49 * @see config
50 *
51 * @return String The class name.
52 */
53 function getClassName()
54 {
55 return ucfirst($this->config['projectName']) . 'SmartyBase';
56 }
57
58 /**Returns the name for an instance created from this class.
59 *
60 * In fact strtolower($this->config['projectName']) . 'Smarty' is returned.
61 * @see config
62 *
63 * @return String The instance name.
64 */
65 function getInstanceName()
66 {
67 return strtolower($this->config['projectName']) . 'SmartyBase';
68 }
69
70 /**Returns the code for this class.
71 *
72 * The generated class will be extending Smarty.
73 * Note that this method requires $this->config to be correctly
74 * filled with all configuration options of the RSDEngine.
75 * @see config
76 * @see RSDApplication
77 *
78 * @return String The code of the smarty child class.
79 */
80 function getCode()
81 {
82 extract($this->config);
83 $className = $this->getClassName();
84 $projectNameUC = strtoupper($projectName);
85 $authors = RSArrayUtil::toString(split("\n",$authors),"\n",'* @author %val');
86
87 $write = $this->config['writeSmartyBaseClass'];
88 $this->setWrite($write);
89
90 $data = "";
91 $data.= '/' . "**Contains just the class $className.\n" .
92 "*\n" .
93 $authors . "\n" .
94 '* @copyright ' . $copyright . "\n" .
95 '* @package ' . $projectName . "\n" .
96 '* @filesource' . "\n" .
97 '*/' . "\n" .
98 "\n" .
99 '/' . '**' . $className . " extends Smarty.\n" .
100 "*/\n" .
101 "require_once(${projectNameUC}_SMARTY_DIR . 'Smarty.class.php');\n\n" .
102 '/' . '**' . $className . ' is the SMARTY base class for this application that handles templates.' . "\n" .
103 '*' . "\n" .
104 $authors . "\n" .
105 '* @copyright ' . $copyright . "\n" .
106 '* @package ' . $projectName . "\n" .
107 '* @version 0.1' . "\n" .
108 '*/' . "\n" .
109 'class ' . $className . ' extends Smarty {' . "\n" .
110 ' /' . '**Initializes SMARTY.' . "\n" .
111 ' */' . "\n" .
112 ' function ' . $className . '()' . "\n" .
113 " {\n" .
114 ' $this->Smarty();' . "\n" .
115 ' ' . "\n" .
116 ' $this->template_dir = "view/templates/";' . "\n" .
117 ' $this->compile_dir = "view/templates_c/";' . "\n" .
118 ' $this->config_dir = "view/configs/";' . "\n" .
119 ' $this->cache_dir = "view/cache/";' . "\n" .
120 ' ' . "\n" .
121 ' $this->caching = false;' . "\n" .
122 "\n" .
123 " \$this->left_delimiter = ${projectNameUC}_SMARTY_LEFT_DELIMITER;\n" .
124 " \$this->right_delimiter = ${projectNameUC}_SMARTY_RIGHT_DELIMITER;\n" .
125 ' $this->assign("app_name", "' . $projectName . '");' . "\n" .
126 ' $this->assign("PHP_SELF", $_SERVER[\'PHP_SELF\']);' . "\n" .
127 ' $this->assign("REQUEST_URI", $_SERVER[\'REQUEST_URI\']);' . "\n" .
128 " if (strpos(\$_SERVER['REQUEST_URI'], '?') === false) {\n" .
129 " \$this->assign('URI', \$_SERVER['REQUEST_URI'] . '?foo=0');\n" .
130 " } else {\n" .
131 " \$this->assign('URI', \$_SERVER['REQUEST_URI']);\n" .
132 " }\n" .
133 ' }' . "\n" .
134 '}';
135 return $data;
136 }
137 }
138 ?>

Documentation generated on Mon, 8 Dec 2003 13:12:49 +0100 by phpDocumentor 1.2.3