|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
You may not change or alter any portion of this comment or credits |
|
5
|
|
|
of supporting developers from this source code or any supporting source code |
|
6
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
|
7
|
|
|
|
|
8
|
|
|
This program is distributed in the hope that it will be useful, |
|
9
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
11
|
|
|
*/ |
|
12
|
|
|
/** |
|
13
|
|
|
* tdmcreate module. |
|
14
|
|
|
* |
|
15
|
|
|
* @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ |
|
16
|
|
|
* @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
|
17
|
|
|
* |
|
18
|
|
|
* @since 2.5.0 |
|
19
|
|
|
* |
|
20
|
|
|
* @author Txmod Xoops http://www.txmodxoops.org |
|
21
|
|
|
* |
|
22
|
|
|
* @version $Id: AdminPages.php 12258 2014-01-02 09:33:29Z timgno $ |
|
23
|
|
|
*/ |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Class AdminPages. |
|
27
|
|
|
*/ |
|
28
|
|
|
class AdminPages extends TDMCreateFile |
|
|
|
|
|
|
29
|
|
|
{ |
|
30
|
|
|
/* |
|
31
|
|
|
* @var string |
|
32
|
|
|
*/ |
|
33
|
|
|
private $tf = null; |
|
34
|
|
|
|
|
35
|
|
|
/* |
|
36
|
|
|
* @var string |
|
37
|
|
|
*/ |
|
38
|
|
|
private $cc = null; |
|
39
|
|
|
|
|
40
|
|
|
/* |
|
41
|
|
|
* @var string |
|
42
|
|
|
*/ |
|
43
|
|
|
private $xc = null; |
|
44
|
|
|
|
|
45
|
|
|
/* |
|
46
|
|
|
* @var string |
|
47
|
|
|
*/ |
|
48
|
|
|
private $axc = null; |
|
49
|
|
|
|
|
50
|
|
|
/* |
|
51
|
|
|
* @public function constructor |
|
52
|
|
|
* @param null |
|
53
|
|
|
* |
|
54
|
|
|
*/ |
|
55
|
|
|
public function __construct() |
|
56
|
|
|
{ |
|
57
|
|
|
parent::__construct(); |
|
58
|
|
|
$this->tf = TDMCreateFile::getInstance(); |
|
|
|
|
|
|
59
|
|
|
$this->phpcode = TDMCreatePhpCode::getInstance(); |
|
|
|
|
|
|
60
|
|
|
$this->xc = TDMCreateXoopsCode::getInstance(); |
|
|
|
|
|
|
61
|
|
|
$this->cc = ClassXoopsCode::getInstance(); |
|
|
|
|
|
|
62
|
|
|
$this->axc = AdminXoopsCode::getInstance(); |
|
|
|
|
|
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/* |
|
66
|
|
|
* @static function &getInstance |
|
67
|
|
|
* @param null |
|
68
|
|
|
* |
|
69
|
|
|
* @return AdminPages |
|
70
|
|
|
*/ |
|
71
|
|
|
public static function &getInstance() |
|
72
|
|
|
{ |
|
73
|
|
|
static $instance = false; |
|
74
|
|
|
if (!$instance) { |
|
75
|
|
|
$instance = new self(); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
return $instance; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/* |
|
82
|
|
|
* @public function write |
|
83
|
|
|
* @param $module |
|
84
|
|
|
* @param $table |
|
85
|
|
|
*/ |
|
86
|
|
|
public function write($module, $table, $filename) |
|
87
|
|
|
{ |
|
88
|
|
|
$this->setModule($module); |
|
89
|
|
|
$this->setTable($table); |
|
90
|
|
|
$this->setFileName($filename); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
/* |
|
94
|
|
|
* @private function getAdminPagesHeader |
|
95
|
|
|
* @param $moduleDirname |
|
96
|
|
|
* @param $tableName |
|
97
|
|
|
* @param $fieldId |
|
98
|
|
|
* @return string |
|
99
|
|
|
*/ |
|
100
|
|
|
private function getAdminPagesHeader($moduleDirname, $tableName, $fieldId) |
|
|
|
|
|
|
101
|
|
|
{ |
|
102
|
|
|
$ccFieldId = $this->getCamelCase($fieldId, false, true); |
|
103
|
|
|
$ret = $this->getInclude(); |
|
104
|
|
|
$ret .= $this->phpcode->getPhpCodeCommentLine('It recovered the value of argument op in URL$'); |
|
|
|
|
|
|
105
|
|
|
$ret .= $this->xc->getXoopsCodeXoopsRequest('op', 'op', 'list'); |
|
|
|
|
|
|
106
|
|
|
$ret .= $this->phpcode->getPhpCodeCommentLine("Request {$fieldId}"); |
|
|
|
|
|
|
107
|
|
|
$ret .= $this->xc->getXoopsCodeXoopsRequest($ccFieldId, $fieldId, '', 'Int'); |
|
|
|
|
|
|
108
|
|
|
|
|
109
|
|
|
return $ret; |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
/* |
|
113
|
|
|
* @private function getAdminPagesSwitch |
|
114
|
|
|
* @param $cases |
|
115
|
|
|
* |
|
116
|
|
|
* @return string |
|
117
|
|
|
*/ |
|
118
|
|
|
private function getAdminPagesSwitch($cases = array()) |
|
119
|
|
|
{ |
|
120
|
|
|
$contentSwitch = $this->phpcode->getPhpCodeCaseSwitch($cases, true, false, "\t"); |
|
|
|
|
|
|
121
|
|
|
|
|
122
|
|
|
return $this->phpcode->getPhpCodeSwitch('op', $contentSwitch); |
|
|
|
|
|
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
/* |
|
126
|
|
|
* @private function getAdminPagesList |
|
127
|
|
|
* @param $moduleDirname |
|
128
|
|
|
* @param $table |
|
129
|
|
|
* @param $tableFieldname |
|
130
|
|
|
* @param $language |
|
131
|
|
|
* @param $fields |
|
132
|
|
|
* @param $fieldId |
|
133
|
|
|
* @param $fieldInForm |
|
134
|
|
|
* @param $fieldMain |
|
135
|
|
|
* @return string |
|
136
|
|
|
*/ |
|
137
|
|
|
private function getAdminPagesList($moduleDirname, $table, $language, $fields, $fieldId, $fieldInForm, $fieldMain) |
|
|
|
|
|
|
138
|
|
|
{ |
|
139
|
|
|
$stuModuleDirname = strtoupper($moduleDirname); |
|
140
|
|
|
$tableName = $table->getVar('table_name'); |
|
141
|
|
|
$tableSoleName = $table->getVar('table_solename'); |
|
142
|
|
|
$stuTableName = strtoupper($tableName); |
|
143
|
|
|
$stuTableSoleName = strtoupper($tableSoleName); |
|
144
|
|
|
|
|
145
|
|
|
$ret = $this->xc->getXoopsCodeXoopsRequest('start', 'start', '0', 'Int'); |
|
|
|
|
|
|
146
|
|
|
$adminpager = $this->xc->getXoopsCodeGetConfig($moduleDirname, 'adminpager'); |
|
|
|
|
|
|
147
|
|
|
$ret .= $this->xc->getXoopsCodeXoopsRequest('limit', 'limit', $adminpager, 'Int', false, "\t\t"); |
|
|
|
|
|
|
148
|
|
|
$ret .= $this->axc->getAdminTemplateMain($moduleDirname, $tableName, "\t\t"); |
|
|
|
|
|
|
149
|
|
|
$navigation = $this->axc->getAdminAddNavigation($tableName); |
|
|
|
|
|
|
150
|
|
|
$ret .= $this->xc->getXoopsCodeTplAssign('navigation', $navigation, true, "\t\t"); |
|
|
|
|
|
|
151
|
|
|
|
|
152
|
|
|
if (in_array(1, $fieldInForm)) { |
|
153
|
|
|
$ret .= $this->axc->getAdminItemButton($language, $tableName, $stuTableSoleName, '?op=new', 'add', "\t\t"); |
|
|
|
|
|
|
154
|
|
|
$ret .= $this->xc->getXoopsCodeTplAssign('buttons', '$adminMenu->renderButton()', true, "\t\t"); |
|
|
|
|
|
|
155
|
|
|
} |
|
156
|
|
|
|
|
157
|
|
|
$ret .= $this->xc->getXoopsCodeObjHandlerCount($tableName, "\t\t"); |
|
|
|
|
|
|
158
|
|
|
$ret .= $this->xc->getXoopsCodeObjHandlerAll($tableName, '', '$start', '$limit', "\t\t"); |
|
|
|
|
|
|
159
|
|
|
$ret .= $this->xc->getXoopsCodeTplAssign("{$tableName}_count", "\${$tableName}Count", true, "\t\t"); |
|
|
|
|
|
|
160
|
|
|
$ret .= $this->xc->getXoopsCodeTplAssign("{$moduleDirname}_url", "{$stuModuleDirname}_URL", true, "\t\t"); |
|
|
|
|
|
|
161
|
|
|
$ret .= $this->xc->getXoopsCodeTplAssign("{$moduleDirname}_upload_url", "{$stuModuleDirname}_UPLOAD_URL", true, "\t\t"); |
|
|
|
|
|
|
162
|
|
|
|
|
163
|
|
|
$ret .= $this->phpcode->getPhpCodeCommentLine('Table view', $tableName, "\t\t"); |
|
|
|
|
|
|
164
|
|
|
$contentForeach = $this->xc->getXoopsCodeGetValues($tableName, $tableSoleName, 'i', false, "\t"); |
|
|
|
|
|
|
165
|
|
|
$contentForeach .= $this->xc->getXoopsCodeXoopsTplAppend("{$tableName}_list", "\${$tableSoleName}", "\t\t\t\t"); |
|
|
|
|
|
|
166
|
|
|
$contentForeach .= $this->phpcode->getPhpCodeUnset($tableSoleName, "\t\t\t\t"); |
|
|
|
|
|
|
167
|
|
|
$condIf = $this->phpcode->getPhpCodeForeach("{$tableName}All", true, false, 'i', $contentForeach, "\t\t\t"); |
|
|
|
|
|
|
168
|
|
|
$condIf .= $this->xc->getXoopsCodePageNav($tableName, "\t\t\t"); |
|
|
|
|
|
|
169
|
|
|
$condElse = $this->xc->getXoopsCodeTplAssign('error', "{$language}THEREARENT_{$stuTableName}", true, "\t\t\t"); |
|
|
|
|
|
|
170
|
|
|
$ret .= $this->phpcode->getPhpCodeConditions("\${$tableName}Count", ' > ', '0', $condIf, $condElse, "\t\t"); |
|
|
|
|
|
|
171
|
|
|
|
|
172
|
|
|
return $ret; |
|
173
|
|
|
} |
|
174
|
|
|
|
|
175
|
|
|
/* |
|
176
|
|
|
* @private function getAdminPagesNew |
|
177
|
|
|
* @param $moduleDirname |
|
178
|
|
|
* @param $tableName |
|
179
|
|
|
* @param $fieldInForm |
|
180
|
|
|
* @param $language |
|
181
|
|
|
* @return string |
|
182
|
|
|
*/ |
|
183
|
|
|
private function getAdminPagesNew($moduleDirname, $tableName, $fieldInForm, $language, $t = '') |
|
184
|
|
|
{ |
|
185
|
|
|
$stuTableName = strtoupper($tableName); |
|
186
|
|
|
$ret = $this->axc->getAdminTemplateMain($moduleDirname, $tableName); |
|
|
|
|
|
|
187
|
|
|
$navigation = $this->axc->getAdminAddNavigation($tableName); |
|
|
|
|
|
|
188
|
|
|
$ret .= $this->xc->getXoopsCodeTplAssign('navigation', $navigation, true, $t); |
|
|
|
|
|
|
189
|
|
|
|
|
190
|
|
|
if (in_array(1, $fieldInForm)) { |
|
191
|
|
|
$ret .= $this->axc->getAdminItemButton($language, $tableName, $stuTableName, '', 'list', $t); |
|
|
|
|
|
|
192
|
|
|
$ret .= $this->xc->getXoopsCodeTplAssign('buttons', '$adminMenu->renderButton()', true, $t); |
|
|
|
|
|
|
193
|
|
|
} |
|
194
|
|
|
$ret .= $this->phpcode->getPhpCodeCommentLine('Get Form', null, "\t\t"); |
|
|
|
|
|
|
195
|
|
|
$ret .= $this->xc->getXoopsCodeObjHandlerCreate($tableName, $t); |
|
|
|
|
|
|
196
|
|
|
$ret .= $this->xc->getXoopsCodeGetForm('form', $tableName, 'Obj', $t); |
|
|
|
|
|
|
197
|
|
|
$ret .= $this->xc->getXoopsCodeTplAssign('form', '$form->render()', true, $t); |
|
|
|
|
|
|
198
|
|
|
|
|
199
|
|
|
return $ret; |
|
200
|
|
|
} |
|
201
|
|
|
|
|
202
|
|
|
/* |
|
203
|
|
|
* @private function getPermissionsSave |
|
204
|
|
|
* @param $moduleDirname |
|
205
|
|
|
* @param $fieldId |
|
206
|
|
|
* @param $ccFieldId |
|
207
|
|
|
* @param $newFieldId |
|
208
|
|
|
* @param $perm |
|
209
|
|
|
* |
|
210
|
|
|
* @return string |
|
211
|
|
|
*/ |
|
212
|
|
|
private function getPermissionsSave($moduleDirname, $fieldId, $ccFieldId, $newFieldId, $perm = 'view') |
|
|
|
|
|
|
213
|
|
|
{ |
|
214
|
|
|
$ret = $this->phpcode->getPhpCodeCommentLine('Permission to', $perm, "\t\t\t"); |
|
|
|
|
|
|
215
|
|
|
$content = $this->xc->getXoopsCodeAddRight('gpermHandler', "{$moduleDirname}_{$perm}", '$permId', '$onegroupId', "\$GLOBALS['xoopsModule']->getVar('mid')", false, "\t"); |
|
|
|
|
|
|
216
|
|
|
$foreach = $this->phpcode->getPhpCodeForeach("_POST['groups_{$perm}']", false, false, 'onegroupId', $content, "\t\t\t\t"); |
|
|
|
|
|
|
217
|
|
|
$ret .= $this->phpcode->getPhpCodeConditions("isset(\$_POST['groups_{$perm}'])", null, null, $foreach, false, "\t\t\t"); |
|
|
|
|
|
|
218
|
|
|
|
|
219
|
|
|
return $ret; |
|
220
|
|
|
} |
|
221
|
|
|
|
|
222
|
|
|
/* |
|
223
|
|
|
* @private function getAdminPagesSave |
|
224
|
|
|
* @param $moduleDirname |
|
225
|
|
|
* @param $tableName |
|
226
|
|
|
* @param $tableCategory |
|
227
|
|
|
* @param $language |
|
228
|
|
|
* @param $fields |
|
229
|
|
|
* @param $fieldId |
|
230
|
|
|
* @param $fieldMain |
|
231
|
|
|
* @return string |
|
232
|
|
|
*/ |
|
233
|
|
|
private function getAdminPagesSave($moduleDirname, $tableName, $tableCategory, $language, $fields, $fieldId, $fieldMain, $t = '') |
|
234
|
|
|
{ |
|
235
|
|
|
$ccFieldId = $this->getCamelCase($fieldId, false, true); |
|
236
|
|
|
$ret = $this->phpcode->getPhpCodeCommentLine('Security Check'); |
|
|
|
|
|
|
237
|
|
|
$xoopsSecurityCheck = $this->xc->getXoopsCodeSecurityCheck('!'); |
|
|
|
|
|
|
238
|
|
|
$securityError = $this->xc->getXoopsCodeSecurityErrors(); |
|
|
|
|
|
|
239
|
|
|
$implode = $this->phpcode->getPhpCodeImplode(',', $securityError); |
|
|
|
|
|
|
240
|
|
|
$redirectError = $this->xc->getXoopsCodeRedirectHeader($tableName, '.php', '3', $implode, true, $t."\t"); |
|
|
|
|
|
|
241
|
|
|
$ret .= $this->phpcode->getPhpCodeConditions($xoopsSecurityCheck, '', '', $redirectError, false, $t); |
|
|
|
|
|
|
242
|
|
|
|
|
243
|
|
|
$isset = $this->phpcode->getPhpCodeIsset($ccFieldId); |
|
|
|
|
|
|
244
|
|
|
$contentIf = $this->xc->getXoopsCodeGet($tableName, $ccFieldId, 'Obj', $tableName.'Handler', false, $t."\t"); |
|
|
|
|
|
|
245
|
|
|
$contentElse = $this->xc->getXoopsCodeObjHandlerCreate($tableName, "\t\t\t"); |
|
|
|
|
|
|
246
|
|
|
$ret .= $this->phpcode->getPhpCodeConditions($isset, '', '', $contentIf, $contentElse, $t); |
|
|
|
|
|
|
247
|
|
|
$ret .= $this->phpcode->getPhpCodeCommentLine('Set Vars', null, "\t\t"); |
|
|
|
|
|
|
248
|
|
|
foreach (array_keys($fields) as $f) { |
|
249
|
|
|
$fieldName = $fields[$f]->getVar('field_name'); |
|
250
|
|
|
$fieldType = $fields[$f]->getVar('field_type'); |
|
251
|
|
|
$fieldElement = $fields[$f]->getVar('field_element'); |
|
252
|
|
|
if ($f > 0) { // If we want to hide field id |
|
253
|
|
|
switch ($fieldElement) { |
|
254
|
|
|
case 5: |
|
255
|
|
|
case 6: |
|
256
|
|
|
$ret .= $this->xc->getXoopsCodeCheckBoxOrRadioYNSetVar($tableName, $fieldName, $t); |
|
|
|
|
|
|
257
|
|
|
break; |
|
258
|
|
|
case 10: |
|
259
|
|
|
$ret .= $this->xc->getXoopsCodeImageListSetVar($moduleDirname, $tableName, $fieldName, $t); |
|
|
|
|
|
|
260
|
|
|
break; |
|
261
|
|
|
case 12: |
|
262
|
|
|
$ret .= $this->xc->getXoopsCodeUrlFileSetVar($moduleDirname, $tableName, $fieldName, $t); |
|
|
|
|
|
|
263
|
|
|
break; |
|
264
|
|
|
case 13: |
|
265
|
|
|
if (1 == $fields[$f]->getVar('field_main')) { |
|
266
|
|
|
$fieldMain = $fieldName; |
|
267
|
|
|
} |
|
268
|
|
|
$ret .= $this->xc->getXoopsCodeUploadImageSetVar($moduleDirname, $tableName, $fieldName, $fieldMain, $t); |
|
|
|
|
|
|
269
|
|
|
break; |
|
270
|
|
|
case 14: |
|
271
|
|
|
$ret .= $this->xc->getXoopsCodeUploadFileSetVar($moduleDirname, $tableName, $fieldName, $t); |
|
|
|
|
|
|
272
|
|
|
break; |
|
273
|
|
|
case 15: |
|
274
|
|
|
$ret .= $this->xc->getXoopsCodeTextDateSelectSetVar($tableName, $fieldName, $t); |
|
|
|
|
|
|
275
|
|
|
break; |
|
276
|
|
|
default: |
|
277
|
|
|
if ($fieldType == 2 || $fieldType == 7 || $fieldType == 8) { |
|
278
|
|
|
$ret .= $this->xc->getXoopsCodeSetVar($tableName, $fieldName, "isset(\$_POST['{$fieldName}']) ? \$_POST['{$fieldName}'] : 0", $t); |
|
|
|
|
|
|
279
|
|
|
} else { |
|
280
|
|
|
$ret .= $this->xc->getXoopsCodeSetVar($tableName, $fieldName, "\$_POST['{$fieldName}']", $t); |
|
|
|
|
|
|
281
|
|
|
} |
|
282
|
|
|
break; |
|
283
|
|
|
} |
|
284
|
|
|
} |
|
285
|
|
|
} |
|
286
|
|
|
$ret .= $this->phpcode->getPhpCodeCommentLine('Insert Data', null, "\t\t"); |
|
|
|
|
|
|
287
|
|
|
$insert = $this->xc->getXoopsCodeInsert($tableName, $tableName, 'Obj', true); |
|
|
|
|
|
|
288
|
|
|
$contentInsert = ''; |
|
289
|
|
|
if ($tableCategory == 1) { |
|
290
|
|
|
$ucfTableName = ucfirst($tableName); |
|
291
|
|
|
$contentInsert = $this->xc->getXoopsCodeEqualsOperator('$newCatId', "\${$tableName}Obj->getNewInsertedId{$ucfTableName}()", null, false, $t."\t"); |
|
|
|
|
|
|
292
|
|
|
$ucfFieldId = $this->getCamelCase($fieldId, true); |
|
293
|
|
|
$contentInsert .= $this->phpcode->getPhpCodeTernaryOperator('permId', "isset(\$_REQUEST['{$fieldId}'])", "\${$ccFieldId}", "\$new{$ucfFieldId}", $t."\t"); |
|
|
|
|
|
|
294
|
|
|
$contentInsert .= $this->xc->getXoopsCodeEqualsOperator('$gpermHandler', "xoops_gethandler('groupperm')", null, true, $t."\t"); |
|
|
|
|
|
|
295
|
|
|
$contentInsert .= $this->getPermissionsSave($moduleDirname, $fieldId, $ccFieldId, 'new'.$ucfFieldId); |
|
296
|
|
|
$contentInsert .= $this->getPermissionsSave($moduleDirname, $fieldId, $ccFieldId, 'new'.$ucfFieldId, 'submit'); |
|
297
|
|
|
$contentInsert .= $this->getPermissionsSave($moduleDirname, $fieldId, $ccFieldId, 'new'.$ucfFieldId, 'approve'); |
|
298
|
|
|
} |
|
299
|
|
|
$contentInsert .= $this->xc->getXoopsCodeRedirectHeader($tableName.'.php', '?op=list', '2', "{$language}FORM_OK", true, $t."\t"); |
|
|
|
|
|
|
300
|
|
|
$ret .= $this->phpcode->getPhpCodeConditions($insert, '', '', $contentInsert, false, $t); |
|
|
|
|
|
|
301
|
|
|
$ret .= $this->phpcode->getPhpCodeCommentLine('Get Form', null, "\t\t"); |
|
|
|
|
|
|
302
|
|
|
$ret .= $this->xc->getXoopsCodeTplAssign('error', "\${$tableName}Obj->getHtmlErrors()", true, $t); |
|
|
|
|
|
|
303
|
|
|
$ret .= $this->xc->getXoopsCodeGetForm('form', $tableName, 'Obj', $t); |
|
|
|
|
|
|
304
|
|
|
$ret .= $this->xc->getXoopsCodeTplAssign('form', '$form->render()', true, $t); |
|
|
|
|
|
|
305
|
|
|
|
|
306
|
|
|
return $ret; |
|
307
|
|
|
} |
|
308
|
|
|
|
|
309
|
|
|
/* |
|
310
|
|
|
* @private function getAdminPagesEdit |
|
311
|
|
|
* @param $moduleDirname |
|
312
|
|
|
* @param $tableName |
|
313
|
|
|
* @param $tableFieldname |
|
314
|
|
|
* @param $language |
|
315
|
|
|
* @param $fieldId |
|
316
|
|
|
* @param $fieldInForm |
|
317
|
|
|
* @return string |
|
318
|
|
|
*/ |
|
319
|
|
|
private function getAdminPagesEdit($moduleDirname, $table, $language, $fieldId, $fieldInForm, $t = '') |
|
320
|
|
|
{ |
|
321
|
|
|
$tableName = $table->getVar('table_name'); |
|
322
|
|
|
$tableSoleName = $table->getVar('table_solename'); |
|
323
|
|
|
$tableFieldname = $table->getVar('table_fieldname'); |
|
324
|
|
|
$stuTableName = strtoupper($tableName); |
|
325
|
|
|
$ucfTableName = ucfirst($tableName); |
|
|
|
|
|
|
326
|
|
|
$stuTableSoleName = strtoupper($tableSoleName); |
|
327
|
|
|
$stuTableFieldname = strtoupper($tableFieldname); |
|
|
|
|
|
|
328
|
|
|
$ccFieldId = $this->getCamelCase($fieldId, false, true); |
|
329
|
|
|
|
|
330
|
|
|
$ret = $this->axc->getAdminTemplateMain($moduleDirname, $tableName); |
|
|
|
|
|
|
331
|
|
|
$navigation = $this->axc->getAdminAddNavigation($tableName); |
|
|
|
|
|
|
332
|
|
|
$ret .= $this->xc->getXoopsCodeTplAssign('navigation', $navigation, true, $t); |
|
|
|
|
|
|
333
|
|
|
|
|
334
|
|
|
if (in_array(1, $fieldInForm)) { |
|
335
|
|
|
$ret .= $this->axc->getAdminItemButton($language, $tableName, $stuTableSoleName, '?op=new', 'add', $t); |
|
|
|
|
|
|
336
|
|
|
$ret .= $this->axc->getAdminItemButton($language, $tableName, $stuTableName, '', 'list', $t); |
|
|
|
|
|
|
337
|
|
|
$ret .= $this->xc->getXoopsCodeTplAssign('buttons', '$adminMenu->renderButton()', true, $t); |
|
|
|
|
|
|
338
|
|
|
} |
|
339
|
|
|
$ret .= $this->phpcode->getPhpCodeCommentLine('Get Form', null, "\t\t"); |
|
|
|
|
|
|
340
|
|
|
$ret .= $this->xc->getXoopsCodeGet($tableName, $ccFieldId, 'Obj', $tableName.'Handler', false, $t); |
|
|
|
|
|
|
341
|
|
|
$ret .= $this->xc->getXoopsCodeGetForm('form', $tableName, 'Obj', $t); |
|
|
|
|
|
|
342
|
|
|
$ret .= $this->xc->getXoopsCodeTplAssign('form', '$form->render()', true, $t); |
|
|
|
|
|
|
343
|
|
|
|
|
344
|
|
|
return $ret; |
|
345
|
|
|
} |
|
346
|
|
|
|
|
347
|
|
|
/* |
|
348
|
|
|
* @private function getAdminPagesDelete |
|
349
|
|
|
* @param $tableName |
|
350
|
|
|
* @param $language |
|
351
|
|
|
* @param $fieldId |
|
352
|
|
|
* @param $fieldMain |
|
353
|
|
|
* @return string |
|
354
|
|
|
*/ |
|
355
|
|
|
private function getAdminPagesDelete($tableName, $language, $fieldId, $fieldMain, $t = '') |
|
356
|
|
|
{ |
|
357
|
|
|
return $this->axc->getAdminCodeCaseDelete($language, $tableName, $fieldId, $fieldMain, $t); |
|
|
|
|
|
|
358
|
|
|
} |
|
359
|
|
|
|
|
360
|
|
|
/* |
|
361
|
|
|
* @public function render |
|
362
|
|
|
* @param null |
|
363
|
|
|
* |
|
364
|
|
|
* @return bool|string |
|
365
|
|
|
*/ |
|
366
|
|
|
public function render() |
|
367
|
|
|
{ |
|
368
|
|
|
$module = $this->getModule(); |
|
369
|
|
|
$table = $this->getTable(); |
|
370
|
|
|
$filename = $this->getFileName(); |
|
371
|
|
|
$moduleDirname = $module->getVar('mod_dirname'); |
|
372
|
|
|
$tableName = $table->getVar('table_name'); |
|
373
|
|
|
$tableCategory = $table->getVar('table_category'); |
|
374
|
|
|
$language = $this->getLanguage($moduleDirname, 'AM'); |
|
375
|
|
|
$fields = $this->tf->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); |
|
|
|
|
|
|
376
|
|
|
$fieldInForm = null; |
|
377
|
|
|
foreach (array_keys($fields) as $f) { |
|
378
|
|
|
$fieldName = $fields[$f]->getVar('field_name'); |
|
379
|
|
|
$fieldInForm[] = $fields[$f]->getVar('field_inform'); |
|
380
|
|
|
if (0 == $f) { |
|
381
|
|
|
$fieldId = $fieldName; |
|
382
|
|
|
} |
|
383
|
|
|
if (1 == $fields[$f]->getVar('field_main')) { |
|
384
|
|
|
$fieldMain = $fieldName; |
|
385
|
|
|
} |
|
386
|
|
|
} |
|
387
|
|
|
$content = $this->getHeaderFilesComments($module, $filename); |
|
388
|
|
|
$content .= $this->getAdminPagesHeader($moduleDirname, $tableName, $fieldId); |
|
|
|
|
|
|
389
|
|
|
$list = $this->getAdminPagesList($moduleDirname, $table, $language, $fields, $fieldId, $fieldInForm, $fieldMain); |
|
|
|
|
|
|
390
|
|
|
if (in_array(1, $fieldInForm)) { |
|
391
|
|
|
$new = $this->getAdminPagesNew($moduleDirname, $tableName, $fieldInForm, $language, "\t\t"); |
|
392
|
|
|
$save = $this->getAdminPagesSave($moduleDirname, $tableName, $tableCategory, $language, $fields, $fieldId, $fieldMain, "\t\t"); |
|
393
|
|
|
$edit = $this->getAdminPagesEdit($moduleDirname, $table, $language, $fieldId, $fieldInForm, "\t\t"); |
|
394
|
|
|
} |
|
395
|
|
|
$delete = $this->getAdminPagesDelete($tableName, $language, $fieldId, $fieldMain, "\t\t"); |
|
396
|
|
|
|
|
397
|
|
|
$cases = array('list' => array($list), |
|
398
|
|
|
'new' => array($new), |
|
|
|
|
|
|
399
|
|
|
'save' => array($save), |
|
|
|
|
|
|
400
|
|
|
'edit' => array($edit), |
|
|
|
|
|
|
401
|
|
|
'delete' => array($delete), ); |
|
402
|
|
|
$content .= $this->getAdminPagesSwitch($cases); |
|
403
|
|
|
$content .= $this->getInclude('footer'); |
|
404
|
|
|
// |
|
405
|
|
|
$this->tf->create($moduleDirname, 'admin', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED); |
|
|
|
|
|
|
406
|
|
|
|
|
407
|
|
|
return $this->tf->renderFile(); |
|
|
|
|
|
|
408
|
|
|
} |
|
409
|
|
|
} |
|
410
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.