Passed
Branch master (38ab27)
by Michael
03:06
created

ClassFiles   F

Complexity

Total Complexity 74

Size/Duplication

Total Lines 788
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 788
rs 1.9047
c 0
b 0
f 0
wmc 74

22 Methods

Rating   Name   Duplication   Size   Complexity  
A getClassGetInsertId() 0 9 1
A getNewInsertId() 0 13 1
A getToArrayInObject() 0 18 1
A getClassGetTableSolenameById() 0 23 1
B getOptionsCheck() 0 28 3
A getClassCriteria() 0 18 1
A getFunctionForm() 0 57 4
B getClassObjectHandler() 0 32 3
A getClassCounter() 0 17 1
A __construct() 0 3 1
A getInitVar() 0 5 1
A getClassAll() 0 17 1
B getPermissionsInForm() 0 41 1
C getInitVars() 0 58 24
A getClassCreate() 0 9 1
A write() 0 6 1
C getClassObject() 0 65 8
B getClassByCategory() 0 37 2
B render() 0 40 6
A getInstance() 0 8 2
A getClassGet() 0 9 1
C getValuesInObject() 0 59 9

How to fix   Complexity   

Complex Class

Complex classes like ClassFiles 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 ClassFiles, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
/*
4
 You may not change or alter any portion of this comment or credits
5
 of supporting developers from this source code or any supporting source code
6
 which is considered copyrighted (c) material of the original comment or credit authors.
7
8
 This program is distributed in the hope that it will be useful,
9
 but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 */
12
/**
13
 * tc module.
14
 *
15
 * @copyright       XOOPS Project (https://xoops.org)
16
 * @license         GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
17
 *
18
 * @since           2.5.0
19
 *
20
 * @author          Txmod Xoops http://www.txmodxoops.org
21
 *
22
 * @version         $Id: ClassFiles.php 12258 2014-01-02 09:33:29Z timgno $
23
 */
24
25
/**
26
 * Class ClassFiles.
27
 */
28
class ClassFiles extends TDMCreateFile
29
{
30
    /**
31
     *  @public function constructor
32
     *
33
     *  @param null
34
     */
35
    public function __construct()
36
    {
37
        parent::__construct();
38
    }
39
40
    /**
41
     *  @static function getInstance
42
     *
43
     *  @param null
44
     *
45
     * @return ClassFiles
46
     */
47
    public static function getInstance()
48
    {
49
        static $instance = false;
50
        if (!$instance) {
51
            $instance = new self();
52
        }
53
54
        return $instance;
55
    }
56
57
    /**
58
     * @public function write
59
     *
60
     * @param string $module
61
     * @param string $table
62
     * @param mixed  $tables
63
     * @param        $filename
64
     */
65
    public function write($module, $table, $tables, $filename)
66
    {
67
        $this->setModule($module);
68
        $this->setTable($table);
69
        $this->setTables($tables);
70
        $this->setFileName($filename);
71
    }
72
73
    /**
74
     *  @private function getInitVar
75
     *
76
     *  @param string $fieldName
77
     *  @param string $type
78
     *
79
     * @return string
80
     */
81
    private function getInitVar($fieldName, $type = 'INT')
82
    {
83
        $cc = ClassXoopsCode::getInstance();
84
85
        return $cc->getClassInitVar($fieldName, $type);
86
    }
87
88
    /**
89
     *  @private function getInitVars
90
     *
91
     *  @param array $fields
92
     *
93
     * @return string
94
     */
95
    private function getInitVars($fields)
96
    {
97
        $tc = TDMCreateHelper::getInstance();
98
        $ret = '';
99
        // Creation of the initVar functions list
100
        foreach (array_keys($fields) as $f) {
101
            $fieldName = $fields[$f]->getVar('field_name');
102
            $fieldType = $fields[$f]->getVar('field_type');
103
            if ($fieldType > 1) {
104
                $fType = $tc->getHandler('fieldtype')->get($fieldType);
105
                $fieldTypeName = $fType->getVar('fieldtype_name');
0 ignored issues
show
Unused Code introduced by
The assignment to $fieldTypeName is dead and can be removed.
Loading history...
106
            } else {
107
                $fieldType = null;
108
            }
109
            switch ($fieldType) {
110
                case 2:
111
                case 3:
112
                case 4:
113
                case 5:
114
                    $ret .= $this->getInitVar($fieldName, 'INT');
115
                    break;
116
                case 6:
117
                    $ret .= $this->getInitVar($fieldName, 'FLOAT');
118
                    break;
119
                case 7:
120
                case 8:
121
                    $ret .= $this->getInitVar($fieldName, 'DECIMAL');
122
                    break;
123
                case 10:
124
                    $ret .= $this->getInitVar($fieldName, 'ENUM');
125
                    break;
126
                case 11:
127
                    $ret .= $this->getInitVar($fieldName, 'EMAIL');
128
                    break;
129
                case 12:
130
                    $ret .= $this->getInitVar($fieldName, 'URL');
131
                    break;
132
                case 13:
133
                case 14:
134
                    $ret .= $this->getInitVar($fieldName, 'TXTBOX');
135
                    break;
136
                case 15:
137
                case 16:
138
                case 17:
139
                case 18:
140
                    $ret .= $this->getInitVar($fieldName, 'TXTAREA');
141
                    break;
142
                case 19:
143
                case 20:
144
                case 21:
145
                case 22:
146
                case 23:
147
                    $ret .= $this->getInitVar($fieldName, 'LTIME');
148
                    break;
149
            }
150
        }
151
152
        return $ret;
153
    }
154
155
    /**
156
     * @private  function getClassObject
157
     * @param $module
158
     * @param $table
159
     * @param $fields
160
     * @return string
161
     */
162
    private function getClassObject($module, $table, $fields)
163
    {
164
        $tc = TDMCreateHelper::getInstance();
165
        $pc = TDMCreatePhpCode::getInstance();
166
        $xc = TDMCreateXoopsCode::getInstance();
167
        $moduleDirname = $module->getVar('mod_dirname');
168
        $tableName = $table->getVar('table_name');
169
        $ucfModuleDirname = ucfirst($moduleDirname);
170
        $ucfTableName = ucfirst($tableName);
171
        $ret = $pc->getPhpCodeDefined();
172
        $ret .= $pc->getPhpCodeCommentMultiLine(['Class Object' => $ucfModuleDirname . $ucfTableName]);
173
        $cCl = '';
174
175
        $fieldInForm = [];
176
        $fieldElementId = [];
177
        $optionsFieldName = [];
178
        foreach (array_keys($fields) as $f) {
179
            $fieldName = $fields[$f]->getVar('field_name');
180
            $fieldElement = $fields[$f]->getVar('field_element');
181
            $fieldInForm[] = $fields[$f]->getVar('field_inform');
182
            $fieldElements = $tc->getHandler('fieldelements')->get($fieldElement);
183
            $fieldElementId[] = $fieldElements->getVar('fieldelement_id');
184
            $rpFieldName = $this->getRightString($fieldName);
185
            if (in_array(5, $fieldElementId)) {
186
                if (count($rpFieldName) % 5) {
0 ignored issues
show
Bug introduced by
$rpFieldName of type string is incompatible with the type Countable|array expected by parameter $var of count(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

186
                if (count(/** @scrutinizer ignore-type */ $rpFieldName) % 5) {
Loading history...
187
                    $optionsFieldName[] = "'".$rpFieldName."'";
188
                } else {
189
                    $optionsFieldName[] = "'".$rpFieldName."'\n";
190
                }
191
            }
192
            if ((0 == $f) && (1 == $table->getVar('table_autoincrement'))) {
193
                $fieldId = $fieldName;
194
            }
195
        }
196
        if (in_array(5, $fieldElementId) > 1) {
197
            $optionsElements = implode(', ', $optionsFieldName);
0 ignored issues
show
Unused Code introduced by
The assignment to $optionsElements is dead and can be removed.
Loading history...
198
            $cCl .= $pc->getPhpCodeCommentMultiLine(['Options' => '']);
199
            $options = $pc->getPhpCodeArray('', $optionsFieldName, true);
200
            $cCl .= $pc->getPhpCodeVariableClass('private', 'options', $options);
201
        }
202
        unset($optionsFieldName);
203
204
        $cCl .= $pc->getPhpCodeCommentMultiLine(['Constructor' => '', '' => '', '@param' => 'null'], "\t");
205
        $constr = $this->getInitVars($fields);
206
        $cCl .= $pc->getPhpCodeFunction('__construct', '', $constr, 'public ', false, "\t");
207
        $arrayGetInstance = ['@static function' => '&getInstance', '' => '', '@param' => 'null'];
208
        $cCl .= $pc->getPhpCodeCommentMultiLine($arrayGetInstance, "\t");
209
        $getInstance = $pc->getPhpCodeVariableClass('static', 'instance', 'false', "\t\t");
210
        $instance = $xc->getXcEqualsOperator('$instance', 'new self()', null, false, "\t\t\t");
211
        $getInstance .= $pc->getPhpCodeConditions('!$instance', '', '', $instance, false, "\t\t");
212
        $cCl .= $pc->getPhpCodeFunction('getInstance', '', $getInstance, 'public static ', false, "\t");
213
214
        $cCl .= $this->getNewInsertId($table);
215
        $cCl .= $this->getFunctionForm($module, $table, $fieldId, $fieldInForm);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $fieldId does not seem to be defined for all execution paths leading up to this point.
Loading history...
216
        $cCl .= $this->getValuesInObject($moduleDirname, $table, $fields);
217
        $cCl .= $this->getToArrayInObject($table);
218
219
        if (in_array(5, $fieldElementId) > 1) {
220
            $cCl .= $this->getOptionsCheck($table);
221
        }
222
        unset($fieldElementId);
223
224
        $ret .= $pc->getPhpCodeClass($ucfModuleDirname.$ucfTableName, $cCl, 'XoopsObject');
225
226
        return $ret;
227
    }
228
229
    /**
230
     *  @private function getNewInsertId
231
     *
232
     *  @param $table
233
     *
234
     * @return string
235
     */
236
    private function getNewInsertId($table)
237
    {
238
        $pc = TDMCreatePhpCode::getInstance();
239
        $xc = TDMCreateXoopsCode::getInstance();
240
        $tableName = $table->getVar('table_name');
241
        $ucfTableName = ucfirst($tableName);
242
        $ret = $pc->getPhpCodeCommentMultiLine(['The new inserted' => '$Id', '@return' => 'inserted id'], "\t");
243
        $getInsertedId = $xc->getXcEqualsOperator('$newInsertedId', "\$GLOBALS['xoopsDB']->getInsertId()", null, false, "\t\t");
244
        $getInsertedId .= $this->getSimpleString('return $newInsertedId;', "\t\t");
245
246
        $ret .= $pc->getPhpCodeFunction('getNewInsertedId'.$ucfTableName, '', $getInsertedId, 'public ', false, "\t");
247
248
        return $ret;
249
    }
250
251
    /**
252
     * @private function getFunctionForm
253
     *
254
     * @param string $module
255
     * @param string $table
256
     *
257
     * @param        $fieldId
258
     * @param        $fieldInForm
259
     * @return string
260
     */
261
    private function getFunctionForm($module, $table, $fieldId, $fieldInForm)
262
    {
263
        $pc = TDMCreatePhpCode::getInstance();
264
        $xc = TDMCreateXoopsCode::getInstance();
265
        $cc = ClassXoopsCode::getInstance();
266
        $fe = ClassFormElements::getInstance();
267
        $moduleDirname = $module->getVar('mod_dirname');
268
        $tableName = $table->getVar('table_name');
269
        $tableSoleName = $table->getVar('table_solename');
270
        $tableCategory = $table->getVar('table_category');
271
        $tablePermissions = $table->getVar('table_permissions');
0 ignored issues
show
Unused Code introduced by
The assignment to $tablePermissions is dead and can be removed.
Loading history...
272
        $ucfTableName = ucfirst($tableName);
273
        $stuTableSoleName = strtoupper($tableSoleName);
274
        $language = $this->getLanguage($moduleDirname, 'AM');
275
        $fe->initForm($module, $table);
276
        $ret = $pc->getPhpCodeCommentMultiLine(['@public function' => 'getForm', '@param bool' => '$action', '@return' => 'XoopsThemeForm'], "\t");
277
        $action = $xc->getXcEqualsOperator('$action', "\$_SERVER['REQUEST_URI']", null, false, "\t\t\t");
278
        $ucfModuleDirname = ucfirst($moduleDirname);
279
        $getForm = $xc->getXcGetInstance("{$moduleDirname}", "{$ucfModuleDirname}Helper", "\t\t");
280
        //$getForm .= $pc->getPhpCodeConditions('$action', ' === ', 'false', $action, false, "\t\t");
281
		$getForm .= $pc->getPhpCodeConditions('false', ' === ', '$action', $action, false, "\t\t");
282
        $xUser = $pc->getPhpCodeGlobals('xoopsUser');
283
        $xModule = $pc->getPhpCodeGlobals('xoopsModule');
284
        if (1 != $tableCategory/* && (1 == $tablePermissions)*/) {
285
            $getForm .= $pc->getPhpCodeCommentLine('Permissions for', 'uploader', "\t\t");
286
            $getForm .= $xc->getXcEqualsOperator('$gpermHandler', "xoops_gethandler('groupperm')", null, true, "\t\t");
287
            $getForm .= $pc->getPhpCodeTernaryOperator('groups', 'is_object('.$xUser.')', $xUser.'->getGroups()', 'XOOPS_GROUP_ANONYMOUS', "\t\t");
288
            $checkRight = $xc->getXcCheckRight('$gpermHandler', $permString = '', 32, '$groups', $xModule.'->getVar(\'mid\')', true);
289
            $ternaryOperator = $pc->getPhpCodeTernaryOperator('permissionUpload', $checkRight, 'true', 'false', "\t\t\t\t");
290
            $permissionUpload = $xc->getXcEqualsOperator('$permissionUpload', 'true', null, false, "\t\t\t\t");
291
            $ternOperator = $pc->getPhpCodeRemoveCarriageReturn($ternaryOperator, '', "\r");
292
            $if = $pc->getPhpCodeConditions('!'.$xUser.'->isAdmin('.$xModule.'->mid())', '', '', $ternaryOperator, $permissionUpload, "\t\t\t");
293
            $getForm .= $pc->getPhpCodeConditions($xUser, '', '', $if, $ternOperator, "\t\t");
294
        }
295
        $getForm .= $pc->getPhpCodeCommentLine('Title', '', "\t\t");
296
        $getForm .= $pc->getPhpCodeTernaryOperator('title', '$this->isNew()', "sprintf({$language}{$stuTableSoleName}_ADD)", "sprintf({$language}{$stuTableSoleName}_EDIT)", "\t\t");
297
        $getForm .= $pc->getPhpCodeCommentLine('Get Theme', 'Form', "\t\t");
298
        $getForm .= $xc->getXcLoad('XoopsFormLoader', "\t\t");
299
        $getForm .= $cc->getClassXoopsThemeForm('form', 'title', 'form', 'action', 'post');
300
        $getForm .= $cc->getClassSetExtra('form', "'enctype=\"multipart/form-data\"'");
301
        $getForm .= $fe->renderElements();
302
303
        if (in_array(1, $fieldInForm)) {
304
            if (1 == $table->getVar('table_permissions')) {
305
                $getForm .= $this->getPermissionsInForm($moduleDirname, $fieldId);
306
            }
307
        }
308
        $getForm .= $pc->getPhpCodeCommentLine('To Save', '', "\t\t");
309
        //$hiddenSave = $cc->getClassXoopsFormHidden('', "'op'", "'save'", true, false);
310
        $getForm .= $cc->getClassAddElement('form', "new XoopsFormHidden('op', 'save')");
311
        //$buttonSend = $cc->getClassXoopsFormButton('', '', 'submit', '_SUBMIT', 'submit', true);
312
        $getForm .= $cc->getClassAddElement('form', "new XoopsFormButton('', 'submit', _SUBMIT, 'submit')");
313
        $getForm .= $this->getSimpleString('return $form;', "\t\t");
314
315
        $ret .= $pc->getPhpCodeFunction('getForm'.$ucfTableName, '$action = false', $getForm, 'public ', false, "\t");
316
317
        return $ret;
318
    }
319
320
    /**
321
     *  @private function getPermissionsInForm
322
     *
323
     *  @param string $moduleDirname
324
     *  @param string $fieldId
325
     *
326
     * @return string
327
     */
328
    private function getPermissionsInForm($moduleDirname, $fieldId)
329
    {
330
        $pc = TDMCreatePhpCode::getInstance();
331
        $xc = TDMCreateXoopsCode::getInstance();
332
        $cc = ClassXoopsCode::getInstance();
333
        $permissionApprove = $this->getLanguage($moduleDirname, 'AM', 'PERMISSIONS_APPROVE');
334
        $permissionSubmit = $this->getLanguage($moduleDirname, 'AM', 'PERMISSIONS_SUBMIT');
335
        $permissionView = $this->getLanguage($moduleDirname, 'AM', 'PERMISSIONS_VIEW');
336
        $ret = $pc->getPhpCodeCommentLine('Permissions', '', "\t\t");
337
        $ret .= $xc->getXcEqualsOperator('$memberHandler', "xoops_gethandler('member')", null, false, "\t\t");
338
        $ret .= $xc->getXcEqualsOperator('$groupList', '$memberHandler->getGroupList()', null, false, "\t\t");
339
        $ret .= $xc->getXcEqualsOperator('$gpermHandler', "xoops_gethandler('groupperm')", null, false, "\t\t");
340
        $ret .= $pc->getPhpCodeArrayType('fullList', 'keys', 'groupList', null, false, "\t\t");
341
        $fId = $xc->getXcGetVar('', 'this', $fieldId, true);
342
        $mId = $xc->getXcGetVar('', "GLOBALS['xoopsModule']", 'mid', true);
343
        $ifGroups = $xc->getXcGetGroupIds('groupsIdsApprove', 'gpermHandler', "'{$moduleDirname}_approve'", $fId, $mId, "\t\t\t");
344
        $ifGroups .= $pc->getPhpCodeArrayType('groupsIdsApprove', 'values', 'groupsIdsApprove', null, false, "\t\t\t");
345
        $ifGroups .= $cc->getClassXoopsFormCheckBox('groupsCanApproveCheckbox', "{$permissionApprove}", 'groups_approve[]', '$groupsIdsApprove', false, "\t\t\t");
346
        $ifGroups .= $xc->getXcGetGroupIds('groupsIdsSubmit', 'gpermHandler', "'{$moduleDirname}_submit'", $fId, $mId, "\t\t\t");
347
        $ifGroups .= $pc->getPhpCodeArrayType('groupsIdsSubmit', 'values', 'groupsIdsSubmit', null, false, "\t\t\t");
348
        $ifGroups .= $cc->getClassXoopsFormCheckBox('groupsCanSubmitCheckbox', "{$permissionSubmit}", 'groups_submit[]', '$groupsIdsSubmit', false, "\t\t\t");
349
        $ifGroups .= $xc->getXcGetGroupIds('groupsIdsView', 'gpermHandler', "'{$moduleDirname}_view'", $fId, $mId, "\t\t\t");
350
        $ifGroups .= $pc->getPhpCodeArrayType('groupsIdsView', 'values', 'groupsIdsView', null, false, "\t\t\t");
351
        $ifGroups .= $cc->getClassXoopsFormCheckBox('groupsCanViewCheckbox', "{$permissionView}", 'groups_view[]', '$groupsIdsView', false, "\t\t\t");
352
353
        $else = $cc->getClassXoopsFormCheckBox('groupsCanApproveCheckbox', "{$permissionApprove}", 'groups_approve[]', '$fullList', false, "\t\t\t");
354
        $else .= $cc->getClassXoopsFormCheckBox('groupsCanSubmitCheckbox', "{$permissionSubmit}", 'groups_submit[]', '$fullList', false, "\t\t\t");
355
        $else .= $cc->getClassXoopsFormCheckBox('groupsCanViewCheckbox', "{$permissionView}", 'groups_view[]', '$fullList', false, "\t\t\t");
356
357
        $ret .= $pc->getPhpCodeConditions('!$this->isNew()', null, null, $ifGroups, $else, "\t\t");
358
        $ret .= $pc->getPhpCodeCommentLine('To Approve', '', "\t\t");
359
        $ret .= $cc->getClassAddOptionArray('groupsCanApproveCheckbox', '$groupList');
360
        $ret .= $cc->getClassAddElement('form', '$groupsCanApproveCheckbox');
361
        $ret .= $pc->getPhpCodeCommentLine('To Submit', '', "\t\t");
362
        $ret .= $cc->getClassAddOptionArray('groupsCanSubmitCheckbox', '$groupList');
363
        $ret .= $cc->getClassAddElement('form', '$groupsCanSubmitCheckbox');
364
        $ret .= $pc->getPhpCodeCommentLine('To View', '', "\t\t");
365
        $ret .= $cc->getClassAddOptionArray('groupsCanViewCheckbox', '$groupList');
366
        $ret .= $cc->getClassAddElement('form', '$groupsCanViewCheckbox');
367
368
        return $ret;
369
    }
370
371
    /**
372
     * @private  function getValuesInObject
373
     *
374
     * @param $moduleDirname
375
     * @param $table
376
     * @param $fields
377
     * @return string
378
     * @internal param $null
379
     */
380
    private function getValuesInObject($moduleDirname, $table, $fields)
381
    {
382
        $tc = TDMCreateHelper::getInstance();
383
        $pc = TDMCreatePhpCode::getInstance();
384
        $xc = TDMCreateXoopsCode::getInstance();
385
        $stuModuleDirname = strtoupper($moduleDirname);
0 ignored issues
show
Unused Code introduced by
The assignment to $stuModuleDirname is dead and can be removed.
Loading history...
386
        $ucfTableName = ucfirst($table->getVar('table_name'));
387
        $ret = $pc->getPhpCodeCommentMultiLine(['Get' => 'Values', '@param null $keys' => '', '@param null $format' => '', '@param null$maxDepth' => '', '@return' => 'array'], "\t");
388
        $ucfModuleDirname = ucfirst($moduleDirname);
389
        $getValues = $xc->getXcGetInstance("{$moduleDirname}", "{$ucfModuleDirname}Helper", "\t\t");
390
        $getValues .= $xc->getXcEqualsOperator('$ret', '$this->getValues($keys, $format, $maxDepth)', null, false, "\t\t");
391
392
        foreach (array_keys($fields) as $f) {
393
            $fieldName = $fields[$f]->getVar('field_name');
394
            $fieldElement = $fields[$f]->getVar('field_element');
395
            $rpFieldName = $this->getRightString($fieldName);
396
            switch ($fieldElement) {
397
                case 3:
398
                case 4:
399
                    $getValues .= $pc->getPhpCodeStripTags("ret['{$rpFieldName}']", "\$this->getVar('{$fieldName}')", false, "\t\t");
400
                break;
401
                case 8:
402
                    $getValues .= $xc->getXcUnameFromId("ret['{$rpFieldName}']", "\$this->getVar('{$fieldName}')", "\t\t");
403
                break;
404
                case 15:
405
                    $getValues .= $xc->getXcFormatTimeStamp("ret['{$rpFieldName}']", "\$this->getVar('{$fieldName}')", 's', "\t\t");
406
                break;
407
                default:
408
                    if ($fieldElement > 15) {
409
                        $fieldElements = $tc->getHandler('fieldelements')->get($fieldElement);
410
                        $fieldElementMid = $fieldElements->getVar('fieldelement_mid');
411
                        $fieldElementTid = $fieldElements->getVar('fieldelement_tid');
412
                        $fieldElementName = $fieldElements->getVar('fieldelement_name');
413
                        $fieldNameDesc = substr($fieldElementName, strrpos($fieldElementName, ':'), strlen($fieldElementName));
414
                        $topicTableName = str_replace(': ', '', strtolower($fieldNameDesc));
415
                        $fieldsTopics = $this->getTableFields($fieldElementMid, $fieldElementTid);
416
                        foreach (array_keys($fieldsTopics) as $g) {
417
                            $fieldNameTopic = $fieldsTopics[$g]->getVar('field_name');
418
                            if (1 == $fieldsTopics[$g]->getVar('field_main')) {
419
                                $fieldMainTopic = $fieldNameTopic;
420
                            }
421
                        }
422
                        $getHandlerVar = "\${$moduleDirname}->getHandler('{$topicTableName}')";
423
                        $getValues .= $xc->getXcEqualsOperator("\${$topicTableName}", $getHandlerVar, null, false, "\t\t");
424
                        $getTopicTable = "\${$topicTableName}->get(\$this->getVar('{$fieldName}'))";
425
                        $getValues .= $xc->getXcEqualsOperator("\${$topicTableName}Obj", $getTopicTable, null, false, "\t\t");
426
                        $fMainTopic = "\${$fieldName}->getVar('{$fieldMainTopic}')";
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $fieldMainTopic does not seem to be defined for all execution paths leading up to this point.
Loading history...
427
                        $getValues .= $xc->getXcEqualsOperator("\$ret['{$rpFieldName}']", $fMainTopic, null, false, "\t\t");
428
                    } else {
429
                        $getValues .= $xc->getXcGetVar("ret['{$rpFieldName}']", 'this', $fieldName, false, "\t\t");
430
                    }
431
                break;
432
            }
433
        }
434
        $getValues .= $this->getSimpleString('return $ret;', "\t\t");
435
436
        $ret .= $pc->getPhpCodeFunction('getValues'.$ucfTableName, '$keys = null, $format = null, $maxDepth = null', $getValues, 'public ', false, "\t");
437
438
        return $ret;
439
    }
440
441
    /**
442
     *  @private function getToArrayInObject
443
     *
444
     *  @param $table
445
     *
446
     * @return string
447
     */
448
    private function getToArrayInObject($table)
449
    {
450
        $pc = TDMCreatePhpCode::getInstance();
451
        $xc = TDMCreateXoopsCode::getInstance();
452
        $tableName = $table->getVar('table_name');
453
        $ucfTableName = ucfirst($tableName);
454
        $multiLineCom = ['Returns an array representation' => 'of the object', '' => '', '@return' => 'array'];
455
        $ret = $pc->getPhpCodeCommentMultiLine($multiLineCom, "\t");
456
457
        $getToArray = $pc->getPhpCodeArray('ret', [], false, "\t\t");
458
        $getToArray .= $xc->getXcEqualsOperator('$vars', '$this->getVars()', null, false, "\t\t");
459
        $foreach = $xc->getXcGetVar('ret[$var]', 'this', '"{$var}"', false, "\t");
460
        $getToArray .= $pc->getPhpCodeForeach('vars', true, false, 'var', $foreach, "\t\t");
461
        $getToArray .= $this->getSimpleString('return $ret;', "\t\t");
462
463
        $ret .= $pc->getPhpCodeFunction('toArray'.$ucfTableName, '', $getToArray, 'public ', false, "\t");
464
465
        return $ret;
466
    }
467
468
    /**
469
     *  @private function getOptionsCheck
470
     *
471
     *  @param $table
472
     *
473
     * @return string
474
     */
475
    private function getOptionsCheck($table)
476
    {
477
        $tc = TDMCreateHelper::getInstance();
478
        $pc = TDMCreatePhpCode::getInstance();
479
        $tableName = $table->getVar('table_name');
480
        $ucfTableName = ucfirst($tableName);
481
        $ret = $pc->getPhpCodeCommentMultiLine(['Get' => 'Options'], "\t");
482
        $getOptions = $pc->getPhpCodeArray('ret', [], false, "\t");
483
484
        $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id'));
485
        foreach (array_keys($fields) as $f) {
486
            $fieldName = $fields[$f]->getVar('field_name');
487
            $fieldElement = $fields[$f]->getVar('field_element');
488
489
            $fieldElements = $tc->getHandler('fieldelements')->get($fieldElement);
490
            $fieldElementId = $fieldElements->getVar('fieldelement_id');
491
            $rpFieldName = $this->getRightString($fieldName);
492
            if (5 == $fieldElementId) {
493
                $arrayPush = $pc->getPhpCodeArrayType('ret', 'push', "'{$rpFieldName}'", null, false, "\t\t\t");
494
                $getOptions .= $pc->getPhpCodeConditions(1, ' == ', "\$this->getVar('{$fieldName}')", $arrayPush, false, "\t\t");
495
            }
496
        }
497
498
        $getOptions .= $this->getSimpleString('return $ret;', "\t\t");
499
500
        $ret .= $pc->getPhpCodeFunction('getOptions'.$ucfTableName, '', $getOptions, 'public ', false, "\t");
501
502
        return $ret;
503
    }
504
505
    /**
506
     * @public function getClassHandler
507
     *
508
     * @param string $moduleDirname
509
     * @param string $table
510
     * @param string $fieldId
511
     * @param        $fieldName
512
     * @param string $fieldMain
513
     *
514
     * @param        $fieldParent
515
     * @param        $fieldParentId
516
     * @param        $fieldElement
517
     * @return string
518
     */
519
    private function getClassObjectHandler($moduleDirname, $table, $fieldId, $fieldName, $fieldMain, $fieldParent, $fieldParentId, $fieldElement)
520
    {
521
        $pc = TDMCreatePhpCode::getInstance();
522
        $tableName = $table->getVar('table_name');
523
        $tableCategory = $table->getVar('table_category');
0 ignored issues
show
Unused Code introduced by
The assignment to $tableCategory is dead and can be removed.
Loading history...
524
        $tableSoleName = $table->getVar('table_solename');
525
        $tableFieldname = $table->getVar('table_fieldname');
0 ignored issues
show
Unused Code introduced by
The assignment to $tableFieldname is dead and can be removed.
Loading history...
526
        $ucfModuleDirname = ucfirst($moduleDirname);
527
        $ucfTableName = ucfirst($tableName);
528
        $ucfTableSoleName = ucfirst($tableSoleName);
0 ignored issues
show
Unused Code introduced by
The assignment to $ucfTableSoleName is dead and can be removed.
Loading history...
529
        $ucfModuleTable = $ucfModuleDirname.$ucfTableName;
530
        $multiLineCom = ['Class Object Handler' => $ucfModuleDirname . $ucfTableName];
531
        $ret = $pc->getPhpCodeCommentMultiLine($multiLineCom);
532
533
        $cClh = $pc->getPhpCodeCommentMultiLine(['Constructor' => '', '' => '', '@param' => 'null|XoopsDatabase $db'], "\t");
534
        $constr = "\t\tparent::__construct(\$db, '{$moduleDirname}_{$tableName}', '{$moduleDirname}{$tableName}', '{$fieldId}', '{$fieldMain}');\n";
535
536
        $cClh .= $pc->getPhpCodeFunction('__construct', 'XoopsDatabase $db', $constr, 'public ', false, "\t");
537
        $cClh .= $this->getClassCreate();
538
        $cClh .= $this->getClassGet();
539
        $cClh .= $this->getClassGetInsertId();
540
        $cClh .= $this->getClassCounter($tableName, $fieldId, $fieldMain);
541
        $cClh .= $this->getClassAll($tableName, $fieldId, $fieldMain);
542
        $cClh .= $this->getClassCriteria($tableName);
543
        if ($fieldElement > 15 && in_array(1, $fieldParentId)) {
544
            $cClh .= $this->getClassByCategory($moduleDirname, $tableName, $tableFieldName, $fieldId, $fieldName, $fieldMain, $fieldParent, $fieldElement);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $tableFieldName does not exist. Did you maybe mean $tableFieldname?
Loading history...
545
            $cClh .= $this->getClassGetTableSolenameById($moduleDirname, $table, $fieldMain);
546
        }
547
548
        $ret .= $pc->getPhpCodeClass("{$ucfModuleTable}Handler", $cClh, 'XoopsPersistableObjectHandler');
549
550
        return $ret;
551
    }
552
553
    /**
554
     *  @public function getClassCreate
555
     *
556
     *  @return string
557
     */
558
    private function getClassCreate()
559
    {
560
        $pc = TDMCreatePhpCode::getInstance();
561
        $ret = $pc->getPhpCodeCommentMultiLine(['@param bool' => '$isNew', '' => '', '@return' => 'object'], "\t");
562
        $cClhc = $this->getSimpleString('return parent::create($isNew);', "\t\t");
563
564
        $ret .= $pc->getPhpCodeFunction('create', '$isNew = true', $cClhc, 'public ', false, "\t");
565
566
        return $ret;
567
    }
568
569
    /**
570
     *  @public function getClassGet
571
     *
572
     *  @return string
573
     */
574
    private function getClassGet()
575
    {
576
        $pc = TDMCreatePhpCode::getInstance();
577
        $ret = $pc->getPhpCodeCommentMultiLine(['retrieve a' => 'field', '' => '', '@param int' => '$i field id', '@param null' => 'fields', '@return mixed reference to the' => '{@link Get} object'], "\t");
578
        $cClhg = $this->getSimpleString('return parent::get($i, $fields);', "\t\t");
579
580
        $ret .= $pc->getPhpCodeFunction('get', '$i = null, $fields = null', $cClhg, 'public ', false, "\t");
581
582
        return $ret;
583
    }
584
585
    /**
586
     *  @public function getClassGetInsertId
587
     *
588
     *  @return string
589
     */
590
    private function getClassGetInsertId()
591
    {
592
        $pc = TDMCreatePhpCode::getInstance();
593
        $ret = $pc->getPhpCodeCommentMultiLine(['get inserted' => 'id', '' => '', '@param' => 'null', '@return integer reference to the' => '{@link Get} object'], "\t");
594
        $cClhgid = $this->getSimpleString('return $this->db->getInsertId();', "\t\t");
595
596
        $ret .= $pc->getPhpCodeFunction('getInsertId', '', $cClhgid, 'public ', false, "\t");
597
598
        return $ret;
599
    }
600
601
    /**
602
     *  @public function getClassCounter
603
     *
604
     *  @param $tableName
605
     *  @param $fieldId
606
     *  @param $fieldMain
607
     *
608
     *  @return string
609
     */
610
    private function getClassCounter($tableName, $fieldId, $fieldMain)
611
    {
612
        $pc = TDMCreatePhpCode::getInstance();
613
        $xc = TDMCreateXoopsCode::getInstance();
614
        $cc = ClassXoopsCode::getInstance();
615
        $ucfTableName = ucfirst($tableName);
616
        $ret = $pc->getPhpCodeCommentMultiLine(['Get Count ' . $ucfTableName => 'in the database', '@param int    $start' => '', '@param int    $limit' => '', '@param string $sort' => '', '@param string $order' => '', '@return' => 'int'], "\t");
617
618
        $critCount = $cc->getClassCriteriaCompo('crCount'.$ucfTableName, "\t\t");
619
        $paramsCrit = "\$this->get{$ucfTableName}Criteria(\$crCount{$ucfTableName}, \$start, \$limit, \$sort, \$order)";
620
        $critCount .= $xc->getXcEqualsOperator('$crCount'.$ucfTableName, $paramsCrit, null, false, "\t\t");
621
        $critCount .= $this->getSimpleString("return parent::getCount(\$crCount{$ucfTableName});", "\t\t");
622
        $params = "\$start = 0, \$limit = 0, \$sort = '{$fieldId} ASC, {$fieldMain}', \$order = 'ASC'";
623
624
        $ret .= $pc->getPhpCodeFunction('getCount'.$ucfTableName, $params, $critCount, 'public ', false, "\t");
625
626
        return $ret;
627
    }
628
629
    /**
630
     *  @public function getClassAll
631
     *
632
     *  @param $tableName
633
     *  @param $fieldId
634
     *  @param $fieldMain
635
     *
636
     *  @return string
637
     */
638
    private function getClassAll($tableName, $fieldId, $fieldMain)
639
    {
640
        $pc = TDMCreatePhpCode::getInstance();
641
        $xc = TDMCreateXoopsCode::getInstance();
642
        $cc = ClassXoopsCode::getInstance();
643
        $ucfTableName = ucfirst($tableName);
644
        $ret = $pc->getPhpCodeCommentMultiLine(['Get All ' . $ucfTableName => 'in the database', '@param int    $start' => '', '@param int    $limit' => '', '@param string $sort' => '', '@param string $order' => '', '@return' => 'array'], "\t");
645
646
        $critAll = $cc->getClassCriteriaCompo('crAll'.$ucfTableName, "\t\t");
647
        $paramsCrit = "\$this->get{$ucfTableName}Criteria(\$crAll{$ucfTableName}, \$start, \$limit, \$sort, \$order)";
648
        $critAll .= $xc->getXcEqualsOperator('$crAll'.$ucfTableName, $paramsCrit, null, false, "\t\t");
649
        $critAll .= $this->getSimpleString("return parent::getAll(\$crAll{$ucfTableName});", "\t\t");
650
        $params = "\$start = 0, \$limit = 0, \$sort = '{$fieldId} ASC, {$fieldMain}', \$order = 'ASC'";
651
652
        $ret .= $pc->getPhpCodeFunction('getAll'.$ucfTableName, $params, $critAll, 'public ', false, "\t");
653
654
        return $ret;
655
    }
656
657
    /**
658
     * @public function getClassByCategory
659
     *
660
     * @param $moduleDirname
661
     * @param $tableName
662
     * @param $tableFieldName
663
     * @param $fieldId
664
     * @param $fieldName
665
     * @param $fieldMain
666
     * @param $fieldParent
667
     *
668
     * @param $fieldElement
669
     * @return string
670
     */
671
    private function getClassByCategory($moduleDirname, $tableName, $tableFieldName, $fieldId, $fieldName, $fieldMain, $fieldParent, $fieldElement)
0 ignored issues
show
Unused Code introduced by
The parameter $fieldParent is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

671
    private function getClassByCategory($moduleDirname, $tableName, $tableFieldName, $fieldId, $fieldName, $fieldMain, /** @scrutinizer ignore-unused */ $fieldParent, $fieldElement)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
672
    {
673
        $tc = TDMCreateHelper::getInstance();
674
        $pc = TDMCreatePhpCode::getInstance();
675
        $xc = TDMCreateXoopsCode::getInstance();
676
        $cc = ClassXoopsCode::getInstance();
677
        $ucfTableName = ucfirst($tableName);
678
        $fieldElements = $tc->getHandler('fieldelements')->get($fieldElement);
679
        $fieldElementMid = $fieldElements->getVar('fieldelement_mid');
0 ignored issues
show
Unused Code introduced by
The assignment to $fieldElementMid is dead and can be removed.
Loading history...
680
        $fieldElementTid = $fieldElements->getVar('fieldelement_tid');
0 ignored issues
show
Unused Code introduced by
The assignment to $fieldElementTid is dead and can be removed.
Loading history...
681
        $fieldElementName = $fieldElements->getVar('fieldelement_name');
682
        $fieldNameDesc = ucfirst(substr($fieldElementName, strrpos($fieldElementName, ':'), strlen($fieldElementName)));
683
        $topicTableName = str_replace(': ', '', $fieldNameDesc);
684
        $lcfTopicTableName = lcfirst($topicTableName);
685
686
        $ret = $pc->getPhpCodeCommentMultiLine(["Get All {$ucfTableName} By" => "{$fieldNameDesc} Id", '@param int    $start' => '', '@param int    $limit' => '', '@param string $sort' => '', '@param string $order' => '', '@return' => 'array'], "\t");
687
688
        $critAll = $xc->getXcEqualsOperator('$gpermHandler', "xoops_gethandler('groupperm')", null, true, "\t\t");
689
        $param1 = "'{$moduleDirname}_view'";
690
        $param2 = "\$GLOBALS['xoopsUser']->getGroups()";
691
        $param3 = "\$GLOBALS['xoopsModule']->getVar('mid')";
692
        $critAll .= $xc->getXcGetItemIds($lcfTopicTableName, 'gpermHandler', $param1, $param2, $param3, "\t\t");
693
        $critAll .= $cc->getClassCriteriaCompo('crAll'.$ucfTableName, "\t\t");
694
695
        if (false !== strpos($fieldName, 'status')) {
696
            $crit = $cc->getClassCriteria('', "'{$fieldName}'", '0', "'!='", true);
697
            $critAll .= $cc->getClassAdd('crAll'.$ucfTableName, $crit, "\t\t");
698
        }
699
        $paramsCritAll = "\$this->get{$ucfTableName}Criteria(\$crAll{$ucfTableName}, \$start, \$limit, \$sort, \$order)";
700
        $critAll .= $xc->getXcEqualsOperator('$crAll'.$ucfTableName, $paramsCritAll, null, false, "\t\t");
701
702
        $critAll .= $this->getSimpleString("return parent::getAll(\$crAll{$ucfTableName});", "\t\t");
703
        $params = "\${$tableFieldName}Id, \$start = 0, \$limit = 0, \$sort = '{$fieldId} ASC, {$fieldMain}', \$order = 'ASC'";
704
705
        $ret .= $pc->getPhpCodeFunction("getAll{$ucfTableName}By{$fieldNameDesc}Id".$ucfTableName, $params, $critAll, 'public ', false, "\t");
706
707
        return $ret;
708
    }
709
710
    /**
711
     *  @public function getClassCriteria
712
     *
713
     *  @param $tableName
714
     *  @return string
715
     */
716
    private function getClassCriteria($tableName)
717
    {
718
        $pc = TDMCreatePhpCode::getInstance();
719
        $cc = ClassXoopsCode::getInstance();
720
        $ucfTableName = ucfirst($tableName);
721
        $ret = $pc->getPhpCodeCommentMultiLine(['Get' => 'Criteria ' . $ucfTableName, '@param       ' => "\$cr{$ucfTableName}", '@param int    $start' => '', '@param int    $limit' => '', '@param string $sort' => '', '@param string $order' => '', '@return' => 'int'], "\t");
722
723
        $paramsAllCriteria = "\$cr{$ucfTableName}, \$start, \$limit, \$sort, \$order";
724
725
        $critSets = $cc->getClassSetStart('cr'.$ucfTableName, 'start', "\t\t");
726
        $critSets .= $cc->getClassSetLimit('cr'.$ucfTableName, 'limit', "\t\t");
727
        $critSets .= $cc->getClassSetSort('cr'.$ucfTableName, 'sort', "\t\t");
728
        $critSets .= $cc->getClassSetOrder('cr'.$ucfTableName, 'order', "\t\t");
729
        $critSets .= $this->getSimpleString("return \$cr{$ucfTableName};", "\t\t");
730
731
        $ret .= $pc->getPhpCodeFunction("get{$ucfTableName}Criteria", $paramsAllCriteria, $critSets, 'private ', false, "\t");
732
733
        return $ret;
734
    }
735
736
    /**
737
     * @public function getClassGetTableSolenameById
738
     *
739
     * @param $moduleDirname
740
     * @param $table
741
     *
742
     * @param $fieldMain
743
     * @return string
744
     */
745
    private function getClassGetTableSolenameById($moduleDirname, $table, $fieldMain)
746
    {
747
        $pc = TDMCreatePhpCode::getInstance();
748
        $xc = TDMCreateXoopsCode::getInstance();
749
        $tableName = $table->getVar('table_name');
750
        $tableSoleName = $table->getVar('table_solename');
751
        $ucfTableSoleName = ucfirst($tableSoleName);
752
        $ccTableSoleName = $this->getCamelCase($tableSoleName, true);
753
        $ret = $pc->getPhpCodeCommentMultiLine(['Returns the' => $ucfTableSoleName . ' from id', '' => '', '@return' => 'string'], "\t");
754
        $soleName = $xc->getXcEqualsOperator("\${$tableSoleName}Id", "(int)( \${$tableSoleName}Id )", null, false, "\t\t");
755
        $soleName .= $xc->getXcEqualsOperator("\${$tableSoleName}", "''", null, false, "\t\t");
756
757
        $contentIf = $xc->getXoopsHandlerLine($moduleDirname, $tableName, "\t\t\t");
758
        $contentIf .= $xc->getXcGet($tableName, "\${$tableSoleName}Id", 'Obj', true, false, "\t\t\t");
0 ignored issues
show
Bug introduced by
true of type true is incompatible with the type string expected by parameter $handler of TDMCreateXoopsCode::getXcGet(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

758
        $contentIf .= $xc->getXcGet($tableName, "\${$tableSoleName}Id", 'Obj', /** @scrutinizer ignore-type */ true, false, "\t\t\t");
Loading history...
759
        $getVar = $xc->getXcGetVar($ccTableSoleName, "{$tableSoleName}Obj", $fieldMain, false, "\t\t\t\t");
760
        $contentIf .= $pc->getPhpCodeConditions("is_object( \${$tableSoleName}Obj )", '', '', $getVar, false, "\t\t\t");
761
762
        $soleName .= $pc->getPhpCodeConditions("\${$tableSoleName}Id", ' > ', '0', $contentIf = null, false, "\t\t");
763
        $soleName .= $this->getSimpleString("return \${$tableSoleName};", "\t\t");
764
765
        $ret .= $pc->getPhpCodeFunction("get{$ucfTableSoleName}FromId", "\${$tableSoleName}Id", $soleName, 'public ', false, "\t");
766
767
        return $ret;
768
    }
769
770
    /**
771
     * @public function render
772
     * @param null
773
     *
774
     * @return bool|string
775
     */
776
    public function render()
777
    {
778
        $tc = TDMCreateHelper::getInstance();
779
        $module = $this->getModule();
780
        $table = $this->getTable();
781
        $filename = $this->getFileName();
782
        $tableName = $table->getVar('table_name');
0 ignored issues
show
Unused Code introduced by
The assignment to $tableName is dead and can be removed.
Loading history...
783
        $tableFieldName = $table->getVar('table_fieldname');
0 ignored issues
show
Unused Code introduced by
The assignment to $tableFieldName is dead and can be removed.
Loading history...
784
        $tableCategory = $table->getVar('table_category');
0 ignored issues
show
Unused Code introduced by
The assignment to $tableCategory is dead and can be removed.
Loading history...
785
        $moduleDirname = $module->getVar('mod_dirname');
786
        $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id'));
787
        $fieldInForm = [];
788
        $fieldParentId = [];
789
        $fieldElementId = [];
790
        $fieldParent = null;
791
        foreach (array_keys($fields) as $f) {
792
            $fieldName = $fields[$f]->getVar('field_name');
793
            $fieldInForm[] = $fields[$f]->getVar('field_inform');
794
            $fieldParentId[] = $fields[$f]->getVar('field_parent');
795
            if ((0 == $f) && (1 == $table->getVar('table_autoincrement'))) {
796
                $fieldId = $fieldName; // $fieldId = fields parameter index field
797
            }
798
            if (1 == $fields[$f]->getVar('field_main')) {
799
                $fieldMain = $fieldName; // $fieldMain = fields parameter main field
800
            }
801
            if (1 == $fields[$f]->getVar('field_parent')) {
802
                $fieldParent = $fieldName; // $fieldParent = fields parameter parent field
803
            }
804
            $fieldElement = $fields[$f]->getVar('field_element');
805
806
            $fieldElements = $tc->getHandler('fieldelements')->get($fieldElement);
807
            $fieldElementId[] = $fieldElements->getVar('fieldelement_id');
808
        }
809
        $content = $this->getHeaderFilesComments($module, $filename);
810
        $content .= $this->getClassObject($module, $table, $fields);
811
        $content .= $this->getClassObjectHandler($moduleDirname, $table, $fieldId, $fieldName, $fieldMain, $fieldParent, $fieldParentId, $fieldElement);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $fieldName seems to be defined by a foreach iteration on line 791. Are you sure the iterator is never empty, otherwise this variable is not defined?
Loading history...
Comprehensibility Best Practice introduced by
The variable $fieldId does not seem to be defined for all execution paths leading up to this point.
Loading history...
Comprehensibility Best Practice introduced by
The variable $fieldElement seems to be defined by a foreach iteration on line 791. Are you sure the iterator is never empty, otherwise this variable is not defined?
Loading history...
Comprehensibility Best Practice introduced by
The variable $fieldMain does not seem to be defined for all execution paths leading up to this point.
Loading history...
812
813
        $this->create($moduleDirname, 'class', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED);
814
815
        return $this->renderFile();
816
    }
817
}
818