CategoryForm::createElements()   F
last analyzed

Complexity

Conditions 26
Paths > 20000

Size

Total Lines 219
Code Lines 146

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 26
eloc 146
c 1
b 0
f 0
nc 106496
nop 0
dl 0
loc 219
rs 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php declare(strict_types=1);
2
3
namespace XoopsModules\Publisher\Form;
4
5
/*
6
 You may not change or alter any portion of this comment or credits
7
 of supporting developers from this source code or any supporting source code
8
 which is considered copyrighted (c) material of the original comment or credit authors.
9
10
 This program is distributed in the hope that it will be useful,
11
 but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
 */
14
15
/**
16
 *  Publisher form class
17
 *
18
 * @copyright       XOOPS Project (https://xoops.org)
19
 * @license         https://www.fsf.org/copyleft/gpl.html GNU public license
20
 * @since           1.0
21
 * @author          trabis <[email protected]>
22
 */
23
24
use Xmf\Request;
25
use XoopsModules\Publisher\Category;
26
use XoopsModules\Publisher\Helper;
27
use XoopsModules\Publisher\Utility;
28
29
// require_once  \dirname(__DIR__, 2) . '/include/common.php';
30
31
\xoops_load('XoopsFormLoader');
32
require_once $GLOBALS['xoops']->path('class/tree.php');
33
34
/**
35
 * Class CategoryForm
36
 */
37
class CategoryForm extends \XoopsThemeForm
38
{
39
    /**
40
     * @var Helper
41
     */
42
    public $helper;
43
    public $targetObject;
44
    public $subCatsCount = 4;
45
    public $userGroups   = [];
46
47
    /**
48
     * @param Category $target
49
     * @param int      $subCatsCount
50
     */
51
    public function __construct(&$target, $subCatsCount = 4)
52
    {
53
        /** @var Helper $this- >helper */
54
        $this->helper = Helper::getInstance();
55
56
        $this->targetObject = &$target;
57
        $this->subCatsCount = $subCatsCount;
58
59
        /** @var \XoopsMemberHandler $memberHandler */
60
        $memberHandler    = \xoops_getHandler('member');
61
        $this->userGroups = $memberHandler->getGroupList();
62
63
        parent::__construct(\_AM_PUBLISHER_CATEGORY, 'form', \xoops_getenv('SCRIPT_NAME'), 'post', true);
64
        $this->setExtra('enctype="multipart/form-data"');
65
66
        $this->createElements();
67
        $this->createButtons();
68
    }
69
70
    public function createElements(): void
71
    {
72
        // require_once  \dirname(__DIR__, 2) . '/include/common.php';
73
        // Category
74
        $criteria = new \Criteria(null);
75
        $criteria->setSort('weight');
76
        $criteria->order = 'ASC'; // patch for XOOPS <= 2.5.10, does not set order correctly using setOrder() method
77
        $myTree          = new \XoopsObjectTree(
78
            $this->helper->getHandler('Category')
79
                         ->getObjects($criteria), 'categoryid', 'parentid'
80
        );
81
        $moduleDirName   = \basename(\dirname(__DIR__));
82
        $module          = \XoopsModule::getByDirname($moduleDirName);
0 ignored issues
show
Unused Code introduced by
The assignment to $module is dead and can be removed.
Loading history...
83
        $catSelect       = $myTree->makeSelectElement('parentid', 'name', '--', $this->targetObject->parentid(), true, 0, '', \_AM_PUBLISHER_PARENT_CATEGORY_EXP);
0 ignored issues
show
Bug introduced by
The method parentid() does not exist on XoopsModules\Publisher\Category. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

83
        $catSelect       = $myTree->makeSelectElement('parentid', 'name', '--', $this->targetObject->/** @scrutinizer ignore-call */ parentid(), true, 0, '', \_AM_PUBLISHER_PARENT_CATEGORY_EXP);
Loading history...
Bug introduced by
It seems like $this->targetObject->parentid() can also be of type array and array; however, parameter $selected of XoopsObjectTree::makeSelectElement() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

83
        $catSelect       = $myTree->makeSelectElement('parentid', 'name', '--', /** @scrutinizer ignore-type */ $this->targetObject->parentid(), true, 0, '', \_AM_PUBLISHER_PARENT_CATEGORY_EXP);
Loading history...
84
        $this->addElement($catSelect);
85
86
        // Name
87
        $this->addElement(new \XoopsFormText(\_AM_PUBLISHER_CATEGORY, 'name', 50, 255, $this->targetObject->name('e')), true);
0 ignored issues
show
Bug introduced by
The method name() does not exist on XoopsModules\Publisher\Category. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

87
        $this->addElement(new \XoopsFormText(\_AM_PUBLISHER_CATEGORY, 'name', 50, 255, $this->targetObject->/** @scrutinizer ignore-call */ name('e')), true);
Loading history...
Bug introduced by
It seems like $this->targetObject->name('e') can also be of type array and array; however, parameter $value of XoopsFormText::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

87
        $this->addElement(new \XoopsFormText(\_AM_PUBLISHER_CATEGORY, 'name', 50, 255, /** @scrutinizer ignore-type */ $this->targetObject->name('e')), true);
Loading history...
88
89
        // Description
90
        $this->addElement(new \XoopsFormTextArea(\_AM_PUBLISHER_COLDESCRIPT, 'description', $this->targetObject->description('e'), 7, 60));
0 ignored issues
show
Bug introduced by
It seems like $this->targetObject->description('e') can also be of type array and array; however, parameter $value of XoopsFormTextArea::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

90
        $this->addElement(new \XoopsFormTextArea(\_AM_PUBLISHER_COLDESCRIPT, 'description', /** @scrutinizer ignore-type */ $this->targetObject->description('e'), 7, 60));
Loading history...
Bug introduced by
The method description() does not exist on XoopsModules\Publisher\Category. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

90
        $this->addElement(new \XoopsFormTextArea(\_AM_PUBLISHER_COLDESCRIPT, 'description', $this->targetObject->/** @scrutinizer ignore-call */ description('e'), 7, 60));
Loading history...
91
92
        // EDITOR
93
        $groups           = $GLOBALS['xoopsUser'] ? $GLOBALS['xoopsUser']->getGroups() : XOOPS_GROUP_ANONYMOUS;
94
        $grouppermHandler = $this->helper->getHandler('GroupPerm');
95
        $moduleId         = $this->helper->getModule()
96
                                         ->mid();
97
        $allowedEditors   = Utility::getEditors($grouppermHandler->getItemIds('editors', $groups, $moduleId));
98
        $nohtml           = false;
99
        if (\count($allowedEditors) > 0) {
100
            $editor = Request::getString('editor', '', 'POST');
101
            if (!empty($editor)) {
102
                Utility::setCookieVar('publisher_editor', $editor);
103
            } else {
104
                $editor = Utility::getCookieVar('publisher_editor');
105
                if (empty($editor) && \is_object($GLOBALS['xoopsUser'])) {
106
                    $editor = $GLOBALS['xoopsUser']->getVar('publisher_editor') ?? ''; // Need set through user profile
107
                }
108
            }
109
            $editor     = (empty($editor) || !\in_array($editor, $allowedEditors, true)) ? $this->helper->getConfig('submit_editor') : $editor;
110
            $formEditor = new \XoopsFormSelectEditor($this, 'editor', $editor, $nohtml, $allowedEditors);
0 ignored issues
show
Bug introduced by
$this of type XoopsModules\Publisher\Form\CategoryForm is incompatible with the type string expected by parameter $form of XoopsFormSelectEditor::__construct(). ( Ignorable by Annotation )

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

110
            $formEditor = new \XoopsFormSelectEditor(/** @scrutinizer ignore-type */ $this, 'editor', $editor, $nohtml, $allowedEditors);
Loading history...
111
            $this->addElement($formEditor);
112
        } else {
113
            $editor = $this->helper->getConfig('submit_editor');
114
        }
115
116
        $editorConfigs           = [];
117
        $editorConfigs['rows']   = '' == $this->helper->getConfig('submit_editor_rows') ? 35 : $this->helper->getConfig('submit_editor_rows');
118
        $editorConfigs['cols']   = '' == $this->helper->getConfig('submit_editor_cols') ? 60 : $this->helper->getConfig('submit_editor_cols');
119
        $editorConfigs['width']  = '' == $this->helper->getConfig('submit_editor_width') ? '100%' : $this->helper->getConfig('submit_editor_width');
120
        $editorConfigs['height'] = '' == $this->helper->getConfig('submit_editor_height') ? '400px' : $this->helper->getConfig('submit_editor_height');
121
122
        $editorConfigs['name']  = 'header';
123
        $editorConfigs['value'] = $this->targetObject->header('e');
0 ignored issues
show
Bug introduced by
The method header() does not exist on XoopsModules\Publisher\Category. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

123
        /** @scrutinizer ignore-call */ 
124
        $editorConfigs['value'] = $this->targetObject->header('e');
Loading history...
124
125
        $textHeader = new \XoopsFormEditor(\_AM_PUBLISHER_CATEGORY_HEADER, $editor, $editorConfigs, $nohtml, $onfailure = null);
126
        $textHeader->setDescription(\_AM_PUBLISHER_CATEGORY_HEADER_DSC);
127
        $this->addElement($textHeader);
128
129
        // IMAGE
130
        $imageArray  = \XoopsLists::getImgListAsArray(Utility::getImageDir('category'));
131
        $imageSelect = new \XoopsFormSelect('', 'image', $this->targetObject->getImage());
132
        //$imageSelect -> addOption ('-1', '---------------');
133
        $imageSelect->addOptionArray($imageArray);
134
        $imageSelect->setExtra("onchange='showImgSelected(\"image3\", \"image\", \"" . 'uploads/' . $this->helper->getDirname() . '/images/category/' . '", "", "' . XOOPS_URL . "\")'");
135
        $imageTray = new \XoopsFormElementTray(\_AM_PUBLISHER_IMAGE, '&nbsp;');
136
        $imageTray->addElement($imageSelect);
137
        $imageTray->addElement(new \XoopsFormLabel('', "<br><br><img src='" . Utility::getImageDir('category', false) . $this->targetObject->getImage() . "' name='image3' id='image3' alt=''>"));
138
        $imageTray->setDescription(\_AM_PUBLISHER_IMAGE_DSC);
139
        $this->addElement($imageTray);
140
141
        // IMAGE UPLOAD
142
        $maxSize = 5000000;
143
        $fileBox = new \XoopsFormFile(\_AM_PUBLISHER_IMAGE_UPLOAD, 'image_file', $maxSize);
144
        $fileBox->setExtra("size ='45'");
145
        $fileBox->setDescription(\_AM_PUBLISHER_IMAGE_UPLOAD_DSC);
146
        $this->addElement($fileBox);
147
148
        // Short url
149
        $textShortUrl = new \XoopsFormText(\_AM_PUBLISHER_CATEGORY_SHORT_URL, 'short_url', 50, 255, $this->targetObject->short_url('e'));
0 ignored issues
show
Bug introduced by
The method short_url() does not exist on XoopsModules\Publisher\Category. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

149
        $textShortUrl = new \XoopsFormText(\_AM_PUBLISHER_CATEGORY_SHORT_URL, 'short_url', 50, 255, $this->targetObject->/** @scrutinizer ignore-call */ short_url('e'));
Loading history...
150
        $textShortUrl->setDescription(\_AM_PUBLISHER_CATEGORY_SHORT_URL_DSC);
151
        $this->addElement($textShortUrl);
152
153
        // Meta Keywords
154
        $textMetaKeywords = new \XoopsFormTextArea(\_AM_PUBLISHER_CATEGORY_META_KEYWORDS, 'meta_keywords', $this->targetObject->meta_keywords('e'), 7, 60);
0 ignored issues
show
Bug introduced by
The method meta_keywords() does not exist on XoopsModules\Publisher\Category. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

154
        $textMetaKeywords = new \XoopsFormTextArea(\_AM_PUBLISHER_CATEGORY_META_KEYWORDS, 'meta_keywords', $this->targetObject->/** @scrutinizer ignore-call */ meta_keywords('e'), 7, 60);
Loading history...
155
        $textMetaKeywords->setDescription(\_AM_PUBLISHER_CATEGORY_META_KEYWORDS_DSC);
156
        $this->addElement($textMetaKeywords);
157
158
        // Meta Description
159
        $textMetaDescription = new \XoopsFormTextArea(\_AM_PUBLISHER_CATEGORY_META_DESCRIPTION, 'meta_description', $this->targetObject->meta_description('e'), 7, 60);
0 ignored issues
show
Bug introduced by
The method meta_description() does not exist on XoopsModules\Publisher\Category. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

159
        $textMetaDescription = new \XoopsFormTextArea(\_AM_PUBLISHER_CATEGORY_META_DESCRIPTION, 'meta_description', $this->targetObject->/** @scrutinizer ignore-call */ meta_description('e'), 7, 60);
Loading history...
160
        $textMetaDescription->setDescription(\_AM_PUBLISHER_CATEGORY_META_DESCRIPTION_DSC);
161
        $this->addElement($textMetaDescription);
162
163
        // Weight
164
        $this->addElement(new \XoopsFormText(\_AM_PUBLISHER_COLPOSIT, 'weight', 4, 4, $this->targetObject->weight()));
0 ignored issues
show
Bug introduced by
The method weight() does not exist on XoopsModules\Publisher\Category. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

164
        $this->addElement(new \XoopsFormText(\_AM_PUBLISHER_COLPOSIT, 'weight', 4, 4, $this->targetObject->/** @scrutinizer ignore-call */ weight()));
Loading history...
165
166
        // Added by skalpa: custom template support for Category view
167
        //        $this->addElement(new \XoopsFormText('Custom template', 'template', 50, 255, $this->targetObject->getTemplate('e')), false);
168
169
        $dir                = $this->helper->path('templates/custom/category');
170
        $availableTemplates = [];
171
        if (\is_dir($dir)) {
172
            $templateList = \XoopsLists::getFileListAsArray($dir);
173
            foreach ($templateList as $file) {
174
                if (\preg_match('/(\.tpl)$/i', $file)) {
175
                    $availableTemplates[$file] = $file;
176
                }
177
            }
178
        }
179
180
        $categoryTemplate = new \XoopsFormSelect(\_AM_PUBLISHER_CUSTOM_CATEGORY_TEMPLATE, 'template', $this->targetObject->getVar('template'));
181
182
        $categoryTemplate->addOption('', '');
183
        $categoryTemplate->addOptionArray($availableTemplates);
184
185
        $this->addElement($categoryTemplate, false);
186
187
        // CUSTOM TEMPLATE FOR ARTICLES in Particular Category
188
        $dirCategoryItem        = $this->helper->path('templates/custom/categoryitem');
189
        $availableItemTemplates = [];
190
        if (\is_dir($dirCategoryItem)) {
191
            $templateItemList = \XoopsLists::getFileListAsArray($dirCategoryItem);
192
            foreach ($templateItemList as $file) {
193
                if (\preg_match('/(\.tpl)$/i', $file)) {
194
                    $availableItemTemplates[$file] = $file;
195
                }
196
            }
197
        }
198
199
        $categoryItemTemplate = new \XoopsFormSelect(\_AM_PUBLISHER_CUSTOM_CATEGORY_ITEM_TEMPLATE, 'template_item', $this->targetObject->getVar('template_item'));
200
201
        $categoryItemTemplate->addOption('', '');
202
        $categoryItemTemplate->addOptionArray($availableItemTemplates);
203
204
        $this->addElement($categoryItemTemplate, false);
205
206
        // READ PERMISSIONS
207
        $readPermissionsTray   = new \XoopsFormElementTray(\_AM_PUBLISHER_PERMISSIONS_CAT_READ, '');
208
        $selectAllReadCheckbox = new \XoopsFormCheckBox('', 'adminbox', 1);
209
        $selectAllReadCheckbox->addOption('allbox', \_AM_SYSTEM_ALL);
210
        $selectAllReadCheckbox->setExtra(" onclick='xoopsCheckGroup(\"form\", \"adminbox\" , \"groupsRead[]\");' ");
211
        $selectAllReadCheckbox->setClass('xo-checkall');
212
        $readPermissionsTray->addElement($selectAllReadCheckbox);
213
214
        $groupsReadCheckbox = new \XoopsFormCheckBox('', 'groupsRead[]', $this->targetObject->getGroupsRead());
215
216
        foreach ($this->userGroups as $groupId => $groupName) {
217
            $groupsReadCheckbox->addOption($groupId, $groupName);
218
        }
219
        $readPermissionsTray->addElement($groupsReadCheckbox);
220
        $this->addElement($readPermissionsTray);
221
222
        // SUBMIT PERMISSIONS
223
        $submitPermissionsTray = new \XoopsFormElementTray(\_AM_PUBLISHER_PERMISSIONS_CAT_SUBMIT, '');
224
        $submitPermissionsTray->setDescription(\_AM_PUBLISHER_PERMISSIONS_CAT_SUBMIT_DSC);
225
226
        $selectAllSubmitCheckbox = new \XoopsFormCheckBox('', 'adminbox2', 1);
227
        $selectAllSubmitCheckbox->addOption('allbox', \_AM_SYSTEM_ALL);
228
        $selectAllSubmitCheckbox->setExtra(" onclick='xoopsCheckGroup(\"form\", \"adminbox2\" , \"groupsSubmit[]\");' ");
229
        $selectAllSubmitCheckbox->setClass('xo-checkall');
230
        $submitPermissionsTray->addElement($selectAllSubmitCheckbox);
231
232
        $groupsSubmitCheckbox = new \XoopsFormCheckBox('', 'groupsSubmit[]', $this->targetObject->getGroupsSubmit());
233
        foreach ($this->userGroups as $groupId => $groupName) {
234
            $groupsSubmitCheckbox->addOption($groupId, $groupName);
235
        }
236
        $submitPermissionsTray->addElement($groupsSubmitCheckbox);
237
        $this->addElement($submitPermissionsTray);
238
239
        // MODERATION PERMISSIONS
240
        $moderatePermissionsTray = new \XoopsFormElementTray(\_AM_PUBLISHER_PERMISSIONS_CAT_MODERATOR, '');
241
        $moderatePermissionsTray->setDescription(\_AM_PUBLISHER_PERMISSIONS_CAT_MODERATOR_DSC);
242
243
        $selectAllModerateCheckbox = new \XoopsFormCheckBox('', 'adminbox3', 1);
244
        $selectAllModerateCheckbox->addOption('allbox', \_AM_SYSTEM_ALL);
245
        $selectAllModerateCheckbox->setExtra(" onclick='xoopsCheckGroup(\"form\", \"adminbox3\" , \"groupsModeration[]\");' ");
246
        $selectAllModerateCheckbox->setClass('xo-checkall');
247
        $moderatePermissionsTray->addElement($selectAllModerateCheckbox);
248
249
        $groupsModerationCheckbox = new \XoopsFormCheckBox('', 'groupsModeration[]', $this->targetObject->getGroupsModeration());
250
251
        foreach ($this->userGroups as $groupId => $groupName) {
252
            $groupsModerationCheckbox->addOption($groupId, $groupName);
253
        }
254
        $moderatePermissionsTray->addElement($groupsModerationCheckbox);
255
        $this->addElement($moderatePermissionsTray);
256
257
        $moderator = new \XoopsFormSelectUser(\_AM_PUBLISHER_CATEGORY_MODERATOR, 'moderator', true, $this->targetObject->moderator('e'), 1, false);
0 ignored issues
show
Bug introduced by
The method moderator() does not exist on XoopsModules\Publisher\Category. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

257
        $moderator = new \XoopsFormSelectUser(\_AM_PUBLISHER_CATEGORY_MODERATOR, 'moderator', true, $this->targetObject->/** @scrutinizer ignore-call */ moderator('e'), 1, false);
Loading history...
258
        $moderator->setDescription(\_AM_PUBLISHER_CATEGORY_MODERATOR_DSC);
259
        $this->addElement($moderator);
260
261
        //SUBCATEGORY
262
        $catTray = new \XoopsFormElementTray(\_AM_PUBLISHER_SCATEGORYNAME, '<br><br>');
263
        for ($i = 0; $i < $this->subCatsCount; ++$i) {
264
            $subname = '';
265
            if ($i < (($scname = Request::getArray('scname', [], 'POST')) ? \count($scname) : 0)) {
266
                $temp    = Request::getArray('scname', [], 'POST');
267
                $subname = ($scname = Request::getArray('scname', '', 'POST')) ? $temp[$i] : '';
0 ignored issues
show
Unused Code introduced by
The assignment to $scname is dead and can be removed.
Loading history...
268
            }
269
            $catTray->addElement(new \XoopsFormText('', 'scname[' . $i . ']', 50, 255, $subname));
270
        }
271
        $t = new \XoopsFormText('', 'nb_subcats', 3, 2);
272
        $l = new \XoopsFormLabel('', \sprintf(\_AM_PUBLISHER_ADD_OPT, $t->render()));
273
        $b = new \XoopsFormButton('', 'submit_subcats', \_AM_PUBLISHER_ADD_OPT_SUBMIT, 'submit');
274
275
        if ($this->targetObject->categoryid()) {
0 ignored issues
show
Bug introduced by
The method categoryid() does not exist on XoopsModules\Publisher\Category. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

275
        if ($this->targetObject->/** @scrutinizer ignore-call */ categoryid()) {
Loading history...
276
            $b->setExtra('onclick="this.form.elements.op.value=\'mod\'"');
277
        } else {
278
            $b->setExtra('onclick="this.form.elements.op.value=\'addsubcats\'"');
279
        }
280
281
        $r = new \XoopsFormElementTray('');
282
        $r->addElement($l);
283
        $r->addElement($b);
284
        $catTray->addElement($r);
285
        $this->addElement($catTray);
286
287
        $this->addElement(new \XoopsFormHidden('categoryid', $this->targetObject->categoryid()));
0 ignored issues
show
Bug introduced by
It seems like $this->targetObject->categoryid() can also be of type array and array; however, parameter $value of XoopsFormHidden::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

287
        $this->addElement(new \XoopsFormHidden('categoryid', /** @scrutinizer ignore-type */ $this->targetObject->categoryid()));
Loading history...
288
        $this->addElement(new \XoopsFormHidden('nb_sub_yet', $this->subCatsCount));
289
    }
290
291
    public function createButtons(): void
292
    {
293
        // Action buttons tray
294
        $buttonTray = new \XoopsFormElementTray('', '');
295
296
        // No ID for category -- then it's new category, button says 'Create'
297
        if ($this->targetObject->categoryid()) {
298
            $buttonTray->addElement(new \XoopsFormButton('', 'addcategory', \_AM_PUBLISHER_MODIFY, 'submit'));
299
            $buttCancel = new \XoopsFormButton('', '', \_AM_PUBLISHER_CANCEL, 'button');
300
            $buttCancel->setExtra('onclick="history.go(-1)"');
301
            $buttonTray->addElement($buttCancel);
302
303
            $this->addElement($buttonTray);
304
        } else {
305
            $buttonTray->addElement(new \XoopsFormButton('', 'addcategory', \_AM_PUBLISHER_CREATE, 'submit'));
306
307
            $buttClear = new \XoopsFormButton('', '', \_AM_PUBLISHER_CLEAR, 'reset');
308
            $buttonTray->addElement($buttClear);
309
310
            $buttCancel = new \XoopsFormButton('', '', \_AM_PUBLISHER_CANCEL, 'button');
311
            $buttCancel->setExtra('onclick="history.go(-1)"');
312
            $buttonTray->addElement($buttCancel);
313
314
            $this->addElement($buttonTray);
315
        }
316
    }
317
}
318