Passed
Push — master ( 856304...9f6f9b )
by Goffy
03:36
created

ClassFormElements::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 7
nc 1
nop 0
dl 0
loc 9
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace XoopsModules\Modulebuilder\Files\Classes;
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
 * tc 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 ClassFormElements.
30
 */
31
class ClassFormElements extends Modulebuilder\Files\CreateAbstractClass
32
{
33
    /**
34
     * @var mixed
35
     */
36
    private $cf = null;
37
38
    /**
39
     * @var mixed
40
     */
41
    private $tf = null;
42
43
    /**
44
     * @var mixed
45
     */
46
    private $uxc = null;
47
48
    /**
49
     * @var mixed
50
     */
51
    private $cxc = null;
52
53
    /**
54
     * @var string
55
     */
56
    private $xc = null;
57
58
    /**
59
     * @var string
60
     */
61
    private $pc = null;
62
63
    /**
64
     * @var string
65
     */
66
    private $helper = null;
67
68
69
    /**
70
     * @public function constructor
71
     * @param null
72
     */
73
    public function __construct()
74
    {
75
        $this->helper = Modulebuilder\Helper::getInstance();
0 ignored issues
show
Documentation Bug introduced by
It seems like XoopsModules\Modulebuilder\Helper::getInstance() of type XoopsModules\Modulebuilder\Helper is incompatible with the declared type string of property $helper.

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..

Loading history...
76
        $this->cf     = Modulebuilder\Files\CreateFile::getInstance();
77
        $this->xc     = Modulebuilder\Files\CreateXoopsCode::getInstance();
0 ignored issues
show
Documentation Bug introduced by
It seems like XoopsModules\Modulebuild...oopsCode::getInstance() of type XoopsModules\Modulebuilder\Files\CreateXoopsCode is incompatible with the declared type string of property $xc.

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..

Loading history...
78
        $this->pc     = Modulebuilder\Files\CreatePhpCode::getInstance();
0 ignored issues
show
Documentation Bug introduced by
It seems like XoopsModules\Modulebuild...ePhpCode::getInstance() of type XoopsModules\Modulebuilder\Files\CreatePhpCode is incompatible with the declared type string of property $pc.

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..

Loading history...
79
        $this->tf     = Modulebuilder\Files\CreateTableFields::getInstance();
80
        $this->uxc    = Modulebuilder\Files\User\UserXoopsCode::getInstance();
81
        $this->cxc    = Modulebuilder\Files\Classes\ClassXoopsCode::getInstance();
82
    }
83
84
    /**
85
     * @static function getInstance
86
     * @param null
87
     *
88
     * @return ClassFormElements
89
     */
90
    public static function getInstance()
91
    {
92
        static $instance = false;
93
        if (!$instance) {
94
            $instance = new self();
95
        }
96
97
        return $instance;
98
    }
99
100
    /**
101
     * @public function initForm
102
     *
103
     * @param $module
104
     * @param $table
105
     */
106
    public function initForm($module, $table)
107
    {
108
        $this->setModule($module);
109
        $this->setTable($table);
110
    }
111
112
    /**
113
     * @private function getXoopsFormText
114
     *
115
     * @param        $language
116
     * @param        $fieldName
117
     * @param        $fieldDefault
118
     * @param string $required
119
     * @return string
120
     */
121
    private function getXoopsFormText($language, $fieldName, $fieldDefault, $required = 'false')
122
    {
123
        $ccFieldName  = $this->cf->getCamelCase($fieldName, false, true);
124
        if ('' != $fieldDefault) {
125
            $ret      = $this->pc->getPhpCodeCommentLine('Form Text', $ccFieldName, "\t\t");
126
            $ret      .= $this->pc->getPhpCodeTernaryOperator($ccFieldName, '$this->isNew()', "'{$fieldDefault}'", "\$this->getVar('{$fieldName}')", "\t\t");
127
            $formText = $this->cxc->getClassXoopsFormText('', $language, $fieldName, 20, 150, $ccFieldName, true);
128
            $ret      .= $this->cxc->getClassAddElement('form', $formText . $required);
129
        } else {
130
            $ret      = $this->pc->getPhpCodeCommentLine('Form Text', $ccFieldName, "\t\t");
131
            $formText = $this->cxc->getClassXoopsFormText('', $language, $fieldName, 50, 255, "this->getVar('{$fieldName}')", true);
132
            $ret      .= $this->cxc->getClassAddElement('form', $formText . $required);
133
        }
134
135
        return $ret;
136
    }
137
138
    /**
139
     * @private function getXoopsFormText
140
     *
141
     * @param $language
142
     * @param $fieldName
143
     * @param $required
144
     *
145
     * @return string
146
     */
147
    private function getXoopsFormTextArea($language, $fieldName, $required = 'false')
148
    {
149
        $ccFieldName  = $this->cf->getCamelCase($fieldName, false, true);
150
        $ret          = $this->pc->getPhpCodeCommentLine('Form Editor', 'TextArea ' . $ccFieldName, "\t\t");
151
        $formTextArea = $this->cxc->getClassXoopsFormTextArea('', $language, $fieldName, 4, 47, true);
152
        $ret          .= $this->cxc->getClassAddElement('form', $formTextArea . $required);
153
154
        return $ret;
155
    }
156
157
    /**
158
     * @private function getXoopsFormDhtmlTextArea
159
     *
160
     * @param $language
161
     * @param $fieldName
162
     * @param $required
163
     *
164
     * @return string
165
     */
166
    private function getXoopsFormDhtmlTextArea($language, $fieldName, $required = 'false')
167
    {
168
        $ccFieldName = $this->cf->getCamelCase($fieldName, false, true);
169
        $ret         = $this->pc->getPhpCodeCommentLine('Form Editor', 'DhtmlTextArea ' . $ccFieldName, "\t\t");
170
        $ret         .= $this->pc->getPhpCodeArray('editorConfigs', null, false, "\t\t");
171
        $getConfig    = $this->xc->getXcGetConfig('editor_admin');
172
        $contIf       = $this->xc->getXcEqualsOperator("\$editor", $getConfig, null, "\t\t\t");
173
        $getConfig    = $this->xc->getXcGetConfig('editor_user');
174
        $contElse     = $this->xc->getXcEqualsOperator("\$editor", $getConfig, null, "\t\t\t");
175
        $ret      .= $this->pc->getPhpCodeConditions('$isAdmin','','', $contIf,  $contElse, "\t\t");
176
177
178
        $configs     = [
179
            'name'   => "'{$fieldName}'",
180
            'value'  => "\$this->getVar('{$fieldName}', 'e')",
181
            'rows'   => 5,
182
            'cols'   => 40,
183
            'width'  => "'100%'",
184
            'height' => "'400px'",
185
            'editor' => '$editor',
186
        ];
187
        foreach ($configs as $c => $d) {
188
            $ret .= $this->xc->getXcEqualsOperator("\$editorConfigs['{$c}']", $d, null, "\t\t");
189
        }
190
        $formEditor = $this->cxc->getClassXoopsFormEditor('', $language, $fieldName, 'editorConfigs', true);
191
        $ret        .= $this->cxc->getClassAddElement('form', $formEditor . $required);
192
193
        return $ret;
194
    }
195
196
    /**
197
     * @private function getXoopsFormCheckBox
198
     *
199
     * @param        $language
200
     * @param        $tableSoleName
201
     * @param        $fieldName
202
     * @param        $fieldElementId
203
     * @param string $required
204
     * @return string
205
     */
206
    private function getXoopsFormCheckBox($language, $tableSoleName, $fieldName, $fieldElementId, $required = 'false')
207
    {
208
        $stuTableSoleName = mb_strtoupper($tableSoleName);
209
        $ucfFieldName     = $this->cf->getCamelCase($fieldName, true);
210
        $ccFieldName      = $this->cf->getCamelCase($fieldName, false, true);
211
        $t                = "\t\t";
212
        if (in_array(5, $fieldElementId) > 1) {
213
            $ret     = $this->pc->getPhpCodeCommentLine('Form Check Box', 'List Options ' . $ccFieldName, $t);
214
            $ret     .= $this->xc->getXcEqualsOperator('$checkOption', '$this->getOptions()');
215
            $foreach = $this->cxc->getClassXoopsFormCheckBox('check' . $ucfFieldName, '<hr />', $tableSoleName . '_option', '$checkOption', false, $t . "\t");
216
            $foreach .= $this->cxc->getClassSetDescription('check' . $ucfFieldName, "{$language}{$stuTableSoleName}_OPTIONS_DESC", $t . "\t");
217
            $foreach .= $this->cxc->getClassAddOption('check' . $ucfFieldName, "\$option, {$language}{$stuTableSoleName}_ . strtoupper(\$option)", $t . "\t");
218
            $ret     .= $this->pc->getPhpCodeForeach("{$tableSoleName}All", false, false, 'option', $foreach, $t);
219
            $intElem = "\$check{$ucfFieldName}{$required}";
220
            $ret     .= $this->cxc->getClassAddElement('form', $intElem, $t);
221
        } else {
222
            $ret     = $this->pc->getPhpCodeCommentLine('Form Check Box', $ccFieldName, $t);
223
            $ret     .= $this->pc->getPhpCodeTernaryOperator($ccFieldName, '$this->isNew()', 0, "\$this->getVar('{$fieldName}')", $t);
224
            $ret     .= $this->cxc->getClassXoopsFormCheckBox('check' . $ucfFieldName, (string)$language, $fieldName, "\${$ccFieldName}", false, $t);
225
            $option  = "1, {$language}";
226
            $ret     .= $this->cxc->getClassAddOption('check' . $ucfFieldName, $option, $t);
227
            $intElem = "\$check{$ucfFieldName}{$required}";
228
            $ret     .= $this->cxc->getClassAddElement('form', $intElem, $t);
229
        }
230
231
        return $ret;
232
    }
233
234
    /**
235
     * @private function getXoopsFormHidden
236
     *
237
     * @param $fieldName
238
     *
239
     * @return string
240
     */
241
    private function getXoopsFormHidden($fieldName)
242
    {
243
        $ccFieldName  = $this->cf->getCamelCase($fieldName, false, true);
244
        $ret          = $this->pc->getPhpCodeCommentLine('Form Hidden', $ccFieldName, "\t\t");
245
        $formHidden   = $this->cxc->getClassXoopsFormHidden('', $fieldName, $fieldName, true, true);
246
        $ret          .= $this->cxc->getClassAddElement('form', $formHidden);
247
248
        return $ret;
249
    }
250
251
    /**
252
     * @private function getXoopsFormImageList
253
     *          provides listbox for select image, a preview of image and an upload field
254
     *
255
     * @param $language
256
     * @param $moduleDirname
257
     * @param $fieldName
258
     * @param $required
259
     *
260
     * @return string
261
     */
262
    private function getXoopsFormImageList($language, $moduleDirname, $fieldName, $required = 'false')
263
    {
264
        $ucfFieldName    = $this->cf->getCamelCase($fieldName, true);
265
        $ccFieldName     = $this->cf->getCamelCase($fieldName, false, true);
266
        $languageShort   = substr($language, 0, 4) . mb_strtoupper($moduleDirname) . '_';
267
        $t               = "\t\t";
268
        $ret             = $this->pc->getPhpCodeCommentLine('Form Frameworks Images', 'Files ' . $ccFieldName, $t);
269
        $ret             .= $this->pc->getPhpCodeCommentLine('Form Frameworks Images', $ccFieldName .': Select Uploaded Image', $t);
270
        $ret             .= $this->xc->getXcEqualsOperator('$get' . $ucfFieldName, "\$this->getVar('{$fieldName}')", null, $t);
271
        $ret             .= $this->pc->getPhpCodeTernaryOperator($ccFieldName, '$get' . $ucfFieldName, '$get' . $ucfFieldName, "'blank.gif'", $t);
272
        $ret             .= $this->xc->getXcEqualsOperator('$imageDirectory', "'/Frameworks/moduleclasses/icons/32'", null, $t);
273
        $ret             .= $this->cxc->getClassXoopsFormElementTray('imageTray', $language, '<br>', $t);
274
        $sprintf         = $this->pc->getPhpCodeSprintf($language . '_UPLOADS', '".{$imageDirectory}/"');
275
        $ret             .= $this->cxc->getClassXoopsFormSelect('imageSelect', $sprintf, $fieldName, $ccFieldName, 5, 'false', false, $t);
276
        $ret             .= $this->xc->getXcXoopsListImgListArray('imageArray', 'XOOPS_ROOT_PATH . $imageDirectory', $t);
277
        $contForeach     = $this->cxc->getClassAddOption('imageSelect', '"{$image1}", $image1', $t . "\t");
278
        $ret             .= $this->pc->getPhpCodeForeach('imageArray', false, false, 'image1', $contForeach, $t);
279
        $setExtraParam   = "\"onchange='showImgSelected(\\\"imglabel_{$fieldName}\\\", \\\"{$fieldName}\\\", \\\"\" . \$imageDirectory . \"\\\", \\\"\\\", \\\"\" . XOOPS_URL . \"\\\")'\"";
280
        $ret             .= $this->cxc->getClassSetExtra('imageSelect', $setExtraParam, $t);
281
        $ret             .= $this->cxc->getClassAddElement('imageTray', '$imageSelect, false', $t);
282
283
        $paramLabel      = "\"<br><img src='\" . XOOPS_URL . \"/\" . \$imageDirectory . \"/\" . \${$ccFieldName} . \"' id='imglabel_{$fieldName}' alt='' style='max-width:100px' />\"";
284
        $xoopsFormLabel  = $this->cxc->getClassXoopsFormLabel('', "''", $paramLabel, true, '');
285
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, 4) . 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, '$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(\\\"filelabel_{$fieldName}\\\", \\\"{$fieldName}\\\", \\\"\".\$fileDirectory.\"\\\", \\\"\\\", \\\"\".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.\"/\".\$fileDirectory.\"/\".\${$ccFieldName}.\"' name='filelabel_{$fieldName}' id='filelabel_{$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, 4) . 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><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')
394
    {
395
        $ucfFieldName    = $this->cf->getCamelCase($fieldName, true);
396
        $ccFieldName     = $this->cf->getCamelCase($fieldName, false, true);
397
        $languageShort   = substr($language, 0, 4) . mb_strtoupper($moduleDirname) . '_';
398
        $t               = "\t\t";
399
        $ret             = $this->pc->getPhpCodeCommentLine('Form Image', $ccFieldName, $t);
400
        $ret             .= $this->pc->getPhpCodeCommentLine("Form Image {$ccFieldName}:", 'Select Uploaded Image ', $t);
401
        $ret             .= $this->xc->getXcEqualsOperator('$get' . $ucfFieldName, "\$this->getVar('{$fieldName}')", null, $t);
402
        $ret             .= $this->pc->getPhpCodeTernaryOperator($ccFieldName, '$get' . $ucfFieldName, '$get' . $ucfFieldName, "'blank.gif'", $t);
403
        $ret             .= $this->xc->getXcEqualsOperator('$imageDirectory', "'/uploads/{$moduleDirname}/images/{$tableName}'", null, $t);
404
        $ret             .= $this->cxc->getClassXoopsFormElementTray('imageTray', $language, '<br>', $t);
405
        $sprintf         = $this->pc->getPhpCodeSprintf($language . '_UPLOADS', '".{$imageDirectory}/"');
406
        $ret             .= $this->cxc->getClassXoopsFormSelect('imageSelect', $sprintf, $fieldName, $ccFieldName, 5, 'false', false, $t);
407
        $ret             .= $this->xc->getXcXoopsListImgListArray('imageArray', 'XOOPS_ROOT_PATH . $imageDirectory', $t);
408
        $contForeach     = $this->cxc->getClassAddOption('imageSelect', '"{$image1}", $image1', $t . "\t");
409
        $ret             .= $this->pc->getPhpCodeForeach('imageArray', false, false, 'image1', $contForeach, $t);
410
        $setExtraParam   = "\"onchange='showImgSelected(\\\"imglabel_{$fieldName}\\\", \\\"{$fieldName}\\\", \\\"\" . \$imageDirectory . \"\\\", \\\"\\\", \\\"\" . XOOPS_URL . \"\\\")'\"";
411
        $ret             .= $this->cxc->getClassSetExtra('imageSelect', $setExtraParam, $t);
412
        $ret             .= $this->cxc->getClassAddElement('imageTray', '$imageSelect, false', $t);
413
        $paramLabel      = "\"<br><img src='\" . XOOPS_URL . \"/\" . \$imageDirectory . \"/\" . \${$ccFieldName} . \"' id='imglabel_{$fieldName}' alt='' style='max-width:100px' />\"";
414
        $xoopsFormLabel  = $this->cxc->getClassXoopsFormLabel('', "''", $paramLabel, true, '');
415
        $ret             .= $this->cxc->getClassAddElement('imageTray', $xoopsFormLabel, $t);
416
        $ret             .= $this->pc->getPhpCodeCommentLine("Form Image {$ccFieldName}:", 'Upload new image', $t);
417
        $getConfigSize   = $this->xc->getXcGetConfig('maxsize_image');
418
        $contIf          = $this->xc->getXcEqualsOperator('$maxsize', $getConfigSize,'', "\t\t\t");
419
        $xoopsFormFile   = $this->cxc->getClassXoopsFormFile('imageTray', "'<br>' . " . $languageShort . 'FORM_UPLOAD_NEW', $fieldName, '$maxsize', true, '');
420
        $contIf          .= $this->cxc->getClassAddElement('imageTray', $xoopsFormFile, $t . "\t");
421
        $configText      = "(\$maxsize / 1048576) . ' '  . " . $languageShort . 'FORM_UPLOAD_SIZE_MB';
422
        $labelInfo1      = $this->cxc->getClassXoopsFormLabel('',  $languageShort . 'FORM_UPLOAD_SIZE', $configText, true, '');
423
        $contIf          .= $this->cxc->getClassAddElement('imageTray', $labelInfo1, $t . "\t");
424
        $getConfig       = $this->xc->getXcGetConfig('maxwidth_image');
425
        $labelInfo2      = $this->cxc->getClassXoopsFormLabel('',  $languageShort . 'FORM_UPLOAD_IMG_WIDTH', $getConfig . " . ' px'", true, '');
426
        $contIf          .= $this->cxc->getClassAddElement('imageTray', $labelInfo2, $t . "\t");
427
        $getConfig       = $this->xc->getXcGetConfig('maxheight_image');
428
        $labelInfo3      = $this->cxc->getClassXoopsFormLabel('',  $languageShort . 'FORM_UPLOAD_IMG_HEIGHT', $getConfig . " . ' px'", true, '');
429
        $contIf          .= $this->cxc->getClassAddElement('imageTray', $labelInfo3, $t . "\t");
430
        $formHidden      = $this->cxc->getClassXoopsFormHidden('', $fieldName, $ccFieldName, true, true, $t, true);
431
        $contElse        = $this->cxc->getClassAddElement('imageTray', $formHidden, $t . "\t");
432
        $ret             .= $this->pc->getPhpCodeConditions('$permissionUpload', null, null, $contIf, $contElse, "\t\t");
433
        $ret             .= $this->cxc->getClassAddElement('form', "\$imageTray {$required}", $t);
434
435
        return $ret;
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')
451
    {
452
        $ccFieldName    = $this->cf->getCamelCase($fieldName, false, true);
453
        $languageShort  = substr($language, 0, 4) . mb_strtoupper($moduleDirname) . '_';
454
        $t              = "\t\t\t";
455
        $ret            = $this->pc->getPhpCodeCommentLine('Form File', 'Upload ' . $ccFieldName, "\t\t");
456
        $ret            .= $this->pc->getPhpCodeTernaryOperator($ccFieldName, '$this->isNew()', "''", "\$this->getVar('{$fieldName}')", "\t\t");
457
        $uForm          = $this->cxc->getClassXoopsFormElementTray('fileUploadTray', $language, '<br>', $t);
458
        $uForm          .= $this->xc->getXcEqualsOperator('$fileDirectory', "'/uploads/{$moduleDirname}/files/{$tableName}'", null, $t);
459
        $sprintf        = $this->pc->getPhpCodeSprintf($language . '_UPLOADS', '".{$fileDirectory}/"');
460
        $xoopsFormLabel = $this->cxc->getClassXoopsFormLabel('', $sprintf, $ccFieldName, true, "\t\t", true);
461
        $condIf         = $this->cxc->getClassAddElement('fileUploadTray', $xoopsFormLabel, $t . "\t");
462
        $uForm          .= $this->pc->getPhpCodeConditions('!$this->isNew()', null, null, $condIf, false, "\t\t\t");
463
        $getConfig      = $this->xc->getXcGetConfig('maxsize_file');
464
        $uForm          .= $this->xc->getXcEqualsOperator('$maxsize', $getConfig,'', "\t\t\t");
465
        $xoopsFormFile  = $this->cxc->getClassXoopsFormFile('', "''", $fieldName, '$maxsize', true, '');
466
        $uForm          .= $this->cxc->getClassAddElement('fileUploadTray', $xoopsFormFile, $t);
467
        $configText     = "(\$maxsize / 1048576) . ' '  . " . $languageShort . 'FORM_UPLOAD_SIZE_MB';
468
        $labelInfo1      = $this->cxc->getClassXoopsFormLabel('',  $languageShort . 'FORM_UPLOAD_SIZE', $configText, true, '');
469
        $uForm          .= $this->cxc->getClassAddElement('fileUploadTray', $labelInfo1, $t );
470
        $uForm          .= $this->cxc->getClassAddElement('form', "\$fileUploadTray, {$required}", $t);
471
        $formHidden     = $this->cxc->getClassXoopsFormHidden('', $fieldName, $ccFieldName, true, true, "\t\t", true);
472
        $contElse       = $this->cxc->getClassAddElement('form', $formHidden, $t);
473
474
        $ret           .= $this->pc->getPhpCodeConditions('$permissionUpload', null, null, $uForm, $contElse, "\t\t");
475
476
        return $ret;
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')
489
    {
490
        $ccFieldName   = $this->cf->getCamelCase($fieldName, false, true);
491
        $t             = "\t\t";
492
        $ret           = $this->pc->getPhpCodeCommentLine('Form Color', 'Picker ' . $ccFieldName, $t);
493
        $getVar        = $this->xc->getXcGetVar('', 'this', $fieldName, true);
494
        $xoopsFormFile = $this->cxc->getClassXoopsFormColorPicker('', $language, $fieldName, $getVar, true, '');
495
        $ret           .= $this->cxc->getClassAddElement('form', $xoopsFormFile. $required, $t);
496
497
        return $ret;
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')
511
    {
512
        $ucfTableName = ucfirst($tableName);
513
        $ccFieldName  = $this->cf->getCamelCase($fieldName, false, true);
514
        $t            = "\t\t";
515
        $ret          = $this->pc->getPhpCodeCommentLine($ucfTableName, 'Handler', $t);
516
        $ret          .= $this->xc->getXcHandlerLine($tableName, $t);
517
        $ret          .= $this->pc->getPhpCodeCommentLine('Form', 'Select ' . $ccFieldName, $t);
518
        $ret          .= $this->cxc->getClassXoopsFormSelect($ccFieldName . 'Select', $language, $fieldName, "this->getVar('{$fieldName}')", null, '', false, $t);
519
        $ret          .= $this->cxc->getClassAddOption($ccFieldName . 'Select', "'Empty'", $t);
520
        $ret          .= $this->cxc->getClassAddOptionArray($ccFieldName . 'Select', "\${$tableName}Handler->getList()", $t);
521
        $ret          .= $this->cxc->getClassAddElement('form', "\${$ccFieldName}Select{$required}", $t);
522
523
        return $ret;
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
        $xoopsSelectUser = $this->cxc->getClassXoopsFormSelectUser('', $language, $fieldName, 'false', $fieldName, true, $t);
540
        $ret             .= $this->cxc->getClassAddElement('form', $xoopsSelectUser . $required, $t);
541
542
        return $ret;
543
    }
544
545
    /**
546
     * @private function getXoopsFormRadioYN
547
     *
548
     * @param $language
549
     * @param $fieldName
550
     * @param $required
551
     *
552
     * @return string
553
     */
554
    private function getXoopsFormRadioYN($language, $fieldName, $required = 'false')
555
    {
556
        $ccFieldName  = $this->cf->getCamelCase($fieldName, false, true);
557
        $t            = "\t\t";
558
        $ret          = $this->pc->getPhpCodeCommentLine('Form Radio', 'Yes/No ' . $ccFieldName, $t);
559
        $ret          .= $this->pc->getPhpCodeTernaryOperator($ccFieldName, '$this->isNew()', 0, "\$this->getVar('{$fieldName}')", $t);
560
        $xoopsRadioYN = $this->cxc->getClassXoopsFormRadioYN('', $language, $fieldName, $ccFieldName, true, $t);
561
        $ret          .= $this->cxc->getClassAddElement('form', $xoopsRadioYN . $required, $t);
562
563
        return $ret;
564
    }
565
566
    /**
567
     * @private function getXoopsFormTextDateSelect
568
     *
569
     * @param $language
570
     * @param $fieldName
571
     * @param $required
572
     *
573
     * @return string
574
     */
575
    private function getXoopsFormTextDateSelect($language, $fieldName, $required = 'false')
576
    {
577
        $t                   = "\t\t";
578
        $ccFieldName         = $this->cf->getCamelCase($fieldName, false, true);
579
        $ret                 = $this->pc->getPhpCodeCommentLine('Form Text', 'Date Select ' . $ccFieldName, $t);
580
        $ret                 .= $this->pc->getPhpCodeTernaryOperator($ccFieldName, '$this->isNew()', 0, "\$this->getVar('{$fieldName}')", $t);
581
        $xoopsTextDateSelect = $this->cxc->getClassXoopsFormTextDateSelect('', $language, $fieldName, $fieldName, $ccFieldName, true, $t);
582
        $ret                 .= $this->cxc->getClassAddElement('form', $xoopsTextDateSelect . $required, $t);
583
584
        return $ret;
585
    }
586
587
    /**
588
     * @private function getXoopsFormDateTime
589
     *
590
     * @param $language
591
     * @param $fieldName
592
     * @param $required
593
     *
594
     * @return string
595
     */
596
    private function getXoopsFormDateTime($language, $fieldName, $required = 'false')
597
    {
598
        $t                   = "\t\t";
599
        $ccFieldName         = $this->cf->getCamelCase($fieldName, false, true);
600
        $ret                 = $this->pc->getPhpCodeCommentLine('Form Text', 'Date Select ' . $ccFieldName, $t);
601
        $ret                 .= $this->pc->getPhpCodeTernaryOperator($ccFieldName, '$this->isNew()', 0, "\$this->getVar('{$fieldName}')", $t);
602
        $xoopsTextDateSelect = $this->cxc->getClassXoopsFormDateTime('', $language, $fieldName, $fieldName, $ccFieldName, true, $t);
603
        $ret                 .= $this->cxc->getClassAddElement('form', $xoopsTextDateSelect . $required, $t);
604
605
        return $ret;
606
    }
607
608
    /**
609
     * @private function getXoopsFormSelectStatus
610
     *
611
     * @param $language
612
     * @param $moduleDirname
613
     * @param $fieldName
614
     * @param string $required
615
     *
616
     * @return string
617
     */
618
    private function getXoopsFormSelectStatus($language, $moduleDirname, $fieldName, $required = 'false')
619
    {
620
        $ccFieldName  = $this->cf->getCamelCase($fieldName, false, true);
621
        $languageShort = substr($language, 0, 4) . mb_strtoupper($moduleDirname) . '_';
622
        $t            = "\t\t";
623
        $ret          = $this->pc->getPhpCodeCommentLine('Form Select', 'Status ' . $ccFieldName, $t);
624
        $ret          .= $this->xc->getXcHandlerLine('permissions', $t);
625
        $ret          .= $this->cxc->getClassXoopsFormSelect($ccFieldName . 'Select', $language, $fieldName, "this->getVar('{$fieldName}')", null, '', false, $t);
626
        $ret          .= $this->cxc->getClassAddOption($ccFieldName . 'Select', $this->xc->getXcGetConstants('STATUS_NONE') . ", {$languageShort}STATUS_NONE", $t);
627
        $ret          .= $this->cxc->getClassAddOption($ccFieldName . 'Select', $this->xc->getXcGetConstants('STATUS_OFFLINE') . ", {$languageShort}STATUS_OFFLINE", $t);
628
        $ret          .= $this->cxc->getClassAddOption($ccFieldName . 'Select', $this->xc->getXcGetConstants('STATUS_SUBMITTED') . ", {$languageShort}STATUS_SUBMITTED", $t);
629
630
        $contIf    = $this->cxc->getClassAddOption($ccFieldName . 'Select', $this->xc->getXcGetConstants('STATUS_APPROVED') . ", {$languageShort}STATUS_APPROVED", $t . "\t");
631
        $ret       .= $this->pc->getPhpCodeConditions('$permissionsHandler->getPermGlobalApprove()', '', '', $contIf, false, $t);
632
633
        $ret          .= $this->cxc->getClassAddOption($ccFieldName . 'Select', $this->xc->getXcGetConstants('STATUS_APPROVED') . ", {$languageShort}STATUS_APPROVED", $t);
634
        $ret          .= $this->cxc->getClassAddOption($ccFieldName . 'Select', $this->xc->getXcGetConstants('STATUS_BROKEN') . ", {$languageShort}STATUS_BROKEN", $t);
635
        $ret          .= $this->cxc->getClassAddElement('form', "\${$ccFieldName}Select{$required}", $t);
636
637
        return $ret;
638
    }
639
640
    /**
641
     * @private function getXoopsFormPassword
642
     *
643
     * @param $language
644
     * @param $fieldName
645
     * @param $required
646
     *
647
     * @return string
648
     */
649
    private function getXoopsFormPassword($language, $fieldName, $required = 'false')
650
    {
651
        $t             = "\t\t";
652
        $ccFieldName   = $this->cf->getCamelCase($fieldName, false, true);
653
        $ret           = $this->pc->getPhpCodeCommentLine('Form Text', 'Enter Password ' . $ccFieldName, $t);
654
        $xoopsPassword = $this->cxc->getClassXoopsFormPassword('', $language, $fieldName, 10, 32, true, $t);
655
        $ret           .= $this->cxc->getClassAddElement('form', $xoopsPassword . $required, $t);
656
657
        return $ret;
658
    }
659
660
    /**
661
     * @private function getXoopsFormSelectCountry
662
     *
663
     * @param $language
664
     * @param $fieldName
665
     * @param string $required
666
     *
667
     * @return string
668
     */
669
    private function getXoopsFormSelectCountry($language, $fieldName, $required = 'false')
670
    {
671
        $ccFieldName  = $this->cf->getCamelCase($fieldName, false, true);
672
        $t            = "\t\t";
673
        $ret          = $this->pc->getPhpCodeCommentLine('Form Select', 'Country ' . $ccFieldName, $t);
674
        $ret          .= $this->cxc->getClassXoopsFormSelect($ccFieldName . 'Select', $language, $fieldName, "this->getVar('{$fieldName}')", null, '', false, $t);
675
        $ret          .= $this->cxc->getClassAddOption($ccFieldName . 'Select', "'', _NONE", $t);
676
        $ret          .= $this->xc->getXcXoopsListCountryList('countryArray', $t);
677
        $ret          .= $this->cxc->getClassAddOptionArray($ccFieldName . 'Select', '$countryArray', $t);
678
        $ret          .= $this->cxc->getClassAddElement('form', "\${$ccFieldName}Select{$required}", $t);
679
680
        return $ret;
681
    }
682
683
    /**
684
     * @private function getXoopsFormSelectLang
685
     *
686
     * @param $language
687
     * @param $fieldName
688
     * @param string $required
689
     *
690
     * @return string
691
     */
692
    private function getXoopsFormSelectLang($language, $fieldName, $required = 'false')
693
    {
694
        $ccFieldName  = $this->cf->getCamelCase($fieldName, false, true);
695
        $t            = "\t\t";
696
        $ret          = $this->pc->getPhpCodeCommentLine('Form Select', 'Lang ' . $ccFieldName, $t);
697
        $ret          .= $this->cxc->getClassXoopsFormSelect($ccFieldName . 'Select', $language, $fieldName, "this->getVar('{$fieldName}')", null, '', false, $t);
698
        $ret          .= $this->cxc->getClassAddOption($ccFieldName . 'Select', "'', _NONE", $t);
699
        $ret          .= $this->xc->getXcXoopsListLangList('langArray', $t);
700
        $ret          .= $this->cxc->getClassAddOptionArray($ccFieldName . 'Select', '$langArray', $t);
701
        $ret          .= $this->cxc->getClassAddElement('form', "\${$ccFieldName}Select{$required}", $t);
702
703
        return $ret;
704
    }
705
706
    /**
707
     * @private function getXoopsFormRadio
708
     *
709
     * @param $language
710
     * @param $moduleDirname
711
     * @param $fieldName
712
     * @param string $required
713
     *
714
     * @return string
715
     */
716
    private function getXoopsFormRadio($language, $moduleDirname, $fieldName, $required = 'false')
717
    {
718
        $ccFieldName   = $this->cf->getCamelCase($fieldName, false, true);
719
        $languageShort = substr($language, 0, 4) . mb_strtoupper($moduleDirname) . '_';
720
        $t             = "\t\t";
721
        $ret           = $this->pc->getPhpCodeCommentLine('Form Radio', $ccFieldName, $t);
722
        $ret           .= $this->pc->getPhpCodeTernaryOperator($ccFieldName, '$this->isNew()', '0', "\$this->getVar('{$fieldName}')", $t);
723
        $ret           .= $this->cxc->getClassXoopsFormRadio($ccFieldName . 'Select', $language, $fieldName, "{$ccFieldName}", false, $t);
724
        $ret           .= $this->cxc->getClassAddOption($ccFieldName . 'Select', "'0', _NONE", $t);
725
        $ret           .= $this->cxc->getClassAddOption($ccFieldName . 'Select', "'1', {$languageShort}LIST_1", $t);
726
        $ret           .= $this->cxc->getClassAddOption($ccFieldName . 'Select', "'2', {$languageShort}LIST_2", $t);
727
        $ret           .= $this->cxc->getClassAddOption($ccFieldName . 'Select', "'3', {$languageShort}LIST_3", $t);
728
        $ret           .= $this->cxc->getClassAddElement('form', "\${$ccFieldName}Select{$required}", $t);
729
730
        return $ret;
731
    }
732
733
    /**
734
     * @private function getXoopsFormSelectCombo
735
     *
736
     * @param $language
737
     * @param $moduleDirname
738
     * @param $tableName
739
     * @param $fieldName
740
     * @param string $required
741
     *
742
     * @return string
743
     */
744
    private function getXoopsFormSelectCombo($language, $moduleDirname, $tableName, $fieldName, $required = 'false')
745
    {
746
        $ucfTableName  = ucfirst($tableName);
747
        $ccFieldName   = $this->cf->getCamelCase($fieldName, false, true);
748
        $languageShort = substr($language, 0, 4) . mb_strtoupper($moduleDirname) . '_';
749
        $t             = "\t\t";
750
        $ret           = $this->pc->getPhpCodeCommentLine($ucfTableName, 'Handler', $t);
751
        $ret           .= $this->xc->getXcHandlerLine($tableName, $t);
752
        $ret           .= $this->pc->getPhpCodeCommentLine('Form', 'Select ' . $ccFieldName, $t);
753
        $ret           .= $this->cxc->getClassXoopsFormSelect($ccFieldName . 'Select', $language, $fieldName, "this->getVar('{$fieldName}')", '5', '', false, $t);
754
        $ret           .= $this->cxc->getClassAddOption($ccFieldName . 'Select', "'0', _NONE", $t);
755
        $ret           .= $this->cxc->getClassAddOption($ccFieldName . 'Select', "'1', {$languageShort}LIST_1", $t);
756
        $ret           .= $this->cxc->getClassAddOption($ccFieldName . 'Select', "'2', {$languageShort}LIST_2", $t);
757
        $ret           .= $this->cxc->getClassAddOption($ccFieldName . 'Select', "'3', {$languageShort}LIST_3", $t);
758
        $ret           .= $this->cxc->getClassAddElement('form', "\${$ccFieldName}Select{$required}", $t);
759
760
        return $ret;
761
    }
762
763
    /**
764
     * @private function getXoopsFormTable
765
     *
766
     * @param $language
767
     * @param $fieldName
768
     * @param $fieldElement
769
     * @param $required
770
     *
771
     * @return string
772
     */
773
    private function getXoopsFormTable($language,$fieldName, $fieldElement, $required = 'false')
774
    {
775
        $t   = "\t\t";
776
        $ret = '';
777
        $fElement           = $this->helper->getHandler('Fieldelements')->get($fieldElement);
778
        $rpFieldelementName = mb_strtolower(str_replace('Table : ', '', $fElement->getVar('fieldelement_name')));
779
        $ret                .= $this->pc->getPhpCodeCommentLine('Form Table', $rpFieldelementName, $t);
780
        $ccFieldName        = $this->cf->getCamelCase($fieldName, false, true);
781
        $ret                .= $this->xc->getXcHandlerLine($rpFieldelementName, $t);
782
        $ret                .= $this->cxc->getClassXoopsFormSelect($ccFieldName . 'Select', $language, $fieldName, "this->getVar('{$fieldName}')", null, '', false, $t);
783
        $ret                .= $this->cxc->getClassAddOptionArray($ccFieldName . 'Select', "\${$rpFieldelementName}Handler->getList()", $t);
784
        $ret                .= $this->cxc->getClassAddElement('form', "\${$ccFieldName}Select{$required}", $t);
785
786
        return $ret;
787
    }
788
789
    /**
790
     * @private  function getXoopsFormTopic
791
     *
792
     * @param        $language
793
     * @param        $topicTableName
794
     * @param        $fieldId
795
     * @param        $fieldPid
796
     * @param        $fieldMain
797
     * @return string
798
     */
799
    private function getXoopsFormTopic($language, $topicTableName, $fieldId, $fieldPid, $fieldMain)
800
    {
801
        $ucfTopicTableName = ucfirst($topicTableName);
802
        $stlTopicTableName = mb_strtolower($topicTableName);
803
        $ccFieldPid        = $this->cf->getCamelCase($fieldPid, false, true);
804
        $t                 = "\t\t";
805
        $ret               = $this->pc->getPhpCodeCommentLine('Form Table', $ucfTopicTableName, $t);
806
        $ret               .= $this->xc->getXcHandlerLine($stlTopicTableName, $t);
807
        $ret               .= $this->xc->getXcCriteriaCompo('cr' . $ucfTopicTableName, $t);
808
        $ret               .= $this->xc->getXcHandlerCountClear($stlTopicTableName . 'Count', $stlTopicTableName, '$cr' . $ucfTopicTableName, $t);
809
        $contIf            = $this->pc->getPhpCodeIncludeDir('XOOPS_ROOT_PATH', 'class/tree', true, false, 'include', $t . "\t");
810
        $contIf            .= $this->xc->getXcHandlerAllClear($stlTopicTableName . 'All', $stlTopicTableName, '$cr' . $ucfTopicTableName, $t . "\t");
811
        $contIf            .= $this->cxc->getClassXoopsObjectTree($stlTopicTableName . 'Tree', $stlTopicTableName . 'All', $fieldId, $fieldPid, $t . "\t");
812
        $contIf            .= $this->cxc->getClassXoopsMakeSelBox($ccFieldPid, $stlTopicTableName . 'Tree', $fieldPid, $fieldMain, '--', $fieldPid, $t . "\t");
813
        $formLabel         = $this->cxc->getClassXoopsFormLabel('', $language, "\${$ccFieldPid}", true, '');
814
        $contIf            .= $this->cxc->getClassAddElement('form', $formLabel, $t . "\t");
815
        $ret               .= $this->pc->getPhpCodeConditions("\${$stlTopicTableName}Count", null, null, $contIf, false, $t);
816
        $ret               .= $this->pc->getPhpCodeUnset('cr' . $ucfTopicTableName, $t);
817
818
        return $ret;
819
    }
820
821
    /**
822
     * @private function getXoopsFormTag
823
     *
824
     * @param $fieldId
825
     * @param $required
826
     *
827
     * @return string
828
     */
829
    private function getXoopsFormTag($fieldId, $required = 'false')
830
    {
831
        $t         = "\t\t";
832
        $ret       = $this->pc->getPhpCodeCommentLine('Use tag', 'module', $t);
833
        $isDir     = $this->pc->getPhpCodeIsDir("XOOPS_ROOT_PATH . '/modules/tag'");
834
        $ret       .= $this->pc->getPhpCodeTernaryOperator('dirTag', $isDir, 'true', 'false', $t);
835
        $paramIf   = '(' . $this->xc->getXcGetConfig('usetag') . ' == 1)';
836
        $condIf    = $this->pc->getPhpCodeTernaryOperator('tagId', '$this->isNew()', '0', "\$this->getVar('{$fieldId}')", $t . "\t");
837
        $condIf    .= $this->pc->getPhpCodeIncludeDir('XOOPS_ROOT_PATH', 'modules/tag/include/formtag', true, false, $type = 'include', $t . "\t");
838
        $paramElem = $this->cxc->getClassXoopsFormTag('', 'tag', 60, 255, 'tagId', 0, true, '');
839
        $condIf    .= $this->cxc->getClassAddElement('form', $paramElem . $required, $t . "\t");
840
        $ret       .= $this->pc->getPhpCodeConditions($paramIf, ' && ', '$dirTag', $condIf, false, $t);
841
842
        return $ret;
843
    }
844
845
    /**
846
     * @public function renderElements
847
     * @param null
848
     * @return string
849
     */
850
    public function renderElements()
851
    {
852
        $module        = $this->getModule();
853
        $table         = $this->getTable();
854
        $moduleDirname = $module->getVar('mod_dirname');
855
        $tableName     = $table->getVar('table_name');
856
        $tableSoleName = $table->getVar('table_solename');
857
        $languageFunct = $this->cf->getLanguage($moduleDirname, 'AM');
858
        //$language_table = $languageFunct . strtoupper($tableName);
859
        $ret            = '';
860
        $fields         = $this->tf->getTableFields($table->getVar('table_mid'), $table->getVar('table_id'), 'field_order ASC, field_id');
861
        $fieldId        = '';
862
        $fieldIdTopic   = '';
863
        $fieldPidTopic  = '';
864
        $fieldMainTopic = '';
865
        $fieldElementId = [];
866
        $counter        = 0;
867
        foreach (array_keys($fields) as $f) {
868
            $fieldName    = $fields[$f]->getVar('field_name');
869
            $fieldDefault = $fields[$f]->getVar('field_default');
870
            $fieldElement = $fields[$f]->getVar('field_element');
871
            $fieldParent  = $fields[$f]->getVar('field_parent');
872
            $fieldInForm  = $fields[$f]->getVar('field_inform');
873
            if ((0 == $f) && (1 == $table->getVar('table_autoincrement'))) {
874
                $fieldId = $fieldName;
875
            }
876
            $rpFieldName = $this->cf->getRightString($fieldName);
877
            $language    = $languageFunct . mb_strtoupper($tableSoleName) . '_' . mb_strtoupper($rpFieldName);
878
            $required    = (1 == $fields[$f]->getVar('field_required')) ? ', true' : ' ';
879
880
            $fieldElements    = $this->helper->getHandler('Fieldelements')->get($fieldElement);
881
            $fieldElementId[] = $fieldElements->getVar('fieldelement_id');
882
883
            if (1 == $fieldInForm) {
884
                $counter++;
885
                // Switch elements
886
                switch ($fieldElement) {
887
                    case 1:
888
                        break;
889
                    case 2:
890
                        $ret .= $this->getXoopsFormText($language, $fieldName, $fieldDefault, $required);
891
                        break;
892
                    case 3:
893
                        $ret .= $this->getXoopsFormTextArea($language, $fieldName, $required);
894
                        break;
895
                    case 4:
896
                        $ret .= $this->getXoopsFormDhtmlTextArea($language, $fieldName, $required);
897
                        break;
898
                    case 5:
899
                        $ret .= $this->getXoopsFormCheckBox($language, $tableSoleName, $fieldName, $fieldElementId, $required);
900
                        break;
901
                    case 6:
902
                        $ret .= $this->getXoopsFormRadioYN($language, $fieldName, $required);
903
                        break;
904
                    case 7:
905
                        $ret .= $this->getXoopsFormSelectBox($language, $tableName, $fieldName, $required);
906
                        break;
907
                    case 8:
908
                        $ret .= $this->getXoopsFormSelectUser($language, $fieldName, $required);
909
                        break;
910
                    case 9:
911
                        $ret .= $this->getXoopsFormColorPicker($language, $fieldName, $required);
912
                        break;
913
                    case 10:
914
                        $ret .= $this->getXoopsFormImageList($language, $moduleDirname, $fieldName, $required);
915
                        break;
916
                    case 11:
917
                        $ret .= $this->getXoopsFormSelectFile($language, $moduleDirname, $tableName, $fieldName, $required);
918
                        break;
919
                    case 12:
920
                        $ret .= $this->getXoopsFormUrlFile($language, $moduleDirname, $fieldName, $fieldDefault, $required);
921
                        break;
922
                    case 13:
923
                        $ret .= $this->getXoopsFormUploadImage($language, $moduleDirname, $tableName, $fieldName, $required);
924
                        break;
925
                    case 14:
926
                        $ret .= $this->getXoopsFormUploadFile($language, $moduleDirname, $tableName, $fieldName, $required);
927
                        break;
928
                    case 15:
929
                        $ret .= $this->getXoopsFormTextDateSelect($language, $fieldName, $required);
930
                        break;
931
                    case 16:
932
                        $ret .= $this->getXoopsFormSelectStatus($language, $moduleDirname, $fieldName, $required);
933
                        break;
934
                    case 17:
935
                        $ret .= $this->getXoopsFormPassword($language,  $fieldName, $required);
936
                        break;
937
                    case 18:
938
                        $ret .= $this->getXoopsFormSelectCountry($language, $fieldName, $required);
939
                        break;
940
                    case 19:
941
                        $ret .= $this->getXoopsFormSelectLang($language, $fieldName, $required);
942
                        break;
943
                    case 20:
944
                        $ret .= $this->getXoopsFormRadio($language, $moduleDirname, $fieldName, $required);
945
                        break;
946
                    case 21:
947
                        $ret .= $this->getXoopsFormDateTime($language, $fieldName, $required);
948
                        break;
949
                    case 22:
950
                        $ret .= $this->getXoopsFormSelectCombo($language, $moduleDirname, $tableName, $fieldName, $required);
951
                        break;
952
                    default:
953
                        // If we use tag module
954
                        if (1 == $table->getVar('table_tag')) {
955
                            $ret .= $this->getXoopsFormTag($fieldId, $required);
956
                        }
957
                        // If we want to hide XoopsFormHidden() or field id
958
                        if ((0 == $f) && (1 == $table->getVar('table_autoincrement'))) {
959
                            $ret .= $this->getXoopsFormHidden($fieldName);
960
                        }
961
                        break;
962
                }
963
964
                $fieldElements    = $this->helper->getHandler('Fieldelements')->get($fieldElement);
965
                $fieldElementTid  = $fieldElements->getVar('fieldelement_tid');
966
                if ((int)$fieldElementTid > 0 ) {
967
                    if ((1 == $fieldParent) || 1 == $table->getVar('table_category')) {
968
                        $fieldElementMid  = $fieldElements->getVar('fieldelement_mid');
969
                        $fieldElementName = $fieldElements->getVar('fieldelement_name');
970
                        $fieldNameDesc    = mb_substr($fieldElementName, mb_strrpos($fieldElementName, ':'), mb_strlen($fieldElementName));
971
                        $topicTableName   = str_replace(': ', '', $fieldNameDesc);
972
                        $fieldsTopics     = $this->tf->getTableFields($fieldElementMid, $fieldElementTid);
973
                        foreach (array_keys($fieldsTopics) as $g) {
974
                            $fieldNameTopic = $fieldsTopics[$g]->getVar('field_name');
975
                            if ((0 == $g) && (1 == $table->getVar('table_autoincrement'))) {
976
                                $fieldIdTopic = $fieldNameTopic;
977
                            }
978
                            if (1 == $fieldsTopics[$g]->getVar('field_parent')) {
979
                                $fieldPidTopic = $fieldNameTopic;
980
                            }
981
                            if (1 == $fieldsTopics[$g]->getVar('field_main')) {
982
                                $fieldMainTopic = $fieldNameTopic;
983
                            }
984
                        }
985
                        $ret .= $this->getXoopsFormTopic($language, $topicTableName, $fieldIdTopic, $fieldPidTopic, $fieldMainTopic);
986
                    } else {
987
                        $ret .= $this->getXoopsFormTable($language, $fieldName, $fieldElement, $required);
988
                    }
989
                }
990
            }
991
        }
992
        unset($fieldElementId);
993
994
        return $ret;
995
    }
996
}
997