This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
1 | <?php |
||||
2 | |||||
3 | namespace XoopsModules\Modulebuilder\Files; |
||||
4 | |||||
5 | use XoopsModules\Modulebuilder; |
||||
6 | |||||
7 | /* |
||||
8 | You may not change or alter any portion of this comment or credits |
||||
9 | of supporting developers from this source code or any supporting source code |
||||
10 | which is considered copyrighted (c) material of the original comment or credit authors. |
||||
11 | |||||
12 | This program is distributed in the hope that it will be useful, |
||||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||||
15 | */ |
||||
16 | /** |
||||
17 | * modulebuilder module. |
||||
18 | * |
||||
19 | * @copyright XOOPS Project (https://xoops.org) |
||||
20 | * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
||||
21 | * |
||||
22 | * @since 2.5.0 |
||||
23 | * |
||||
24 | * @author Txmod Xoops https://xoops.org |
||||
25 | * Goffy https://myxoops.org |
||||
26 | * |
||||
27 | */ |
||||
28 | |||||
29 | /** |
||||
30 | * Class CreateXoopsCode. |
||||
31 | */ |
||||
32 | class CreateXoopsCode |
||||
33 | { |
||||
34 | /** |
||||
35 | * @static function getInstance |
||||
36 | * @param null |
||||
37 | */ |
||||
38 | |||||
39 | /** |
||||
40 | * @return Modulebuilder\Files\CreateXoopsCode |
||||
41 | */ |
||||
42 | public static function getInstance() |
||||
43 | { |
||||
44 | static $instance = false; |
||||
45 | if (!$instance) { |
||||
46 | $instance = new self(); |
||||
47 | } |
||||
48 | |||||
49 | return $instance; |
||||
50 | } |
||||
51 | |||||
52 | /** |
||||
53 | * @public function getXcSwitch |
||||
54 | * @param string $op |
||||
55 | * @param array $cases |
||||
56 | * @param bool $defaultAfterCase |
||||
57 | * @param bool $default |
||||
58 | * @param string $t - Indentation |
||||
59 | * |
||||
60 | * @param bool $isString |
||||
61 | * @param bool $isConst |
||||
62 | * @return string |
||||
63 | */ |
||||
64 | public function getXcSwitch($op = '', $cases = [], $defaultAfterCase = false, $default = false, $t = '', $isString = true, $isConst = false) |
||||
65 | { |
||||
66 | $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); |
||||
67 | $contentSwitch = $pc->getPhpCodeCaseSwitch($cases, $defaultAfterCase, $default, $t . "\t", $isConst); |
||||
68 | |||||
69 | return $pc->getPhpCodeSwitch($op, $contentSwitch, $t, $isString); |
||||
70 | } |
||||
71 | |||||
72 | /** |
||||
73 | * @public function getXcEqualsOperator |
||||
74 | * @param $var |
||||
75 | * @param $value |
||||
76 | * @param $interlock |
||||
77 | * @param $t - Indentation |
||||
0 ignored issues
–
show
Documentation
Bug
introduced
by
![]() |
|||||
78 | * |
||||
79 | * @return string |
||||
80 | */ |
||||
81 | public function getXcEqualsOperator($var, $value, $interlock = null, $t = '') |
||||
82 | { |
||||
83 | return "{$t}{$var} {$interlock}= {$value};\n"; |
||||
84 | } |
||||
85 | |||||
86 | /** |
||||
87 | * @public function getXcAnchorFunction |
||||
88 | * @param $anchor |
||||
89 | * @param $name |
||||
90 | * @param $vars |
||||
91 | * @param $close |
||||
92 | * |
||||
93 | * @return string |
||||
94 | */ |
||||
95 | public function getXcAnchorFunction($anchor, $name, $vars, $close = false) |
||||
96 | { |
||||
97 | $semicolon = false !== $close ? ';' : ''; |
||||
98 | |||||
99 | return "\${$anchor}->{$name}({$vars}){$semicolon}"; |
||||
100 | } |
||||
101 | |||||
102 | /** |
||||
103 | * @public function getXcSetVarObj |
||||
104 | * @param $tableName |
||||
105 | * @param $fieldName |
||||
106 | * @param $var |
||||
107 | * @param $t |
||||
108 | * @return string |
||||
109 | */ |
||||
110 | public function getXcSetVarObj($tableName, $fieldName, $var, $t = '') |
||||
111 | { |
||||
112 | return "{$t}\${$tableName}Obj->setVar('{$fieldName}', {$var});\n"; |
||||
113 | } |
||||
114 | |||||
115 | /** |
||||
116 | * @public function getXcGetVar |
||||
117 | * @param string $varLeft |
||||
118 | * @param string $handle |
||||
119 | * @param string $var |
||||
120 | * @param bool $isParam |
||||
121 | * @param string $t |
||||
122 | * |
||||
123 | * @param string $format |
||||
124 | * @return string |
||||
125 | */ |
||||
126 | public function getXcGetVar($varLeft = '', $handle = '', $var = '', $isParam = false, $t = '', $format = '') |
||||
127 | { |
||||
128 | if (!$isParam) { |
||||
129 | $ret = "{$t}\${$varLeft} = \${$handle}->getVar('{$var}'{$format});\n"; |
||||
130 | } else { |
||||
131 | $ret = "\${$handle}->getVar('{$var}'{$format})"; |
||||
132 | } |
||||
133 | |||||
134 | return $ret; |
||||
135 | } |
||||
136 | |||||
137 | /** |
||||
138 | * @public function getXcAddItem |
||||
139 | * @param $varLeft |
||||
140 | * @param $paramLeft |
||||
141 | * @param $paramRight |
||||
142 | * @param $t |
||||
143 | * |
||||
144 | * @return string |
||||
145 | */ |
||||
146 | public function getXcAddItem($varLeft = '', $paramLeft = '', $paramRight = '', $t = '') |
||||
147 | { |
||||
148 | return "{$t}\${$varLeft}->addItem({$paramLeft}, {$paramRight});\n"; |
||||
149 | } |
||||
150 | |||||
151 | /** |
||||
152 | * @public function getXcGetGroupIds |
||||
153 | * @param string $var |
||||
154 | * @param string $anchor |
||||
155 | * @param $param1 |
||||
156 | * @param $param2 |
||||
157 | * @param $param3 |
||||
158 | * @param string $t |
||||
159 | * @return string |
||||
160 | */ |
||||
161 | public function getXcGetGroupIds($var = '', $anchor = '', $param1 = null, $param2 = null, $param3 = null, $t = '') |
||||
162 | { |
||||
163 | return "{$t}\${$var} = \${$anchor}->getGroupIds({$param1}, {$param2}, {$param3});\n"; |
||||
164 | } |
||||
165 | |||||
166 | /** |
||||
167 | * @public function getXcGetItemIds |
||||
168 | * @param string $var |
||||
169 | * @param string $anchor |
||||
170 | * @param $param1 |
||||
171 | * @param $param2 |
||||
172 | * @param $param3 |
||||
173 | * @param string $t |
||||
174 | * @return string |
||||
175 | */ |
||||
176 | public function getXcGetItemIds($var = '', $anchor = '', $param1 = null, $param2 = null, $param3 = null, $t = '') |
||||
177 | { |
||||
178 | return "{$t}\${$var} = \${$anchor}->getItemIds({$param1}, {$param2}, {$param3});\n"; |
||||
179 | } |
||||
180 | |||||
181 | /** |
||||
182 | * @public function getXcSetVarTextDateSelect |
||||
183 | * @param $tableName |
||||
184 | * @param $tableSoleName |
||||
185 | * @param $fieldName |
||||
186 | * @param string $t |
||||
187 | * @return string |
||||
188 | */ |
||||
189 | public function getXcSetVarTextDateSelect($tableName, $tableSoleName, $fieldName, $t = '') |
||||
190 | { |
||||
191 | $tf = Modulebuilder\Files\CreateFile::getInstance(); |
||||
192 | $rightField = $tf->getRightString($fieldName); |
||||
193 | $ucfRightField = \ucfirst($rightField); |
||||
194 | $value = "\DateTime::createFromFormat(\_SHORTDATESTRING, Request::getString('{$fieldName}'))"; |
||||
195 | $ret = $this->getXcEqualsOperator("\${$tableSoleName}{$ucfRightField}Obj", $value, null, $t); |
||||
196 | $ret .= $this->getXcSetVarObj($tableName, $fieldName, "\${$tableSoleName}{$ucfRightField}Obj->getTimestamp()", $t); |
||||
197 | |||||
198 | return $ret; |
||||
199 | } |
||||
200 | |||||
201 | /** |
||||
202 | * @public function getXcSetVarDateTime |
||||
203 | * @param $tableName |
||||
204 | * @param $tableSoleName |
||||
205 | * @param $fieldName |
||||
206 | * @param string $t |
||||
207 | * @return string |
||||
208 | */ |
||||
209 | public function getXcSetVarDateTime($tableName, $tableSoleName, $fieldName, $t = '') |
||||
210 | { |
||||
211 | $tf = Modulebuilder\Files\CreateFile::getInstance(); |
||||
212 | $rightField = $tf->getRightString($fieldName); |
||||
213 | $ucfRightField = \ucfirst($rightField); |
||||
214 | $request = "Request::getArray('{$fieldName}')"; |
||||
215 | $var = "\${$tableSoleName}{$ucfRightField}"; |
||||
216 | $varArr = "\${$tableSoleName}{$ucfRightField}Arr"; |
||||
217 | $ret = $this->getXcEqualsOperator($varArr, $request, null, $t); |
||||
218 | $varObj = "\${$tableSoleName}{$ucfRightField}Obj"; |
||||
219 | $value = "\DateTime::createFromFormat(\_SHORTDATESTRING, {$varArr}['date'])"; |
||||
220 | $ret .= $this->getXcEqualsOperator($varObj, $value, null, $t); |
||||
221 | $ret .= "{$t}{$varObj}->setTime(0, 0, 0);\n"; |
||||
222 | $value = "{$varObj}->getTimestamp() + (int){$varArr}['time']"; |
||||
223 | $ret .= $this->getXcEqualsOperator($var, $value, null, $t); |
||||
224 | $ret .= $this->getXcSetVarObj($tableName, $fieldName, $var, $t); |
||||
225 | |||||
226 | return $ret; |
||||
227 | } |
||||
228 | |||||
229 | /** |
||||
230 | * @public function getXcSetVarCheckBoxOrRadioYN |
||||
231 | * @param $tableName |
||||
232 | * @param $fieldName |
||||
233 | * @param $t |
||||
234 | * @return string |
||||
235 | */ |
||||
236 | public function getXcSetVarCheckBoxOrRadioYN($tableName, $fieldName, $t = '') |
||||
237 | { |
||||
238 | return $this->getXcSetVarObj($tableName, $fieldName, "Request::getInt('{$fieldName}', 0)", $t); |
||||
239 | } |
||||
240 | |||||
241 | /** |
||||
242 | * @public function getXcMediaUploader |
||||
243 | * @param $var |
||||
244 | * @param $dirPath |
||||
245 | * @param $mimetype |
||||
246 | * @param $maxsize |
||||
247 | * @param string $t |
||||
248 | * @return string |
||||
249 | */ |
||||
250 | public function getXcMediaUploader($var, $dirPath, $mimetype, $maxsize, $t = '') |
||||
251 | { |
||||
252 | $mimetypes_file = $this->getXcGetConfig($mimetype); |
||||
253 | $maxsize_file = $this->getXcGetConfig($maxsize); |
||||
254 | |||||
255 | return "{$t}\${$var} = new \XoopsMediaUploader({$dirPath}, |
||||
256 | {$mimetypes_file}, |
||||
257 | {$maxsize_file}, null, null);\n"; |
||||
258 | } |
||||
259 | |||||
260 | /** |
||||
261 | * @public function getXcXoopsCaptcha |
||||
262 | * @param $var |
||||
263 | * @param $instance |
||||
264 | * @param $t |
||||
265 | * |
||||
266 | * @return string |
||||
267 | */ |
||||
268 | public function getXcGetInstance($var = '', $instance = '', $t = '') |
||||
269 | { |
||||
270 | return "{$t}\${$var} = {$instance}::getInstance();\n"; |
||||
271 | } |
||||
272 | |||||
273 | /** |
||||
274 | * @public function getXcGetConfig |
||||
275 | * @param $name |
||||
276 | * @return string |
||||
277 | */ |
||||
278 | public function getXcGetConfig($name) |
||||
279 | { |
||||
280 | return "\$helper->getConfig('{$name}')"; |
||||
281 | } |
||||
282 | |||||
283 | /** |
||||
284 | * @public function getXcIdGetVar |
||||
285 | * @param $lpFieldName |
||||
286 | * @param $t |
||||
287 | * @return string |
||||
288 | */ |
||||
289 | public function getXcIdGetVar($lpFieldName, $t = '') |
||||
290 | { |
||||
291 | return "{$t}\${$lpFieldName}['id'] = \$i;\n"; |
||||
292 | } |
||||
293 | |||||
294 | /** |
||||
295 | * @public function getXcGetVarAll |
||||
296 | * @param $lpFieldName |
||||
297 | * @param $rpFieldName |
||||
298 | * @param $tableName |
||||
299 | * @param $fieldName |
||||
300 | * @param $t |
||||
301 | * @return string |
||||
302 | */ |
||||
303 | public function getXcGetVarAll($lpFieldName, $rpFieldName, $tableName, $fieldName, $t = '') |
||||
304 | { |
||||
305 | return "{$t}\${$lpFieldName}['{$rpFieldName}'] = \${$tableName}All[\$i]->getVar('{$fieldName}');\n"; |
||||
306 | } |
||||
307 | |||||
308 | /** |
||||
309 | * @public function getXcHelperGetInstance |
||||
310 | * @param $moduleDirname |
||||
311 | * |
||||
312 | * @param string $t |
||||
313 | * @return string |
||||
314 | */ |
||||
315 | public function getXcHelperGetInstance($moduleDirname, $t = '') |
||||
316 | { |
||||
317 | $ucfModuleDirname = \ucfirst($moduleDirname); |
||||
318 | $ret = "{$t}// Get instance of module\n"; |
||||
319 | $ret .= "{$t}\$helper = \XoopsModules\\{$ucfModuleDirname}\Helper::getInstance();\n"; |
||||
320 | |||||
321 | return $ret; |
||||
322 | } |
||||
323 | |||||
324 | /** |
||||
325 | * @public function getXcFormatTimeStamp |
||||
326 | * @param $left |
||||
327 | * @param $value |
||||
328 | * @param string $format |
||||
329 | * @param string $t |
||||
330 | * @return string |
||||
331 | */ |
||||
332 | public function getXcFormatTimeStamp($left, $value, $format = 's', $t = '') |
||||
333 | { |
||||
334 | return "{$t}\${$left} = \\formatTimestamp({$value}, '{$format}');\n"; |
||||
335 | } |
||||
336 | |||||
337 | /** |
||||
338 | * @public function getXcTopicGetVar |
||||
339 | * @param $lpFieldName |
||||
340 | * @param $rpFieldName |
||||
341 | * @param $tableName |
||||
342 | * @param $tableNameTopic |
||||
343 | * @param $fieldNameParent |
||||
344 | * @param $fieldNameTopic |
||||
345 | * @param string $t |
||||
346 | * @return string |
||||
347 | */ |
||||
348 | public function getXcTopicGetVar($lpFieldName, $rpFieldName, $tableName, $tableNameTopic, $fieldNameParent, $fieldNameTopic, $t = '') |
||||
349 | { |
||||
350 | $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); |
||||
351 | $ret = $pc->getPhpCodeCommentLine('Get Var', $fieldNameParent, $t); |
||||
352 | $fieldParent = $this->getXcGetVar('', "\${$tableName}All[\$i]", $fieldNameParent, true, ''); |
||||
353 | $ret .= $this->getXcHandlerGet($rpFieldName, $fieldParent, '', $tableNameTopic . 'Handler', false, $t); |
||||
354 | $ret .= $this->getXcGetVar("\${$lpFieldName}['{$rpFieldName}']", "\${$rpFieldName}", $fieldNameTopic, false, $t); |
||||
355 | |||||
356 | return $ret; |
||||
357 | } |
||||
358 | |||||
359 | /** |
||||
360 | * @public function getXcParentTopicGetVar |
||||
361 | * @param $lpFieldName |
||||
362 | * @param $rpFieldName |
||||
363 | * @param $tableName |
||||
364 | * @param $tableSoleNameTopic |
||||
365 | * @param $tableNameTopic |
||||
366 | * @param $fieldNameParent |
||||
367 | * @param string $t |
||||
368 | * @return string |
||||
369 | */ |
||||
370 | public function getXcParentTopicGetVar($lpFieldName, $rpFieldName, $tableName, $tableSoleNameTopic, $tableNameTopic, $fieldNameParent, $t = '') |
||||
371 | { |
||||
372 | $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); |
||||
373 | $parentTopic = $pc->getPhpCodeCommentLine('Get', $tableNameTopic . ' Handler', $t . "\t"); |
||||
374 | $parentTopic .= $this->getXcHandlerLine($tableNameTopic, $t . "\t"); |
||||
375 | $elseGroups = $this->getXcEqualsOperator('$groups', '\XOOPS_GROUP_ANONYMOUS'); |
||||
376 | $ret = $pc->getPhpCodeConditions("!isset(\${$tableNameTopic}Handler", '', '', $parentTopic, $elseGroups); |
||||
377 | $ret .= $this->getXcGetVarFromID("\${$lpFieldName}['{$rpFieldName}']", $tableNameTopic, $tableSoleNameTopic, $tableName, $fieldNameParent, $t); |
||||
378 | |||||
379 | return $ret; |
||||
380 | } |
||||
381 | |||||
382 | /** |
||||
383 | * @public function getXcGetVarFromID |
||||
384 | * @param $left |
||||
385 | * @param $anchor |
||||
386 | * @param $var |
||||
387 | * @param $tableName |
||||
388 | * @param $fieldName |
||||
389 | * @param string $t |
||||
390 | * @return string |
||||
391 | */ |
||||
392 | public function getXcGetVarFromID($left, $anchor, $var, $tableName, $fieldName, $t = '') |
||||
393 | { |
||||
394 | $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); |
||||
395 | $ret = $pc->getPhpCodeCommentLine('Get Var', $fieldName, $t); |
||||
396 | $getVarFromID = $this->getXcGetVar('', "\${$tableName}All[\$i]", $fieldName, true, ''); |
||||
397 | $rightGet = $this->getXcAnchorFunction($anchor . 'Handler', 'get' . $var . 'FromId', $getVarFromID); |
||||
398 | $ret .= $this->getXcEqualsOperator($left, $rightGet, null, $t); |
||||
399 | |||||
400 | return $ret; |
||||
401 | } |
||||
402 | |||||
403 | /** |
||||
404 | * @public function getXcGetVarUploadImage |
||||
405 | * @param $lpFieldName |
||||
406 | * @param $rpFieldName |
||||
407 | * @param $tableName |
||||
408 | * @param $fieldName |
||||
409 | * @param string $t |
||||
410 | * @return string |
||||
411 | */ |
||||
412 | /* |
||||
413 | public function getXcGetVarUploadImage($lpFieldName, $rpFieldName, $tableName, $fieldName, $t = '') |
||||
414 | { |
||||
415 | $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); |
||||
416 | $ret = $pc->getPhpCodeCommentLine('Get Var', $fieldName, $t); |
||||
417 | $ret .= $this->getXcGetVar($fieldName, "\${$tableName}All[\$i]", $fieldName, false, ''); |
||||
418 | $ret .= $pc->getPhpCodeTernaryOperator("{$lpFieldName}['{$rpFieldName}']", "\${$fieldName}", "\${$fieldName}", "'blank.gif'", $t); |
||||
419 | |||||
420 | return $ret; |
||||
421 | } |
||||
422 | */ |
||||
423 | |||||
424 | /** |
||||
425 | * @public function getXcGetVarUrlFile |
||||
426 | * @param $lpFieldName |
||||
427 | * @param $rpFieldName |
||||
428 | * @param $tableName |
||||
429 | * @param $fieldName |
||||
430 | * @return string |
||||
431 | */ |
||||
432 | public function getXcGetVarUrlFile($lpFieldName, $rpFieldName, $tableName, $fieldName) |
||||
433 | { |
||||
434 | return $this->getXcGetVarAll($lpFieldName, $rpFieldName, $tableName, $fieldName); |
||||
435 | } |
||||
436 | |||||
437 | /** |
||||
438 | * @public function getXcGetVarTextArea |
||||
439 | * @param $lpFieldName |
||||
440 | * @param $rpFieldName |
||||
441 | * @param $tableName |
||||
442 | * @param $fieldName |
||||
443 | * @param string $t |
||||
444 | * @return string |
||||
445 | */ |
||||
446 | public function getXcGetVarTextArea($lpFieldName, $rpFieldName, $tableName, $fieldName, $t = '') |
||||
447 | { |
||||
448 | $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); |
||||
449 | $getVar = $this->getXcGetVar('', "\${$tableName}All[\$i]", $fieldName, true, ''); |
||||
450 | |||||
451 | return $t . $pc->getPhpCodeStripTags("{$lpFieldName}['{$rpFieldName}']", $getVar, false, $t); |
||||
452 | } |
||||
453 | |||||
454 | /** |
||||
455 | * @public function getXcGetVarSelectUser |
||||
456 | * @param $lpFieldName |
||||
457 | * @param $rpFieldName |
||||
458 | * @param $tableName |
||||
459 | * @param $fieldName |
||||
460 | * @param string $t |
||||
461 | * @return string |
||||
462 | */ |
||||
463 | public function getXcGetVarSelectUser($lpFieldName, $rpFieldName, $tableName, $fieldName, $t = '') |
||||
464 | { |
||||
465 | return "{$t}\${$lpFieldName}['{$rpFieldName}'] = \XoopsUser::getUnameFromId(\${$tableName}All[\$i]->getVar('{$fieldName}'), 's');\n"; |
||||
466 | } |
||||
467 | |||||
468 | /** |
||||
469 | * @public function getXcGetVarTextDateSelect |
||||
470 | * @param $lpFieldName |
||||
471 | * @param $rpFieldName |
||||
472 | * @param $tableName |
||||
473 | * @param $fieldName |
||||
474 | * @param string $t |
||||
475 | * @return string |
||||
476 | */ |
||||
477 | public function getXcGetVarTextDateSelect($lpFieldName, $rpFieldName, $tableName, $fieldName, $t = '') |
||||
478 | { |
||||
479 | return "{$t}\${$lpFieldName}['{$rpFieldName}'] = \\formatTimestamp(\${$tableName}All[\$i]->getVar('{$fieldName}'), 's');\n"; |
||||
480 | } |
||||
481 | |||||
482 | /** |
||||
483 | * @public function getXcUserHeader |
||||
484 | * @param $moduleDirname |
||||
485 | * @param $tableName |
||||
486 | * @param string $t |
||||
487 | * @return string |
||||
488 | */ |
||||
489 | public function getXcXoopsOptionTemplateMain($moduleDirname, $tableName, $t = '') |
||||
490 | { |
||||
491 | return "{$t}\$GLOBALS['xoopsOption']['template_main'] = '{$moduleDirname}_{$tableName}.tpl';\n"; |
||||
492 | } |
||||
493 | |||||
494 | /** |
||||
495 | * @public function getXcUserHeader |
||||
496 | * @param $moduleDirname |
||||
497 | * @param $tableName |
||||
498 | * @return string |
||||
499 | */ |
||||
500 | public function getXcUserHeader($moduleDirname, $tableName) |
||||
501 | { |
||||
502 | $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); |
||||
503 | $ret = $pc->getPhpCodeIncludeDir('__DIR__', 'header'); |
||||
504 | $ret .= $this->getXcXoopsOptionTemplateMain($moduleDirname, $tableName); |
||||
505 | $ret .= $pc->getPhpCodeIncludeDir('\XOOPS_ROOT_PATH', 'header', true); |
||||
506 | |||||
507 | return $ret; |
||||
508 | } |
||||
509 | |||||
510 | /** |
||||
511 | * @public function getXcPermissionsHeader |
||||
512 | * @param null |
||||
513 | * @return string |
||||
514 | */ |
||||
515 | public function getXcPermissionsHeader() |
||||
516 | { |
||||
517 | $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); |
||||
518 | $ret = $pc->getPhpCodeCommentLine('Permission'); |
||||
519 | $ret .= $pc->getPhpCodeIncludeDir('\XOOPS_ROOT_PATH', 'class/xoopsform/grouppermform', true); |
||||
520 | $ret .= $this->getXcXoopsHandler('groupperm'); |
||||
521 | $groups = $this->getXcEqualsOperator('$groups', '$xoopsUser->getGroups()'); |
||||
522 | $elseGroups = $this->getXcEqualsOperator('$groups', '\XOOPS_GROUP_ANONYMOUS'); |
||||
523 | $ret .= $pc->getPhpCodeConditions('\is_object($xoopsUser)', '', $type = '', $groups, $elseGroups); |
||||
524 | |||||
525 | return $ret; |
||||
526 | } |
||||
527 | |||||
528 | /** |
||||
529 | * @public function getXcGetFieldId |
||||
530 | * |
||||
531 | * @param $fields |
||||
532 | * |
||||
533 | * @return string |
||||
534 | */ |
||||
535 | public function getXcGetFieldId($fields) |
||||
536 | { |
||||
537 | $fieldId = 'id'; |
||||
538 | foreach (\array_keys($fields) as $f) { |
||||
539 | $fieldName = $fields[$f]->getVar('field_name'); |
||||
540 | if (0 == $f) { |
||||
541 | $fieldId = $fieldName; |
||||
542 | } |
||||
543 | } |
||||
544 | |||||
545 | return $fieldId; |
||||
546 | } |
||||
547 | |||||
548 | /** |
||||
549 | * @public function getXcGetFieldName |
||||
550 | * |
||||
551 | * @param $fields |
||||
552 | * |
||||
553 | * @return string |
||||
554 | */ |
||||
555 | public function getXcGetFieldName($fields) |
||||
556 | { |
||||
557 | $fieldName = ''; |
||||
558 | foreach (\array_keys($fields) as $f) { |
||||
559 | $fieldName = $fields[$f]->getVar('field_name'); |
||||
560 | } |
||||
561 | |||||
562 | return $fieldName; |
||||
563 | } |
||||
564 | |||||
565 | /** |
||||
566 | * @public function getXcGetFieldParentId |
||||
567 | * |
||||
568 | * @param $fields |
||||
569 | * |
||||
570 | * @return string |
||||
571 | */ |
||||
572 | public function getXcGetFieldParentId($fields) |
||||
573 | { |
||||
574 | $fieldPid = 'pid'; |
||||
575 | foreach (\array_keys($fields) as $f) { |
||||
576 | $fieldName = $fields[$f]->getVar('field_name'); |
||||
577 | if (1 == $fields[$f]->getVar('field_parent')) { |
||||
578 | $fieldPid = $fieldName; |
||||
579 | } |
||||
580 | } |
||||
581 | |||||
582 | return $fieldPid; |
||||
583 | } |
||||
584 | |||||
585 | /** |
||||
586 | * @public function getXcUserSaveElements |
||||
587 | * |
||||
588 | * @param $moduleDirname |
||||
589 | * @param $tableName |
||||
590 | * @param $tableSoleName |
||||
591 | * @param $fields |
||||
592 | * @return string |
||||
593 | */ |
||||
594 | public function getXcUserSaveElements($moduleDirname, $tableName, $tableSoleName, $fields) |
||||
595 | { |
||||
596 | $axc = Modulebuilder\Files\Admin\AdminXoopsCode::getInstance(); |
||||
597 | $ret = ''; |
||||
598 | $fieldMain = ''; |
||||
599 | $countUploader = 0; |
||||
600 | foreach (\array_keys($fields) as $f) { |
||||
601 | $fieldName = $fields[$f]->getVar('field_name'); |
||||
602 | $fieldElement = $fields[$f]->getVar('field_element'); |
||||
603 | if (1 == $fields[$f]->getVar('field_main')) { |
||||
604 | $fieldMain = $fieldName; |
||||
605 | } |
||||
606 | if ((5 == $fieldElement) || (6 == $fieldElement)) { |
||||
607 | $ret .= $this->getXcSetVarCheckBoxOrRadioYN($tableName, $fieldName); |
||||
608 | } elseif (13 == $fieldElement) { |
||||
609 | $ret .= $axc->getAxcSetVarUploadImage($moduleDirname, $tableName, $fieldName, $fieldMain, '', $countUploader); |
||||
610 | $countUploader++; |
||||
611 | } elseif (14 == $fieldElement) { |
||||
612 | $ret .= $axc->getAxcSetVarUploadFile($moduleDirname, $tableName, $fieldName, '', '', $countUploader); |
||||
0 ignored issues
–
show
'' of type string is incompatible with the type boolean expected by parameter $formatUrl of XoopsModules\Modulebuild...etAxcSetVarUploadFile() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
613 | $countUploader++; |
||||
614 | } elseif (15 == $fieldElement) { |
||||
615 | $ret .= $this->getXcSetVarTextDateSelect($tableName, $tableSoleName, $fieldName); |
||||
616 | } else { |
||||
617 | $ret .= $this->getXcSetVarObj($tableName, $fieldName, "\$_POST['{$fieldName}']"); |
||||
618 | } |
||||
619 | } |
||||
620 | |||||
621 | return $ret; |
||||
622 | } |
||||
623 | |||||
624 | /** |
||||
625 | * @public function getXcXoopsRequest |
||||
626 | * @param string $left |
||||
627 | * @param string $var1 |
||||
628 | * @param string $var2 |
||||
629 | * @param string $type |
||||
630 | * @param bool $method |
||||
631 | * @param string $t |
||||
632 | * @return string |
||||
633 | */ |
||||
634 | public function getXcXoopsRequest($left = '', $var1 = '', $var2 = '', $type = 'String', $method = false, $t = '') |
||||
635 | { |
||||
636 | $ret = ''; |
||||
637 | $intVars = ('' != $var2) ? "'{$var1}', {$var2}" : "'{$var1}'"; |
||||
638 | if ('String' === $type) { |
||||
639 | $ret .= "{$t}\${$left} = Request::getString('{$var1}', '{$var2}');\n"; |
||||
640 | } elseif ('Int' === $type) { |
||||
641 | $ret .= "{$t}\${$left} = Request::getInt({$intVars});\n"; |
||||
642 | } elseif ('Int' === $type && false !== $method) { |
||||
643 | $ret .= "{$t}\${$left} = Request::getInt({$intVars}, '{$method}');\n"; |
||||
644 | } else { |
||||
645 | $ret .= "{$t}\${$left} = Request::get{$type}('{$var1}', '{$var2}');\n"; |
||||
646 | } |
||||
647 | |||||
648 | return $ret; |
||||
649 | } |
||||
650 | |||||
651 | /** |
||||
652 | * @public function getXcAddRight |
||||
653 | * |
||||
654 | * @param $anchor |
||||
655 | * @param string $permString |
||||
656 | * @param string $var |
||||
657 | * @param string $groups |
||||
658 | * @param string $mid |
||||
659 | * @param bool $isParam |
||||
660 | * |
||||
661 | * @param string $t |
||||
662 | * @return string |
||||
663 | */ |
||||
664 | public function getXcAddRight($anchor, $permString = '', $var = '', $groups = '', $mid = '', $isParam = false, $t = '') |
||||
665 | { |
||||
666 | if (!$isParam) { |
||||
667 | $ret = "{$t}\${$anchor}->addRight('{$permString}', {$var}, {$groups}, {$mid});\n"; |
||||
668 | } else { |
||||
669 | $ret = "\${$anchor}->addRight('{$permString}', {$var}, {$groups}, {$mid})"; |
||||
670 | } |
||||
671 | |||||
672 | return $ret; |
||||
673 | } |
||||
674 | |||||
675 | /** |
||||
676 | * @public function getXcCheckRight |
||||
677 | * |
||||
678 | * @param $anchor |
||||
679 | * @param string $permString |
||||
680 | * @param string $var |
||||
681 | * @param string $groups |
||||
682 | * @param string $mid |
||||
683 | * @param bool $isParam |
||||
684 | * |
||||
685 | * @param string $t |
||||
686 | * @return string |
||||
687 | */ |
||||
688 | public function getXcCheckRight($anchor, $permString = '', $var = '', $groups = '', $mid = '', $isParam = false, $t = '') |
||||
689 | { |
||||
690 | if (!$isParam) { |
||||
691 | $ret = "{$t}{$anchor}->checkRight('{$permString}', {$var}, {$groups}, {$mid});\n"; |
||||
692 | } else { |
||||
693 | $ret = "{$anchor}->checkRight('{$permString}', {$var}, {$groups}, {$mid})"; |
||||
694 | } |
||||
695 | |||||
696 | return $ret; |
||||
697 | } |
||||
698 | |||||
699 | /** |
||||
700 | * @public function getXcAddRight |
||||
701 | * |
||||
702 | * @param $anchor |
||||
703 | * @param string $permString |
||||
704 | * @param string $mid |
||||
705 | * @param string $var |
||||
706 | * @param bool $isParam |
||||
707 | * |
||||
708 | * @param string $t |
||||
709 | * @return string |
||||
710 | */ |
||||
711 | public function getXcDeleteRight($anchor, $permString = '', $mid = '', $var = '', $isParam = false, $t = '') |
||||
712 | { |
||||
713 | if (!$isParam) { |
||||
714 | $ret = "{$t}\${$anchor}->deleteByModule({$mid}, '{$permString}', {$var});\n"; |
||||
715 | } else { |
||||
716 | $ret = "\${$anchor}->deleteByModule({$mid}, '{$permString}', {$var})"; |
||||
717 | } |
||||
718 | return $ret; |
||||
719 | } |
||||
720 | |||||
721 | /** |
||||
722 | * @public function getXcHandlerLine |
||||
723 | * @param $tableName |
||||
724 | * @param string $t |
||||
725 | * @return string |
||||
726 | */ |
||||
727 | public function getXcHandlerLine($tableName, $t = '') |
||||
728 | { |
||||
729 | $ucfTableName = \ucfirst($tableName); |
||||
730 | return "{$t}\${$tableName}Handler = \$helper->getHandler('{$ucfTableName}');\n"; |
||||
731 | } |
||||
732 | |||||
733 | /** |
||||
734 | * @public function getXcHandlerCreateObj |
||||
735 | * |
||||
736 | * @param $tableName |
||||
737 | * |
||||
738 | * @param string $t |
||||
739 | * @return string |
||||
740 | */ |
||||
741 | public function getXcHandlerCreateObj($tableName, $t = '') |
||||
742 | { |
||||
743 | return "{$t}\${$tableName}Obj = \${$tableName}Handler->create();\n"; |
||||
744 | } |
||||
745 | |||||
746 | /** |
||||
747 | * @public function getXcHandlerGetObj |
||||
748 | * |
||||
749 | * @param $tableName |
||||
750 | * @param $ccFieldId |
||||
751 | * @param string $t |
||||
752 | * @return string |
||||
753 | */ |
||||
754 | public function getXcHandlerGetObj($tableName, $ccFieldId, $t = '') |
||||
755 | { |
||||
756 | return "{$t}\${$tableName}Obj = \${$tableName}Handler->get(\${$ccFieldId});\n"; |
||||
757 | } |
||||
758 | |||||
759 | /** |
||||
760 | * @public function getXcHandlerCountObj |
||||
761 | * |
||||
762 | * @param $tableName |
||||
763 | * |
||||
764 | * @param string $t |
||||
765 | * @return string |
||||
766 | */ |
||||
767 | public function getXcHandlerCountObj($tableName, $t = '') |
||||
768 | { |
||||
769 | $ucfTableName = \ucfirst($tableName); |
||||
770 | $ret = "{$t}\${$tableName}Count = \${$tableName}Handler->getCount{$ucfTableName}();\n"; |
||||
771 | |||||
772 | return $ret; |
||||
773 | } |
||||
774 | |||||
775 | /** |
||||
776 | * @public function getXcClearCount |
||||
777 | * @param $left |
||||
778 | * @param $anchor |
||||
779 | * @param $params |
||||
780 | * @param $t |
||||
781 | * |
||||
782 | * @return string |
||||
783 | */ |
||||
784 | public function getXcHandlerCountClear($left, $anchor = '', $params = '', $t = '') |
||||
785 | { |
||||
786 | $ret = "{$t}\${$left} = \${$anchor}Handler->getCount({$params});\n"; |
||||
787 | |||||
788 | return $ret; |
||||
789 | } |
||||
790 | |||||
791 | /** |
||||
792 | * @public function getXcHandlerAllObj |
||||
793 | * |
||||
794 | * @param $tableName |
||||
795 | * @param string $fieldMain |
||||
796 | * @param string $start |
||||
797 | * @param string $limit |
||||
798 | * |
||||
799 | * @param string $t |
||||
800 | * @return string |
||||
801 | */ |
||||
802 | public function getXcHandlerAllObj($tableName, $fieldMain = '', $start = '0', $limit = '0', $t = '') |
||||
803 | { |
||||
804 | $ucfTableName = \ucfirst($tableName); |
||||
805 | $startLimit = ('0' != $limit) ? "{$start}, {$limit}" : '0'; |
||||
806 | $params = ('' != $fieldMain) ? "{$startLimit}, '{$fieldMain}'" : $startLimit; |
||||
807 | $ret = "{$t}\${$tableName}All = \${$tableName}Handler->getAll{$ucfTableName}({$params});\n"; |
||||
808 | |||||
809 | return $ret; |
||||
810 | } |
||||
811 | |||||
812 | /** |
||||
813 | * @public function getXcHandlerAllClear |
||||
814 | * @param $left |
||||
815 | * @param string $anchor |
||||
816 | * @param string $params |
||||
817 | * @param string $t |
||||
818 | * @return string |
||||
819 | */ |
||||
820 | public function getXcHandlerAllClear($left, $anchor = '', $params = '', $t = '') |
||||
821 | { |
||||
822 | $ret = "{$t}\${$left} = \${$anchor}Handler->getAll({$params});\n"; |
||||
823 | |||||
824 | return $ret; |
||||
825 | } |
||||
826 | |||||
827 | /** |
||||
828 | * @public function getXcHandlerGet |
||||
829 | * |
||||
830 | * @param $left |
||||
831 | * @param $var |
||||
832 | * @param string $obj |
||||
833 | * @param string $handler |
||||
834 | * @param bool $isParam |
||||
835 | * |
||||
836 | * @param string $t |
||||
837 | * @return string |
||||
838 | */ |
||||
839 | public function getXcHandlerGet($left, $var, $obj = '', $handler = 'Handler', $isParam = false, $t = '') |
||||
840 | { |
||||
841 | if ($isParam) { |
||||
842 | $ret = "\${$left}{$handler}->get(\${$var})"; |
||||
843 | } else { |
||||
844 | $ret = "{$t}\${$left}{$obj} = \${$handler}->get(\${$var});\n"; |
||||
845 | } |
||||
846 | |||||
847 | return $ret; |
||||
848 | } |
||||
849 | |||||
850 | /** |
||||
851 | * @public function getXcHandler |
||||
852 | * |
||||
853 | * @param $left |
||||
854 | * @param $var |
||||
855 | * @param $obj |
||||
856 | * @param $handler |
||||
857 | * |
||||
858 | * @return string |
||||
859 | */ |
||||
860 | public function getXcHandlerInsert($left, $var, $obj = '', $handler = 'Handler') |
||||
861 | { |
||||
862 | return "\${$left}{$handler}->insert(\${$var}{$obj})"; |
||||
863 | } |
||||
864 | |||||
865 | /** |
||||
866 | * @public function getXcHandlerDelete |
||||
867 | * |
||||
868 | * @param $left |
||||
869 | * @param $var |
||||
870 | * @param string $obj |
||||
871 | * @param string $handler |
||||
872 | * @return string |
||||
873 | */ |
||||
874 | public function getXcHandlerDelete($left, $var, $obj = '', $handler = 'Handler') |
||||
875 | { |
||||
876 | return "\${$left}{$handler}->delete(\${$var}{$obj})"; |
||||
877 | } |
||||
878 | |||||
879 | /** |
||||
880 | * @public function getXcGetValues |
||||
881 | * |
||||
882 | * @param $tableName |
||||
883 | * @param $tableSoleName |
||||
884 | * |
||||
885 | * @param string $index |
||||
886 | * @param bool $noArray |
||||
887 | * @param string $t |
||||
888 | * @param string $obj |
||||
889 | * @return string |
||||
890 | */ |
||||
891 | public function getXcGetValues($tableName, $tableSoleName, $index = 'i', $noArray = false, $t = '', $obj = '') |
||||
892 | { |
||||
893 | $index = '' !== $index ? $index : 'i'; |
||||
894 | $ucfTableName = \ucfirst($tableName); |
||||
895 | if (!$noArray) { |
||||
896 | $ret = "{$t}\${$tableSoleName} = \${$tableName}All[\${$index}]->getValues{$ucfTableName}();\n"; |
||||
897 | } else { |
||||
898 | $ret = "{$t}\${$tableSoleName} = \${$tableName}{$obj}->getValues{$ucfTableName}();\n"; |
||||
899 | } |
||||
900 | |||||
901 | return $ret; |
||||
902 | } |
||||
903 | |||||
904 | /** |
||||
905 | * @public function getXcSetVarsObjects |
||||
906 | * |
||||
907 | * @param $moduleDirname |
||||
908 | * @param $tableName |
||||
909 | * @param $tableSoleName |
||||
910 | * @param $fields |
||||
911 | * @return string |
||||
912 | */ |
||||
913 | public function getXcSetVarsObjects($moduleDirname, $tableName, $tableSoleName, $fields) |
||||
914 | { |
||||
915 | $axc = Modulebuilder\Files\Admin\AdminXoopsCode::getInstance(); |
||||
916 | $ret = ''; |
||||
917 | $fieldMain = ''; |
||||
918 | $countUploader = 0; |
||||
919 | foreach (\array_keys($fields) as $f) { |
||||
920 | $fieldName = $fields[$f]->getVar('field_name'); |
||||
921 | $fieldElement = $fields[$f]->getVar('field_element'); |
||||
922 | if (1 == $fields[$f]->getVar('field_main')) { |
||||
923 | $fieldMain = $fieldName; |
||||
924 | } |
||||
925 | if ($f > 0) { // If we want to hide field id |
||||
926 | switch ($fieldElement) { |
||||
927 | case 5: |
||||
928 | case 6: |
||||
929 | $ret .= $this->getXcSetVarCheckBoxOrRadioYN($tableName, $fieldName); |
||||
930 | break; |
||||
931 | case 11: |
||||
932 | $ret .= $axc->getAxcSetVarImageList($tableName, $fieldName, '', $countUploader); |
||||
933 | $countUploader++; |
||||
934 | break; |
||||
935 | case 12: |
||||
936 | $ret .= $axc->getAxcSetVarUploadFile($moduleDirname, $tableName, $fieldName, true, $countUploader, $fieldMain); |
||||
937 | $countUploader++; |
||||
938 | break; |
||||
939 | case 13: |
||||
940 | $ret .= $axc->getAxcSetVarUploadImage($moduleDirname, $tableName, $fieldName, $fieldMain, '', $countUploader); |
||||
941 | $countUploader++; |
||||
942 | break; |
||||
943 | case 14: |
||||
944 | $ret .= $axc->getAxcSetVarUploadFile($moduleDirname, $tableName, $fieldName, false, $countUploader, $fieldMain); |
||||
945 | $countUploader++; |
||||
946 | break; |
||||
947 | case 15: |
||||
948 | $ret .= $this->getXcSetVarTextDateSelect($tableName, $tableSoleName, $fieldName); |
||||
949 | break; |
||||
950 | default: |
||||
951 | $ret .= $this->getXcSetVarObj($tableName, $fieldName, "\$_POST['{$fieldName}']"); |
||||
952 | break; |
||||
953 | } |
||||
954 | } |
||||
955 | } |
||||
956 | |||||
957 | return $ret; |
||||
958 | } |
||||
959 | |||||
960 | /** |
||||
961 | * @public function getXcSecurity |
||||
962 | * |
||||
963 | * @param $tableName |
||||
964 | * |
||||
965 | * @param string $t |
||||
966 | * @return string |
||||
967 | */ |
||||
968 | public function getXcSecurity($tableName, $t = '') |
||||
969 | { |
||||
970 | $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); |
||||
971 | $securityError = $this->getXcXoopsSecurityErrors(); |
||||
972 | $implode = $pc->getPhpCodeImplode(',', $securityError); |
||||
973 | $content = "{$t}\t" . $this->getXcRedirectHeader($tableName, '', 3, $implode, false, $t); |
||||
974 | $securityCheck = $this->getXcXoopsSecurityCheck(); |
||||
975 | |||||
976 | return $pc->getPhpCodeConditions('!' . $securityCheck, '', '', $content, $t); |
||||
977 | } |
||||
978 | |||||
979 | /** |
||||
980 | * @public function getXcInsertData |
||||
981 | * @param $tableName |
||||
982 | * @param $language |
||||
983 | * @param string $t |
||||
984 | * @return string |
||||
985 | */ |
||||
986 | public function getXcInsertData($tableName, $language, $t = '') |
||||
987 | { |
||||
988 | $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); |
||||
989 | $content = "{$t}\t" . $this->getXcRedirectHeader($tableName, '?op=list', 2, "{$language}FORM_OK"); |
||||
990 | $handlerInsert = $this->getXcHandlerInsert($tableName, $tableName, 'Obj'); |
||||
991 | |||||
992 | return $pc->getPhpCodeConditions($handlerInsert, '', '', $content, $t); |
||||
993 | } |
||||
994 | |||||
995 | /** |
||||
996 | * @public function getXcRedirectHeader |
||||
997 | * @param $directory |
||||
998 | * @param $options |
||||
999 | * @param $numb |
||||
1000 | * @param $var |
||||
1001 | * @param bool $isString |
||||
1002 | * @param string $t |
||||
1003 | * @return string |
||||
1004 | */ |
||||
1005 | public function getXcRedirectHeader($directory, $options, $numb, $var, $isString = true, $t = '') |
||||
1006 | { |
||||
1007 | if (!$isString) { |
||||
1008 | $ret = "{$t}\\redirect_header({$directory}, {$numb}, {$var});\n"; |
||||
1009 | } else { |
||||
1010 | $ret = "{$t}\\redirect_header('{$directory}.php{$options}', {$numb}, {$var});\n"; |
||||
1011 | } |
||||
1012 | |||||
1013 | return $ret; |
||||
1014 | } |
||||
1015 | |||||
1016 | /** |
||||
1017 | * @public function getXcXoopsConfirm |
||||
1018 | * @param $tableName |
||||
1019 | * @param $language |
||||
1020 | * @param $fieldId |
||||
1021 | * @param $fieldMain |
||||
1022 | * @param string $options |
||||
1023 | * |
||||
1024 | * @param string $t |
||||
1025 | * @return string |
||||
1026 | */ |
||||
1027 | public function getXcXoopsConfirm($tableName, $language, $fieldId, $fieldMain, $options = 'delete', $t = '') |
||||
1028 | { |
||||
1029 | $stuOptions = \mb_strtoupper($options); |
||||
1030 | $ccFieldId = Modulebuilder\Files\CreateFile::getInstance()->getCamelCase($fieldId, false, true); |
||||
1031 | $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); |
||||
1032 | $xc = Modulebuilder\Files\CreateXoopsCode::getInstance(); |
||||
1033 | |||||
1034 | $array = "['ok' => 1, '{$fieldId}' => \${$ccFieldId}, 'start' => \$start, 'limit' => \$limit, 'op' => '{$options}']"; |
||||
1035 | $server = $pc->getPhpCodeGlobalsVariables('REQUEST_URI', 'SERVER'); |
||||
1036 | $getVar = $this->getXcGetVar('', $tableName . 'Obj', $fieldMain, true, ''); |
||||
1037 | $sprintf = $pc->getPhpCodeSprintf($language . 'FORM_SURE_' . $stuOptions, $getVar); |
||||
1038 | $confirm = 'new Common\XoopsConfirm(' . "\n"; |
||||
1039 | $confirm .= $t . "\t" . $array . ",\n"; |
||||
1040 | $confirm .= $t . "\t" . $server . ",\n"; |
||||
1041 | $confirm .= $t . "\t" . $sprintf . ')'; |
||||
1042 | $ret = $xc->getXcEqualsOperator('$xoopsconfirm', $confirm, '', $t); |
||||
1043 | $ret .= $xc->getXcEqualsOperator('$form', '$xoopsconfirm->getFormXoopsConfirm()', '', $t); |
||||
1044 | $ret .= $xc->getXcXoopsTplAssign('form', '$form->render()', true, $t); |
||||
1045 | return $ret; |
||||
1046 | } |
||||
1047 | |||||
1048 | /** |
||||
1049 | * @public function getXcHtmlErrors |
||||
1050 | * |
||||
1051 | * @param $tableName |
||||
1052 | * @param bool $isParam |
||||
1053 | * @param string $obj |
||||
1054 | * |
||||
1055 | * @param string $t |
||||
1056 | * @return string |
||||
1057 | */ |
||||
1058 | public function getXcHtmlErrors($tableName, $isParam = false, $obj = 'Obj', $t = '') |
||||
1059 | { |
||||
1060 | if ($isParam) { |
||||
1061 | $ret = "\${$tableName}{$obj}->getHtmlErrors()"; |
||||
1062 | } else { |
||||
1063 | $ret = "{$t}\${$tableName}{$obj} = \${$tableName}->getHtmlErrors();"; |
||||
1064 | } |
||||
1065 | |||||
1066 | return $ret; |
||||
1067 | } |
||||
1068 | |||||
1069 | /** |
||||
1070 | * @public function getXcGetForm |
||||
1071 | * |
||||
1072 | * @param $left |
||||
1073 | * @param $tableName |
||||
1074 | * @param string $obj |
||||
1075 | * |
||||
1076 | * @param string $t |
||||
1077 | * @return string |
||||
1078 | */ |
||||
1079 | public function getXcGetForm($left, $tableName, $obj = '', $t = '') |
||||
1080 | { |
||||
1081 | $ucfTableName = \ucfirst($tableName); |
||||
1082 | |||||
1083 | return "{$t}\${$left} = \${$tableName}{$obj}->getForm{$ucfTableName}();\n"; |
||||
1084 | } |
||||
1085 | |||||
1086 | /** |
||||
1087 | * @public function getTopicGetVar |
||||
1088 | * @param $lpFieldName |
||||
1089 | * @param $rpFieldName |
||||
1090 | * @param $tableName |
||||
1091 | * @param $tableNameTopic |
||||
1092 | * @param $fieldNameParent |
||||
1093 | * @param $fieldNameTopic |
||||
1094 | * @param string $t |
||||
1095 | * @return string |
||||
1096 | */ |
||||
1097 | public function getTopicGetVar($lpFieldName, $rpFieldName, $tableName, $tableNameTopic, $fieldNameParent, $fieldNameTopic, $t = '') |
||||
1098 | { |
||||
1099 | $ret = Modulebuilder\Files\CreatePhpCode::getInstance()->getPhpCodeCommentLine('Get Var', $fieldNameParent, $t); |
||||
1100 | $paramGet = $this->getXcGetVar('', "\${$tableName}All[\$i]", $fieldNameParent, true, ''); |
||||
1101 | $ret .= $this->getXcHandlerGet($rpFieldName, $paramGet, '', $tableNameTopic . 'Handler', false, $t); |
||||
1102 | $ret .= $this->getXcGetVar("\${$lpFieldName}['{$rpFieldName}']", "\${$rpFieldName}", $fieldNameTopic, false, $t); |
||||
1103 | |||||
1104 | return $ret; |
||||
1105 | } |
||||
1106 | |||||
1107 | /** |
||||
1108 | * @public function getUploadImageGetVar |
||||
1109 | * @param $lpFieldName |
||||
1110 | * @param $rpFieldName |
||||
1111 | * @param $tableName |
||||
1112 | * @param $fieldName |
||||
1113 | * @param string $t |
||||
1114 | * @return string |
||||
1115 | */ |
||||
1116 | /* |
||||
1117 | public function getUploadImageGetVar($lpFieldName, $rpFieldName, $tableName, $fieldName, $t = '') |
||||
1118 | { |
||||
1119 | $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); |
||||
1120 | $ret = $pc->getPhpCodeCommentLine('Get Var', $fieldName, $t); |
||||
1121 | $ret .= $this->getXcGetVar($fieldName, "\${$tableName}All[\$i]", $fieldName, false, ''); |
||||
1122 | $ret .= $pc->getPhpCodeTernaryOperator('uploadImage', "\${$fieldName}", "\${$fieldName}", "'blank.gif'", $t); |
||||
1123 | $ret .= $this->getXcEqualsOperator("${$lpFieldName}['{$rpFieldName}']", '$uploadImage', null, $t); |
||||
1124 | |||||
1125 | return $ret; |
||||
1126 | } |
||||
1127 | */ |
||||
1128 | |||||
1129 | /** |
||||
1130 | * @public function getXcSaveFieldId |
||||
1131 | * |
||||
1132 | * @param $fields |
||||
1133 | * |
||||
1134 | * @return string |
||||
1135 | */ |
||||
1136 | public function getXcSaveFieldId($fields) |
||||
1137 | { |
||||
1138 | $fieldId = ''; |
||||
1139 | foreach (\array_keys($fields) as $f) { |
||||
1140 | if (0 == $f) { |
||||
1141 | $fieldId = $fields[$f]->getVar('field_name'); |
||||
1142 | } |
||||
1143 | } |
||||
1144 | |||||
1145 | return $fieldId; |
||||
1146 | } |
||||
1147 | |||||
1148 | /** |
||||
1149 | * @public function getXcSaveFieldMain |
||||
1150 | * |
||||
1151 | * @param $fields |
||||
1152 | * |
||||
1153 | * @return string |
||||
1154 | */ |
||||
1155 | public function getXcSaveFieldMain($fields) |
||||
1156 | { |
||||
1157 | $fieldMain = ''; |
||||
1158 | foreach (\array_keys($fields) as $f) { |
||||
1159 | if (1 == $fields[$f]->getVar('field_main')) { |
||||
1160 | $fieldMain = $fields[$f]->getVar('field_name'); |
||||
1161 | } |
||||
1162 | } |
||||
1163 | |||||
1164 | return $fieldMain; |
||||
1165 | } |
||||
1166 | |||||
1167 | /** |
||||
1168 | * @public function getXcSaveElements |
||||
1169 | * |
||||
1170 | * @param $moduleDirname |
||||
1171 | * @param $tableName |
||||
1172 | * @param $tableSoleName |
||||
1173 | * @param $fields |
||||
1174 | * |
||||
1175 | * @param string $t |
||||
1176 | * @return string |
||||
1177 | */ |
||||
1178 | public function getXcSaveElements($moduleDirname, $tableName, $tableSoleName, $fields, $t = '') |
||||
1179 | { |
||||
1180 | $axc = Modulebuilder\Files\Admin\AdminXoopsCode::getInstance(); |
||||
1181 | $xc = Modulebuilder\Files\CreateXoopsCode::getInstance(); |
||||
1182 | $ret = ''; |
||||
1183 | $fieldMain = ''; |
||||
1184 | $countUploader = 0; |
||||
1185 | $fieldLines = ''; |
||||
1186 | foreach (\array_keys($fields) as $f) { |
||||
1187 | |||||
1188 | $fieldName = $fields[$f]->getVar('field_name'); |
||||
1189 | $fieldType = $fields[$f]->getVar('field_type'); |
||||
1190 | $fieldElement = $fields[$f]->getVar('field_element'); |
||||
1191 | if (1 == $fields[$f]->getVar('field_main')) { |
||||
1192 | $fieldMain = $fieldName; |
||||
1193 | } |
||||
1194 | if ($f > 0) { // If we want to hide field id |
||||
1195 | switch ($fieldElement) { |
||||
1196 | case 5: |
||||
1197 | case 6: |
||||
1198 | $fieldLines .= $this->getXcSetVarCheckBoxOrRadioYN($tableName, $fieldName, $t); |
||||
1199 | break; |
||||
1200 | case 10: |
||||
1201 | $fieldLines .= $axc->getAxcSetVarImageList($tableName, $fieldName, $t, $countUploader); |
||||
1202 | $countUploader++; |
||||
1203 | break; |
||||
1204 | case 11: |
||||
1205 | $fieldLines .= $axc->getAxcSetVarUploadFile($moduleDirname, $tableName, $fieldName, false, $t, $countUploader, $fieldMain); |
||||
1206 | $countUploader++; |
||||
1207 | break; |
||||
1208 | case 12: |
||||
1209 | $fieldLines .= $axc->getAxcSetVarUploadFile($moduleDirname, $tableName, $fieldName, true, $t, $countUploader, $fieldMain); |
||||
1210 | $countUploader++; |
||||
1211 | break; |
||||
1212 | case 13: |
||||
1213 | $fieldLines .= $axc->getAxcSetVarUploadImage($moduleDirname, $tableName, $fieldName, $fieldMain, $t, $countUploader); |
||||
1214 | $countUploader++; |
||||
1215 | break; |
||||
1216 | case 14: |
||||
1217 | $fieldLines .= $axc->getAxcSetVarUploadFile($moduleDirname, $tableName, $fieldName, false, $t, $countUploader, $fieldMain); |
||||
1218 | $countUploader++; |
||||
1219 | break; |
||||
1220 | case 15: |
||||
1221 | $fieldLines .= $this->getXcSetVarTextDateSelect($tableName, $tableSoleName, $fieldName, $t); |
||||
1222 | break; |
||||
1223 | case 17: |
||||
1224 | $fieldLines .= $axc->getAxcSetVarPassword($tableName, $fieldName, $t); |
||||
1225 | $countUploader++; |
||||
1226 | break; |
||||
1227 | case 21: |
||||
1228 | $fieldLines .= $this->getXcSetVarDateTime($tableName, $tableSoleName, $fieldName, $t); |
||||
1229 | break; |
||||
1230 | default: |
||||
1231 | $fieldLines .= $axc->getAxcSetVarMisc($tableName, $fieldName, $fieldType, $fieldElement, $t); |
||||
1232 | break; |
||||
1233 | } |
||||
1234 | } |
||||
1235 | } |
||||
1236 | if ($countUploader > 0) { |
||||
1237 | $ret .= $xc->getXcEqualsOperator('$uploaderErrors', "''", null, $t); |
||||
1238 | } |
||||
1239 | $ret .= $fieldLines; |
||||
1240 | |||||
1241 | return $ret; |
||||
1242 | } |
||||
1243 | |||||
1244 | /** |
||||
1245 | * @public function getXcPageNav |
||||
1246 | * @param $tableName |
||||
1247 | * |
||||
1248 | * @param string $t |
||||
1249 | * @param string $paramStart |
||||
1250 | * @param string $paramOp |
||||
1251 | * @return string |
||||
1252 | */ |
||||
1253 | public function getXcPageNav($tableName, $t = '', $paramStart = 'start', $paramOp = "'op=list&limit=' . \$limit") |
||||
1254 | { |
||||
1255 | $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); |
||||
1256 | $cxc = Modulebuilder\Files\Classes\ClassXoopsCode::getInstance(); |
||||
1257 | $ret = $pc->getPhpCodeCommentLine('Display Navigation', null, $t); |
||||
1258 | $condition = $pc->getPhpCodeIncludeDir('\XOOPS_ROOT_PATH', 'class/pagenav', true, false, 'require', $t . "\t"); |
||||
1259 | $condition .= $cxc->getClassXoopsPageNav('pagenav', $tableName . 'Count', 'limit', 'start', $paramStart, $paramOp, false, $t . "\t"); |
||||
1260 | $condition .= $this->getXcXoopsTplAssign('pagenav', '$pagenav->renderNav(4)', true, $t . "\t"); |
||||
1261 | $ret .= $pc->getPhpCodeConditions("\${$tableName}Count", ' > ', '$limit', $condition, false, $t); |
||||
1262 | |||||
1263 | return $ret; |
||||
1264 | } |
||||
1265 | |||||
1266 | /* @public function getXcGetGlobal |
||||
1267 | * @param $globals |
||||
1268 | * |
||||
1269 | * @param string $t |
||||
1270 | * @return string |
||||
1271 | */ |
||||
1272 | public function getXcGetGlobal($globals, $t = '') |
||||
1273 | { |
||||
1274 | $ret = $t . "global "; |
||||
1275 | $detail = ''; |
||||
1276 | foreach ($globals as $global) { |
||||
1277 | if ($detail !== '') { |
||||
1278 | $detail .= ', '; |
||||
1279 | } |
||||
1280 | $detail .= '$' . $global; |
||||
1281 | } |
||||
1282 | $ret .= $detail . ";\n"; |
||||
1283 | |||||
1284 | return $ret; |
||||
1285 | } |
||||
1286 | |||||
1287 | /** |
||||
1288 | * @public function getXcGetCriteriaCompo |
||||
1289 | * |
||||
1290 | * @param $var |
||||
1291 | * @param string $t |
||||
1292 | * |
||||
1293 | * @return string |
||||
1294 | */ |
||||
1295 | public function getXcCriteriaCompo($var, $t = '') |
||||
1296 | { |
||||
1297 | return "{$t}\${$var} = new \CriteriaCompo();\n"; |
||||
1298 | } |
||||
1299 | |||||
1300 | /** |
||||
1301 | * @public function getXcCriteria |
||||
1302 | * |
||||
1303 | * @param $var |
||||
1304 | * @param $param1 |
||||
1305 | * @param string $param2 |
||||
1306 | * @param string $param3 |
||||
1307 | * @param bool $isParam |
||||
1308 | * @param string $t |
||||
1309 | * |
||||
1310 | * @return string |
||||
1311 | */ |
||||
1312 | public function getXcCriteria($var, $param1, $param2 = '', $param3 = '', $isParam = false, $t = '') |
||||
1313 | { |
||||
1314 | $params = ('' != $param2) ? ', ' . $param2 : ''; |
||||
1315 | $params .= ('' != $param3) ? ', ' . $param3 : ''; |
||||
1316 | |||||
1317 | if (false === $isParam) { |
||||
1318 | $ret = "{$t}\${$var} = new \Criteria({$param1}{$params});\n"; |
||||
1319 | } else { |
||||
1320 | $ret = "new \Criteria({$param1}{$params})"; |
||||
1321 | } |
||||
1322 | |||||
1323 | return $ret; |
||||
1324 | } |
||||
1325 | |||||
1326 | /** |
||||
1327 | * @public function getXcCriteriaAdd |
||||
1328 | * |
||||
1329 | * @param $var |
||||
1330 | * @param $param |
||||
1331 | * @param string $t |
||||
1332 | * @param string $n |
||||
1333 | * @param string $condition |
||||
1334 | * @return string |
||||
1335 | */ |
||||
1336 | public function getXcCriteriaAdd($var, $param, $t = '', $n = "\n", $condition = '') |
||||
1337 | { |
||||
1338 | if ('' !== $condition) { |
||||
1339 | $condition = ", {$condition}"; |
||||
1340 | } |
||||
1341 | return "{$t}\${$var}->add({$param}{$condition});{$n}"; |
||||
1342 | } |
||||
1343 | |||||
1344 | /** |
||||
1345 | * @public function getXcCriteriaSetStart |
||||
1346 | * |
||||
1347 | * @param $var |
||||
1348 | * @param $start |
||||
1349 | * @param string $t |
||||
1350 | * |
||||
1351 | * @param string $n |
||||
1352 | * @return string |
||||
1353 | */ |
||||
1354 | public function getXcCriteriaSetStart($var, $start, $t = '', $n = "\n") |
||||
1355 | { |
||||
1356 | return "{$t}\${$var}->setStart({$start});{$n}"; |
||||
1357 | } |
||||
1358 | |||||
1359 | /** |
||||
1360 | * @public function getXcCriteriaSetLimit |
||||
1361 | * |
||||
1362 | * @param $var |
||||
1363 | * @param $limit |
||||
1364 | * @param string $t |
||||
1365 | * |
||||
1366 | * @param string $n |
||||
1367 | * @return string |
||||
1368 | */ |
||||
1369 | public function getXcCriteriaSetLimit($var, $limit, $t = '', $n = "\n") |
||||
1370 | { |
||||
1371 | return "{$t}\${$var}->setLimit({$limit});{$n}"; |
||||
1372 | } |
||||
1373 | |||||
1374 | /** |
||||
1375 | * @public function getXcCriteriaSetSort |
||||
1376 | * |
||||
1377 | * @param $var |
||||
1378 | * @param $sort |
||||
1379 | * @param string $t |
||||
1380 | * |
||||
1381 | * @param string $n |
||||
1382 | * @return string |
||||
1383 | */ |
||||
1384 | public function getXcCriteriaSetSort($var, $sort, $t = '', $n = "\n") |
||||
1385 | { |
||||
1386 | return "{$t}\${$var}->setSort({$sort});{$n}"; |
||||
1387 | } |
||||
1388 | |||||
1389 | /** |
||||
1390 | * @public function getXcCriteriaSetOrder |
||||
1391 | * |
||||
1392 | * @param $var |
||||
1393 | * @param $order |
||||
1394 | * @param string $t |
||||
1395 | * |
||||
1396 | * @param string $n |
||||
1397 | * @return string |
||||
1398 | */ |
||||
1399 | public function getXcCriteriaSetOrder($var, $order, $t = '', $n = "\n") |
||||
1400 | { |
||||
1401 | return "{$t}\${$var}->setOrder({$order});{$n}"; |
||||
1402 | } |
||||
1403 | |||||
1404 | /*************************************************************/ |
||||
1405 | /** Xoops form components */ |
||||
1406 | /*************************************************************/ |
||||
1407 | |||||
1408 | /** |
||||
1409 | * @public function getXcXoopsFormGroupPerm |
||||
1410 | * @param $varLeft |
||||
1411 | * @param $formTitle |
||||
1412 | * @param $moduleId |
||||
1413 | * @param $permName |
||||
1414 | * @param $permDesc |
||||
1415 | * @param $filename |
||||
1416 | * @param $t |
||||
1417 | * |
||||
1418 | * @return string |
||||
1419 | */ |
||||
1420 | public function getXcXoopsFormGroupPerm($varLeft = '', $formTitle = '', $moduleId = '', $permName = '', $permDesc = '', $filename = '', $t = '') |
||||
1421 | { |
||||
1422 | return "{$t}\${$varLeft} = new \XoopsGroupPermForm({$formTitle}, {$moduleId}, {$permName}, {$permDesc}, {$filename});\n"; |
||||
1423 | } |
||||
1424 | |||||
1425 | |||||
1426 | /** |
||||
1427 | * @public function getXoopsFormSelectExtraOptions |
||||
1428 | * @param string $varSelect |
||||
1429 | * @param string $caption |
||||
1430 | * @param string $var |
||||
1431 | * @param array $options |
||||
1432 | * @param bool $setExtra |
||||
1433 | * |
||||
1434 | * @param string $t |
||||
1435 | * @return string |
||||
1436 | */ |
||||
1437 | public function getXoopsFormSelectExtraOptions($varSelect = '', $caption = '', $var = '', $options = [], $setExtra = true, $t = '') |
||||
1438 | { |
||||
1439 | $ret = "{$t}\${$varSelect} = new \XoopsFormSelect({$caption}, '{$var}', \${$var});\n"; |
||||
1440 | if (false !== $setExtra) { |
||||
1441 | $ret .= "{$t}\${$varSelect}->setExtra('{$setExtra}');\n"; |
||||
1442 | } |
||||
1443 | foreach ($options as $key => $value) { |
||||
1444 | $ret .= "{$t}\${$varSelect}->addOption('{$key}', {$value});\n"; |
||||
1445 | } |
||||
1446 | |||||
1447 | return $ret; |
||||
1448 | } |
||||
1449 | |||||
1450 | |||||
1451 | /*************************************************************/ |
||||
1452 | /** special components */ |
||||
1453 | /*************************************************************/ |
||||
1454 | /** |
||||
1455 | * @public function getXcGetConstants |
||||
1456 | * @param null |
||||
1457 | * @return string |
||||
1458 | */ |
||||
1459 | public function getXcGetConstants($const) |
||||
1460 | { |
||||
1461 | $ret = "Constants::{$const}"; |
||||
1462 | return $ret; |
||||
1463 | } |
||||
1464 | |||||
1465 | /*************************************************************/ |
||||
1466 | /** other Xoops components */ |
||||
1467 | /*************************************************************/ |
||||
1468 | |||||
1469 | |||||
1470 | /** |
||||
1471 | * @public function getXcXoopsCPHeader |
||||
1472 | * @param null |
||||
1473 | * @return string |
||||
1474 | */ |
||||
1475 | public function getXcXoopsCPHeader() |
||||
1476 | { |
||||
1477 | return "xoops_cp_header();\n"; |
||||
1478 | } |
||||
1479 | |||||
1480 | /** |
||||
1481 | * @public function getXcXoopsCPFooter |
||||
1482 | * @param null |
||||
1483 | * @return string |
||||
1484 | */ |
||||
1485 | public function getXcXoopsCPFooter() |
||||
1486 | { |
||||
1487 | return "xoops_cp_footer();\n"; |
||||
1488 | } |
||||
1489 | |||||
1490 | /** |
||||
1491 | * @public function getXcXoopsLoad |
||||
1492 | * |
||||
1493 | * @param $var |
||||
1494 | * @param $t |
||||
1495 | * @return string |
||||
1496 | */ |
||||
1497 | public function getXcXoopsLoad($var = '', $t = '') |
||||
1498 | { |
||||
1499 | return "{$t}\xoops_load('{$var}');\n"; |
||||
1500 | } |
||||
1501 | |||||
1502 | /** |
||||
1503 | * @public function getXcXoopsLoadLanguage |
||||
1504 | * |
||||
1505 | * @param $lang |
||||
1506 | * @param $t |
||||
1507 | * @param $domain |
||||
1508 | * |
||||
1509 | * @return string |
||||
1510 | */ |
||||
1511 | public function getXcXoopsLoadLanguage($lang, $t = '', $domain = '') |
||||
1512 | { |
||||
1513 | if ('' === $domain) { |
||||
1514 | return "{$t}\xoops_loadLanguage('{$lang}');\n"; |
||||
1515 | } |
||||
1516 | |||||
1517 | return "{$t}\xoops_loadLanguage('{$lang}', '{$domain}');\n"; |
||||
1518 | } |
||||
1519 | |||||
1520 | /** |
||||
1521 | * @public function getXcXoopsCaptcha |
||||
1522 | * @param $t |
||||
1523 | * @return string |
||||
1524 | */ |
||||
1525 | public function getXcXoopsCaptcha($t = '') |
||||
1526 | { |
||||
1527 | return "{$t}\$xoopsCaptcha = \XoopsCaptcha::getInstance();\n"; |
||||
1528 | } |
||||
1529 | |||||
1530 | /** |
||||
1531 | * @public function getXcXoopsListImgListArray |
||||
1532 | * @param $return |
||||
1533 | * @param $var |
||||
1534 | * @param $t |
||||
1535 | * |
||||
1536 | * @return string |
||||
1537 | */ |
||||
1538 | public function getXcXoopsListImgListArray($return, $var, $t = '') |
||||
1539 | { |
||||
1540 | return "{$t}\${$return} = \XoopsLists::getImgListAsArray( {$var} );\n"; |
||||
1541 | } |
||||
1542 | |||||
1543 | /** |
||||
1544 | * @public function getXcXoopsListLangList |
||||
1545 | * @param $return |
||||
1546 | * @param string $t |
||||
1547 | * |
||||
1548 | * @return string |
||||
1549 | */ |
||||
1550 | public function getXcXoopsListLangList($return, $t = '') |
||||
1551 | { |
||||
1552 | return "{$t}\${$return} = \XoopsLists::getLangList();\n"; |
||||
1553 | } |
||||
1554 | |||||
1555 | /** |
||||
1556 | * @public function getXcXoopsListCountryList |
||||
1557 | * @param $return |
||||
1558 | * @param string $t |
||||
1559 | * |
||||
1560 | * @return string |
||||
1561 | */ |
||||
1562 | public function getXcXoopsListCountryList($return, $t = '') |
||||
1563 | { |
||||
1564 | return "{$t}\${$return} = \XoopsLists::getCountryList();\n"; |
||||
1565 | } |
||||
1566 | |||||
1567 | /** |
||||
1568 | * @public function getXcXoopsUserUnameFromId |
||||
1569 | * @param $left |
||||
1570 | * @param $value |
||||
1571 | * @param string $t |
||||
1572 | * |
||||
1573 | * @return string |
||||
1574 | */ |
||||
1575 | public function getXcXoopsUserUnameFromId($left, $value, $t = '') |
||||
1576 | { |
||||
1577 | return "{$t}\${$left} = \XoopsUser::getUnameFromId({$value});\n"; |
||||
1578 | } |
||||
1579 | |||||
1580 | /** |
||||
1581 | * @public function getXcXoopsTplAssign |
||||
1582 | * |
||||
1583 | * @param $tplString |
||||
1584 | * @param $phpRender |
||||
1585 | * @param bool $leftIsString |
||||
1586 | * @param string $t |
||||
1587 | * @param string $tpl |
||||
1588 | * @return string |
||||
1589 | */ |
||||
1590 | public function getXcXoopsTplAssign($tplString, $phpRender, $leftIsString = true, $t = '', $tpl = '') |
||||
1591 | { |
||||
1592 | $assign = "{$t}\$GLOBALS['xoopsTpl']->assign("; |
||||
1593 | if ('' !== $tpl) { |
||||
1594 | $assign = "{$t}\${$tpl}->assign("; |
||||
1595 | } |
||||
1596 | |||||
1597 | if (false === $leftIsString) { |
||||
1598 | $ret = $assign . "{$tplString}, {$phpRender});\n"; |
||||
1599 | } else { |
||||
1600 | $ret = $assign . "'{$tplString}', {$phpRender});\n"; |
||||
1601 | } |
||||
1602 | |||||
1603 | return $ret; |
||||
1604 | } |
||||
1605 | |||||
1606 | /** |
||||
1607 | * @public function getXcXoopsTplAppend |
||||
1608 | * |
||||
1609 | * @param $tplString |
||||
1610 | * @param $phpRender |
||||
1611 | * |
||||
1612 | * @param string $t |
||||
1613 | * @return string |
||||
1614 | */ |
||||
1615 | public function getXcXoopsTplAppend($tplString, $phpRender, $t = '') |
||||
1616 | { |
||||
1617 | return "{$t}\$GLOBALS['xoopsTpl']->append('{$tplString}', {$phpRender});\n"; |
||||
1618 | } |
||||
1619 | |||||
1620 | /** |
||||
1621 | * @public function getXcXoopsTplAppendByRef |
||||
1622 | * |
||||
1623 | * @param $tplString |
||||
1624 | * @param $phpRender |
||||
1625 | * |
||||
1626 | * @param string $t |
||||
1627 | * @return string |
||||
1628 | */ |
||||
1629 | public function getXcXoopsTplAppendByRef($tplString, $phpRender, $t = '') |
||||
1630 | { |
||||
1631 | return "{$t}\$GLOBALS['xoopsTpl']->appendByRef('{$tplString}', {$phpRender});\n"; |
||||
1632 | } |
||||
1633 | |||||
1634 | /** |
||||
1635 | * @public function getXcXoopsTplDisplay |
||||
1636 | * |
||||
1637 | * @param string $displayTpl |
||||
1638 | * @param string $t |
||||
1639 | * @param bool $usedoublequotes |
||||
1640 | * @return string |
||||
1641 | */ |
||||
1642 | public function getXcXoopsTplDisplay($displayTpl = '{$templateMain}', $t = '', $usedoublequotes = true) |
||||
1643 | { |
||||
1644 | if ($usedoublequotes) { |
||||
1645 | return "{$t}\$GLOBALS['xoopsTpl']->display(\"db:{$displayTpl}\");\n"; |
||||
1646 | } |
||||
1647 | |||||
1648 | return "{$t}\$GLOBALS['xoopsTpl']->display('db:" . $displayTpl . "');\n"; |
||||
1649 | } |
||||
1650 | |||||
1651 | /** |
||||
1652 | * @public function getXcXoopsPath |
||||
1653 | * |
||||
1654 | * @param $directory |
||||
1655 | * @param $filename |
||||
1656 | * @param bool $isParam |
||||
1657 | * |
||||
1658 | * @param string $t |
||||
1659 | * @return string |
||||
1660 | */ |
||||
1661 | public function getXcXoopsPath($directory, $filename, $isParam = false, $t = '') |
||||
1662 | { |
||||
1663 | if (!$isParam) { |
||||
1664 | $ret = "{$t}\$GLOBALS['xoops']->path({$directory}.'/{$filename}.php');\n"; |
||||
1665 | } else { |
||||
1666 | $ret = "\$GLOBALS['xoops']->path({$directory}.'/{$filename}.php')"; |
||||
1667 | } |
||||
1668 | |||||
1669 | return $ret; |
||||
1670 | } |
||||
1671 | |||||
1672 | /** |
||||
1673 | * @public function getXcXoopsModuleGetInfo |
||||
1674 | * |
||||
1675 | * @param $left |
||||
1676 | * @param $string |
||||
1677 | * @param bool $isParam |
||||
1678 | * |
||||
1679 | * @param string $t |
||||
1680 | * @return string |
||||
1681 | */ |
||||
1682 | public function getXcXoopsModuleGetInfo($left, $string, $isParam = false, $t = '') |
||||
1683 | { |
||||
1684 | if (!$isParam) { |
||||
1685 | $ret = "{$t}\${$left} = \$GLOBALS['xoopsModule']->getInfo('{$string}');\n"; |
||||
1686 | } else { |
||||
1687 | $ret = "\$GLOBALS['xoopsModule']->getInfo('{$string}')"; |
||||
1688 | } |
||||
1689 | |||||
1690 | return $ret; |
||||
1691 | } |
||||
1692 | |||||
1693 | |||||
1694 | /** |
||||
1695 | * @public function getXcXoThemeAddStylesheet |
||||
1696 | * @param string $style |
||||
1697 | * |
||||
1698 | * @param string $t |
||||
1699 | * @param bool $isString |
||||
1700 | * @return string |
||||
1701 | */ |
||||
1702 | public function getXcXoThemeAddStylesheet($style = 'style', $t = '', $isString = true) |
||||
1703 | { |
||||
1704 | $ret = "{$t}\$GLOBALS['xoTheme']->addStylesheet("; |
||||
1705 | if ($isString) { |
||||
1706 | $ret .= '$'; |
||||
1707 | } |
||||
1708 | $ret .= "{$style}, null);\n"; |
||||
1709 | return $ret; |
||||
1710 | } |
||||
1711 | |||||
1712 | /** |
||||
1713 | * @public function getXcXoopsSecurityCheck |
||||
1714 | * @param $denial |
||||
1715 | * @return bool |
||||
1716 | */ |
||||
1717 | public function getXcXoopsSecurityCheck($denial = '') |
||||
1718 | { |
||||
1719 | return "{$denial}\$GLOBALS['xoopsSecurity']->check()"; |
||||
0 ignored issues
–
show
|
|||||
1720 | } |
||||
1721 | |||||
1722 | /** |
||||
1723 | * @public function getXcXoopsSecurityErrors |
||||
1724 | * @param null |
||||
1725 | * @return string |
||||
1726 | */ |
||||
1727 | public function getXcXoopsSecurityErrors() |
||||
1728 | { |
||||
1729 | return "\$GLOBALS['xoopsSecurity']->getErrors()"; |
||||
1730 | } |
||||
1731 | |||||
1732 | /** |
||||
1733 | * @public function getXcXoopsHandler |
||||
1734 | * @param $left |
||||
1735 | * @param string $t |
||||
1736 | * @param string $n |
||||
1737 | * @return string |
||||
1738 | */ |
||||
1739 | public function getXcXoopsHandler($left, $t = '', $n = "\n") |
||||
1740 | { |
||||
1741 | return "{$t}\${$left}Handler = \xoops_getHandler('{$left}');{$n}"; |
||||
1742 | } |
||||
1743 | |||||
1744 | |||||
1745 | /*************************************************************/ |
||||
1746 | /** common components for user and admin pages */ |
||||
1747 | /*************************************************************/ |
||||
1748 | |||||
1749 | /** |
||||
1750 | * @public function getXcCommonPagesEdit |
||||
1751 | * @param $tableName |
||||
1752 | * @param $ccFieldId |
||||
1753 | * @param string $t |
||||
1754 | * @return string |
||||
1755 | */ |
||||
1756 | public function getXcCommonPagesEdit($tableName, $ccFieldId, $t = '') |
||||
1757 | { |
||||
1758 | $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); |
||||
1759 | $xc = Modulebuilder\Files\CreateXoopsCode::getInstance(); |
||||
1760 | |||||
1761 | $ret = $pc->getPhpCodeCommentLine('Get Form', null, "\t\t"); |
||||
1762 | $ret .= $xc->getXcHandlerGet($tableName, $ccFieldId, 'Obj', $tableName . 'Handler', false, $t); |
||||
1763 | $ret .= $xc->getXcEqualsOperator("\${$tableName}Obj->start", '$start', null, $t); |
||||
1764 | $ret .= $xc->getXcEqualsOperator("\${$tableName}Obj->limit", '$limit', null, $t); |
||||
1765 | $ret .= $xc->getXcGetForm('form', $tableName, 'Obj', $t); |
||||
1766 | $ret .= $xc->getXcXoopsTplAssign('form', '$form->render()', true, $t); |
||||
1767 | |||||
1768 | return $ret; |
||||
1769 | } |
||||
1770 | |||||
1771 | /** |
||||
1772 | * @public function getXcCommonPagesNew |
||||
1773 | * @param $tableName |
||||
1774 | * @param string $t |
||||
1775 | * @return string |
||||
1776 | */ |
||||
1777 | public function getXcCommonPagesNew($tableName, $t = '') |
||||
1778 | { |
||||
1779 | $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); |
||||
1780 | $xc = Modulebuilder\Files\CreateXoopsCode::getInstance(); |
||||
1781 | |||||
1782 | $ret = $pc->getPhpCodeCommentLine('Form Create', null, $t); |
||||
1783 | $ret .= $xc->getXcHandlerCreateObj($tableName, $t); |
||||
1784 | $ret .= $xc->getXcGetForm('form', $tableName, 'Obj', $t); |
||||
1785 | $ret .= $xc->getXcXoopsTplAssign('form', '$form->render()', true, $t); |
||||
1786 | |||||
1787 | return $ret; |
||||
1788 | } |
||||
1789 | |||||
1790 | /** |
||||
1791 | * @public function getXcCommonPagesClone |
||||
1792 | * @param $tableName |
||||
1793 | * @param $ccFieldId |
||||
1794 | * @param string $t |
||||
1795 | * @return string |
||||
1796 | */ |
||||
1797 | public function getXcCommonPagesClone($tableName, $ccFieldId, $t = '') |
||||
1798 | { |
||||
1799 | $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); |
||||
1800 | $xc = Modulebuilder\Files\CreateXoopsCode::getInstance(); |
||||
1801 | |||||
1802 | $ret = $pc->getPhpCodeCommentLine('Get Form', null, "\t\t"); |
||||
1803 | $ret .= $xc->getXcHandlerGet($tableName, $ccFieldId . 'Source', 'ObjSource', $tableName . 'Handler', false, $t); |
||||
1804 | $ret .= $xc->getXcEqualsOperator('$' . $tableName . 'Obj', '$' . $tableName . 'ObjSource->xoopsClone()', null, $t); |
||||
1805 | $ret .= $xc->getXcGetForm('form', $tableName, 'Obj', $t); |
||||
1806 | $ret .= $xc->getXcXoopsTplAssign('form', '$form->render()', true, $t); |
||||
1807 | |||||
1808 | return $ret; |
||||
1809 | } |
||||
1810 | |||||
1811 | |||||
1812 | /** |
||||
1813 | * @public function getXcCommonPagesDelete |
||||
1814 | * @param $language |
||||
1815 | * @param $tableName |
||||
1816 | * @param $tableSoleName |
||||
1817 | * @param $fieldId |
||||
1818 | * @param $fieldMain |
||||
1819 | * @param $tableNotifications |
||||
1820 | * @param string $t |
||||
1821 | * @param bool $admin |
||||
1822 | * @return string |
||||
1823 | */ |
||||
1824 | public function getXcCommonPagesDelete($language, $tableName, $tableSoleName, $fieldId, $fieldMain, $tableNotifications, $t = '', $admin = false) |
||||
1825 | { |
||||
1826 | $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); |
||||
1827 | $xc = Modulebuilder\Files\CreateXoopsCode::getInstance(); |
||||
1828 | $cf = Modulebuilder\Files\CreateFile::getInstance(); |
||||
1829 | |||||
1830 | $ccFieldId = $cf->getCamelCase($fieldId, false, true); |
||||
1831 | $ccFieldMain = $cf->getCamelCase($fieldMain, false, true); |
||||
1832 | |||||
1833 | $ret = $xc->getXcHandlerGet($tableName, $ccFieldId, 'Obj', $tableName . 'Handler', false, $t); |
||||
1834 | $ret .= $xc->getXcGetVar($ccFieldMain, "{$tableName}Obj", $fieldMain, false, $t); |
||||
1835 | $reqOk = "_REQUEST['ok']"; |
||||
1836 | $isset = $pc->getPhpCodeIsset($reqOk); |
||||
1837 | $xoopsSecurityCheck = $xc->getXcXoopsSecurityCheck(); |
||||
1838 | $xoopsSecurityErrors = $xc->getXcXoopsSecurityErrors(); |
||||
1839 | $implode = $pc->getPhpCodeImplode(', ', $xoopsSecurityErrors); |
||||
1840 | $redirectHeaderErrors = $xc->getXcRedirectHeader($tableName, '', '3', $implode, true, $t . "\t\t"); |
||||
1841 | $delete = $xc->getXcHandlerDelete($tableName, $tableName, 'Obj', 'Handler'); |
||||
1842 | $condition = $pc->getPhpCodeConditions('!' . $xoopsSecurityCheck, '', '', $redirectHeaderErrors, false, $t . "\t"); |
||||
1843 | $contInsert = ''; |
||||
1844 | if (!$admin && 1 == $tableNotifications) { |
||||
1845 | $contInsert .= $pc->getPhpCodeCommentLine('Event delete notification', null, $t . "\t\t"); |
||||
1846 | $contInsert .= $pc->getPhpCodeArray('tags', [], false, $t . "\t\t"); |
||||
1847 | $contInsert .= $xc->getXcEqualsOperator("\$tags['ITEM_NAME']", "\${$ccFieldMain}", '', $t . "\t\t"); |
||||
1848 | $contInsert .= $xc->getXcXoopsHandler('notification', $t . "\t\t"); |
||||
1849 | $contInsert .= $cf->getSimpleString("\$notificationHandler->triggerEvent('global', 0, 'global_delete', \$tags);", $t . "\t\t"); |
||||
1850 | $contInsert .= $cf->getSimpleString("\$notificationHandler->triggerEvent('{$tableName}', \${$ccFieldId}, '{$tableSoleName}_delete', \$tags);", $t . "\t\t"); |
||||
1851 | } |
||||
1852 | $contInsert .= $xc->getXcRedirectHeader($tableName, '', '3', "{$language}FORM_DELETE_OK", true, $t . "\t\t"); |
||||
1853 | $htmlErrors = $xc->getXcHtmlErrors($tableName, true); |
||||
1854 | $internalElse = $xc->getXcXoopsTplAssign('error', $htmlErrors, true, $t . "\t\t"); |
||||
1855 | $condition .= $pc->getPhpCodeConditions($delete, '', '', $contInsert, $internalElse, $t . "\t"); |
||||
1856 | $mainElse = $xc->getXcXoopsConfirm($tableName, $language, $fieldId, $fieldMain, 'delete', $t . "\t"); |
||||
1857 | $ret .= $pc->getPhpCodeConditions($isset, ' && ', "1 == \${$reqOk}", $condition, $mainElse, $t); |
||||
1858 | |||||
1859 | return $ret; |
||||
1860 | } |
||||
1861 | } |
||||
1862 |