Conditions | 19 |
Paths | > 20000 |
Total Lines | 135 |
Code Lines | 103 |
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); |
||
92 | public function getForm($action = false) |
||
93 | { |
||
94 | $helper = \XoopsModules\Wgevents\Helper::getInstance(); |
||
95 | |||
96 | $eventHandler = $helper->getHandler('Event'); |
||
97 | $questionHandler = $helper->getHandler('Question'); |
||
98 | |||
99 | if (!$action) { |
||
100 | $action = $_SERVER['REQUEST_URI']; |
||
101 | } |
||
102 | $isAdmin = (\is_object($GLOBALS['xoopsUser']) && \is_object($GLOBALS['xoopsModule'])) && $GLOBALS['xoopsUser']->isAdmin($GLOBALS['xoopsModule']->mid()); |
||
103 | // Title |
||
104 | $title = $this->isNew() ? \_MA_WGEVENTS_QUESTION_ADD : \_MA_WGEVENTS_QUESTION_EDIT; |
||
105 | // Get Theme Form |
||
106 | \xoops_load('XoopsFormLoader'); |
||
107 | $form = new \XoopsThemeForm($title, 'formQuestion', $action, 'post', true); |
||
108 | $form->setExtra('enctype="multipart/form-data"'); |
||
109 | // Form Table events |
||
110 | $evId = ($this->getVar('evid')) ?? 0; |
||
111 | $addEvidSelect = new \XoopsFormSelect(\_MA_WGEVENTS_QUESTION_EVID, 'evid', $evId); |
||
112 | $addEvidSelect->addOptionArray($eventHandler->getList()); |
||
113 | $form->addElement($addEvidSelect); |
||
114 | // Form Select queType |
||
115 | $queType = (int)$this->getVar('fdid') > 0 ? (int)$this->getVar('fdid') : 1; //set default for new as 'Infofield |
||
116 | $enableValues = true; |
||
117 | $enablePlaceholder = true; |
||
118 | $queTypeSelect = new \XoopsFormSelect(\_MA_WGEVENTS_QUESTION_TYPE, 'type', $queType); |
||
119 | $fieldHandler = $helper->getHandler('Field'); |
||
120 | $fieldObj = $fieldHandler->get($queType); |
||
121 | $fieldType = $fieldObj->getVar('type'); |
||
122 | |||
123 | $crField = new \CriteriaCompo(); |
||
124 | $crField->add(new \Criteria('status', Constants::STATUS_ONLINE)); |
||
125 | $crField->setSort('weight'); |
||
126 | $crField->setOrder('ASC'); |
||
127 | $fieldsCount = $fieldHandler->getCount($crField); |
||
128 | if ($fieldsCount > 0) { |
||
129 | $fieldsAll = $fieldHandler->getAll($crField); |
||
130 | foreach (\array_keys($fieldsAll) as $i) { |
||
131 | $queTypeSelect->addOption($i, $fieldsAll[$i]->getVar('caption')); |
||
132 | $form->addElement(new \XoopsFormHidden('caption_def[' . $i . ']', $fieldsAll[$i]->getVar('caption'))); |
||
133 | $form->addElement(new \XoopsFormHidden('placeholder_def[' . $i . ']', $fieldsAll[$i]->getVar('placeholder'))); |
||
134 | $form->addElement(new \XoopsFormHidden('required_def[' . $i . ']', $fieldsAll[$i]->getVar('required'))); |
||
135 | $form->addElement(new \XoopsFormHidden('print_def[' . $i . ']', $fieldsAll[$i]->getVar('print'))); |
||
136 | $form->addElement(new \XoopsFormHidden('display_desc[' . $i . ']', $fieldsAll[$i]->getVar('display_desc'))); |
||
137 | $form->addElement(new \XoopsFormHidden('display_values[' . $i . ']', $fieldsAll[$i]->getVar('display_values'))); |
||
138 | $form->addElement(new \XoopsFormHidden('display_placeholder[' . $i . ']', $fieldsAll[$i]->getVar('display_placeholder'))); |
||
139 | if ((int)$fieldsAll[$i]->getVar('type') == $fieldType) { |
||
140 | $enableDesc = (bool)$fieldsAll[$i]->getVar('display_desc'); |
||
141 | $enableValues = (bool)$fieldsAll[$i]->getVar('display_values'); |
||
142 | $enablePlaceholder = (bool)$fieldsAll[$i]->getVar('display_placeholder'); |
||
143 | } |
||
144 | } |
||
145 | } |
||
146 | $queTypeSelect->setExtra(" onchange='fillInQuestions()' "); |
||
147 | $form->addElement($queTypeSelect); |
||
148 | // Form Text queCaption |
||
149 | $queCaptionField = new \XoopsFormText(\_MA_WGEVENTS_QUESTION_CAPTION, 'caption', 50, 255, (string)$this->getVar('caption')); |
||
150 | $queCaptionField->setDescription(\_MA_WGEVENTS_QUESTION_CAPTION_DESC); |
||
151 | $form->addElement($queCaptionField, true); |
||
152 | // Form Editor TextArea queDesc |
||
153 | $editorConfigs = []; |
||
154 | if ($isAdmin) { |
||
155 | $editor = $helper->getConfig('editor_admin'); |
||
156 | } else { |
||
157 | $editor = $helper->getConfig('editor_user'); |
||
158 | } |
||
159 | $editorConfigs['name'] = 'desc'; |
||
160 | $editorConfigs['value'] = $this->getVar('desc', 'e'); |
||
161 | $editorConfigs['rows'] = 5; |
||
162 | $editorConfigs['cols'] = 40; |
||
163 | $editorConfigs['width'] = '100%'; |
||
164 | $editorConfigs['height'] = '400px'; |
||
165 | $editorConfigs['editor'] = $editor; |
||
166 | $queDescField = new \XoopsFormEditor(\_MA_WGEVENTS_QUESTION_DESC, 'desc', $editorConfigs); |
||
167 | //$queDescField = new \XoopsFormTextArea(\_MA_WGEVENTS_QUESTION_DESC, 'desc', $this->getVar('desc', 'e'), 3, 47); |
||
168 | $queDescField->setDescription(\_MA_WGEVENTS_QUESTION_DESC_DESC); |
||
169 | if (!$enableDesc) { |
||
170 | $queDescField->setExtra('disabled="disabled"'); |
||
171 | } |
||
172 | $form->addElement($queDescField); |
||
173 | // Form Editor TextArea queValues |
||
174 | $queValues = (string)$this->getVar('values'); |
||
175 | $queValuesText = ''; |
||
176 | if ('' !== $queValues) { |
||
177 | $queValuesText = \implode("\n", \unserialize($queValues, ['allowed_classes' => false])); |
||
178 | } |
||
179 | $queValuesField = new \XoopsFormTextArea(\_MA_WGEVENTS_QUESTION_VALUE, 'values', $queValuesText, 5, 47); |
||
180 | $queValuesField->setDescription(\_MA_WGEVENTS_QUESTION_VALUE_DESC); |
||
181 | if (!$enableValues) { |
||
182 | $queValuesField->setExtra('disabled="disabled"'); |
||
183 | } |
||
184 | $form->addElement($queValuesField); |
||
185 | // Form Text quePlaceholder |
||
186 | $quePlaceholderField = new \XoopsFormText(\_MA_WGEVENTS_QUESTION_PLACEHOLDER, 'placeholder', 50, 255, $this->getVar('placeholder')); |
||
187 | $quePlaceholderField->setDescription(\_MA_WGEVENTS_QUESTION_PLACEHOLDER_DESC); |
||
188 | if (!$enablePlaceholder) { |
||
189 | $quePlaceholderField->setExtra('disabled="disabled"'); |
||
190 | } |
||
191 | $form->addElement($quePlaceholderField); |
||
192 | // Form Radio Yes/No queRequired |
||
193 | $queRequired = (int)$this->getVar('required'); |
||
194 | $queRequiredField = new \XoopsFormRadioYN(\_MA_WGEVENTS_QUESTION_REQUIRED, 'required', $queRequired); |
||
195 | $queRequiredField->setDescription(\_MA_WGEVENTS_QUESTION_REQUIRED_DESC); |
||
196 | $form->addElement($queRequiredField); |
||
197 | // Form Radio Yes/No quePrint |
||
198 | $quePrint = (int)$this->getVar('print'); |
||
199 | $quePrintField = new \XoopsFormRadioYN(\_MA_WGEVENTS_QUESTION_PRINT, 'print', $quePrint); |
||
200 | $quePrintField->setDescription(\_MA_WGEVENTS_QUESTION_PRINT_DESC); |
||
201 | $form->addElement($quePrintField); |
||
202 | // Form Text queWeight |
||
203 | $queWeight = $this->isNew() ? $questionHandler->getNextWeight($evId) : $this->getVar('weight'); |
||
204 | if ($isAdmin) { |
||
205 | $form->addElement(new \XoopsFormText(\_MA_WGEVENTS_WEIGHT, 'weight', 50, 255, $queWeight)); |
||
206 | } else { |
||
207 | $form->addElement(new \XoopsFormHidden('weight', $queWeight)); |
||
208 | } |
||
209 | // Form Text Date Select queDatecreated |
||
210 | // Form Select User queSubmitter |
||
211 | $queSubmitter = \is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->uid() : 0; |
||
212 | if ($isAdmin) { |
||
213 | // Form Text Date Select queDatecreated |
||
214 | $queDatecreated = $this->isNew() ? \time() : $this->getVar('datecreated'); |
||
215 | $form->addElement(new \XoopsFormTextDateSelect(\_MA_WGEVENTS_DATECREATED, 'datecreated', '', $queDatecreated)); |
||
216 | $form->addElement(new \XoopsFormSelectUser(\_MA_WGEVENTS_SUBMITTER, 'submitter', false, $queSubmitter)); |
||
217 | } else { |
||
218 | $form->addElement(new \XoopsFormHidden('datecreated_int', \time())); |
||
219 | $form->addElement(new \XoopsFormHidden('submitter', $queSubmitter)); |
||
220 | } |
||
221 | // To Save |
||
222 | $form->addElement(new \XoopsFormHidden('op', 'save')); |
||
223 | $form->addElement(new \XoopsFormHidden('start', $this->start)); |
||
224 | $form->addElement(new \XoopsFormHidden('limit', $this->limit)); |
||
225 | $form->addElement(new \XoopsFormButtonTray('submit', \_SUBMIT, 'submit', '', false)); |
||
226 | return $form; |
||
227 | } |
||
281 |
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