Source for file RSDEngineDBTemplateFileUpdateGroup.php

Documentation is available at RSDEngineDBTemplateFileUpdateGroup.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 RSDEngineDBTemplateFileUpdateGroup.
20 *
21 * @package RSDEngine
22 * @author Lukas Feiler <lukas.feiler@chello.at>
23 * @copyright Lukas Feiler 2003
24 * @filesource
25 */
26
27 /**RSDEngineDBTemplateFileUpdateGroup extends RSDEngineTemplateFile.
28 */
29 require_once('RSDEngine/RSDEngineTemplateFile.php');
30
31 /**Generates the smarty template file for updating a LiveUser group.
32 *
33 * @author Lukas Feiler <lukas.feiler@chello.at>
34 * @version 0.1.9
35 * @copyright Lukas Feiler 2003
36 * @package RSDEngine
37 */
38 class RSDEngineDBTemplateFileUpdateGroup extends RSDEngineTemplateFile {
39
40 /**Whether to overwrite an existing file.
41 * @var boolean
42 */
43 var $overwriteExisting = false;
44
45 /**Returns the filename.
46 * @return String
47 */
48 function getFilename()
49 {
50 return "update" . ucfirst($this->config['table']->getTableNameWithoutPrefix()) . "Group" . ucfirst($this->config['column']->getColumnNameForVariableName()) . ".tpl";
51 }
52
53 /**Returns the filename of the corresponding controller.
54 * @return String
55 */
56 function getControllerFilename()
57 {
58 return "update" . ucfirst($this->config['table']->getTableNameWithoutPrefix()) . "Group" . ucfirst($this->config['column']->getColumnNameForVariableName()) . ".php";
59 }
60
61 /**Returns the code for the template file for updating a LiveUser group.
62 *
63 * @access private
64 * @return String The code for the file.
65 */
66 function getCode()
67 {
68 extract($this->config);
69 $table =& $this->config['table'];
70 $OPEN = $smartyLeftDelimiter;
71 $CLOSE = $smartyRightDelimiter;
72 $authors = RSArrayUtil::toString(split("\n",$authors),"\n",'* @author %val');
73 $records = ucfirst($this->config['table']->getTableNameWithoutPrefix());
74 $tableInstanceName = $table->getChildClassInstanceName();
75 $appInstanceName = $this->relatedClasses['dbApplicationClass']->getInstanceName();
76 $columnName = $column->name;
77 $columnNameForVariableName = $column->getColumnNameForVariableName();
78 $columnNameForPartialMethodName = $column->getColumnNameForPartialMethodName();
79 $tableNameForVariableName = $table->getTableNameForVariableName();
80
81 $header = $table->getFileOptionProperty('updateTemplate', 'header');
82 $footer = $table->getFileOptionProperty('updateTemplate', 'footer');
83 $write = $table->getFileOptionProperty('updateTemplate', 'write');
84
85 $this->setWrite($write);
86
87 $data = '';
88 if (($primaryKeyColumn = $table->getPrimaryKeyColumn()) === false) {
89 $data .="No primary key was defined! Without a primary key the RSDEngine cannot generate code to update a single record!";
90 return "$data?>";
91 }
92 $primaryKeyColumnNameForVariableName = $primaryKeyColumn->getColumnNameForVariableName();
93
94 $data .= <<<END
95 <html>
96 <head>
97 <title>update $tableNameForVariableName Group $columnNameForVariableName</title>
98 </head>
99 <body>
100 END;;;
101 if ($header) {
102 $data .="{{include file=\"header.tpl\"}}\n";
103 }
104
105 $data .= <<<END
106 ${OPEN}if \$error${CLOSE}
107 <font color="red">An error occured!</font>
108 ${OPEN}/if${CLOSE}
109 <form name="endlosForm" enctype="multipart/form-data" method="POST">
110 <table>
111 ${OPEN}if \$canAddUserTo${columnNameForPartialMethodName}${CLOSE}
112 <tr>
113 <td>Add users to group:</td>
114 <td>
115 <select name="addUserTo${columnNameForPartialMethodName}[]" multiple="true">
116 ${OPEN}html_options options=\$addUserTo${columnNameForPartialMethodName}Options selected=\$addUserTo${columnNameForPartialMethodName}Selected${CLOSE}
117 </select>
118 ${OPEN}if \$addUserTo${columnNameForPartialMethodName}Error${CLOSE}
119 <font color="red">&nbsp;&nbsp;An error occurred.</font>
120 ${OPEN}/if${CLOSE}
121 </td>
122 </tr>
123 ${OPEN}/if${CLOSE}
124 ${OPEN}if \$canRemoveUserFrom${columnNameForPartialMethodName}${CLOSE}
125 <tr>
126 <td>Remove users from group:</td>
127 <td>
128 <select name="removeUserFrom${columnNameForPartialMethodName}[]" multiple="true">
129 ${OPEN}html_options options=\$removeUserFrom${columnNameForPartialMethodName}Options selected=\$removeUserFrom${columnNameForPartialMethodName}Selected${CLOSE}
130 </select>
131 ${OPEN}if \$removeUserFrom${columnNameForPartialMethodName}Error${CLOSE}
132 <font color="red">&nbsp;&nbsp;An error occurred.</font>
133 ${OPEN}/if${CLOSE}
134 </td>
135 </tr>
136 ${OPEN}/if${CLOSE}
137 ${OPEN}if \$canUpdate${columnNameForPartialMethodName}NameAndComment${CLOSE}
138 <tr>
139 <td>Group name:</td>
140 <td>
141 <input type="text" name="${columnNameForVariableName}Name" value="${OPEN}\$${columnNameForVariableName}Name${CLOSE}">
142 ${OPEN}if \$update${columnNameForPartialMethodName}NameAndCommentError${CLOSE}
143 <font color="red">&nbsp;&nbsp;An error occurred.</font>
144 ${OPEN}/if${CLOSE}
145 </td>
146 </tr>
147 <tr>
148 <td>Group comment:</td>
149 <td>
150 <input type="text" name="${columnNameForVariableName}Comment" value="${OPEN}\$${columnNameForVariableName}Comment${CLOSE}">
151 ${OPEN}if \$update${columnNameForPartialMethodName}NameAndCommentError${CLOSE}
152 <font color="red">&nbsp;&nbsp;An error occurred.</font>
153 ${OPEN}/if${CLOSE}
154 </td>
155 </tr>
156 ${OPEN}/if${CLOSE}
157 ${OPEN}if activate${columnNameForPartialMethodName}${CLOSE}
158 ${OPEN}if \$canDeactivate${columnNameForPartialMethodName}${CLOSE}
159 <tr>
160 <td>Activated: </td>
161 <td>
162 <select name="activate${columnNameForPartialMethodName}">
163 <option value="1" SELECTED="true">true</option>
164 <option value="0">false</option>
165 </select>
166 ${OPEN}if activate${columnNameForPartialMethodName}Error${CLOSE}
167 <font color="red">&nbsp;&nbsp;An error occurred.</font>
168 ${OPEN}/if${CLOSE}
169 </td>
170 </tr>
171 ${OPEN}/if${CLOSE}
172 ${OPEN}else${CLOSE}
173 ${OPEN}if \$canActivate${columnNameForPartialMethodName}${CLOSE}
174 <tr>
175 <td>Activated: </td>
176 <td>
177 <select name="activate${columnNameForPartialMethodName}">
178 <option value="1">true</option>
179 <option value="0" SELECTED="true">false</option>
180 </select>
181 ${OPEN}if activate${columnNameForPartialMethodName}Error${CLOSE}
182 <font color="red">&nbsp;&nbsp;An error occurred.</font>
183 ${OPEN}/if${CLOSE}
184 </td>
185 </tr>
186 ${OPEN}/if${CLOSE}
187 ${OPEN}/if${CLOSE}
188 <tr>
189 <td></td>
190 <td>
191 <input type="hidden" name="action" value="1">
192 <input type="hidden" name="$primaryKeyColumnNameForVariableName" value="${OPEN}\$$primaryKeyColumnNameForVariableName${CLOSE}">
193 <input type="submit" value="Update">
194 <input type="submit" value="Next >>" name="next">
195 </td>
196 <tr>
197 </table>
198 </form>
199 END;;;
200 if ($footer) {
201 $data .="{{include file=\"footer.tpl\"}}\n";
202 }
203
204 $data .= <<<END
205 </body>
206 </html>
207
208 END;;; return $data;
209 }
210 }
211 ?>

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