| Conditions | 8 |
| Paths | 30 |
| Total Lines | 59 |
| Code Lines | 42 |
| 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 |
||
| 157 | public function render() |
||
| 158 | { |
||
| 159 | // load all child ids for javascript codes |
||
| 160 | foreach (array_keys($this->_itemTree) as $item_id) { |
||
| 161 | $this->_itemTree[$item_id]['allchild'] = []; |
||
| 162 | $this->_loadAllChildItemIds($item_id, $this->_itemTree[$item_id]['allchild']); |
||
| 163 | } |
||
| 164 | $grouppermHandler = xoops_getHandler('groupperm'); |
||
| 165 | $memberHandler = xoops_getHandler('member'); |
||
| 166 | $glist = $memberHandler->getGroupList(); |
||
|
|
|||
| 167 | foreach (array_keys($glist) as $i) { |
||
| 168 | // get selected item id(s) for each group |
||
| 169 | $selected = $grouppermHandler->getItemIds($this->_permName, $i, $this->_modid); |
||
| 170 | $ele = new GroupFormCheckBox($glist[$i], 'perms[' . $this->_permName . ']', $i, $selected); |
||
| 171 | $ele->setOptionTree($this->_itemTree); |
||
| 172 | |||
| 173 | foreach ($this->_appendix as $key => $append) { |
||
| 174 | $this->_appendix[$key]['selected'] = $grouppermHandler->checkRight($append['permname'], $append['itemid'], $i, $this->_modid); |
||
| 175 | } |
||
| 176 | $ele->setAppendix($this->_appendix); |
||
| 177 | $this->addElement($ele); |
||
| 178 | unset($ele); |
||
| 179 | } |
||
| 180 | |||
| 181 | // GIJ start |
||
| 182 | $jstray = new \XoopsFormElementTray(' '); |
||
| 183 | $jsuncheckbutton = new \XoopsFormButton('', 'none', _NONE, 'button'); |
||
| 184 | $jsuncheckbutton->setExtra("onclick=\"with(document.groupperm_form){for (i=0;i<length;i++) {if (elements[i].type=='checkbox') {elements[i].checked=false;}}}\""); |
||
| 185 | $jscheckbutton = new \XoopsFormButton('', 'all', _ALL, 'button'); |
||
| 186 | $jscheckbutton->setExtra("onclick=\"with(document.groupperm_form){for (i=0;i<length;i++) {if (elements[i].type=='checkbox' && (elements[i].name.indexOf('module_admin')<0 || elements[i].name.indexOf('[groups][1]')>=0)) {elements[i].checked=true;}}}\""); |
||
| 187 | $jstray->addElement($jsuncheckbutton); |
||
| 188 | $jstray->addElement($jscheckbutton); |
||
| 189 | $this->addElement($jstray); |
||
| 190 | // GIJ end |
||
| 191 | |||
| 192 | $tray = new \XoopsFormElementTray(''); |
||
| 193 | $tray->addElement(new \XoopsFormButton('', 'reset', _CANCEL, 'reset')); |
||
| 194 | $tray->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
||
| 195 | $this->addElement($tray); |
||
| 196 | |||
| 197 | $ret = '<h4>' . $this->getTitle() . '</h4>' . $this->_permDesc . '<br>'; |
||
| 198 | $ret .= "<form name='" . $this->getName() . "' id='" . $this->getName() . "' action='" . $this->getAction() . "' method='" . $this->getMethod() . "'" . $this->getExtra() . ">\n<table width='100%' class='outer' cellspacing='1'>\n"; |
||
| 199 | $elements = &$this->getElements(); |
||
| 200 | foreach (array_keys($elements) as $i) { |
||
| 201 | if (!is_object($elements[$i])) { |
||
| 202 | $ret .= $elements[$i]; |
||
| 203 | } elseif (!$elements[$i]->isHidden()) { |
||
| 204 | $ret .= "<tr valign='top' align='left'><td class='head'>" . $elements[$i]->getCaption(); |
||
| 205 | if ('' != $elements[$i]->getDescription()) { |
||
| 206 | $ret .= '<br><br><span style="font-weight: normal;">' . $elements[$i]->getDescription() . '</span>'; |
||
| 207 | } |
||
| 208 | $ret .= "</td>\n<td class='even'>\n" . $elements[$i]->render() . "\n</td></tr>\n"; |
||
| 209 | } else { |
||
| 210 | $ret .= $elements[$i]->render(); |
||
| 211 | } |
||
| 212 | } |
||
| 213 | $ret .= '</table></form>'; |
||
| 214 | |||
| 215 | return $ret; |
||
| 216 | } |
||
| 218 |