Conditions | 2 |
Paths | 2 |
Total Lines | 55 |
Code Lines | 44 |
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 |
||
74 | public function getFormFeedback($action = false) |
||
75 | { |
||
76 | if (!$action) { |
||
77 | $action = $_SERVER['REQUEST_URI']; |
||
|
|||
78 | } |
||
79 | $moduleDirName = \basename(\dirname(__DIR__, 2)); |
||
80 | $moduleDirNameUpper = mb_strtoupper($moduleDirName); |
||
81 | // Get Theme Form |
||
82 | \xoops_load('XoopsFormLoader'); |
||
83 | $form = new XoopsThemeForm(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_FORM_TITLE'), 'formfeedback', 'feedback.php', 'post', true); |
||
84 | $form->setExtra('enctype="multipart/form-data"'); |
||
85 | |||
86 | $recipient = new XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_RECIPIENT'), 'recipient', 50, 255, $GLOBALS['xoopsModule']->getInfo('author_mail')); |
||
87 | $recipient->setExtra('disabled="disabled"'); |
||
88 | $form->addElement($recipient); |
||
89 | $your_name = new XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_NAME'), 'your_name', 50, 255, $this->name); |
||
90 | $your_name->setExtra('placeholder="' . \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_NAME_PLACEHOLER') . '"'); |
||
91 | $form->addElement($your_name); |
||
92 | $your_site = new XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_SITE'), 'your_site', 50, 255, $this->site); |
||
93 | $your_site->setExtra('placeholder="' . \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_SITE_PLACEHOLER') . '"'); |
||
94 | $form->addElement($your_site); |
||
95 | $your_mail = new XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_MAIL'), 'your_mail', 50, 255, $this->email); |
||
96 | $your_mail->setExtra('placeholder="' . \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_MAIL_PLACEHOLER') . '"'); |
||
97 | $form->addElement($your_mail); |
||
98 | |||
99 | $fbtypeSelect = new XoopsFormSelect(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE'), 'fb_type', $this->type); |
||
100 | $fbtypeSelect->addOption('', ''); |
||
101 | $fbtypeSelect->addOption(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_SUGGESTION'), \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_SUGGESTION')); |
||
102 | $fbtypeSelect->addOption(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_BUGS'), \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_BUGS')); |
||
103 | $fbtypeSelect->addOption(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_TESTIMONIAL'), \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_TESTIMONIAL')); |
||
104 | $fbtypeSelect->addOption(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_FEATURES'), \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_FEATURES')); |
||
105 | $fbtypeSelect->addOption(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_OTHERS'), \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_OTHERS')); |
||
106 | $form->addElement($fbtypeSelect, true); |
||
107 | |||
108 | $editorConfigs = []; |
||
109 | $editorConfigs['name'] = 'fb_content'; |
||
110 | $editorConfigs['value'] = $this->content; |
||
111 | $editorConfigs['rows'] = 5; |
||
112 | $editorConfigs['cols'] = 40; |
||
113 | $editorConfigs['width'] = '100%'; |
||
114 | $editorConfigs['height'] = '400px'; |
||
115 | /** @var \XoopsModuleHandler $moduleHandler */ |
||
116 | $moduleHandler = \xoops_getHandler('module'); |
||
117 | $module = $moduleHandler->getByDirname('system'); |
||
118 | /** @var \XoopsConfigHandler $configHandler */ |
||
119 | $configHandler = \xoops_getHandler('config'); |
||
120 | $config = $configHandler->getConfigsByCat(0, $module->getVar('mid')); |
||
121 | $editorConfigs['editor'] = $config['general_editor']; |
||
122 | $editor = new XoopsFormEditor(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_CONTENT'), 'fb_content', $editorConfigs); |
||
123 | $form->addElement($editor, true); |
||
124 | |||
125 | $form->addElement(new XoopsFormHidden('op', 'send')); |
||
126 | $form->addElement(new XoopsFormButtonTray('', _SUBMIT, 'submit', '', false)); |
||
127 | |||
128 | return $form; |
||
129 | } |
||
131 |