Documentation is available at RSDEngineDBApplicationClass.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 RSDEngineDBApplicationClass.
20 *
21 * @package RSDEngine
22 * @author Lukas Feiler <lukas.feiler@chello.at>
23 * @copyright Lukas Feiler 2003
24 * @filesource
25 */
26
27 /**RSDEngineDBApplicationClass extends RSDEngineClass.
28 */
29 require_once('RSDEngine/RSDEngineClass.php');
30
31
32 /**Generates the Application class (the main class) for database backended applications.
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 RSDEngineDBApplicationClass 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']) is returned.
49 * @see config
50 *
51 * @return String The class name.
52 */
53 function getClassName()
54 {
55 return ucfirst($this->config['projectName']);
56 }
57
58 /**Returns the name for an instance created from this class.
59 *
60 * In fact strtolower($this->config['projectName']) is returned.
61 * @see config
62 *
63 * @return String The instance name.
64 */
65 function getInstanceName()
66 {
67 return strtolower($this->config['projectName']);
68 }
69
70 /**Returns the code for this class.
71 *
72 * The generated class will be extending the application base class.
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 appplication class.
79 */
80 function getCode()
81 {
82 extract($this->config);
83 $className = $this->getClassName();
84 $instanceName = $this->getInstanceName();
85 $authors = RSArrayUtil::toString(split("\n", $authors), "\n", '* @author %val');
86 $baseClassName = "${className}Base";
87 $projectNameUC = strtoupper($projectName);
88
89 $write = $this->config['writeApplicationChildClass'];
90 $this->setWrite($write);
91
92 $data = "";
93 $data.= '/' . "**Contains just the class $className.\n" .
94 "*\n" .
95 $authors . "\n" .
96 '* @copyright ' . $copyright . "\n" .
97 '* @package ' . $projectName . "\n" .
98 '* @filesource' . "\n" .
99 '*/' . "\n" .
100 "\n" .
101 '/' . '**' . $className . " extends $baseClassName.\n" .
102 "*/\n" .
103 "require_once('$baseClassName.php');\n" .
104 "\n" .
105 '/' . '**' . $className . ' is the main class of this application.' . "\n" .
106 '*' . "\n" .
107 '* It holds handles to all objects used in this application.' . "\n" .
108 '* It can be used as the only entry point to the whole application!' . "\n" .
109 $authors . "\n" .
110 '* @copyright ' . $copyright . "\n" .
111 '* @package ' . $projectName . "\n" .
112 '* @version 0.1' . "\n" .
113 '*/' . "\n" .
114 "class $className extends $baseClassName{\n" .
115 "\n" .
116 ' /' . '**Initializes the application.' . "\n" .
117 ' * @param RSErrorManager $errorManager An instance of the class RSErrorManager.' . "\n" .
118 " */\n" .
119 " function $className(&\$errorManager)\n" .
120 " {\n" .
121 " \n" .
122 " //Call parent constructor.\n" .
123 " \$this->$baseClassName(\$errorManager);\n" .
124 ' }' . "\n" .
125 "}";
126 return $data;
127 }
128 }
129 ?>
Documentation generated on Mon, 8 Dec 2003 13:10:58 +0100 by phpDocumentor 1.2.3