Conditions | 39 |
Paths | 0 |
Total Lines | 224 |
Code Lines | 172 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
133 | public function getFormModules($action = false) |
||
134 | { |
||
135 | $helper = Modulebuilder\Helper::getInstance(); |
||
136 | if (false === $action) { |
||
137 | $action = \Xmf\Request::getString('REQUEST_URI', '', 'SERVER'); |
||
138 | } |
||
139 | $set = []; |
||
140 | $settings = $helper->getHandler('Settings')->getActiveSetting(); |
||
141 | foreach ($settings as $setting) { |
||
142 | $set['name'] = $setting->getVar('set_name'); |
||
143 | $set['dirname'] = $setting->getVar('set_dirname'); |
||
144 | $set['version'] = $setting->getVar('set_version'); |
||
145 | $set['since'] = $setting->getVar('set_since'); |
||
146 | $set['min_php'] = $setting->getVar('set_min_php'); |
||
147 | $set['min_xoops'] = $setting->getVar('set_min_xoops'); |
||
148 | $set['min_admin'] = $setting->getVar('set_min_admin'); |
||
149 | $set['min_mysql'] = $setting->getVar('set_min_mysql'); |
||
150 | $set['description'] = $setting->getVar('set_description'); |
||
151 | $set['author'] = $setting->getVar('set_author'); |
||
152 | $set['license'] = $setting->getVar('set_license'); |
||
153 | $set['admin'] = $setting->getVar('set_admin'); |
||
154 | $set['user'] = $setting->getVar('set_user'); |
||
155 | $set['blocks'] = $setting->getVar('set_blocks'); |
||
156 | $set['search'] = $setting->getVar('set_search'); |
||
157 | $set['comments'] = $setting->getVar('set_comments'); |
||
158 | $set['notifications'] = $setting->getVar('set_notifications'); |
||
159 | $set['permissions'] = $setting->getVar('set_permissions'); |
||
160 | $set['inroot'] = $setting->getVar('set_inroot_copy'); |
||
161 | $set['image'] = $setting->getVar('set_image'); |
||
162 | $set['author_mail'] = $setting->getVar('set_author_mail'); |
||
163 | $set['author_website_url'] = $setting->getVar('set_author_website_url'); |
||
164 | $set['author_website_name'] = $setting->getVar('set_author_website_name'); |
||
165 | $set['credits'] = $setting->getVar('set_credits'); |
||
166 | $set['release_info'] = $setting->getVar('set_release_info'); |
||
167 | $set['release_file'] = $setting->getVar('set_release_file'); |
||
168 | $set['manual'] = $setting->getVar('set_manual'); |
||
169 | $set['manual_file'] = $setting->getVar('set_manual_file'); |
||
170 | $set['demo_site_url'] = $setting->getVar('set_demo_site_url'); |
||
171 | $set['demo_site_name'] = $setting->getVar('set_demo_site_name'); |
||
172 | $set['support_url'] = $setting->getVar('set_support_url'); |
||
173 | $set['support_name'] = $setting->getVar('set_support_name'); |
||
174 | $set['website_url'] = $setting->getVar('set_website_url'); |
||
175 | $set['website_name'] = $setting->getVar('set_website_name'); |
||
176 | $set['release'] = $setting->getVar('set_release'); |
||
177 | $set['status'] = $setting->getVar('set_status'); |
||
178 | $set['donations'] = $setting->getVar('set_donations'); |
||
179 | $set['subversion'] = $setting->getVar('set_subversion'); |
||
180 | } |
||
181 | |||
182 | $isNew = $this->isNew(); |
||
183 | $title = $isNew ? \sprintf(\_AM_MODULEBUILDER_MODULE_NEW) : \sprintf(\_AM_MODULEBUILDER_MODULE_EDIT); |
||
184 | |||
185 | require_once \XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
||
186 | |||
187 | $form = new \XoopsThemeForm($title, 'moduleform', $action, 'post', true); |
||
188 | $form->setExtra('enctype="multipart/form-data"'); |
||
189 | |||
190 | $modName = $isNew ? $set['name'] : $this->getVar('mod_name'); |
||
191 | $modNameText = new \XoopsFormText(\_AM_MODULEBUILDER_MODULE_NAME, 'mod_name', 50, 255, $modName); |
||
|
|||
192 | $modNameText->setDescription(\_AM_MODULEBUILDER_MODULE_NAME_DESC); |
||
193 | $form->addElement($modNameText, true); |
||
194 | |||
195 | $modDirname = $isNew ? $set['dirname'] : $this->getVar('mod_dirname'); |
||
196 | $modDirnameText = new \XoopsFormText(\_AM_MODULEBUILDER_MODULE_DIRNAME, 'mod_dirname', 25, 255, $modDirname); |
||
197 | $modDirnameText->setDescription(\_AM_MODULEBUILDER_MODULE_DIRNAME_DESC); |
||
198 | $form->addElement($modDirnameText, true); |
||
199 | |||
200 | $modVersion = $isNew ? $set['version'] : $this->getVar('mod_version'); |
||
201 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_MODULE_VERSION, 'mod_version', 10, 25, $modVersion), true); |
||
202 | |||
203 | $modSince = $isNew ? $set['since'] : $this->getVar('mod_since'); |
||
204 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_MODULE_SINCE, 'mod_since', 10, 25, $modSince), true); |
||
205 | |||
206 | $modMinPhp = $isNew ? $set['min_php'] : $this->getVar('mod_min_php'); |
||
207 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_MODULE_MIN_PHP, 'mod_min_php', 10, 25, $modMinPhp), true); |
||
208 | |||
209 | $modMinXoops = $isNew ? $set['min_xoops'] : $this->getVar('mod_min_xoops'); |
||
210 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_MODULE_MIN_XOOPS, 'mod_min_xoops', 10, 25, $modMinXoops), true); |
||
211 | |||
212 | $modMinAdmin = $isNew ? $set['min_admin'] : $this->getVar('mod_min_admin'); |
||
213 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_MODULE_MIN_ADMIN, 'mod_min_admin', 10, 25, $modMinAdmin), true); |
||
214 | |||
215 | $modMinMysql = $isNew ? $set['min_mysql'] : $this->getVar('mod_min_mysql'); |
||
216 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_MODULE_MIN_MYSQL, 'mod_min_mysql', 10, 25, $modMinMysql), true); |
||
217 | // Name description |
||
218 | $editorConfigs = []; |
||
219 | $editorConfigs['name'] = 'mod_description'; |
||
220 | $editorConfigs['value'] = $isNew ? $set['description'] : $this->getVar('mod_description', 'e'); |
||
221 | $editorConfigs['rows'] = 5; |
||
222 | $editorConfigs['cols'] = 100; |
||
223 | $editorConfigs['width'] = '50%'; |
||
224 | $editorConfigs['height'] = '100px'; |
||
225 | $editorConfigs['editor'] = $helper->getConfig('modulebuilder_editor'); |
||
226 | $form->addElement(new \XoopsFormEditor(\_AM_MODULEBUILDER_MODULE_DESCRIPTION, 'mod_description', $editorConfigs), true); |
||
227 | // Author |
||
228 | $modAuthor = $isNew ? $set['author'] : $this->getVar('mod_author'); |
||
229 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_MODULE_AUTHOR, 'mod_author', 50, 255, $modAuthor), true); |
||
230 | $modLicense = $isNew ? $set['license'] : $this->getVar('mod_license'); |
||
231 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_MODULE_LICENSE, 'mod_license', 50, 255, $modLicense), true); |
||
232 | |||
233 | $optionsTray = new \XoopsFormElementTray(_OPTIONS, '<br>'); |
||
234 | $optionsTray->setDescription(\_AM_MODULEBUILDER_OPTIONS_DESC); |
||
235 | // Check All Modules Options |
||
236 | $checkAllOptions = new \XoopsFormCheckBox('', 'modulebox', 1); |
||
237 | $checkAllOptions->addOption('allbox', \_AM_MODULEBUILDER_MODULE_ALL); |
||
238 | $checkAllOptions->setExtra(' onclick="xoopsCheckAll(\'moduleform\', \'modulebox\');" '); |
||
239 | $checkAllOptions->setClass('xo-checkall'); |
||
240 | $optionsTray->addElement($checkAllOptions); |
||
241 | // Options |
||
242 | $checkbox = new \XoopsFormCheckbox(' ', 'module_option', $this->getOptionsModules(), '<br>'); |
||
243 | foreach ($this->options as $option) { |
||
244 | $checkbox->addOption($option, self::getDefinedLanguage('\_AM_MODULEBUILDER_MODULE_' . \mb_strtoupper($option))); |
||
245 | } |
||
246 | $optionsTray->addElement($checkbox); |
||
247 | |||
248 | $form->addElement($optionsTray); |
||
249 | |||
250 | $modImage = $this->getVar('mod_image'); |
||
251 | $modImage = $modImage ?: $set['image']; |
||
252 | |||
253 | $uploadDirectory = 'uploads/' . $GLOBALS['xoopsModule']->dirname() . '/images/modules'; |
||
254 | $imgtray = new \XoopsFormElementTray(\_AM_MODULEBUILDER_MODULE_IMAGE, '<br>'); |
||
255 | $imgpath = \sprintf(\_AM_MODULEBUILDER_FORMIMAGE_PATH, './' . $uploadDirectory . '/'); |
||
256 | $imageselect = new \XoopsFormSelect($imgpath, 'mod_image', $modImage); |
||
257 | $modImageArray = \XoopsLists::getImgListAsArray(TDMC_UPLOAD_IMGMOD_PATH); |
||
258 | foreach ($modImageArray as $image) { |
||
259 | $imageselect->addOption($image, $image); |
||
260 | } |
||
261 | $imageselect->setExtra("onchange='showImgSelected(\"image3\", \"mod_image\", \"" . $uploadDirectory . '", "", "' . \XOOPS_URL . "\")'"); |
||
262 | $imgtray->addElement($imageselect); |
||
263 | $imgtray->addElement(new \XoopsFormLabel('', "<br><img src='" . TDMC_UPLOAD_IMGMOD_URL . '/' . $modImage . "' id='image3' alt='' /><br>")); |
||
264 | |||
265 | $fileseltray = new \XoopsFormElementTray('', '<br>'); |
||
266 | $fileseltray->addElement(new \XoopsFormFile(\_AM_MODULEBUILDER_FORMUPLOAD, 'attachedfile', $helper->getConfig('maxsize_image'))); |
||
267 | $fileseltray->addElement(new \XoopsFormLabel('')); |
||
268 | $imgtray->addElement($fileseltray); |
||
269 | $form->addElement($imgtray); |
||
270 | //---------- START LOGO GENERATOR ----------------- |
||
271 | $tables_img = $this->getVar('table_image') ?: 'about.png'; |
||
272 | $iconsdir = '/Frameworks/moduleclasses/icons/32'; |
||
273 | if (\is_dir(\XOOPS_ROOT_PATH . $iconsdir)) { |
||
274 | $uploadDirectory = $iconsdir; |
||
275 | $imgpath = \sprintf(\_AM_MODULEBUILDER_FORMIMAGE_PATH, ".{$iconsdir}/"); |
||
276 | } else { |
||
277 | $uploadDirectory = '/uploads/' . $GLOBALS['xoopsModule']->dirname() . '/images/tables'; |
||
278 | $imgpath = \sprintf(\_AM_MODULEBUILDER_FORMIMAGE_PATH, './uploads/' . $GLOBALS['xoopsModule']->dirname() . '/images/tables'); |
||
279 | } |
||
280 | $createLogoTray = new \XoopsFormElementTray(\_AM_MODULEBUILDER_MODULE_CREATENEWLOGO, '<br>'); |
||
281 | $iconSelect = new \XoopsFormSelect($imgpath, 'tables_img', $tables_img, 8); |
||
282 | $tablesImagesArray = \XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH . $uploadDirectory); |
||
283 | foreach ($tablesImagesArray as $image) { |
||
284 | $iconSelect->addOption($image, $image); |
||
285 | } |
||
286 | $iconSelect->setExtra(" onchange='showImgSelected2(\"image4\", \"tables_img\", \"" . $uploadDirectory . '", "", "' . XOOPS_URL . "\")' "); |
||
287 | $createLogoTray->addElement($iconSelect); |
||
288 | $createLogoTray->addElement(new \XoopsFormLabel('', "<br><img src='" . XOOPS_URL . '/' . $uploadDirectory . '/' . $tables_img . "' id='image4' alt='' />")); |
||
289 | // Create preview and submit buttons |
||
290 | $buttonLogoGenerator4 = new \XoopsFormButton('', 'button4', \_AM_MODULEBUILDER_MODULE_CREATENEWLOGO, 'button'); |
||
291 | $buttonLogoGenerator4->setExtra(" onclick='createNewModuleLogo(\"" . TDMC_URL . "\")' "); |
||
292 | $createLogoTray->addElement($buttonLogoGenerator4); |
||
293 | |||
294 | $form->addElement($createLogoTray); |
||
295 | //------------ END LOGO GENERATOR -------------------- |
||
296 | |||
297 | $modAuthorMail = $isNew ? $set['author_mail'] : $this->getVar('mod_author_mail'); |
||
298 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_MODULE_AUTHOR_MAIL, 'mod_author_mail', 50, 255, $modAuthorMail)); |
||
299 | |||
300 | $modAuthorWebsiteUrl = $isNew ? $set['author_website_url'] : $this->getVar('mod_author_website_url'); |
||
301 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_MODULE_AUTHOR_WEBSITE_URL, 'mod_author_website_url', 50, 255, $modAuthorWebsiteUrl)); |
||
302 | |||
303 | $modAuthorWebsiteName = $isNew ? $set['author_website_name'] : $this->getVar('mod_author_website_name'); |
||
304 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_MODULE_AUTHOR_WEBSITE_NAME, 'mod_author_website_name', 50, 255, $modAuthorWebsiteName)); |
||
305 | |||
306 | $modCredits = $isNew ? $set['credits'] : $this->getVar('mod_credits'); |
||
307 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_MODULE_CREDITS, 'mod_credits', 50, 255, $modCredits)); |
||
308 | |||
309 | $modReleaseInfo = $isNew ? $set['release_info'] : $this->getVar('mod_release_info'); |
||
310 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_MODULE_RELEASE_INFO, 'mod_release_info', 50, 255, $modReleaseInfo)); |
||
311 | |||
312 | $modReleaseFile = $isNew ? $set['release_file'] : $this->getVar('mod_release_file'); |
||
313 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_MODULE_RELEASE_FILE, 'mod_release_file', 50, 255, $modReleaseFile)); |
||
314 | |||
315 | $modManual = $isNew ? $set['manual'] : $this->getVar('mod_manual'); |
||
316 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_MODULE_MANUAL, 'mod_manual', 50, 255, $modManual)); |
||
317 | |||
318 | $modManualFile = $isNew ? $set['manual_file'] : $this->getVar('mod_manual_file'); |
||
319 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_MODULE_MANUAL_FILE, 'mod_manual_file', 50, 255, $modManualFile)); |
||
320 | |||
321 | $modDemoSiteUrl = $isNew ? $set['demo_site_url'] : $this->getVar('mod_demo_site_url'); |
||
322 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_MODULE_DEMO_SITE_URL, 'mod_demo_site_url', 50, 255, $modDemoSiteUrl)); |
||
323 | |||
324 | $modDemoSiteName = $isNew ? $set['demo_site_name'] : $this->getVar('mod_demo_site_name'); |
||
325 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_MODULE_DEMO_SITE_NAME, 'mod_demo_site_name', 50, 255, $modDemoSiteName)); |
||
326 | |||
327 | $modSupportUrl = $isNew ? $set['support_url'] : $this->getVar('mod_support_url'); |
||
328 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_MODULE_SUPPORT_URL, 'mod_support_url', 50, 255, $modSupportUrl)); |
||
329 | |||
330 | $modSupportName = $isNew ? $set['support_name'] : $this->getVar('mod_support_name'); |
||
331 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_MODULE_SUPPORT_NAME, 'mod_support_name', 50, 255, $modSupportName)); |
||
332 | |||
333 | $modWebsiteUrl = $isNew ? $set['website_url'] : $this->getVar('mod_website_url'); |
||
334 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_MODULE_WEBSITE_URL, 'mod_website_url', 50, 255, $modWebsiteUrl)); |
||
335 | |||
336 | $modWebsiteName = $isNew ? $set['website_name'] : $this->getVar('mod_website_name'); |
||
337 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_MODULE_WEBSITE_NAME, 'mod_website_name', 50, 255, $modWebsiteName)); |
||
338 | |||
339 | $modRelease = $isNew ? $set['release'] : $this->getVar('mod_release'); |
||
340 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_MODULE_RELEASE, 'mod_release', 50, 255, $modRelease)); |
||
341 | |||
342 | $modStatus = $isNew ? $set['status'] : $this->getVar('mod_status'); |
||
343 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_MODULE_STATUS, 'mod_status', 50, 255, $modStatus)); |
||
344 | |||
345 | $modDonations = $isNew ? $set['donations'] : $this->getVar('mod_donations'); |
||
346 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_MODULE_PAYPAL_BUTTON, 'mod_donations', 50, 255, $modDonations)); |
||
347 | |||
348 | $modSubversion = $isNew ? $set['subversion'] : $this->getVar('mod_subversion'); |
||
349 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_MODULE_SUBVERSION, 'mod_subversion', 50, 255, $modSubversion)); |
||
350 | |||
351 | $buttonTray = new \XoopsFormElementTray(_REQUIRED . ' <sup class="red bold">*</sup>', ''); |
||
352 | $buttonTray->addElement(new \XoopsFormHidden('op', 'save')); |
||
353 | $buttonTray->addElement(new \XoopsFormButton('', 'submit', \_SUBMIT, 'submit')); |
||
354 | $form->addElement($buttonTray); |
||
355 | |||
356 | return $form; |
||
357 | } |
||
461 |