| Conditions | 14 |
| Paths | 336 |
| Total Lines | 104 |
| Code Lines | 83 |
| 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 |
||
| 95 | private function getTemplatesUserPagesItemPanel($moduleDirname, $tableId, $tableMid, $tableName, $tableSoleName, $tableRate, $language) |
||
| 96 | { |
||
| 97 | $fields = $this->getTableFields($tableMid, $tableId); |
||
| 98 | $ret = ''; |
||
| 99 | $retNumb = ''; |
||
| 100 | $fieldId = ''; |
||
| 101 | $ccFieldId = ''; |
||
| 102 | $keyDouble = ''; |
||
| 103 | foreach (array_keys($fields) as $f) { |
||
| 104 | if (0 == $f) { |
||
| 105 | $fieldId = $fields[$f]->getVar('field_name'); |
||
| 106 | $ccFieldId = $this->getCamelCase($fieldId, false, true); |
||
| 107 | $keyDouble = $this->sc->getSmartyDoubleVar($tableSoleName, $fieldId); |
||
| 108 | } |
||
| 109 | $fieldElement = $fields[$f]->getVar('field_element'); |
||
| 110 | if (1 == $fields[$f]->getVar('field_user')) { |
||
| 111 | if (1 == $fields[$f]->getVar('field_thead')) { |
||
| 112 | switch ($fieldElement) { |
||
| 113 | default: |
||
| 114 | //case 2: |
||
| 115 | $fieldName = $fields[$f]->getVar('field_name'); |
||
| 116 | $rpFieldName = $this->getRightString($fieldName); |
||
| 117 | $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
||
| 118 | $retNumb .= $this->hc->getHtmlHNumb($doubleVar, '3', 'panel-title', "\t"); |
||
| 119 | break; |
||
| 120 | } |
||
| 121 | } |
||
| 122 | } |
||
| 123 | } |
||
| 124 | $ret .= $this->hc->getHtmlI('', '', $ccFieldId . '_' . $keyDouble); |
||
| 125 | $ret .= $this->hc->getHtmlDiv($retNumb, 'panel-heading'); |
||
| 126 | $retElem = ''; |
||
| 127 | foreach (array_keys($fields) as $f) { |
||
| 128 | $fieldElement = $fields[$f]->getVar('field_element'); |
||
| 129 | if (1 == $fields[$f]->getVar('field_user')) { |
||
| 130 | if (1 == $fields[$f]->getVar('field_tbody')) { |
||
| 131 | switch ($fieldElement) { |
||
| 132 | default: |
||
| 133 | //case 3: |
||
| 134 | //case 4: |
||
| 135 | $fieldName = $fields[$f]->getVar('field_name'); |
||
| 136 | $rpFieldName = $this->getRightString($fieldName); |
||
| 137 | $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
||
| 138 | $retElem .= $this->hc->getHtmlSpan($doubleVar, 'col-sm-9 justify', "\t"); |
||
| 139 | break; |
||
| 140 | case 10: |
||
| 141 | $fieldName = $fields[$f]->getVar('field_name'); |
||
| 142 | $rpFieldName = $this->getRightString($fieldName); |
||
| 143 | $singleVar = $this->sc->getSmartySingleVar('xoops_icons32_url'); |
||
| 144 | $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
||
| 145 | $img = $this->hc->getHtmlImage($singleVar . '/' . $doubleVar, (string)$tableName); |
||
| 146 | $retElem .= $this->hc->getHtmlSpan($img, 'col-sm-3', "\t"); |
||
| 147 | unset($img); |
||
| 148 | break; |
||
| 149 | case 13: |
||
| 150 | $fieldName = $fields[$f]->getVar('field_name'); |
||
| 151 | $rpFieldName = $this->getRightString($fieldName); |
||
| 152 | $singleVar = $this->sc->getSmartySingleVar($moduleDirname . '_upload_url'); |
||
| 153 | $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
||
| 154 | $img = $this->hc->getHtmlImage($singleVar . "/images/{$tableName}/" . $doubleVar, (string)$tableName); |
||
| 155 | $retElem .= $this->hc->getHtmlSpan($img, 'col-sm-3',"\t"); |
||
| 156 | unset($img); |
||
| 157 | break; |
||
| 158 | } |
||
| 159 | } |
||
| 160 | } |
||
| 161 | } |
||
| 162 | $ret .= $this->hc->getHtmlDiv($retElem, 'panel-body'); |
||
| 163 | |||
| 164 | $retFoot = ''; |
||
| 165 | foreach (array_keys($fields) as $f) { |
||
| 166 | if (1 == $fields[$f]->getVar('field_user')) { |
||
| 167 | if (1 == $fields[$f]->getVar('field_tfoot')) { |
||
| 168 | $fieldName = $fields[$f]->getVar('field_name'); |
||
| 169 | $rpFieldName = $this->getRightString($fieldName); |
||
| 170 | $langConst = mb_strtoupper($tableSoleName) . '_' . mb_strtoupper($rpFieldName); |
||
| 171 | $lang = $this->sc->getSmartyConst($language, $langConst); |
||
| 172 | $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
||
| 173 | $retFoot .= $this->hc->getHtmlSpan($lang . ': ' . $doubleVar, 'block-pie justify',"\t"); |
||
| 174 | } |
||
| 175 | } |
||
| 176 | } |
||
| 177 | |||
| 178 | $anchors = ''; |
||
| 179 | $lang = $this->sc->getSmartyConst($language, mb_strtoupper($tableName) . '_LIST'); |
||
| 180 | $contIf = $this->hc->getHtmlAnchor($tableName . ".php?op=list&#{$ccFieldId}_" . $keyDouble, $lang, $lang, '', 'btn btn-success right', '', "\t\t\t", "\n"); |
||
| 181 | $lang = $this->sc->getSmartyConst($language, 'DETAILS'); |
||
| 182 | $contElse = $this->hc->getHtmlAnchor($tableName . ".php?op=show&{$fieldId}=" . $keyDouble, $lang, $lang, '', 'btn btn-success right', '', "\t\t\t", "\n"); |
||
| 183 | $anchors .= $this->sc->getSmartyConditions('showItem', '', '', $contIf, $contElse, '', '', "\t\t"); |
||
| 184 | $lang = $this->sc->getSmartyConst('', '_EDIT'); |
||
| 185 | $contIf = $this->hc->getHtmlAnchor($tableName . ".php?op=edit&{$fieldId}=" . $keyDouble, $lang, $lang, '', 'btn btn-primary right', '', "\t\t\t", "\n"); |
||
| 186 | $lang = $this->sc->getSmartyConst('', '_DELETE'); |
||
| 187 | $contIf .= $this->hc->getHtmlAnchor($tableName . ".php?op=delete&{$fieldId}=" . $keyDouble, $lang, $lang, '', 'btn btn-danger right', '', "\t\t\t", "\n"); |
||
| 188 | $anchors .= $this->sc->getSmartyConditions('permEdit', '', '', $contIf, false, '', '', "\t\t"); |
||
| 189 | $lang = $this->sc->getSmartyConst($language, 'BROKEN'); |
||
| 190 | $anchors .= $this->hc->getHtmlAnchor($tableName . ".php?op=broken&{$fieldId}=" . $keyDouble, $lang, $lang, '', 'btn btn-warning right', '', "\t\t", "\n"); |
||
| 191 | $retFoot .= $this->hc->getHtmlDiv($anchors, 'col-sm-12 right',"\t", "\n"); |
||
| 192 | $ret .= $this->hc->getHtmlDiv($retFoot, 'panel-foot'); |
||
| 193 | if ($tableRate) { |
||
| 194 | $rate = $this->sc->getSmartyIncludeFile($moduleDirname, 'rate', false, false, "\t", "\n", 'item=$' . $tableSoleName); |
||
| 195 | $ret .= $this->sc->getSmartyConditions('rating', '', '', $rate, false); |
||
| 196 | } |
||
| 197 | |||
| 198 | return $ret; |
||
| 199 | } |
||
| 229 |