Conditions | 20 |
Paths | > 20000 |
Total Lines | 184 |
Code Lines | 96 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
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:
If many parameters/temporary variables are present:
1 | <?php declare(strict_types=1); |
||
97 | public function getForm($action = false) |
||
98 | { |
||
99 | $helper = \XoopsModules\Wgevents\Helper::getInstance(); |
||
100 | if (!$action) { |
||
101 | $action = $_SERVER['REQUEST_URI']; |
||
102 | } |
||
103 | $isAdmin = (\is_object($GLOBALS['xoopsUser']) && \is_object($GLOBALS['xoopsModule'])) && $GLOBALS['xoopsUser']->isAdmin($GLOBALS['xoopsModule']->mid()); |
||
104 | // Title |
||
105 | $title = $this->isNew() ? \_AM_WGEVENTS_CATEGORY_ADD : \_AM_WGEVENTS_CATEGORY_EDIT; |
||
106 | // Get Theme Form |
||
107 | \xoops_load('XoopsFormLoader'); |
||
108 | $form = new \XoopsThemeForm($title, 'form', $action, 'post', true); |
||
109 | $form->setExtra('enctype="multipart/form-data"'); |
||
110 | // Form Table categories |
||
111 | $categoryHandler = $helper->getHandler('Category'); |
||
112 | $catPidSelect = new \XoopsFormSelect(\_AM_WGEVENTS_CATEGORY_PID, 'pid', $this->getVar('pid')); |
||
113 | $catPidSelect->addOption(''); |
||
114 | $catPidSelect->addOptionArray($categoryHandler->getList()); |
||
115 | $form->addElement($catPidSelect); |
||
116 | // Form Text catName |
||
117 | $form->addElement(new \XoopsFormText(\_AM_WGEVENTS_CATEGORY_NAME, 'name', 50, 255, $this->getVar('name')), true); |
||
118 | // Form Editor DhtmlTextArea catDesc |
||
119 | $editorConfigs = []; |
||
120 | if ($isAdmin) { |
||
121 | $editor = $helper->getConfig('editor_admin'); |
||
122 | } else { |
||
123 | $editor = $helper->getConfig('editor_user'); |
||
124 | } |
||
125 | $editorConfigs['name'] = 'desc'; |
||
126 | $editorConfigs['value'] = $this->getVar('desc', 'e'); |
||
127 | $editorConfigs['rows'] = 5; |
||
128 | $editorConfigs['cols'] = 40; |
||
129 | $editorConfigs['width'] = '100%'; |
||
130 | $editorConfigs['height'] = '400px'; |
||
131 | $editorConfigs['editor'] = $editor; |
||
132 | $form->addElement(new \XoopsFormEditor(\_AM_WGEVENTS_CATEGORY_DESC, 'desc', $editorConfigs)); |
||
133 | // Form Image catLogo |
||
134 | // Form Image catLogo: Select Uploaded Image |
||
135 | $getCatLogo = $this->getVar('logo'); |
||
136 | $catLogo = $getCatLogo ?: 'blank.gif'; |
||
137 | $logoDirectory = '/uploads/wgevents/categories/logos'; |
||
138 | $logoTray = new \XoopsFormElementTray(\_AM_WGEVENTS_CATEGORY_LOGO, '<br>'); |
||
139 | $logoSelect = new \XoopsFormSelect(\sprintf(\_AM_WGEVENTS_CATEGORY_LOGO_UPLOADS, ".$logoDirectory/"), 'logo', $catLogo, 5); |
||
140 | $logoArray = \XoopsLists::getImgListAsArray( \XOOPS_ROOT_PATH . $logoDirectory ); |
||
141 | foreach ($logoArray as $logo1) { |
||
142 | $logoSelect->addOption($logo1, $logo1); |
||
143 | } |
||
144 | $logoSelect->setExtra("onchange='showImgSelected(\"imglabel_cat_logo\", \"logo\", \"" . $logoDirectory . '", "", "' . \XOOPS_URL . "\")'"); |
||
145 | $logoTray->addElement($logoSelect); |
||
146 | $logoTray->addElement(new \XoopsFormLabel('', "<br><img src='" . \XOOPS_URL . '/' . $logoDirectory . '/' . $catLogo . "' id='imglabel_cat_logo' alt='' style='max-width:100px' >")); |
||
147 | // Form Image catLogo: Upload new image |
||
148 | $maxsize = $helper->getConfig('maxsize_image'); |
||
149 | $logoTray->addElement(new \XoopsFormFile('<br>' . \_AM_WGEVENTS_FORM_UPLOAD_NEW, 'logo', $maxsize)); |
||
150 | $logoTray->addElement(new \XoopsFormLabel(\_AM_WGEVENTS_FORM_UPLOAD_SIZE, ($maxsize / 1048576) . ' ' . \_AM_WGEVENTS_FORM_UPLOAD_SIZE_MB)); |
||
151 | $logoTray->addElement(new \XoopsFormLabel(\_AM_WGEVENTS_FORM_UPLOAD_IMG_WIDTH, $helper->getConfig('maxwidth_image') . ' px')); |
||
152 | $logoTray->addElement(new \XoopsFormLabel(\_AM_WGEVENTS_FORM_UPLOAD_IMG_HEIGHT, $helper->getConfig('maxheight_image') . ' px')); |
||
153 | $form->addElement($logoTray); |
||
154 | |||
155 | |||
156 | |||
157 | // Form Image catImage |
||
158 | // Form Image catImage: Select Uploaded Image |
||
159 | $getCatImage = $this->getVar('logo'); |
||
160 | $catImage = $getCatImage ?: 'blank.gif'; |
||
161 | $imageDirectory = '/uploads/wgevents/categories/images'; |
||
162 | $imageTray = new \XoopsFormElementTray(\_AM_WGEVENTS_CATEGORY_IMAGE, '<br>'); |
||
163 | $imageSelect = new \XoopsFormSelect(\sprintf(\_AM_WGEVENTS_CATEGORY_IMAGE_UPLOADS, ".$imageDirectory/"), 'image', $catImage, 5); |
||
164 | $imageArray = \XoopsLists::getImgListAsArray( \XOOPS_ROOT_PATH . $imageDirectory ); |
||
165 | foreach ($imageArray as $image1) { |
||
166 | $imageSelect->addOption(($image1), $image1); |
||
167 | } |
||
168 | $imageSelect->setExtra("onchange='showImgSelected(\"imglabel_cat_image\", \"image\", \"" . $imageDirectory . '", "", "' . \XOOPS_URL . "\")'"); |
||
169 | $imageTray->addElement($imageSelect); |
||
170 | $imageTray->addElement(new \XoopsFormLabel('', "<br><img src='" . \XOOPS_URL . '/' . $imageDirectory . '/' . $catImage . "' id='imglabel_cat_image' alt='' style='max-width:100px' >")); |
||
171 | // Form Image catImage: Upload new image |
||
172 | $imageTray->addElement(new \XoopsFormFile('<br>' . \_AM_WGEVENTS_FORM_UPLOAD_NEW, 'image', $maxsize)); |
||
173 | $imageTray->addElement(new \XoopsFormLabel(\_AM_WGEVENTS_FORM_UPLOAD_SIZE, ($maxsize / 1048576) . ' ' . \_AM_WGEVENTS_FORM_UPLOAD_SIZE_MB)); |
||
174 | $imageTray->addElement(new \XoopsFormLabel(\_AM_WGEVENTS_FORM_UPLOAD_IMG_WIDTH, $helper->getConfig('maxwidth_image') . ' px')); |
||
175 | $imageTray->addElement(new \XoopsFormLabel(\_AM_WGEVENTS_FORM_UPLOAD_IMG_HEIGHT, $helper->getConfig('maxheight_image') . ' px')); |
||
176 | $form->addElement($imageTray); |
||
177 | |||
178 | |||
179 | |||
180 | |||
181 | // Form Color Picker catColor |
||
182 | $catColor = $this->isNew() ? '#000000' : (string)$this->getVar('color'); |
||
183 | $form->addElement(new \XoopsFormColorPicker(\_AM_WGEVENTS_CATEGORY_COLOR, 'color', $catColor)); |
||
184 | // Form Color Picker catBorderColor |
||
185 | $catBorderColor = $this->isNew() ? '#cccccc' : (string)$this->getVar('bordercolor'); |
||
186 | $form->addElement(new \XoopsFormColorPicker(\_AM_WGEVENTS_CATEGORY_BORDERCOLOR, 'bordercolor', $catBorderColor)); |
||
187 | // Form Color Picker catBgColor |
||
188 | $catBgColor = $this->isNew() ? '#ffffff' : (string)$this->getVar('bgcolor'); |
||
189 | $form->addElement(new \XoopsFormColorPicker(\_AM_WGEVENTS_CATEGORY_BGCOLOR, 'bgcolor', $catBgColor)); |
||
190 | // Form Text catOtherstyles |
||
191 | $catOtherstyles = $this->isNew() ? 'margin:1px 0;padding:8px 5px 20px 5px;border-radius:5px;' : $this->getVar('othercss'); |
||
192 | $form->addElement(new \XoopsFormText(\_AM_WGEVENTS_CATEGORY_OTHERCSS, 'othercss', 100, 255, $catOtherstyles)); |
||
193 | // Form Text catIdentifier |
||
194 | $catIdentifier = new \XoopsFormText(\_AM_WGEVENTS_CATEGORY_IDENTIFIER, 'identifier', 100, 255, $this->getVar('identifier')); |
||
195 | $catIdentifier->setDescription(\_AM_WGEVENTS_CATEGORY_IDENTIFIER_DESC); |
||
196 | $form->addElement($catIdentifier); |
||
197 | // Form Radio catStatus |
||
198 | $catStatus = $this->isNew() ? Constants::STATUS_OFFLINE : $this->getVar('status'); |
||
199 | $catStatusRadio = new \XoopsFormRadio(\_MA_WGEVENTS_STATUS, 'status', $catStatus); |
||
200 | $catStatusRadio->addOption(Constants::STATUS_OFFLINE, \_MA_WGEVENTS_STATUS_OFFLINE); |
||
201 | $catStatusRadio->addOption(Constants::STATUS_ONLINE, \_MA_WGEVENTS_STATUS_ONLINE); |
||
202 | $form->addElement($catStatusRadio); |
||
203 | // Form Radio catType |
||
204 | $catType = $this->isNew() ? Constants::CATEGORY_TYPE_BOTH : (int)$this->getVar('type'); |
||
205 | $catTypeRadio = new \XoopsFormRadio(\_AM_WGEVENTS_CATEGORY_TYPE, 'type', $catType); |
||
206 | $catTypeRadio->addOption(Constants::CATEGORY_TYPE_MAIN, \_AM_WGEVENTS_CATEGORY_TYPE_MAIN); |
||
207 | $catTypeRadio->addOption(Constants::CATEGORY_TYPE_SUB, \_AM_WGEVENTS_CATEGORY_TYPE_SUB); |
||
208 | $catTypeRadio->addOption(Constants::CATEGORY_TYPE_BOTH, \_AM_WGEVENTS_CATEGORY_TYPE_BOTH); |
||
209 | $form->addElement($catTypeRadio); |
||
210 | // Form Text catWeight |
||
211 | $catWeight = $this->getVar('weight'); |
||
212 | if ($this->isNew()) { |
||
213 | $catWeight = $categoryHandler->getNextWeight(); |
||
214 | } |
||
215 | $form->addElement(new \XoopsFormText(\_MA_WGEVENTS_WEIGHT, 'weight', 50, 255, $catWeight)); |
||
216 | // Form Text Date Select catDatecreated |
||
217 | $catDatecreated = $this->isNew() ? \time() : $this->getVar('datecreated'); |
||
218 | $form->addElement(new \XoopsFormTextDateSelect(\_MA_WGEVENTS_DATECREATED, 'datecreated', '', $catDatecreated)); |
||
219 | // Form Select User catSubmitter |
||
220 | $uidCurrent = \is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->uid() : 0; |
||
221 | $catSubmitter = $this->isNew() ? $uidCurrent : $this->getVar('submitter'); |
||
222 | $form->addElement(new \XoopsFormSelectUser(\_MA_WGEVENTS_SUBMITTER, 'submitter', false, $catSubmitter)); |
||
223 | /* |
||
224 | // Permission |
||
225 | $memberHandler = \xoops_getHandler('member'); |
||
226 | $groupList = $memberHandler->getGroupList(); |
||
227 | $grouppermHandler = \xoops_getHandler('groupperm'); |
||
228 | $fullList[] = \array_keys($groupList); |
||
229 | if ($this->isNew()) { |
||
230 | $groupsCanApproveEventsCheckbox = new \XoopsFormCheckBox(\_AM_WGEVENTS_PERMISSIONS_CAT_EVENTS_APPROVE, 'groups_approve_cat_events[]', $fullList); |
||
231 | $groupsCanSubmitEventsCheckbox = new \XoopsFormCheckBox(\_AM_WGEVENTS_PERMISSIONS_CAT_EVENTS_SUBMIT, 'groups_submit_cat_events[]', $fullList); |
||
232 | $groupsCanViewEventsCheckbox = new \XoopsFormCheckBox(\_AM_WGEVENTS_PERMISSIONS_CAT_EVENTS_VIEW, 'groups_view_cat_events[]', $fullList); |
||
233 | $groupsCanApproveRegsCheckbox = new \XoopsFormCheckBox(\_AM_WGEVENTS_PERMISSIONS_CAT_REGS_APPROVE, 'groups_approve_cat_regs[]', $fullList); |
||
234 | $groupsCanSubmitRegsCheckbox = new \XoopsFormCheckBox(\_AM_WGEVENTS_PERMISSIONS_CAT_REGS_SUBMIT, 'groups_submit_cat_regs[]', $fullList); |
||
235 | $groupsCanViewRegsCheckbox = new \XoopsFormCheckBox(\_AM_WGEVENTS_PERMISSIONS_CAT_REGS_VIEW, 'groups_view_cat_regs[]', $fullList); |
||
236 | } else { |
||
237 | $groupsIdsApproveEvents = $grouppermHandler->getGroupIds('wgevents_approve_cat_events', $this->getVar('id'), $GLOBALS['xoopsModule']->getVar('mid')); |
||
238 | $groupsIdsApproveEvents[] = \array_values($groupsIdsApproveEvents); |
||
239 | $groupsCanApproveEventsCheckbox = new \XoopsFormCheckBox(\_AM_WGEVENTS_PERMISSIONS_CAT_EVENTS_APPROVE, 'groups_approve_cat_events[]', $groupsIdsApproveEvents); |
||
240 | $groupsIdsSubmitEvents = $grouppermHandler->getGroupIds('wgevents_submit_cat_events', $this->getVar('id'), $GLOBALS['xoopsModule']->getVar('mid')); |
||
241 | $groupsIdsSubmitEvents[] = \array_values($groupsIdsSubmitEvents); |
||
242 | $groupsCanSubmitEventsCheckbox = new \XoopsFormCheckBox(\_AM_WGEVENTS_PERMISSIONS_CAT_EVENTS_SUBMIT, 'groups_submit_cat_events[]', $groupsIdsSubmitEvents); |
||
243 | $groupsIdsViewEvents = $grouppermHandler->getGroupIds('wgevents_view_cat_events', $this->getVar('id'), $GLOBALS['xoopsModule']->getVar('mid')); |
||
244 | $groupsIdsViewEvents[] = \array_values($groupsIdsViewEvents); |
||
245 | $groupsCanViewEventsCheckbox = new \XoopsFormCheckBox(\_AM_WGEVENTS_PERMISSIONS_CAT_EVENTS_VIEW, 'groups_view_cat_events[]', $groupsIdsViewEvents); |
||
246 | $groupsIdsApproveRegs = $grouppermHandler->getGroupIds('wgevents_approve_cat_regs', $this->getVar('id'), $GLOBALS['xoopsModule']->getVar('mid')); |
||
247 | $groupsIdsApproveRegs[] = \array_values($groupsIdsApproveRegs); |
||
248 | $groupsCanApproveRegsCheckbox = new \XoopsFormCheckBox(\_AM_WGEVENTS_PERMISSIONS_CAT_REGS_APPROVE, 'groups_approve_cat_regs[]', $groupsIdsApproveRegs); |
||
249 | $groupsIdsSubmitRegs = $grouppermHandler->getGroupIds('wgevents_submit_cat_regs', $this->getVar('id'), $GLOBALS['xoopsModule']->getVar('mid')); |
||
250 | $groupsIdsSubmitRegs[] = \array_values($groupsIdsSubmitRegs); |
||
251 | $groupsCanSubmitRegsCheckbox = new \XoopsFormCheckBox(\_AM_WGEVENTS_PERMISSIONS_CAT_REGS_SUBMIT, 'groups_submit_cat_regs[]', $groupsIdsSubmitRegs); |
||
252 | $groupsIdsViewRegs = $grouppermHandler->getGroupIds('wgevents_view_cat_regs', $this->getVar('id'), $GLOBALS['xoopsModule']->getVar('mid')); |
||
253 | $groupsIdsViewRegs[] = \array_values($groupsIdsViewRegs); |
||
254 | $groupsCanViewRegsCheckbox = new \XoopsFormCheckBox(\_AM_WGEVENTS_PERMISSIONS_CAT_REGS_VIEW, 'groups_view_cat_regs[]', $groupsIdsViewRegs); |
||
255 | } |
||
256 | // To Approve |
||
257 | $groupsCanApproveEventsCheckbox->addOptionArray($groupList); |
||
258 | $form->addElement($groupsCanApproveEventsCheckbox); |
||
259 | // To Submit |
||
260 | $groupsCanSubmitEventsCheckbox->addOptionArray($groupList); |
||
261 | $form->addElement($groupsCanSubmitEventsCheckbox); |
||
262 | // To View |
||
263 | $groupsCanViewEventsCheckbox->addOptionArray($groupList); |
||
264 | $form->addElement($groupsCanViewEventsCheckbox); |
||
265 | // To Approve |
||
266 | $groupsCanApproveRegsCheckbox->addOptionArray($groupList); |
||
267 | $form->addElement($groupsCanApproveRegsCheckbox); |
||
268 | // To Submit |
||
269 | $groupsCanSubmitRegsCheckbox->addOptionArray($groupList); |
||
270 | $form->addElement($groupsCanSubmitRegsCheckbox); |
||
271 | // To View |
||
272 | $groupsCanViewRegsCheckbox->addOptionArray($groupList); |
||
273 | $form->addElement($groupsCanViewRegsCheckbox); |
||
274 | */ |
||
275 | // To Save |
||
276 | $form->addElement(new \XoopsFormHidden('op', 'save')); |
||
277 | $form->addElement(new \XoopsFormHidden('start', $this->start)); |
||
278 | $form->addElement(new \XoopsFormHidden('limit', $this->limit)); |
||
279 | $form->addElement(new \XoopsFormButtonTray('', \_SUBMIT, 'submit', '', false)); |
||
280 | return $form; |
||
281 | } |
||
342 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths