Conditions | 5 |
Paths | 16 |
Total Lines | 95 |
Code Lines | 76 |
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 |
||
139 | public function getFormSettings($action = false) |
||
140 | { |
||
141 | $helper = Modulebuilder\Helper::getInstance(); |
||
142 | if (false === $action) { |
||
143 | $action = \Xmf\Request::getString('REQUEST_URI', '', 'SERVER'); |
||
144 | } |
||
145 | |||
146 | $isNew = $this->isNew(); |
||
147 | $title = $isNew ? \sprintf(\_AM_MODULEBUILDER_SETTING_NEW) : \sprintf(\_AM_MODULEBUILDER_SETTING_EDIT); |
||
148 | |||
149 | require_once \XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
||
150 | |||
151 | $form = new \XoopsThemeForm($title, 'settingform', $action, 'post', true); |
||
152 | $form->setExtra('enctype="multipart/form-data"'); |
||
153 | |||
154 | $form->addElement(new \XoopsFormHidden('set_id', $this->getVar('set_id'))); |
||
|
|||
155 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_NAME, 'set_name', 50, 255, $this->getVar('set_name'))); |
||
156 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_DIRNAME, 'set_dirname', 25, 255, $this->getVar('set_dirname'))); |
||
157 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_VERSION, 'set_version', 10, 25, $this->getVar('set_version'))); |
||
158 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_SINCE, 'set_since', 10, 25, $this->getVar('set_since'))); |
||
159 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_MIN_PHP, 'set_min_php', 10, 25, $this->getVar('set_min_php'))); |
||
160 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_MIN_XOOPS, 'set_min_xoops', 10, 25, $this->getVar('set_min_xoops'))); |
||
161 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_MIN_ADMIN, 'set_min_admin', 10, 25, $this->getVar('set_min_admin'))); |
||
162 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_MIN_MYSQL, 'set_min_mysql', 10, 25, $this->getVar('set_min_mysql'))); |
||
163 | $form->addElement(new \XoopsFormTextArea(\_AM_MODULEBUILDER_SETTING_DESCRIPTION, 'set_description', $this->getVar('set_description'), 4, 25)); |
||
164 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_AUTHOR, 'set_author', 50, 255, $this->getVar('set_author'))); |
||
165 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_LICENSE, 'set_license', 50, 255, $this->getVar('set_license'))); |
||
166 | // Check All Settings Options |
||
167 | $optionsTray = new \XoopsFormElementTray(_OPTIONS, '<br>'); |
||
168 | $checkAllOptions = new \XoopsFormCheckBox('', 'settingbox', 1); |
||
169 | $checkAllOptions->addOption('allbox', \_AM_MODULEBUILDER_SETTING_ALL); |
||
170 | $checkAllOptions->setExtra(' onclick="xoopsCheckAll(\'settingform\', \'settingbox\');" '); |
||
171 | $checkAllOptions->setClass('xo-checkall'); |
||
172 | $optionsTray->addElement($checkAllOptions); |
||
173 | // Options |
||
174 | $settingOption = $this->getOptionsSettings(); |
||
175 | $checkbox = new \XoopsFormCheckbox(' ', 'setting_option', $settingOption, '<br>'); |
||
176 | $checkbox->setDescription(\_AM_MODULEBUILDER_OPTIONS_DESC); |
||
177 | foreach ($this->options as $option) { |
||
178 | $checkbox->addOption($option, self::getDefinedLanguage('\_AM_MODULEBUILDER_SETTING_' . \mb_strtoupper($option))); |
||
179 | } |
||
180 | $optionsTray->addElement($checkbox); |
||
181 | |||
182 | $form->addElement($optionsTray); |
||
183 | |||
184 | $modImage = $this->getVar('set_image'); |
||
185 | //$modImage = $modImage ?: $set['image']; |
||
186 | |||
187 | $uploadDirectory = 'uploads/' . $GLOBALS['xoopsModule']->dirname() . '/images/modules'; |
||
188 | $imgtray = new \XoopsFormElementTray(\_AM_MODULEBUILDER_SETTING_IMAGE, '<br>'); |
||
189 | $imgpath = \sprintf(\_AM_MODULEBUILDER_FORMIMAGE_PATH, './' . $uploadDirectory . '/'); |
||
190 | $imageSelect = new \XoopsFormSelect($imgpath, 'set_image', $modImage); |
||
191 | $modImage_array = \XoopsLists::getImgListAsArray(TDMC_UPLOAD_IMGMOD_PATH); |
||
192 | foreach ($modImage_array as $image) { |
||
193 | $imageSelect->addOption($image, $image); |
||
194 | } |
||
195 | $imageSelect->setExtra("onchange='showImgSelected(\"image3\", \"set_image\", \"" . $uploadDirectory . '", "", "' . \XOOPS_URL . "\")'"); |
||
196 | $imgtray->addElement($imageSelect); |
||
197 | $imgtray->addElement(new \XoopsFormLabel('', "<br><img src='" . TDMC_UPLOAD_IMGMOD_URL . '/' . $modImage . "' id='image3' alt='' /><br>")); |
||
198 | |||
199 | $fileseltray = new \XoopsFormElementTray('', '<br>'); |
||
200 | $fileseltray->addElement(new \XoopsFormFile(\_AM_MODULEBUILDER_FORMUPLOAD, 'attachedfile', $helper->getConfig('maxsize_image'))); |
||
201 | $fileseltray->addElement(new \XoopsFormLabel('')); |
||
202 | $imgtray->addElement($fileseltray); |
||
203 | $form->addElement($imgtray); |
||
204 | |||
205 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_AUTHOR_MAIL, 'set_author_mail', 50, 255, $this->getVar('set_author_mail'))); |
||
206 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_AUTHOR_WEBSITE_URL, 'set_author_website_url', 50, 255, $this->getVar('set_author_website_url'))); |
||
207 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_AUTHOR_WEBSITE_NAME, 'set_author_website_name', 50, 255, $this->getVar('set_author_website_name'))); |
||
208 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_CREDITS, 'set_credits', 50, 255, $this->getVar('set_credits'))); |
||
209 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_RELEASE_INFO, 'set_release_info', 50, 255, $this->getVar('set_release_info'))); |
||
210 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_RELEASE_FILE, 'set_release_file', 50, 255, $this->getVar('set_release_file'))); |
||
211 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_MANUAL, 'set_manual', 50, 255, $this->getVar('set_manual'))); |
||
212 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_MANUAL_FILE, 'set_manual_file', 50, 255, $this->getVar('set_manual_file'))); |
||
213 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_DEMO_SITE_URL, 'set_demo_site_url', 50, 255, $this->getVar('set_demo_site_url'))); |
||
214 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_DEMO_SITE_NAME, 'set_demo_site_name', 50, 255, $this->getVar('set_demo_site_name'))); |
||
215 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_SUPPORT_URL, 'set_support_url', 50, 255, $this->getVar('set_support_url'))); |
||
216 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_SUPPORT_NAME, 'set_support_name', 50, 255, $this->getVar('set_support_name'))); |
||
217 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_WEBSITE_URL, 'set_website_url', 50, 255, $this->getVar('set_website_url'))); |
||
218 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_WEBSITE_NAME, 'set_website_name', 50, 255, $this->getVar('set_website_name'))); |
||
219 | $form->addElement(new \XoopsFormTextDateSelect(\_AM_MODULEBUILDER_SETTING_RELEASE, 'set_release', '', $this->getVar('set_release'))); |
||
220 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_STATUS, 'set_status', 50, 255, $this->getVar('set_status'))); |
||
221 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_PAYPAL_BUTTON, 'set_donations', 50, 255, $this->getVar('set_donations'))); |
||
222 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_SUBVERSION, 'set_subversion', 50, 255, $this->getVar('set_subversion'))); |
||
223 | $setTypeRadio = new \XoopsFormRadio(\_AM_MODULEBUILDER_SETTING_TYPE, 'set_type', $this->getVar('set_type')); |
||
224 | $setTypeRadio->addOption(0, \_AM_MODULEBUILDER_SETTING_TYPE_INACTIVE); |
||
225 | $setTypeRadio->addOption(1, \_AM_MODULEBUILDER_SETTING_TYPE_ACTIVE); |
||
226 | $form->addElement($setTypeRadio); |
||
227 | |||
228 | $buttonTray = new \XoopsFormElementTray(_REQUIRED . ' <sup class="red bold">*</sup>', ''); |
||
229 | $buttonTray->addElement(new \XoopsFormHidden('op', 'save')); |
||
230 | $buttonTray->addElement(new \XoopsFormButton('', 'submit', \_SUBMIT, 'submit')); |
||
231 | $form->addElement($buttonTray); |
||
232 | |||
233 | return $form; |
||
234 | } |
||
292 |