Source for file RSDEngineDBApplicationInitFile.php

Documentation is available at RSDEngineDBApplicationInitFile.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 RSDEngineDBApplicationInitFile.
20 *
21 * @package RSDEngine
22 * @author Lukas Feiler <lukas.feiler@chello.at>
23 * @copyright Lukas Feiler 2003
24 * @filesource
25 */
26
27 /**RSDEngineDBApplicationInitFile extends RSDEngineFile.
28 */
29 require_once('RSDEngine/RSDEngineFile.php');
30
31
32 /**Generates the init file.
33 *
34 * The init file performs the initialization of the generated application.
35 *
36 * @author Lukas Feiler <lukas.feiler@chello.at>
37 * @version 0.1.9
38 * @copyright Lukas Feiler 2003
39 * @package RSDEngine
40 */
41 class RSDEngineDBApplicationInitFile extends RSDEngineFile{
42
43 /**Whether to overwrite an existing file.
44 * @var boolean
45 */
46 var $overwriteExisting = false;
47
48 /**Returns the name of the initialization file of the application class.
49 *
50 * In fact strtolower($this->config['projectName']). "Init.php" is returned.
51 * @see config
52 *
53 * @return String The initialization file name.
54 */
55 function getFilename()
56 {
57 return strtolower($this->config['projectName']). "Init.php";
58 }
59
60 /**Returns the code for the configuratin file of the application (for a database backended application).
61 *
62 * Note that this method requires $this->config to be correctly
63 * filled with all configuration options of the RSDEngine.
64 * @see config
65 *
66 * @return String The code of the configuration file.
67 */
68 function getCode()
69 {
70 extract($this->config);
71 $authors = RSArrayUtil::toString(split("\n",$authors),"\n",'* @author %val');
72 $configFile = $this->relatedFiles['dbApplicationConfigFile']->getFilename();
73 $appName = $this->relatedClasses['dbApplicationClass']->getClassName();
74 $appInstanceName = $this->relatedClasses['dbApplicationClass']->getInstanceName();
75 $errorManagerFileName = $this->relatedFiles['errorManagerClass']->getFileName();
76 $errorManagerClassName = $this->relatedClasses['errorManagerClass']->getClassName();
77 $errorManagerInstanceName = $this->relatedClasses['errorManagerClass']->getInstanceName();
78
79 $write = $this->config['writeInitFile'];
80 $this->setWrite($write);
81
82 if ($webApplication) {
83 $smartyClassName = $this->relatedClasses['smartyClass']->getClassName();
84 $smartyFilename = $this->relatedFiles['smartyClass']->getFilename();
85 }
86
87 $prjectNameUC = strtoupper($projectName);
88
89 $body = "";
90 $body .="<?php\n" .
91 '/' . "**This file initializes $projectName\n" .
92 "*\n" .
93 $authors . "\n" .
94 '* @copyright ' . $copyright . "\n" .
95 '* @package ' . $projectName . "\n" .
96 '* @filesource' . "\n" .
97 '*/' . "\n" .
98 "\n" .
99 '/' . "**Contains the configuration of $projectName.\n" .
100 "*/\n" .
101 "require_once('$configFile');\n" .
102 "\n";
103 $body .='/' . "**Contains the error management class.\n" .
104 "*/\n" .
105 "require_once('$errorManagerFileName');\n\n" .
106 '/' . "**Utility Class for handling magic quotes.\n" .
107 "*/\n" .
108 "require_once('MagicQuotesUtil/MagicQuotesUtil.php');\n\n" .
109 '/' . "**Contains the application class.\n" .
110 "*/\n" .
111 "require_once('$appName.php');\n" .
112 "\n" .
113 "\n";
114
115 //MagicQuotesUtil::undo()
116 $body .='/' . '**Undo all magic quoting performed by the PHP Engine.' . "\n" .
117 "*/\n" .
118 "MagicQuotesUtil::undo();\n";
119
120 //initialize error manager
121 $body .='/' . '**Creates a new instance of RSErrorManager and configures PEAR to hand all errors to that instance by default.' . "\n" .
122 '*/' . "\n" .
123 "\$$errorManagerInstanceName =& new $errorManagerClassName();\n" .
124 "PEAR::setErrorHandling(PEAR_ERROR_CALLBACK,array(&\$$errorManagerInstanceName,'catch'));\n" .
125 "\n";
126 $body .='/' . '**Creates a new instance of the application class.' . "\n" .
127 '*/' . "\n" .
128 "\$$appInstanceName =& new $appName(\$$errorManagerInstanceName);\n" .
129 '?>';
130 return $body;
131 }
132 }
133 ?>

Documentation generated on Mon, 8 Dec 2003 13:11:05 +0100 by phpDocumentor 1.2.3