|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace XoopsModules\Modulebuilder\Files\Admin; |
|
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 Axc. |
|
30
|
|
|
*/ |
|
31
|
|
|
class AdminXoopsCode |
|
32
|
|
|
{ |
|
33
|
|
|
/** |
|
34
|
|
|
* @var string |
|
35
|
|
|
*/ |
|
36
|
|
|
private $xc = null; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @var string |
|
40
|
|
|
*/ |
|
41
|
|
|
private $pc = null; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @public function constructor |
|
45
|
|
|
* @param null |
|
46
|
|
|
*/ |
|
47
|
|
|
public function __construct() |
|
48
|
|
|
{ |
|
49
|
|
|
$this->xc = Modulebuilder\Files\CreateXoopsCode::getInstance(); |
|
|
|
|
|
|
50
|
|
|
$this->pc = Modulebuilder\Files\CreatePhpCode::getInstance(); |
|
|
|
|
|
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @static function getInstance |
|
55
|
|
|
* @param null |
|
56
|
|
|
* @return AdminXoopsCode |
|
57
|
|
|
*/ |
|
58
|
|
|
public static function getInstance() |
|
59
|
|
|
{ |
|
60
|
|
|
static $instance = false; |
|
61
|
|
|
if (!$instance) { |
|
62
|
|
|
$instance = new self(); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
return $instance; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* @public function getAdminTemplateMain |
|
70
|
|
|
* @param $moduleDirname |
|
71
|
|
|
* @param $tableName |
|
72
|
|
|
* |
|
73
|
|
|
* @param string $t |
|
74
|
|
|
* @return string |
|
75
|
|
|
*/ |
|
76
|
|
|
public function getAdminTemplateMain($moduleDirname, $tableName, $t = '') |
|
77
|
|
|
{ |
|
78
|
|
|
return "{$t}\$templateMain = '{$moduleDirname}_admin_{$tableName}.tpl';\n"; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* @public function getAdminTemplateMain |
|
83
|
|
|
* @param $language |
|
84
|
|
|
* @param $tableName |
|
85
|
|
|
* @param $stuTableSoleName |
|
86
|
|
|
* @param string $op |
|
87
|
|
|
* @param string $type |
|
88
|
|
|
* |
|
89
|
|
|
* @param string $t |
|
90
|
|
|
* @return string |
|
91
|
|
|
*/ |
|
92
|
|
|
public function getAdminItemButton($language, $tableName, $stuTableSoleName, $op = '?op=new', $type = 'add', $t = '') |
|
93
|
|
|
{ |
|
94
|
|
|
$stuType = mb_strtoupper($type); |
|
95
|
|
|
$aM = $t . '$adminObject->addItemButton('; |
|
96
|
|
|
switch ($type) { |
|
97
|
|
|
case 'add'; |
|
98
|
|
|
$ret = $aM . "{$language}ADD_{$stuTableSoleName}, '{$tableName}.php{$op}', '{$type}');\n"; |
|
99
|
|
|
break; |
|
100
|
|
|
case 'samplebutton'; |
|
101
|
|
|
$ret = $aM . "{$language}, '{$op}', 'add');\n"; |
|
102
|
|
|
break; |
|
103
|
|
|
case 'default': |
|
104
|
|
|
default: |
|
105
|
|
|
$ret = $aM . "{$language}{$stuTableSoleName}_{$stuType}, '{$tableName}.php{$op}', '{$type}');\n"; |
|
106
|
|
|
break; |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
return $ret; |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
/** |
|
113
|
|
|
* @public function getAdminAddNavigation |
|
114
|
|
|
* |
|
115
|
|
|
* @param $type |
|
116
|
|
|
* @param string $t |
|
117
|
|
|
* @return string |
|
118
|
|
|
*/ |
|
119
|
|
|
public function getAdminDisplayButton($type, $t = '') |
|
120
|
|
|
{ |
|
121
|
|
|
return "{$t}\$adminObject->displayButton('{$type}');\n"; |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
/** |
|
125
|
|
|
* @public function getAdminAddNavigation |
|
126
|
|
|
* |
|
127
|
|
|
* @param $tableName |
|
128
|
|
|
* |
|
129
|
|
|
* @param string $t |
|
130
|
|
|
* @return string |
|
131
|
|
|
*/ |
|
132
|
|
|
public function getAdminDisplayNavigation($tableName, $t = '') |
|
133
|
|
|
{ |
|
134
|
|
|
return "{$t}\$adminObject->displayNavigation('{$tableName}.php')"; |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
/** |
|
138
|
|
|
* @public function getAxcAddInfoBox |
|
139
|
|
|
* @param $language |
|
140
|
|
|
* |
|
141
|
|
|
* @param string $t |
|
142
|
|
|
* @return string |
|
143
|
|
|
*/ |
|
144
|
|
|
public function getAxcAddInfoBox($language, $t = '') |
|
145
|
|
|
{ |
|
146
|
|
|
return "{$t}\$adminObject->addInfoBox({$language});\n"; |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
/** |
|
150
|
|
|
* @public function getAxcAddInfoBoxLine |
|
151
|
|
|
* @param string $label |
|
152
|
|
|
* @param string $var |
|
153
|
|
|
* |
|
154
|
|
|
* @param string $t |
|
155
|
|
|
* @return string |
|
156
|
|
|
*/ |
|
157
|
|
|
public function getAxcAddInfoBoxLine($label = '', $var = '', $t = '') |
|
158
|
|
|
{ |
|
159
|
|
|
$aMenu = $t . '$adminObject->addInfoBoxLine(sprintf('; |
|
160
|
|
|
if ('' != $var) { |
|
161
|
|
|
$ret = $aMenu . " '<label>'.{$label}.'</label>', {$var}));\n"; |
|
162
|
|
|
} else { |
|
163
|
|
|
$ret = $aMenu . " '<label>'.{$label}.'</label>'));\n"; |
|
164
|
|
|
} |
|
165
|
|
|
|
|
166
|
|
|
return $ret; |
|
167
|
|
|
} |
|
168
|
|
|
|
|
169
|
|
|
/** |
|
170
|
|
|
* @public function getAxcAddConfigBoxLine |
|
171
|
|
|
* @param $language |
|
172
|
|
|
* @param string $label |
|
173
|
|
|
* @param string $var |
|
174
|
|
|
* |
|
175
|
|
|
* @param string $t |
|
176
|
|
|
* @return string |
|
177
|
|
|
*/ |
|
178
|
|
|
public function getAxcAddConfigBoxLine($language, $label = '', $var = '', $t = '') |
|
179
|
|
|
{ |
|
180
|
|
|
$aMenu = $t . '$adminObject->addConfigBoxLine('; |
|
181
|
|
|
if ('' != $var) { |
|
182
|
|
|
$ret = $aMenu . "{$language}, '{$label}', {$var});\n"; |
|
183
|
|
|
} else { |
|
184
|
|
|
$ret = $aMenu . "{$language}, '{$label}');\n"; |
|
185
|
|
|
} |
|
186
|
|
|
|
|
187
|
|
|
return $ret; |
|
188
|
|
|
} |
|
189
|
|
|
|
|
190
|
|
|
/** |
|
191
|
|
|
* @public function getAxcSetVarImageList |
|
192
|
|
|
* @param string $tableName |
|
193
|
|
|
* @param string $fieldName |
|
194
|
|
|
* @param string $t |
|
195
|
|
|
* @param int $countUploader |
|
196
|
|
|
* @return string |
|
197
|
|
|
*/ |
|
198
|
|
|
public function getAxcSetVarImageList($tableName, $fieldName, $t = '', $countUploader = 0) |
|
199
|
|
|
{ |
|
200
|
|
|
$ret = $this->pc->getPhpCodeCommentLine('Set Var', $fieldName, $t); |
|
201
|
|
|
$ret .= $this->pc->getPhpCodeIncludeDir('XOOPS_ROOT_PATH', 'class/uploader', true, false, '', $t); |
|
202
|
|
|
$xRootPath = "XOOPS_ROOT_PATH . '/Frameworks/moduleclasses/icons/32'"; |
|
203
|
|
|
$ret .= $this->xc->getXcMediaUploader('uploader', $xRootPath, 'mimetypes_image', 'maxsize_image', $t); |
|
204
|
|
|
$post = $this->pc->getPhpCodeGlobalsVariables('xoops_upload_file', 'POST') . '[' . $countUploader . ']'; |
|
205
|
|
|
$fetchMedia = $this->getAxcFetchMedia('uploader', $post); |
|
206
|
|
|
$ifelse = $t . "\t//" . $this->getAxcSetPrefix('uploader', "{$fieldName}_") . ";\n"; |
|
207
|
|
|
$ifelse .= $t . "\t//{$fetchMedia};\n"; |
|
208
|
|
|
$contElseInt = $this->xc->getXcSetVarObj($tableName, $fieldName, '$uploader->getSavedFileName()', $t . "\t\t"); |
|
209
|
|
|
$contIf = $this->xc->getXcEqualsOperator('$errors', '$uploader->getErrors()', null, $t . "\t\t"); |
|
210
|
|
|
$contIf .= $this->xc->getXcRedirectHeader('javascript:history.go(-1)', '', '3', '$errors', true, $t . "\t\t"); |
|
211
|
|
|
$ifelse .= $this->pc->getPhpCodeConditions('!$uploader->upload()', '', '', $contIf, $contElseInt, $t . "\t"); |
|
212
|
|
|
$contElseExt = $this->xc->getXcSetVarObj($tableName, $fieldName, "Request::getString('{$fieldName}')", $t . "\t"); |
|
213
|
|
|
|
|
214
|
|
|
$ret .= $this->pc->getPhpCodeConditions($fetchMedia, '', '', $ifelse, $contElseExt, $t); |
|
215
|
|
|
|
|
216
|
|
|
return $ret; |
|
217
|
|
|
} |
|
218
|
|
|
|
|
219
|
|
|
/** |
|
220
|
|
|
* @public function getAxcSetVarUploadImage |
|
221
|
|
|
* @param string $moduleDirname |
|
222
|
|
|
* @param string $tableName |
|
223
|
|
|
* @param string $fieldName |
|
224
|
|
|
* @param $fieldMain |
|
225
|
|
|
* @param string $t |
|
226
|
|
|
* @param int $countUploader |
|
227
|
|
|
* @return string |
|
228
|
|
|
*/ |
|
229
|
|
|
public function getAxcSetVarUploadImage($moduleDirname, $tableName, $fieldName, $fieldMain, $t = '', $countUploader = 0) |
|
230
|
|
|
{ |
|
231
|
|
|
$stuModuleDirname = mb_strtoupper($moduleDirname); |
|
232
|
|
|
$ucfModuleDirname = ucfirst($moduleDirname); |
|
233
|
|
|
$ret = $this->pc->getPhpCodeCommentLine('Set Var', $fieldName, $t); |
|
234
|
|
|
$ret .= $this->pc->getPhpCodeIncludeDir('XOOPS_ROOT_PATH', 'class/uploader', true, false, '', $t); |
|
235
|
|
|
$file = $this->pc->getPhpCodeGlobalsVariables($fieldName, 'FILES') . "['name']"; |
|
236
|
|
|
$ret .= $this->xc->getXcEqualsOperator('$filename ', $file, null, $t); |
|
237
|
|
|
$mimetype = $this->pc->getPhpCodeGlobalsVariables($fieldName, 'FILES') . "['type']"; |
|
238
|
|
|
$ret .= $this->xc->getXcEqualsOperator('$imgMimetype ', $mimetype, null, $t); |
|
239
|
|
|
$ret .= $this->xc->getXcEqualsOperator('$imgNameDef ', "Request::getString('{$fieldMain}')", null, $t); |
|
240
|
|
|
$ret .= $this->xc->getXcEqualsOperator('$uploaderErrors', "''", null, $t); |
|
241
|
|
|
$xUploadImage = "{$stuModuleDirname}_UPLOAD_IMAGE_PATH"; |
|
242
|
|
|
$ret .= $this->xc->getXcMediaUploader('uploader', $xUploadImage . " . '/{$tableName}/'", 'mimetypes_image', 'maxsize_image', $t); |
|
243
|
|
|
$post = $this->pc->getPhpCodeGlobalsVariables('xoops_upload_file', 'POST') . '[' . $countUploader . ']'; |
|
244
|
|
|
$fetchMedia = $this->getAxcFetchMedia('uploader', $post); |
|
245
|
|
|
$expr = '/^.+\.([^.]+)$/sU'; |
|
246
|
|
|
$ifelse = $this->pc->getPhpCodePregFunzions('extension', $expr, '', "\$filename", 'replace', false, $t . "\t"); |
|
247
|
|
|
$ifelse .= $t . "\t\$imgName = str_replace(' ', '', \$imgNameDef) . '.' . \$extension;\n"; |
|
248
|
|
|
$ifelse .= $this->getAxcSetPrefix('uploader', '$imgName', $t . "\t") . ";\n"; |
|
249
|
|
|
$ifelse .= $t . "\t{$fetchMedia};\n"; |
|
250
|
|
|
$contElseInt = $this->xc->getXcEqualsOperator('$savedFilename', '$uploader->getSavedFileName()', null, $t . "\t\t"); |
|
251
|
|
|
$config = $this->xc->getXcGetConfig('maxwidth_image'); |
|
252
|
|
|
$contElseInt .= $this->xc->getXcEqualsOperator('$maxwidth ', "(int){$config}", null, $t . "\t\t"); |
|
253
|
|
|
$config = $this->xc->getXcGetConfig('maxheight_image'); |
|
254
|
|
|
$contElseInt .= $this->xc->getXcEqualsOperator('$maxheight', "(int){$config}", null, $t . "\t\t"); |
|
255
|
|
|
$resizer = $this->pc->getPhpCodeCommentLine('Resize image', '', $t . "\t\t\t"); |
|
256
|
|
|
$resizer .= $this->xc->getXcEqualsOperator('$imgHandler ', "new {$ucfModuleDirname}\Common\Resizer()", null, $t . "\t\t\t"); |
|
257
|
|
|
$resizer .= $this->xc->getXcEqualsOperator('$imgHandler->sourceFile ', $xUploadImage . " . '/{$tableName}/' . \$savedFilename", null, $t . "\t\t\t"); |
|
258
|
|
|
$resizer .= $this->xc->getXcEqualsOperator('$imgHandler->endFile ', $xUploadImage . " . '/{$tableName}/' . \$savedFilename", null, $t . "\t\t\t"); |
|
259
|
|
|
$resizer .= $this->xc->getXcEqualsOperator('$imgHandler->imageMimetype', '$imgMimetype', null, $t . "\t\t\t"); |
|
260
|
|
|
$resizer .= $this->xc->getXcEqualsOperator('$imgHandler->maxWidth ', '$maxwidth', null, $t . "\t\t\t"); |
|
261
|
|
|
$resizer .= $this->xc->getXcEqualsOperator('$imgHandler->maxHeight ', '$maxheight', null, $t . "\t\t\t"); |
|
262
|
|
|
$resizer .= $this->xc->getXcEqualsOperator('$result ', '$imgHandler->resizeImage()', null, $t . "\t\t\t"); |
|
263
|
|
|
$contElseInt .= $this->pc->getPhpCodeConditions('$maxwidth > 0 && $maxheight > 0', '', '', $resizer, false, $t . "\t\t"); |
|
264
|
|
|
$contElseInt .= $this->xc->getXcSetVarObj($tableName, $fieldName, '$savedFilename', $t . "\t\t"); |
|
265
|
|
|
$contIf = $this->xc->getXcEqualsOperator('$uploaderErrors', '$uploader->getErrors()', null, $t . "\t\t"); |
|
266
|
|
|
$ifelse .= $this->pc->getPhpCodeConditions('!$uploader->upload()', '', '', $contIf, $contElseInt, $t . "\t"); |
|
267
|
|
|
$ifelseExt = $this->xc->getXcEqualsOperator('$uploaderErrors', '$uploader->getErrors()', null, $t . "\t\t"); |
|
268
|
|
|
$contElseExt = $this->pc->getPhpCodeConditions("\$filename", ' > ', "''", $ifelseExt, false, $t . "\t"); |
|
269
|
|
|
$contElseExt .= $this->xc->getXcSetVarObj($tableName, $fieldName, "Request::getString('{$fieldName}')", $t . "\t"); |
|
270
|
|
|
|
|
271
|
|
|
$ret .= $this->pc->getPhpCodeConditions($fetchMedia, '', '', $ifelse, $contElseExt, $t); |
|
272
|
|
|
|
|
273
|
|
|
return $ret; |
|
274
|
|
|
} |
|
275
|
|
|
|
|
276
|
|
|
/** |
|
277
|
|
|
* @public function getAxcFileSetVar |
|
278
|
|
|
* @param $moduleDirname |
|
279
|
|
|
* @param $tableName |
|
280
|
|
|
* @param $fieldName |
|
281
|
|
|
* @param bool $formatUrl |
|
282
|
|
|
* @param string $t |
|
283
|
|
|
* @param int $countUploader |
|
284
|
|
|
* @param string $fieldMain |
|
285
|
|
|
* @return string |
|
286
|
|
|
*/ |
|
287
|
|
|
public function getAxcSetVarUploadFile($moduleDirname, $tableName, $fieldName, $formatUrl = false, $t = '', $countUploader = 0, $fieldMain = '') |
|
288
|
|
|
{ |
|
289
|
|
|
$stuModuleDirname = mb_strtoupper($moduleDirname); |
|
290
|
|
|
$ret = $this->getAxcSetVarImageFile($stuModuleDirname . '_UPLOAD_FILES_PATH', $tableName, $fieldName, $formatUrl, $t, $countUploader, $fieldMain, 'mimetypes_file', 'maxsize_file'); |
|
291
|
|
|
|
|
292
|
|
|
return $ret; |
|
293
|
|
|
} |
|
294
|
|
|
|
|
295
|
|
|
/** |
|
296
|
|
|
* @private function getAxcSetVarImageFile |
|
297
|
|
|
* @param $dirname |
|
298
|
|
|
* @param $tableName |
|
299
|
|
|
* @param $fieldName |
|
300
|
|
|
* @param bool $formatUrl |
|
301
|
|
|
* @param string $t |
|
302
|
|
|
* @param int $countUploader |
|
303
|
|
|
* @param string $fieldMain |
|
304
|
|
|
* @param string $mimetype |
|
305
|
|
|
* @param string $maxsize |
|
306
|
|
|
* @return string |
|
307
|
|
|
*/ |
|
308
|
|
|
private function getAxcSetVarImageFile($dirname, $tableName, $fieldName, $formatUrl = false, $t = '', $countUploader = 0, $fieldMain = '', $mimetype = 'mimetypes_image', $maxsize = 'maxsize_image') |
|
309
|
|
|
{ |
|
310
|
|
|
$ret = ''; |
|
311
|
|
|
$files = ''; |
|
312
|
|
|
$contIf = ''; |
|
313
|
|
|
|
|
314
|
|
|
if ($formatUrl) { |
|
315
|
|
|
$ret .= $this->xc->getXcSetVarObj($tableName, $fieldName, "formatUrl(\$_REQUEST['{$fieldName}'])", $t); |
|
316
|
|
|
} |
|
317
|
|
|
$ret .= $this->pc->getPhpCodeCommentLine('Set Var', $fieldName, $t); |
|
318
|
|
|
$ret .= $this->pc->getPhpCodeIncludeDir('XOOPS_ROOT_PATH', 'class/uploader', true, false, '', $t); |
|
319
|
|
|
$file = $this->pc->getPhpCodeGlobalsVariables($fieldName, 'FILES') . "['name']"; |
|
320
|
|
|
$ret .= $this->xc->getXcEqualsOperator('$filename ', $file, null, $t); |
|
321
|
|
|
$ret .= $this->xc->getXcEqualsOperator('$imgNameDef ', "Request::getString('{$fieldMain}')", null, $t); |
|
322
|
|
|
$ret .= $this->xc->getXcMediaUploader('uploader', $dirname . " . '/{$tableName}{$files}/'", $mimetype, $maxsize, $t); |
|
323
|
|
|
$post = $this->pc->getPhpCodeGlobalsVariables('xoops_upload_file', 'POST') . '[' . $countUploader . ']'; |
|
324
|
|
|
$fetchMedia = $this->getAxcFetchMedia('uploader', $post); |
|
325
|
|
|
$expr = '/^.+\.([^.]+)$/sU'; |
|
326
|
|
|
$ifelse = $this->pc->getPhpCodePregFunzions('extension', $expr, '', "\$filename", 'replace', false, $t . "\t"); |
|
327
|
|
|
$ifelse .= $t . "\t\$imgName = str_replace(' ', '', \$imgNameDef) . '.' . \$extension;\n"; |
|
328
|
|
|
$ifelse .= $this->getAxcSetPrefix('uploader', '$imgName', $t . "\t") . ";\n"; |
|
329
|
|
|
$ifelse .= $t . "\t{$fetchMedia};\n"; |
|
330
|
|
|
$contElseInt = $this->xc->getXcSetVarObj($tableName, $fieldName, '$uploader->getSavedFileName()', $t . "\t\t"); |
|
331
|
|
|
$contIf .= $this->xc->getXcEqualsOperator('$errors', '$uploader->getErrors()', null, $t . "\t\t"); |
|
332
|
|
|
$ifelse .= $this->pc->getPhpCodeConditions('!$uploader->upload()', '', '', $contIf, $contElseInt, $t . "\t"); |
|
333
|
|
|
$ifelseExt = $this->xc->getXcEqualsOperator('$uploaderErrors', '$uploader->getErrors()', null, $t . "\t\t"); |
|
334
|
|
|
$contElseExt = $this->pc->getPhpCodeConditions("\$filename", ' > ', "''", $ifelseExt, false, $t . "\t"); |
|
335
|
|
|
$contElseExt .= $this->xc->getXcSetVarObj($tableName, $fieldName, "Request::getString('{$fieldName}')", $t . "\t"); |
|
336
|
|
|
|
|
337
|
|
|
$ret .= $this->pc->getPhpCodeConditions($fetchMedia, '', '', $ifelse, $contElseExt, $t); |
|
338
|
|
|
|
|
339
|
|
|
return $ret; |
|
340
|
|
|
} |
|
341
|
|
|
|
|
342
|
|
|
/** |
|
343
|
|
|
* @public function getAxcSetVarPassword |
|
344
|
|
|
* @param $tableName |
|
345
|
|
|
* @param $fieldName |
|
346
|
|
|
* @param string $t |
|
347
|
|
|
* @return string |
|
348
|
|
|
*/ |
|
349
|
|
|
public function getAxcSetVarPassword($tableName, $fieldName, $t = '') |
|
350
|
|
|
{ |
|
351
|
|
|
$cf = Modulebuilder\Files\CreateFile::getInstance(); |
|
352
|
|
|
$ccFieldId = $cf->getCamelCase($fieldName, false, true); |
|
353
|
|
|
$ret = $this->xc->getXcEqualsOperator("\${$ccFieldId}", "Request::getString('{$fieldName}', '')", '',$t); |
|
354
|
|
|
$contIf = $this->xc->getXcSetVarObj($tableName, $fieldName, "password_hash(\${$ccFieldId}, PASSWORD_DEFAULT)", $t . "\t"); |
|
355
|
|
|
$ret .= $this->pc->getPhpCodeConditions("\${$ccFieldId}", ' !== ', "''", $contIf, false, $t); |
|
356
|
|
|
|
|
357
|
|
|
return $ret; |
|
358
|
|
|
} |
|
359
|
|
|
|
|
360
|
|
|
|
|
361
|
|
|
/** |
|
362
|
|
|
* @public function getAxcSetVarMisc |
|
363
|
|
|
* @param $tableName |
|
364
|
|
|
* @param $fieldName |
|
365
|
|
|
* @param $fieldType |
|
366
|
|
|
* @param $fieldElement |
|
367
|
|
|
* @param string $t |
|
368
|
|
|
* @return string |
|
369
|
|
|
*/ |
|
370
|
|
|
public function getAxcSetVarMisc($tableName, $fieldName, $fieldType, $fieldElement, $t = '') |
|
371
|
|
|
{ |
|
372
|
|
|
switch ((int)$fieldType){ |
|
373
|
|
|
case 2: |
|
374
|
|
|
case 3: |
|
375
|
|
|
case 4: |
|
376
|
|
|
case 5: |
|
377
|
|
|
$ret = $this->xc->getXcSetVarObj($tableName, $fieldName, "Request::getInt('{$fieldName}', 0)", $t); |
|
378
|
|
|
break; |
|
379
|
|
|
case 6: |
|
380
|
|
|
case 7: |
|
381
|
|
|
case 8: |
|
382
|
|
|
$ret = $this->xc->getXcSetVarObj($tableName, $fieldName, "Request::getFloat('{$fieldName}', 0)", $t); |
|
383
|
|
|
break; |
|
384
|
|
|
case 13: |
|
385
|
|
|
case 14: |
|
386
|
|
|
case 15: |
|
387
|
|
|
case 16: |
|
388
|
|
|
case 17: |
|
389
|
|
|
case 18: |
|
390
|
|
|
if ((int)$fieldElement == 4) { |
|
391
|
|
|
$ret = $this->xc->getXcSetVarObj($tableName, $fieldName, "Request::getText('{$fieldName}', '')", $t); |
|
392
|
|
|
} else { |
|
393
|
|
|
$ret = $this->xc->getXcSetVarObj($tableName, $fieldName, "Request::getString('{$fieldName}', '')", $t); |
|
394
|
|
|
} |
|
395
|
|
|
break; |
|
396
|
|
|
case 0: |
|
397
|
|
|
default: |
|
398
|
|
|
//TODO: should be finally |
|
399
|
|
|
$ret = $this->xc->getXcSetVarObj($tableName, $fieldName, "\$_POST['{$fieldName}']", $t); |
|
400
|
|
|
break; |
|
401
|
|
|
} |
|
402
|
|
|
|
|
403
|
|
|
return $ret; |
|
404
|
|
|
} |
|
405
|
|
|
|
|
406
|
|
|
/** |
|
407
|
|
|
* @public function getAxcFetchMedia |
|
408
|
|
|
* |
|
409
|
|
|
* @param $anchor |
|
410
|
|
|
* @param $var |
|
411
|
|
|
* |
|
412
|
|
|
* @param string $t |
|
413
|
|
|
* @return string |
|
414
|
|
|
*/ |
|
415
|
|
|
public function getAxcFetchMedia($anchor, $var, $t = '') |
|
416
|
|
|
{ |
|
417
|
|
|
return "{$t}\${$anchor}->fetchMedia({$var})"; |
|
418
|
|
|
} |
|
419
|
|
|
|
|
420
|
|
|
/** |
|
421
|
|
|
* @public function getAxcSetPrefix |
|
422
|
|
|
* |
|
423
|
|
|
* @param $anchor |
|
424
|
|
|
* @param $var |
|
425
|
|
|
* |
|
426
|
|
|
* @param string $t |
|
427
|
|
|
* @return string |
|
428
|
|
|
*/ |
|
429
|
|
|
public function getAxcSetPrefix($anchor, $var, $t = '') |
|
430
|
|
|
{ |
|
431
|
|
|
return "{$t}\${$anchor}->setPrefix({$var})"; |
|
432
|
|
|
} |
|
433
|
|
|
} |
|
434
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..