Total Complexity | 82 |
Total Lines | 1017 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 2 | Features | 0 |
Complex classes like ClassFormElements often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use ClassFormElements, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
33 | class ClassFormElements extends Modulebuilder\Files\CreateAbstractClass |
||
34 | { |
||
35 | /** |
||
36 | * @var mixed |
||
37 | */ |
||
38 | private $cf = null; |
||
39 | |||
40 | /** |
||
41 | * @var mixed |
||
42 | */ |
||
43 | private $tf = null; |
||
44 | |||
45 | /** |
||
46 | * @var mixed |
||
47 | */ |
||
48 | private $uxc = null; |
||
49 | |||
50 | /** |
||
51 | * @var mixed |
||
52 | */ |
||
53 | private $cxc = null; |
||
54 | |||
55 | /** |
||
56 | * @var mixed |
||
57 | */ |
||
58 | private $xc = null; |
||
59 | |||
60 | /** |
||
61 | * @var mixed |
||
62 | */ |
||
63 | private $pc = null; |
||
64 | |||
65 | /** |
||
66 | * @var mixed |
||
67 | */ |
||
68 | private $helper = null; |
||
69 | |||
70 | |||
71 | /** |
||
72 | * @public function constructor |
||
73 | * @param null |
||
74 | */ |
||
75 | public function __construct() |
||
76 | { |
||
77 | $this->helper = Modulebuilder\Helper::getInstance(); |
||
78 | $this->cf = Modulebuilder\Files\CreateFile::getInstance(); |
||
79 | $this->xc = Modulebuilder\Files\CreateXoopsCode::getInstance(); |
||
80 | $this->pc = Modulebuilder\Files\CreatePhpCode::getInstance(); |
||
81 | $this->tf = Modulebuilder\Files\CreateTableFields::getInstance(); |
||
82 | $this->uxc = Modulebuilder\Files\User\UserXoopsCode::getInstance(); |
||
83 | $this->cxc = Modulebuilder\Files\Classes\ClassXoopsCode::getInstance(); |
||
84 | } |
||
85 | |||
86 | /** |
||
87 | * @static function getInstance |
||
88 | * @param null |
||
89 | * |
||
90 | * @return ClassFormElements |
||
91 | */ |
||
92 | public static function getInstance() |
||
93 | { |
||
94 | static $instance = false; |
||
95 | if (!$instance) { |
||
96 | $instance = new self(); |
||
97 | } |
||
98 | |||
99 | return $instance; |
||
100 | } |
||
101 | |||
102 | /** |
||
103 | * @public function initForm |
||
104 | * |
||
105 | * @param $module |
||
106 | * @param $table |
||
107 | */ |
||
108 | public function initForm($module, $table) |
||
109 | { |
||
110 | $this->setModule($module); |
||
111 | $this->setTable($table); |
||
112 | } |
||
113 | |||
114 | /** |
||
115 | * @private function getXoopsFormText |
||
116 | * |
||
117 | * @param $language |
||
118 | * @param $fieldName |
||
119 | * @param $fieldDefault |
||
120 | * @param string $required |
||
121 | * @return string |
||
122 | */ |
||
123 | private function getXoopsFormText($language, $fieldName, $fieldDefault, $required = 'false') |
||
124 | { |
||
125 | $ccFieldName = $this->cf->getCamelCase($fieldName, false, true); |
||
126 | if ('' != $fieldDefault) { |
||
127 | $ret = $this->pc->getPhpCodeCommentLine('Form Text', $ccFieldName, "\t\t"); |
||
128 | $ret .= $this->pc->getPhpCodeTernaryOperator($ccFieldName, '$this->isNew()', "'{$fieldDefault}'", "\$this->getVar('{$fieldName}')", "\t\t"); |
||
129 | $formText = $this->cxc->getClassXoopsFormText('', $language, $fieldName, 20, 150, $ccFieldName, true); |
||
130 | $ret .= $this->cxc->getClassAddElement('form', $formText . $required); |
||
131 | } else { |
||
132 | $ret = $this->pc->getPhpCodeCommentLine('Form Text', $ccFieldName, "\t\t"); |
||
133 | $formText = $this->cxc->getClassXoopsFormText('', $language, $fieldName, 50, 255, "this->getVar('{$fieldName}')", true); |
||
134 | $ret .= $this->cxc->getClassAddElement('form', $formText . $required); |
||
135 | } |
||
136 | |||
137 | return $ret; |
||
138 | } |
||
139 | |||
140 | /** |
||
141 | * @private function getXoopsFormText |
||
142 | * |
||
143 | * @param $language |
||
144 | * @param $fieldName |
||
145 | * @param $required |
||
146 | * |
||
147 | * @return string |
||
148 | */ |
||
149 | private function getXoopsFormTextArea($language, $fieldName, $required = 'false') |
||
150 | { |
||
151 | $ccFieldName = $this->cf->getCamelCase($fieldName, false, true); |
||
152 | $ret = $this->pc->getPhpCodeCommentLine('Form Editor', 'TextArea ' . $ccFieldName, "\t\t"); |
||
153 | $formTextArea = $this->cxc->getClassXoopsFormTextArea('', $language, $fieldName, 4, 47, true); |
||
154 | $ret .= $this->cxc->getClassAddElement('form', $formTextArea . $required); |
||
155 | |||
156 | return $ret; |
||
157 | } |
||
158 | |||
159 | /** |
||
160 | * @private function getXoopsFormDhtmlTextArea |
||
161 | * |
||
162 | * @param $language |
||
163 | * @param $fieldName |
||
164 | * @param $required |
||
165 | * |
||
166 | * @return string |
||
167 | */ |
||
168 | private function getXoopsFormDhtmlTextArea($language, $fieldName, $required = 'false') |
||
169 | { |
||
170 | $ccFieldName = $this->cf->getCamelCase($fieldName, false, true); |
||
171 | $ret = $this->pc->getPhpCodeCommentLine('Form Editor', 'DhtmlTextArea ' . $ccFieldName, "\t\t"); |
||
172 | $ret .= $this->pc->getPhpCodeArray('editorConfigs', null, false, "\t\t"); |
||
173 | $getConfig = $this->xc->getXcGetConfig('editor_admin'); |
||
174 | $contIf = $this->xc->getXcEqualsOperator("\$editor", $getConfig, null, "\t\t\t"); |
||
175 | $getConfig = $this->xc->getXcGetConfig('editor_user'); |
||
176 | $contElse = $this->xc->getXcEqualsOperator("\$editor", $getConfig, null, "\t\t\t"); |
||
177 | $ret .= $this->pc->getPhpCodeConditions('$isAdmin','','', $contIf, $contElse, "\t\t"); |
||
178 | |||
179 | |||
180 | $configs = [ |
||
181 | 'name' => "'{$fieldName}'", |
||
182 | 'value' => "\$this->getVar('{$fieldName}', 'e')", |
||
183 | 'rows' => 5, |
||
184 | 'cols' => 40, |
||
185 | 'width' => "'100%'", |
||
186 | 'height' => "'400px'", |
||
187 | 'editor' => '$editor', |
||
188 | ]; |
||
189 | foreach ($configs as $c => $d) { |
||
190 | $ret .= $this->xc->getXcEqualsOperator("\$editorConfigs['{$c}']", $d, null, "\t\t"); |
||
191 | } |
||
192 | $formEditor = $this->cxc->getClassXoopsFormEditor('', $language, $fieldName, 'editorConfigs', true); |
||
193 | $ret .= $this->cxc->getClassAddElement('form', $formEditor . $required); |
||
194 | |||
195 | return $ret; |
||
196 | } |
||
197 | |||
198 | /** |
||
199 | * @private function getXoopsFormCheckBox |
||
200 | * |
||
201 | * @param $language |
||
202 | * @param $tableSoleName |
||
203 | * @param $fieldName |
||
204 | * @param $fieldElementId |
||
205 | * @param string $required |
||
206 | * @return string |
||
207 | */ |
||
208 | private function getXoopsFormCheckBox($language, $tableSoleName, $fieldName, $fieldElementId, $required = 'false') |
||
209 | { |
||
210 | $stuTableSoleName = \mb_strtoupper($tableSoleName); |
||
211 | $ucfFieldName = $this->cf->getCamelCase($fieldName, true); |
||
212 | $ccFieldName = $this->cf->getCamelCase($fieldName, false, true); |
||
213 | $t = "\t\t"; |
||
214 | if (\in_array(5, $fieldElementId) > 1) { |
||
215 | $ret = $this->pc->getPhpCodeCommentLine('Form Check Box', 'List Options ' . $ccFieldName, $t); |
||
216 | $ret .= $this->xc->getXcEqualsOperator('$checkOption', '$this->getOptions()'); |
||
217 | $foreach = $this->cxc->getClassXoopsFormCheckBox('check' . $ucfFieldName, '<hr />', $tableSoleName . '_option', '$checkOption', false, $t . "\t"); |
||
218 | $foreach .= $this->cxc->getClassSetDescription('check' . $ucfFieldName, "{$language}{$stuTableSoleName}_OPTIONS_DESC", $t . "\t"); |
||
219 | $foreach .= $this->cxc->getClassAddOption('check' . $ucfFieldName, "\$option, {$language}{$stuTableSoleName}_ . strtoupper(\$option)", $t . "\t"); |
||
220 | $ret .= $this->pc->getPhpCodeForeach("{$tableSoleName}All", false, false, 'option', $foreach, $t); |
||
221 | $intElem = "\$check{$ucfFieldName}{$required}"; |
||
222 | $ret .= $this->cxc->getClassAddElement('form', $intElem, $t); |
||
223 | } else { |
||
224 | $ret = $this->pc->getPhpCodeCommentLine('Form Check Box', $ccFieldName, $t); |
||
225 | $ret .= $this->pc->getPhpCodeTernaryOperator($ccFieldName, '$this->isNew()', 0, "\$this->getVar('{$fieldName}')", $t); |
||
226 | $ret .= $this->cxc->getClassXoopsFormCheckBox('check' . $ucfFieldName, $language, $fieldName, "\${$ccFieldName}", false, $t); |
||
227 | $option = "1, {$language}"; |
||
228 | $ret .= $this->cxc->getClassAddOption('check' . $ucfFieldName, $option, $t); |
||
229 | $intElem = "\$check{$ucfFieldName}{$required}"; |
||
230 | $ret .= $this->cxc->getClassAddElement('form', $intElem, $t); |
||
231 | } |
||
232 | |||
233 | return $ret; |
||
234 | } |
||
235 | |||
236 | /** |
||
237 | * @private function getXoopsFormHidden |
||
238 | * |
||
239 | * @param $fieldName |
||
240 | * |
||
241 | * @return string |
||
242 | */ |
||
243 | private function getXoopsFormHidden($fieldName) |
||
244 | { |
||
245 | $ccFieldName = $this->cf->getCamelCase($fieldName, false, true); |
||
246 | $ret = $this->pc->getPhpCodeCommentLine('Form Hidden', $ccFieldName, "\t\t"); |
||
247 | $formHidden = $this->cxc->getClassXoopsFormHidden('', $fieldName, $fieldName, true, true); |
||
248 | $ret .= $this->cxc->getClassAddElement('form', $formHidden); |
||
249 | |||
250 | return $ret; |
||
251 | } |
||
252 | |||
253 | /** |
||
254 | * @private function getXoopsFormImageList |
||
255 | * provides listbox for select image, a preview of image and an upload field |
||
256 | * |
||
257 | * @param $language |
||
258 | * @param $moduleDirname |
||
259 | * @param $fieldName |
||
260 | * @param $required |
||
261 | * |
||
262 | * @return string |
||
263 | */ |
||
264 | private function getXoopsFormImageList($language, $moduleDirname, $fieldName, $required = 'false') |
||
265 | { |
||
266 | $ucfFieldName = $this->cf->getCamelCase($fieldName, true); |
||
267 | $ccFieldName = $this->cf->getCamelCase($fieldName, false, true); |
||
268 | $languageShort = \substr($language, 0, 5) . \mb_strtoupper($moduleDirname) . '_'; |
||
269 | $t = "\t\t"; |
||
270 | $ret = $this->pc->getPhpCodeCommentLine('Form Frameworks Images', 'Files ' . $ccFieldName, $t); |
||
271 | $ret .= $this->pc->getPhpCodeCommentLine('Form Frameworks Images', $ccFieldName .': Select Uploaded Image', $t); |
||
272 | $ret .= $this->xc->getXcEqualsOperator('$get' . $ucfFieldName, "\$this->getVar('{$fieldName}')", null, $t); |
||
273 | $ret .= $this->pc->getPhpCodeTernaryOperator($ccFieldName, '$get' . $ucfFieldName, '', "'blank.gif'", $t); |
||
274 | $ret .= $this->xc->getXcEqualsOperator('$imageDirectory', "'/Frameworks/moduleclasses/icons/32'", null, $t); |
||
275 | $ret .= $this->cxc->getClassXoopsFormElementTray('imageTray', $language, '<br>', $t); |
||
276 | $sprintf = $this->pc->getPhpCodeSprintf($language . '_UPLOADS', '".{$imageDirectory}/"'); |
||
277 | $ret .= $this->cxc->getClassXoopsFormSelect('imageSelect', $sprintf, $fieldName, $ccFieldName, 5, 'false', false, $t); |
||
278 | $ret .= $this->xc->getXcXoopsListImgListArray('imageArray', '\XOOPS_ROOT_PATH . $imageDirectory', $t); |
||
279 | $contForeach = $this->cxc->getClassAddOption('imageSelect', '($image1), $image1', $t . "\t"); |
||
280 | $ret .= $this->pc->getPhpCodeForeach('imageArray', false, false, 'image1', $contForeach, $t); |
||
281 | $setExtraParam = "\"onchange='showImgSelected(\\\"imglabel_{$fieldName}\\\", \\\"{$fieldName}\\\", \\\"\" . \$imageDirectory . '\", \"\", \"' . \XOOPS_URL . \"\\\")'\""; |
||
282 | $ret .= $this->cxc->getClassSetExtra('imageSelect', $setExtraParam, $t); |
||
283 | $ret .= $this->cxc->getClassAddElement('imageTray', '$imageSelect, false', $t); |
||
284 | $paramLabel = "\"<br><img src='\" . \XOOPS_URL . '/' . \$imageDirectory . '/' . \${$ccFieldName} . \"' id='imglabel_{$fieldName}' alt='' style='max-width:100px' >\""; |
||
285 | $xoopsFormLabel = $this->cxc->getClassXoopsFormLabel('', "''", $paramLabel, true, ''); |
||
286 | $ret .= $this->cxc->getClassAddElement('imageTray', $xoopsFormLabel, $t); |
||
287 | $ret .= $this->pc->getPhpCodeCommentLine('Form Frameworks Images', $ccFieldName .': Upload new image', $t); |
||
288 | $ret .= $this->cxc->getClassXoopsFormElementTray('fileSelectTray', "''", '<br>', $t); |
||
289 | $getConfig = $this->xc->getXcGetConfig('maxsize_image'); |
||
290 | $xoopsFormFile = $this->cxc->getClassXoopsFormFile('', $languageShort . 'FORM_UPLOAD_NEW', $fieldName, $getConfig, true, ''); |
||
291 | $ret .= $this->cxc->getClassAddElement('fileSelectTray', $xoopsFormFile, $t); |
||
292 | $xoopsFormLabel1 = $this->cxc->getClassXoopsFormLabel('', "''", null, true, $t); |
||
293 | $ret .= $this->cxc->getClassAddElement('fileSelectTray', $xoopsFormLabel1, $t); |
||
294 | $ret .= $this->cxc->getClassAddElement('imageTray', '$fileSelectTray', $t); |
||
295 | $ret .= $this->cxc->getClassAddElement('form', "\$imageTray{$required}", $t); |
||
296 | |||
297 | return $ret; |
||
298 | } |
||
299 | |||
300 | /** |
||
301 | * @private function getXoopsFormSelectFile |
||
302 | * provides listbox for select file and an upload field |
||
303 | * |
||
304 | * @param $language |
||
305 | * @param $moduleDirname |
||
306 | * @param $tableName |
||
307 | * @param $fieldName |
||
308 | * @param $required |
||
309 | * |
||
310 | * @return string |
||
311 | */ |
||
312 | private function getXoopsFormSelectFile($language, $moduleDirname, $tableName, $fieldName, $required = 'false') |
||
313 | { |
||
314 | $ucfFieldName = $this->cf->getCamelCase($fieldName, true); |
||
315 | $ccFieldName = $this->cf->getCamelCase($fieldName, false, true); |
||
316 | $languageShort = \substr($language, 0, 5) . \mb_strtoupper($moduleDirname) . '_'; |
||
317 | $t = "\t\t"; |
||
318 | $ret = $this->pc->getPhpCodeCommentLine('Form File', $ccFieldName, $t); |
||
319 | $ret .= $this->pc->getPhpCodeCommentLine("Form File {$ccFieldName}:", 'Select Uploaded File ', $t); |
||
320 | $ret .= $this->xc->getXcEqualsOperator('$get' . $ucfFieldName, "\$this->getVar('{$fieldName}')", null, $t); |
||
321 | $ret .= $this->pc->getPhpCodeTernaryOperator($ccFieldName, '$get' . $ucfFieldName, '', "'blank.gif'", $t); |
||
322 | $ret .= $this->xc->getXcEqualsOperator('$fileDirectory', "'/uploads/{$moduleDirname}/files/{$tableName}'", null, $t); |
||
323 | $ret .= $this->cxc->getClassXoopsFormElementTray('fileTray', $language, '<br>', $t); |
||
324 | $sprintf = $this->pc->getPhpCodeSprintf($language . '_UPLOADS', '".{$fileDirectory}/"'); |
||
325 | $ret .= $this->cxc->getClassXoopsFormSelect('fileSelect', $sprintf, $fieldName, $ccFieldName, 5, 'false', false, $t); |
||
326 | $ret .= $this->xc->getXcXoopsListImgListArray('fileArray', '\XOOPS_ROOT_PATH . $fileDirectory', $t); |
||
327 | $contForeach = $this->cxc->getClassAddOption('fileSelect', '($file1), $file1', $t . "\t"); |
||
328 | $ret .= $this->pc->getPhpCodeForeach('fileArray', false, false, 'file1', $contForeach, $t); |
||
329 | //TODO: make preview for images or show "no preview possible" |
||
330 | //$setExtraParam = "\"onchange='showImgSelected(\\\"imglabel_{$fieldName}\\\", \\\"{$fieldName}\\\", \\\"\" . \$imageDirectory . '\", \"\", \"' . \XOOPS_URL . \"\\\")'\""; |
||
331 | //$ret .= $cc->getClassSetExtra('fileSelect', $setExtraParam, $t); |
||
332 | $ret .= $this->cxc->getClassAddElement('fileTray', '$fileSelect, false', $t); |
||
333 | //$paramLabel = "\"<br><img src='\" . \XOOPS_URL . '/' . \$imageDirectory . '/' . \${$ccFieldName} . \"' id='imglabel_{$fieldName}' alt='' style='max-width:100px' />\""; |
||
334 | //$xoopsFormLabel = $cc->getClassXoopsFormLabel('', "''", $paramLabel, true, ''); |
||
335 | //$ret .= $cc->getClassAddElement('fileTray', $xoopsFormLabel, $t); |
||
336 | $ret .= $this->pc->getPhpCodeCommentLine("Form File {$ccFieldName}:", 'Upload new file', $t); |
||
337 | $getConfigSize = $this->xc->getXcGetConfig('maxsize_file'); |
||
338 | $contIf = $this->xc->getXcEqualsOperator('$maxsize', $getConfigSize,'', "\t\t\t"); |
||
339 | $xoopsFormFile = $this->cxc->getClassXoopsFormFile('fileTray', "'<br>' . " . $languageShort . 'FORM_UPLOAD_NEW', $fieldName, '$maxsize', true, ''); |
||
340 | $contIf .= $this->cxc->getClassAddElement('fileTray', $xoopsFormFile, $t . "\t"); |
||
341 | $configText = "(\$maxsize / 1048576) . ' ' . " . $languageShort . 'FORM_UPLOAD_SIZE_MB'; |
||
342 | $labelInfo1 = $this->cxc->getClassXoopsFormLabel('', $languageShort . 'FORM_UPLOAD_SIZE', $configText, true, ''); |
||
343 | $contIf .= $this->cxc->getClassAddElement('fileTray', $labelInfo1, $t . "\t"); |
||
344 | $formHidden = $this->cxc->getClassXoopsFormHidden('', $fieldName, $ccFieldName, true, true, $t, true); |
||
345 | $contElse = $this->cxc->getClassAddElement('fileTray', $formHidden, $t . "\t"); |
||
346 | $ret .= $this->pc->getPhpCodeConditions('$permissionUpload', null, null, $contIf, $contElse, "\t\t"); |
||
347 | $ret .= $this->cxc->getClassAddElement('form', "\$fileTray{$required}", $t); |
||
348 | |||
349 | return $ret; |
||
350 | } |
||
351 | |||
352 | /** |
||
353 | * @private function getXoopsFormUrlFile |
||
354 | * provides textbox with last uploaded url and an upload field |
||
355 | * |
||
356 | * @param $language |
||
357 | * @param $moduleDirname |
||
358 | * @param $fieldName |
||
359 | * @param $fieldDefault |
||
360 | * @param $required |
||
361 | * |
||
362 | * @return string |
||
363 | */ |
||
364 | private function getXoopsFormUrlFile($language, $moduleDirname, $fieldName, $fieldDefault, $required = 'false') |
||
365 | { |
||
366 | $ccFieldName = $this->cf->getCamelCase($fieldName, false, true); |
||
367 | $languageShort = \substr($language, 0, 5) . \mb_strtoupper($moduleDirname) . '_'; |
||
368 | $t = "\t\t"; |
||
369 | $ret = $this->pc->getPhpCodeCommentLine('Form Url', 'Text File ' . $ccFieldName, $t); |
||
370 | $ret .= $this->cxc->getClassXoopsFormElementTray('formUrlFile', $language, '<br>', $t); |
||
371 | $ret .= $this->pc->getPhpCodeTernaryOperator('formUrl', '$this->isNew()', "'{$fieldDefault}'", "\$this->getVar('{$fieldName}')", $t); |
||
372 | $ret .= $this->cxc->getClassXoopsFormText('formText', $language . '_UPLOADS', $fieldName, 75, 255, 'formUrl', false, $t); |
||
373 | $ret .= $this->cxc->getClassAddElement('formUrlFile', '$formText' . $required, $t); |
||
374 | $getConfig = $this->xc->getXcGetConfig('maxsize_file'); |
||
375 | $xoopsFormFile = $this->cxc->getClassXoopsFormFile('', $languageShort . 'FORM_UPLOAD', $fieldName, $getConfig, true, ''); |
||
376 | $ret .= $this->cxc->getClassAddElement('formUrlFile', $xoopsFormFile . $required, $t); |
||
377 | $ret .= $this->cxc->getClassAddElement('form', '$formUrlFile', $t); |
||
378 | |||
379 | return $ret; |
||
380 | } |
||
381 | |||
382 | /** |
||
383 | * @private function getXoopsFormUploadImage |
||
384 | * provides listbox for select image, a preview of image and an upload field |
||
385 | * |
||
386 | * @param $language |
||
387 | * @param $moduleDirname |
||
388 | * @param $tableName |
||
389 | * @param $fieldName |
||
390 | * @param string $required |
||
391 | * @return string |
||
392 | */ |
||
393 | private function getXoopsFormUploadImage($language, $moduleDirname, $tableName, $fieldName, $required = 'false') |
||
436 | } |
||
437 | |||
438 | /** |
||
439 | * @private function getXoopsFormUploadFile |
||
440 | * provides label with last uploaded file and an upload field |
||
441 | * |
||
442 | * @param $language |
||
443 | * @param $moduleDirname |
||
444 | * @param $tableName |
||
445 | * @param $fieldName |
||
446 | * |
||
447 | * @param string $required |
||
448 | * @return string |
||
449 | */ |
||
450 | private function getXoopsFormUploadFile($language, $moduleDirname, $tableName, $fieldName, $required = 'false') |
||
477 | } |
||
478 | |||
479 | /** |
||
480 | * @private function getXoopsFormColorPicker |
||
481 | * |
||
482 | * @param $language |
||
483 | * @param $fieldName |
||
484 | * |
||
485 | * @param string $required |
||
486 | * @return string |
||
487 | */ |
||
488 | private function getXoopsFormColorPicker($language, $fieldName, $required = 'false') |
||
498 | } |
||
499 | |||
500 | /** |
||
501 | * @private function getXoopsFormSelectBox |
||
502 | * |
||
503 | * @param $language |
||
504 | * @param $tableName |
||
505 | * @param $fieldName |
||
506 | * @param $required |
||
507 | * |
||
508 | * @return string |
||
509 | */ |
||
510 | private function getXoopsFormSelectBox($language, $tableName, $fieldName, $required = 'false') |
||
524 | } |
||
525 | |||
526 | /** |
||
527 | * @private function getXoopsFormSelectUser |
||
528 | * |
||
529 | * @param $language |
||
530 | * @param $fieldName |
||
531 | * @param string $required |
||
532 | * @return string |
||
533 | */ |
||
534 | private function getXoopsFormSelectUser($language, $fieldName, $required = 'false') |
||
535 | { |
||
536 | $ccFieldName = $this->cf->getCamelCase($fieldName, false, true); |
||
537 | $t = "\t\t"; |
||
538 | $ret = $this->pc->getPhpCodeCommentLine('Form Select', 'User ' . $ccFieldName, $t); |
||
539 | $ret .= $this->pc->getPhpCodeTernaryOperator($ccFieldName, '$this->isNew()', '$GLOBALS[\'xoopsUser\']->uid()', "\$this->getVar('{$fieldName}')", $t); |
||
540 | $xoopsSelectUser = $this->cxc->getClassXoopsFormSelectUser('', $language, $fieldName, 'false', '$' . $ccFieldName, true, $t); |
||
541 | $ret .= $this->cxc->getClassAddElement('form', $xoopsSelectUser . $required, $t); |
||
542 | |||
543 | return $ret; |
||
544 | } |
||
545 | |||
546 | /** |
||
547 | * @private function getXoopsFormRadioYN |
||
548 | * |
||
549 | * @param $language |
||
550 | * @param $fieldName |
||
551 | * @param $required |
||
552 | * |
||
553 | * @return string |
||
554 | */ |
||
555 | private function getXoopsFormRadioYN($language, $fieldName, $required = 'false') |
||
556 | { |
||
557 | $ccFieldName = $this->cf->getCamelCase($fieldName, false, true); |
||
558 | $t = "\t\t"; |
||
559 | $ret = $this->pc->getPhpCodeCommentLine('Form Radio', 'Yes/No ' . $ccFieldName, $t); |
||
560 | $ret .= $this->pc->getPhpCodeTernaryOperator($ccFieldName, '$this->isNew()', 0, "\$this->getVar('{$fieldName}')", $t); |
||
561 | $xoopsRadioYN = $this->cxc->getClassXoopsFormRadioYN('', $language, $fieldName, $ccFieldName, true, $t); |
||
562 | $ret .= $this->cxc->getClassAddElement('form', $xoopsRadioYN . $required, $t); |
||
563 | |||
564 | return $ret; |
||
565 | } |
||
566 | |||
567 | /** |
||
568 | * @private function getXoopsFormTextDateSelect |
||
569 | * |
||
570 | * @param $language |
||
571 | * @param $fieldName |
||
572 | * @param $required |
||
573 | * |
||
574 | * @return string |
||
575 | */ |
||
576 | private function getXoopsFormTextDateSelect($language, $fieldName, $required = 'false') |
||
577 | { |
||
578 | $t = "\t\t"; |
||
579 | $ccFieldName = $this->cf->getCamelCase($fieldName, false, true); |
||
580 | $ret = $this->pc->getPhpCodeCommentLine('Form Text', 'Date Select ' . $ccFieldName, $t); |
||
581 | $ret .= $this->pc->getPhpCodeTernaryOperator($ccFieldName, '$this->isNew()', '\time()', "\$this->getVar('{$fieldName}')", $t); |
||
582 | $xoopsTextDateSelect = $this->cxc->getClassXoopsFormTextDateSelect('', $language, $fieldName, $fieldName, $ccFieldName, true, $t); |
||
583 | $ret .= $this->cxc->getClassAddElement('form', $xoopsTextDateSelect . $required, $t); |
||
584 | |||
585 | return $ret; |
||
586 | } |
||
587 | |||
588 | /** |
||
589 | * @private function getXoopsFormDateTime |
||
590 | * |
||
591 | * @param $language |
||
592 | * @param $fieldName |
||
593 | * @param $required |
||
594 | * |
||
595 | * @return string |
||
596 | */ |
||
597 | private function getXoopsFormDateTime($language, $fieldName, $required = 'false') |
||
598 | { |
||
599 | $t = "\t\t"; |
||
600 | $ccFieldName = $this->cf->getCamelCase($fieldName, false, true); |
||
601 | $ret = $this->pc->getPhpCodeCommentLine('Form Text', 'Date Select ' . $ccFieldName, $t); |
||
602 | $ret .= $this->pc->getPhpCodeTernaryOperator($ccFieldName, '$this->isNew()', '\time()', "\$this->getVar('{$fieldName}')", $t); |
||
603 | $xoopsTextDateSelect = $this->cxc->getClassXoopsFormDateTime('', $language, $fieldName, $fieldName, $ccFieldName, true, $t); |
||
604 | $ret .= $this->cxc->getClassAddElement('form', $xoopsTextDateSelect . $required, $t); |
||
605 | |||
606 | return $ret; |
||
607 | } |
||
608 | |||
609 | /** |
||
610 | * @private function getXoopsFormSelectStatus |
||
611 | * |
||
612 | * @param $language |
||
613 | * @param $moduleDirname |
||
614 | * @param $fieldName |
||
615 | * @param $tablePermissions |
||
616 | * @param string $required |
||
617 | * |
||
618 | * @return string |
||
619 | */ |
||
620 | private function getXoopsFormSelectStatus($language, $moduleDirname, $fieldName, $tablePermissions, $required = 'false') |
||
621 | { |
||
622 | $ccFieldName = $this->cf->getCamelCase($fieldName, false, true); |
||
623 | $languageShort = \substr($language, 0, 5) . \mb_strtoupper($moduleDirname) . '_'; |
||
624 | $t = "\t\t"; |
||
625 | $ret = $this->pc->getPhpCodeCommentLine('Form Select', 'Status ' . $ccFieldName, $t); |
||
626 | if (1 == $tablePermissions) { |
||
627 | $ret .= $this->xc->getXcHandlerLine('permissions', $t); |
||
628 | } |
||
629 | $ret .= $this->cxc->getClassXoopsFormSelect($ccFieldName . 'Select', $language, $fieldName, "this->getVar('{$fieldName}')", null, '', false, $t); |
||
630 | $ret .= $this->cxc->getClassAddOption($ccFieldName . 'Select', $this->xc->getXcGetConstants('STATUS_NONE') . ", {$languageShort}STATUS_NONE", $t); |
||
631 | $ret .= $this->cxc->getClassAddOption($ccFieldName . 'Select', $this->xc->getXcGetConstants('STATUS_OFFLINE') . ", {$languageShort}STATUS_OFFLINE", $t); |
||
632 | $ret .= $this->cxc->getClassAddOption($ccFieldName . 'Select', $this->xc->getXcGetConstants('STATUS_SUBMITTED') . ", {$languageShort}STATUS_SUBMITTED", $t); |
||
633 | if (1 == $tablePermissions) { |
||
634 | $contIf = $this->cxc->getClassAddOption($ccFieldName . 'Select', $this->xc->getXcGetConstants('STATUS_APPROVED') . ", {$languageShort}STATUS_APPROVED", $t . "\t"); |
||
635 | $ret .= $this->pc->getPhpCodeConditions('$permissionsHandler->getPermGlobalApprove()', '', '', $contIf, false, $t); |
||
636 | } |
||
637 | $ret .= $this->cxc->getClassAddOption($ccFieldName . 'Select', $this->xc->getXcGetConstants('STATUS_BROKEN') . ", {$languageShort}STATUS_BROKEN", $t); |
||
638 | $ret .= $this->cxc->getClassAddElement('form', "\${$ccFieldName}Select{$required}", $t); |
||
639 | |||
640 | return $ret; |
||
641 | } |
||
642 | |||
643 | /** |
||
644 | * @private function getXoopsFormPassword |
||
645 | * |
||
646 | * @param $language |
||
647 | * @param $fieldName |
||
648 | * @param $required |
||
649 | * |
||
650 | * @return string |
||
651 | */ |
||
652 | private function getXoopsFormPassword($language, $fieldName, $required = 'false') |
||
653 | { |
||
654 | $t = "\t\t"; |
||
655 | $ccFieldName = $this->cf->getCamelCase($fieldName, false, true); |
||
656 | $ret = $this->pc->getPhpCodeCommentLine('Form Text', 'Enter Password ' . $ccFieldName, $t); |
||
657 | $xoopsPassword = $this->cxc->getClassXoopsFormPassword('', $language, $fieldName, 10, 32, true, $t); |
||
658 | $ret .= $this->cxc->getClassAddElement('form', $xoopsPassword . $required, $t); |
||
659 | |||
660 | return $ret; |
||
661 | } |
||
662 | |||
663 | /** |
||
664 | * @private function getXoopsFormSelectCountry |
||
665 | * |
||
666 | * @param $language |
||
667 | * @param $fieldName |
||
668 | * @param string $required |
||
669 | * |
||
670 | * @return string |
||
671 | */ |
||
672 | private function getXoopsFormSelectCountry($language, $fieldName, $required = 'false') |
||
684 | } |
||
685 | |||
686 | /** |
||
687 | * @private function getXoopsFormSelectLang |
||
688 | * |
||
689 | * @param $language |
||
690 | * @param $fieldName |
||
691 | * @param string $required |
||
692 | * |
||
693 | * @return string |
||
694 | */ |
||
695 | private function getXoopsFormSelectLang($language, $fieldName, $required = 'false') |
||
696 | { |
||
697 | $ccFieldName = $this->cf->getCamelCase($fieldName, false, true); |
||
698 | $t = "\t\t"; |
||
699 | $ret = $this->pc->getPhpCodeCommentLine('Form Select', 'Lang ' . $ccFieldName, $t); |
||
700 | $ret .= $this->cxc->getClassXoopsFormSelect($ccFieldName . 'Select', $language, $fieldName, "this->getVar('{$fieldName}')", null, '', false, $t); |
||
701 | $ret .= $this->cxc->getClassAddOption($ccFieldName . 'Select', "'', \_NONE", $t); |
||
702 | $ret .= $this->xc->getXcXoopsListLangList('langArray', $t); |
||
703 | $ret .= $this->cxc->getClassAddOptionArray($ccFieldName . 'Select', '$langArray', $t); |
||
704 | $ret .= $this->cxc->getClassAddElement('form', "\${$ccFieldName}Select{$required}", $t); |
||
705 | |||
706 | return $ret; |
||
707 | } |
||
708 | |||
709 | /** |
||
710 | * @private function getXoopsFormRadio |
||
711 | * |
||
712 | * @param $language |
||
713 | * @param $moduleDirname |
||
714 | * @param $fieldName |
||
715 | * @param string $required |
||
716 | * |
||
717 | * @return string |
||
718 | */ |
||
719 | private function getXoopsFormRadio($language, $moduleDirname, $fieldName, $required = 'false') |
||
720 | { |
||
721 | $ccFieldName = $this->cf->getCamelCase($fieldName, false, true); |
||
722 | $languageShort = \substr($language, 0, 5) . \mb_strtoupper($moduleDirname) . '_'; |
||
723 | $t = "\t\t"; |
||
724 | $ret = $this->pc->getPhpCodeCommentLine('Form Radio', $ccFieldName, $t); |
||
725 | $ret .= $this->pc->getPhpCodeTernaryOperator($ccFieldName, '$this->isNew()', '0', "\$this->getVar('{$fieldName}')", $t); |
||
726 | $ret .= $this->cxc->getClassXoopsFormRadio($ccFieldName . 'Select', $language, $fieldName, "{$ccFieldName}", false, $t); |
||
727 | $ret .= $this->cxc->getClassAddOption($ccFieldName . 'Select', "'0', \_NONE", $t); |
||
728 | $ret .= $this->cxc->getClassAddOption($ccFieldName . 'Select', "'1', {$languageShort}LIST_1", $t); |
||
729 | $ret .= $this->cxc->getClassAddOption($ccFieldName . 'Select', "'2', {$languageShort}LIST_2", $t); |
||
730 | $ret .= $this->cxc->getClassAddOption($ccFieldName . 'Select', "'3', {$languageShort}LIST_3", $t); |
||
731 | $ret .= $this->cxc->getClassAddElement('form', "\${$ccFieldName}Select{$required}", $t); |
||
732 | |||
733 | return $ret; |
||
734 | } |
||
735 | |||
736 | /** |
||
737 | * @private function getXoopsFormSelectCombo |
||
738 | * |
||
739 | * @param $language |
||
740 | * @param $moduleDirname |
||
741 | * @param $tableName |
||
742 | * @param $fieldName |
||
743 | * @param string $required |
||
744 | * |
||
745 | * @return string |
||
746 | */ |
||
747 | private function getXoopsFormSelectCombo($language, $moduleDirname, $tableName, $fieldName, $required = 'false') |
||
748 | { |
||
749 | $ucfTableName = \ucfirst($tableName); |
||
750 | $ccFieldName = $this->cf->getCamelCase($fieldName, false, true); |
||
751 | $languageShort = \substr($language, 0, 5) . \mb_strtoupper($moduleDirname) . '_'; |
||
752 | $t = "\t\t"; |
||
753 | $ret = $this->pc->getPhpCodeCommentLine($ucfTableName, 'Handler', $t); |
||
754 | $ret .= $this->xc->getXcHandlerLine($tableName, $t); |
||
755 | $ret .= $this->pc->getPhpCodeCommentLine('Form', 'Select ' . $ccFieldName, $t); |
||
756 | $ret .= $this->cxc->getClassXoopsFormSelect($ccFieldName . 'Select', $language, $fieldName, "this->getVar('{$fieldName}')", '5', '', false, $t); |
||
757 | $ret .= $this->cxc->getClassAddOption($ccFieldName . 'Select', "'0', \_NONE", $t); |
||
758 | $ret .= $this->cxc->getClassAddOption($ccFieldName . 'Select', "'1', {$languageShort}LIST_1", $t); |
||
759 | $ret .= $this->cxc->getClassAddOption($ccFieldName . 'Select', "'2', {$languageShort}LIST_2", $t); |
||
760 | $ret .= $this->cxc->getClassAddOption($ccFieldName . 'Select', "'3', {$languageShort}LIST_3", $t); |
||
761 | $ret .= $this->cxc->getClassAddElement('form', "\${$ccFieldName}Select{$required}", $t); |
||
762 | |||
763 | return $ret; |
||
764 | } |
||
765 | |||
766 | /** |
||
767 | * @private function getXoopsFormTable |
||
768 | * |
||
769 | * @param $language |
||
770 | * @param $fieldName |
||
771 | * @param $fieldElement |
||
772 | * @param $required |
||
773 | * |
||
774 | * @return string |
||
775 | */ |
||
776 | private function getXoopsFormTable($language,$fieldName, $fieldElement, $required = 'false') |
||
777 | { |
||
778 | $t = "\t\t"; |
||
779 | $ret = ''; |
||
780 | $fElement = $this->helper->getHandler('Fieldelements')->get($fieldElement); |
||
781 | $rpFieldelementName = \mb_strtolower(\str_replace('Table : ', '', $fElement->getVar('fieldelement_name'))); |
||
782 | $ret .= $this->pc->getPhpCodeCommentLine('Form Table', $rpFieldelementName, $t); |
||
783 | $ccFieldName = $this->cf->getCamelCase($fieldName, false, true); |
||
784 | $ret .= $this->xc->getXcHandlerLine($rpFieldelementName, $t); |
||
785 | $ret .= $this->cxc->getClassXoopsFormSelect($ccFieldName . 'Select', $language, $fieldName, "this->getVar('{$fieldName}')", null, '', false, $t); |
||
786 | $ret .= $this->cxc->getClassAddOptionArray($ccFieldName . 'Select', "\${$rpFieldelementName}Handler->getList()", $t); |
||
787 | $ret .= $this->cxc->getClassAddElement('form', "\${$ccFieldName}Select{$required}", $t); |
||
788 | |||
789 | return $ret; |
||
790 | } |
||
791 | |||
792 | /** |
||
793 | * @private function getXoopsFormTopic |
||
794 | * |
||
795 | * @param $language |
||
796 | * @param $topicTableName |
||
797 | * @param $fieldId |
||
798 | * @param $fieldPid |
||
799 | * @param $fieldMain |
||
800 | * @return string |
||
801 | */ |
||
802 | private function getXoopsFormTopic($language, $topicTableName, $fieldId, $fieldPid, $fieldMain) |
||
803 | { |
||
804 | $ucfTopicTableName = \ucfirst($topicTableName); |
||
805 | $stlTopicTableName = \mb_strtolower($topicTableName); |
||
806 | $ccFieldPid = $this->cf->getCamelCase($fieldPid, false, true); |
||
807 | $t = "\t\t"; |
||
808 | $ret = $this->pc->getPhpCodeCommentLine('Form Table', $ucfTopicTableName, $t); |
||
809 | $ret .= $this->xc->getXcHandlerLine($stlTopicTableName, $t); |
||
810 | $ret .= $this->xc->getXcCriteriaCompo('cr' . $ucfTopicTableName, $t); |
||
811 | $ret .= $this->xc->getXcHandlerCountClear($stlTopicTableName . 'Count', $stlTopicTableName, '$cr' . $ucfTopicTableName, $t); |
||
812 | $contIf = $this->pc->getPhpCodeIncludeDir('\XOOPS_ROOT_PATH', 'class/tree', true, false, 'require', $t . "\t"); |
||
813 | $contIf .= $this->xc->getXcHandlerAllClear($stlTopicTableName . 'All', $stlTopicTableName, '$cr' . $ucfTopicTableName, $t . "\t"); |
||
814 | $contIf .= $this->cxc->getClassXoopsObjectTree($stlTopicTableName . 'Tree', $stlTopicTableName . 'All', $fieldId, $fieldPid, $t . "\t"); |
||
815 | $contIf .= $this->cxc->getClassXoopsMakeSelBox($ccFieldPid, $stlTopicTableName . 'Tree', $fieldPid, $fieldMain, '--', $fieldPid, $t . "\t"); |
||
816 | $formLabel = $this->cxc->getClassXoopsFormLabel('', $language, "\${$ccFieldPid}", true, ''); |
||
817 | $contIf .= $this->cxc->getClassAddElement('form', $formLabel, $t . "\t"); |
||
818 | $ret .= $this->pc->getPhpCodeConditions("\${$stlTopicTableName}Count", null, null, $contIf, false, $t); |
||
819 | $ret .= $this->pc->getPhpCodeUnset('cr' . $ucfTopicTableName, $t); |
||
820 | |||
821 | return $ret; |
||
822 | } |
||
823 | |||
824 | /** |
||
825 | * @private function getXoopsFormTag |
||
826 | * |
||
827 | * @param $fieldId |
||
828 | * @param $required |
||
829 | * |
||
830 | * @return string |
||
831 | */ |
||
832 | private function getXoopsFormTag($fieldId, $required = 'false') |
||
833 | { |
||
834 | $t = "\t\t"; |
||
835 | $ret = $this->pc->getPhpCodeCommentLine('Use tag', 'module', $t); |
||
836 | $isDir = $this->pc->getPhpCodeIsDir("\XOOPS_ROOT_PATH . '/modules/tag'"); |
||
837 | $ret .= $this->pc->getPhpCodeTernaryOperator('dirTag', $isDir, 'true', 'false', $t); |
||
838 | $paramIf = '(' . $this->xc->getXcGetConfig('usetag') . ' == 1)'; |
||
839 | $condIf = $this->pc->getPhpCodeTernaryOperator('tagId', '$this->isNew()', '0', "\$this->getVar('{$fieldId}')", $t . "\t"); |
||
840 | $condIf .= $this->pc->getPhpCodeIncludeDir('\XOOPS_ROOT_PATH', 'modules/tag/include/formtag', true, false, $type = 'require', $t . "\t"); |
||
841 | $paramElem = $this->cxc->getClassXoopsFormTag('', 'tag', 60, 255, 'tagId', 0, true, ''); |
||
842 | $condIf .= $this->cxc->getClassAddElement('form', $paramElem . $required, $t . "\t"); |
||
843 | $ret .= $this->pc->getPhpCodeConditions($paramIf, ' && ', '$dirTag', $condIf, false, $t); |
||
844 | |||
845 | return $ret; |
||
846 | } |
||
847 | |||
848 | /** |
||
849 | * @private function getXoopsFormTextUuid |
||
850 | * |
||
851 | * @param $language |
||
852 | * @param $fieldName |
||
853 | * @param string $required |
||
854 | * @return string |
||
855 | */ |
||
856 | private function getXoopsFormTextUuid($language, $fieldName, $required = 'false') |
||
866 | } |
||
867 | |||
868 | /** |
||
869 | * @private function getXoopsFormTextIp |
||
870 | * |
||
871 | * @param $language |
||
872 | * @param $fieldName |
||
873 | * @param string $required |
||
874 | * @return string |
||
875 | */ |
||
876 | private function getXoopsFormTextIp($language, $fieldName, $required = 'false') |
||
877 | { |
||
878 | $ccFieldName = $this->cf->getCamelCase($fieldName, false, true); |
||
879 | |||
880 | $ret = $this->pc->getPhpCodeCommentLine('Form Text IP', $ccFieldName, "\t\t"); |
||
881 | $ret .= $this->xc->getXcEqualsOperator('$' . $ccFieldName, "\$_SERVER['REMOTE_ADDR']", null, "\t\t"); |
||
882 | $formText = $this->cxc->getClassXoopsFormText('', $language, $fieldName, 20, 150, $ccFieldName, true); |
||
883 | $ret .= $this->cxc->getClassAddElement('form', $formText . $required); |
||
884 | |||
885 | return $ret; |
||
886 | } |
||
887 | |||
888 | /** |
||
889 | * @public function renderElements |
||
890 | * @param null |
||
891 | * @return string |
||
892 | */ |
||
893 | public function renderElements() |
||
1050 | } |
||
1051 | } |
||
1052 |