Conditions | 7 |
Paths | 64 |
Total Lines | 99 |
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 |
||
72 | public function getForm($action = false) |
||
73 | { |
||
74 | global $xoopsDB, $xoopsModuleConfig; |
||
75 | |||
76 | if (false === $action) { |
||
77 | $action = $_SERVER['REQUEST_URI']; |
||
78 | } |
||
79 | |||
80 | $title = $this->isNew() ? sprintf(_AM_PRESENTER_SLIDES_ADD) : sprintf(_AM_PRESENTER_SLIDES_EDIT); |
||
81 | |||
82 | require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
||
83 | |||
84 | $form = new XoopsThemeForm($title, 'form', $action, 'post', true); |
||
85 | $form->setExtra('enctype="multipart/form-data"'); |
||
86 | |||
87 | // Slides_cid |
||
88 | $form->addElement(new XoopsFormText(_AM_PRESENTER_SLIDES_CID, 'slides_cid', 50, 255, $this->getVar('slides_cid')), false); |
||
89 | // Slides_uid |
||
90 | $form->addElement(new XoopsFormText(_AM_PRESENTER_SLIDES_UID, 'slides_uid', 50, 255, $this->getVar('slides_uid')), false); |
||
91 | // Slides_title |
||
92 | $form->addElement(new XoopsFormText(_AM_PRESENTER_SLIDES_TITLE, 'slides_title', 50, 255, $this->getVar('slides_title')), true); |
||
93 | // Slides_content |
||
94 | $editor_configs = []; |
||
95 | $editor_configs['name'] = 'slides_content'; |
||
96 | $editor_configs['value'] = $this->getVar('slides_content', 'e'); |
||
97 | $editor_configs['rows'] = 10; |
||
98 | $editor_configs['cols'] = 80; |
||
99 | $editor_configs['width'] = '100%'; |
||
100 | $editor_configs['height'] = '400px'; |
||
101 | $editor_configs['editor'] = $GLOBALS['xoopsModuleConfig']['presenter_editor']; |
||
102 | $form->addElement(new XoopsFormEditor(_AM_PRESENTER_SLIDES_CONTENT, 'slides_content', $editor_configs), true); |
||
103 | |||
104 | $form->addElement(new XoopsFormText(_AM_PRESENTER_SLIDES_CSS_ID, 'css_id', 50, 255, $this->getVar('css_id')), true); |
||
105 | $form->addElement(new XoopsFormText(_AM_PRESENTER_SLIDES_CSS_CLASS, 'css_class', 50, 255, $this->getVar('css_class')), true); |
||
106 | |||
107 | // Slides_transition_x |
||
108 | $form->addElement(new XoopsFormText(_AM_PRESENTER_SLIDES_TRANSITION_X, 'slides_transition_x', 50, 255, $this->getVar('slides_transition_x')), false); |
||
109 | // Slides_transition_y |
||
110 | $form->addElement(new XoopsFormText(_AM_PRESENTER_SLIDES_TRANSITION_Y, 'slides_transition_y', 50, 255, $this->getVar('slides_transition_y')), false); |
||
111 | // Slides_transition_z |
||
112 | $form->addElement(new XoopsFormText(_AM_PRESENTER_SLIDES_TRANSITION_Z, 'slides_transition_z', 50, 255, $this->getVar('slides_transition_z')), false); |
||
113 | // Slides_rotation_x |
||
114 | $form->addElement(new XoopsFormText(_AM_PRESENTER_SLIDES_ROTATION_X, 'slides_rotation_x', 50, 255, $this->getVar('slides_rotation_x')), false); |
||
115 | // Slides_rotation_y |
||
116 | $form->addElement(new XoopsFormText(_AM_PRESENTER_SLIDES_ROTATION_Y, 'slides_rotation_y', 50, 255, $this->getVar('slides_rotation_y')), false); |
||
117 | // Slides_rotation_z |
||
118 | $form->addElement(new XoopsFormText(_AM_PRESENTER_SLIDES_ROTATION_Z, 'slides_rotation_z', 50, 255, $this->getVar('slides_rotation_z')), false); |
||
119 | // Slides_scale_x |
||
120 | $form->addElement(new XoopsFormText(_AM_PRESENTER_SLIDES_SCALE_X, 'slides_scale_x', 50, 255, $this->getVar('slides_scale_x')), false); |
||
121 | // Slides_scale_y |
||
122 | $form->addElement(new XoopsFormText(_AM_PRESENTER_SLIDES_SCALE_Y, 'slides_scale_y', 50, 255, $this->getVar('slides_scale_y')), false); |
||
123 | // Slides_scale_z |
||
124 | $form->addElement(new XoopsFormText(_AM_PRESENTER_SLIDES_SCALE_Z, 'slides_scale_z', 50, 255, $this->getVar('slides_scale_z')), false); |
||
125 | // Slides_created |
||
126 | $form->addElement(new XoopsFormTextDateSelect(_AM_PRESENTER_SLIDES_CREATED, 'slides_created', '', $this->getVar('slides_created'))); |
||
127 | // Slides_published |
||
128 | $form->addElement(new XoopsFormTextDateSelect(_AM_PRESENTER_SLIDES_PUBLISHED, 'slides_published', '', $this->getVar('slides_published'))); |
||
129 | // Slides_position |
||
130 | $form->addElement(new XoopsFormText(_AM_PRESENTER_SLIDES_POSITION, 'slides_position', 50, 255, $this->getVar('slides_position')), false); |
||
131 | // Slides_online |
||
132 | $slides_online = $this->isNew() ? 0 : $this->getVar('slides_online'); |
||
133 | $form->addElement(new XoopsFormRadioYN(_AM_PRESENTER_SLIDES_ONLINE, 'slides_online', $slides_online), false); |
||
134 | // Slides_type |
||
135 | $form->addElement(new XoopsFormText(_AM_PRESENTER_SLIDES_TYPE, 'slides_type', 50, 255, $this->getVar('slides_type')), false); |
||
136 | // Slides_notes |
||
137 | $editor_configs = []; |
||
138 | $editor_configs['name'] = 'slides_notes'; |
||
139 | $editor_configs['value'] = $this->getVar('slides_notes', 'e'); |
||
140 | $editor_configs['rows'] = 10; |
||
141 | $editor_configs['cols'] = 80; |
||
142 | $editor_configs['width'] = '100%'; |
||
143 | $editor_configs['height'] = '400px'; |
||
144 | $editor_configs['editor'] = $GLOBALS['xoopsModuleConfig']['presenter_editor']; |
||
145 | $form->addElement(new XoopsFormEditor(_AM_PRESENTER_SLIDES_NOTES, 'slides_notes', $editor_configs), false); |
||
146 | // Slides_mp3 |
||
147 | $form->addElement(new XoopsFormFile(_AM_PRESENTER_SLIDES_MP3, 'slides_mp3', $xoopsModuleConfig['maxsize']), false); |
||
148 | // Slides_time |
||
149 | $form->addElement(new XoopsFormText(_AM_PRESENTER_SLIDES_TIME, 'slides_time', 50, 255, $this->getVar('slides_time')), false); |
||
150 | // Slides_status |
||
151 | $slides_status = $this->isNew() ? 0 : $this->getVar('slides_status'); |
||
152 | $check_slides_status = new XoopsFormCheckBox(_AM_PRESENTER_SLIDES_STATUS, 'slides_status', $slides_status); |
||
153 | $check_slides_status->addOption(1, ' '); |
||
154 | $form->addElement($check_slides_status); |
||
155 | // Slides_waiting |
||
156 | $slides_waiting = $this->isNew() ? 0 : $this->getVar('slides_waiting'); |
||
157 | $check_slides_waiting = new XoopsFormCheckBox(_AM_PRESENTER_SLIDES_WAITING, 'slides_waiting', $slides_waiting); |
||
158 | $check_slides_waiting->addOption(1, ' '); |
||
159 | $form->addElement($check_slides_waiting); |
||
160 | // Slides_online |
||
161 | $slides_online = $this->isNew() ? 0 : $this->getVar('slides_online'); |
||
162 | $check_slides_online = new XoopsFormCheckBox(_AM_PRESENTER_SLIDES_ONLINE, 'slides_online', $slides_online); |
||
163 | $check_slides_online->addOption(1, ' '); |
||
164 | $form->addElement($check_slides_online); |
||
165 | |||
166 | $form->addElement(new XoopsFormHidden('op', 'save')); |
||
167 | $form->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
||
168 | |||
169 | return $form; |
||
170 | } |
||
171 | } |
||
187 |