| Conditions | 10 |
| Paths | 30 |
| Total Lines | 69 |
| Code Lines | 47 |
| 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 |
||
| 123 | private function getTemplatesBlocksTableTbody($moduleDirname, $tableId, $tableMid, $tableName, $tableSoleName, $tableAutoincrement, $language) |
||
| 124 | { |
||
| 125 | $td = ''; |
||
| 126 | $fieldId = ''; |
||
| 127 | $stuTableSoleName = \mb_strtoupper($tableSoleName); |
||
| 128 | if (1 == $tableAutoincrement) { |
||
| 129 | $double = $this->sc->getSmartyDoubleVar($tableSoleName, 'id'); |
||
| 130 | $td .= $this->hc->getHtmlTableData($double, 'center', '', "\t\t\t"); |
||
| 131 | } |
||
| 132 | $fields = $this->getTableFields($tableMid, $tableId); |
||
| 133 | foreach (\array_keys($fields) as $f) { |
||
| 134 | if (0 == $f) { |
||
| 135 | $fieldId = $fields[$f]->getVar('field_name'); |
||
| 136 | } |
||
| 137 | if (1 === (int)$fields[$f]->getVar('field_block')) { |
||
| 138 | $fieldName = $fields[$f]->getVar('field_name'); |
||
| 139 | $fieldElement = $fields[$f]->getVar('field_element'); |
||
| 140 | $rpFieldName = $this->getRightString($fieldName); |
||
| 141 | if (1 == $fields[$f]->getVar('field_inlist')) { |
||
| 142 | switch ($fieldElement) { |
||
| 143 | case 9: |
||
| 144 | $double = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
||
| 145 | $span = $this->hc->getHtmlTag('span', [], $double); |
||
| 146 | $td .= $this->hc->getHtmlTableData($span, 'center', '', "\t\t\t"); |
||
| 147 | break; |
||
| 148 | case 10: |
||
| 149 | $src = $this->sc->getSmartyNoSimbol('xoModuleIcons32'); |
||
| 150 | $src .= $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
||
| 151 | $img = $this->hc->getHtmlTag('img', ['src' => $src, 'alt' => $tableName], '', true, '', ''); |
||
| 152 | $td .= $this->hc->getHtmlTableData($img, 'center', '', "\t\t\t"); |
||
| 153 | break; |
||
| 154 | case 13: |
||
| 155 | $single = $this->sc->getSmartySingleVar($moduleDirname . '_upload_url'); |
||
| 156 | $double = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
||
| 157 | $img = $this->hc->getHtmlTag('img', ['src' => $single . "/images/{$tableName}/" . $double, 'alt' => $tableName], '', true, '', ''); |
||
| 158 | $td .= $this->hc->getHtmlTableData($img, 'center', '', "\t\t\t"); |
||
| 159 | break; |
||
| 160 | default: |
||
| 161 | if (0 != $f) { |
||
| 162 | $double = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
||
| 163 | $td .= $this->hc->getHtmlTableData($double, 'center', '', "\t\t\t"); |
||
| 164 | } |
||
| 165 | break; |
||
| 166 | } |
||
| 167 | } |
||
| 168 | } |
||
| 169 | } |
||
| 170 | // TODO: allow edit only for admins |
||
| 171 | // $lang = $this->sc->getSmartyConst('', '_EDIT'); |
||
| 172 | // $double = $this->sc->getSmartyDoubleVar($tableSoleName, 'id'); |
||
| 173 | // $src = $this->sc->getSmartyNoSimbol('xoModuleIcons32 edit.png'); |
||
| 174 | // $img = $this->hc->getHtmlTag('img', ['src' => $src, 'alt' => $tableName], '', true, '', ''); |
||
| 175 | // $anchor = $this->hc->getHtmlTag('a', ['href' => $tableName . ".php?op=edit&{$fieldId}=" . $double, 'title' => $lang], $img, false, "\t\t\t\t"); |
||
| 176 | // $lang = $this->sc->getSmartyConst('', '_DELETE'); |
||
| 177 | // $double = $this->sc->getSmartyDoubleVar($tableSoleName, 'id'); |
||
| 178 | // $src = $this->sc->getSmartyNoSimbol('xoModuleIcons32 delete.png'); |
||
| 179 | // $img = $this->hc->getHtmlTag('img', ['src' => $src . $double, 'alt' => $tableName], '', true, '', ''); |
||
| 180 | // $anchor .= $this->hc->getHtmlTag('a', ['href' => $tableName . ".php?op=delete&{$fieldId}=" . $double, 'title' => $lang], $img, false, "\t\t\t\t"); |
||
| 181 | // $td .= $this->hc->getHtmlTag('td', ['class' => 'center'], "\n" . $anchor . "\t\t\t", false, "\t\t\t"); |
||
| 182 | $double = $this->sc->getSmartyDoubleVar($tableSoleName, 'id'); |
||
| 183 | $lang = $this->sc->getSmartyConst($language, $stuTableSoleName . '_GOTO'); |
||
| 184 | $anchor = $this->hc->getHtmlAnchor($tableName . ".php?op=show&{$fieldId}=" . $double, $lang, $lang); |
||
| 185 | $td .= $this->hc->getHtmlTableData($anchor, 'center', '', "\t\t\t"); |
||
| 186 | $cycle = $this->sc->getSmartyNoSimbol('cycle values="odd, even"'); |
||
| 187 | $tr = $this->hc->getHtmlTableRow($td, $cycle, "\t\t"); |
||
| 188 | $foreach = $this->sc->getSmartyForeach($tableSoleName, 'block', $tr, '','', "\t\t"); |
||
| 189 | $tbody = $this->hc->getHtmlTableTbody($foreach,'' , "\t"); |
||
| 190 | |||
| 191 | return $this->sc->getSmartyConditions("block", '', '', $tbody, false, true, true, "\t"); |
||
| 192 | } |
||
| 252 |