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