| Conditions | 9 |
| Paths | 26 |
| Total Lines | 66 |
| Code Lines | 51 |
| 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 namespace XoopsModules\Tdmcreate\Files\Templates\Admin; |
||
| 129 | private function getTemplatesAdminPagesTableTBody($moduleDirname, $tableName, $tableSoleName, $tableAutoincrement, $fields) |
||
| 130 | { |
||
| 131 | $hc = Tdmcreate\Files\CreateHtmlSmartyCodes::getInstance(); |
||
| 132 | $td = ''; |
||
| 133 | if (1 == $tableAutoincrement) { |
||
| 134 | $double = $hc->getSmartyDoubleVar($tableSoleName, 'id'); |
||
| 135 | $td .= $hc->getHtmlTableData($double, 'center'); |
||
| 136 | } |
||
| 137 | foreach (array_keys($fields) as $f) { |
||
| 138 | $fieldName = $fields[$f]->getVar('field_name'); |
||
| 139 | $fieldElement = $fields[$f]->getVar('field_element'); |
||
| 140 | $rpFieldName = $this->getRightString($fieldName); |
||
| 141 | if (0 == $f) { |
||
| 142 | $fieldId = $fieldName; |
||
| 143 | } |
||
| 144 | if (1 == $fields[$f]->getVar('field_inlist')) { |
||
| 145 | switch ($fieldElement) { |
||
| 146 | case 9: |
||
| 147 | // This is to be reviewed, as it was initially to style = "backgroung-color: #" |
||
| 148 | // Now with HTML5 is not supported inline style in the parameters of the HTML tag |
||
| 149 | // Old code was <span style="background-color: #<{\$list.{$rpFieldName}}>;">... |
||
| 150 | $double = $hc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
||
| 151 | $span = $hc->getHtmlTag('span', [], $double); |
||
| 152 | $td .= $hc->getHtmlTag('td', ['class' => 'center'], $span); |
||
| 153 | /*$ret .= <<<EOT |
||
| 154 | <td class="center"><span style="background-color: #<{\$list.{$rpFieldName}}>;"> </span></td>\n |
||
| 155 | EOT;*/ |
||
| 156 | break; |
||
| 157 | case 10: |
||
| 158 | $src = $hc->getSmartyNoSimbol('xoModuleIcons32'); |
||
| 159 | $src .= $hc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
||
| 160 | $img = $hc->getHtmlTag('img', ['src' => $src, 'alt' => $tableName], '', true, false); |
||
| 161 | $td .= $hc->getHtmlTag('td', ['class' => 'center'], "\n\t" . $img); |
||
| 162 | break; |
||
| 163 | case 13: |
||
| 164 | $single = $hc->getSmartySingleVar($moduleDirname . '_upload_url'); |
||
| 165 | $double = $hc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
||
| 166 | $img = $hc->getHtmlTag('img', ['src' => $single . "/images/{$tableName}/" . $double, 'alt' => $tableName, 'style' => 'max-width:100px'], '', true, false); |
||
| 167 | $td .= $hc->getHtmlTag('td', ['class' => 'center'], $img, false, false, "\t\t"); |
||
| 168 | break; |
||
| 169 | default: |
||
| 170 | if (0 != $f) { |
||
| 171 | $double = $hc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
||
| 172 | $td .= $hc->getHtmlTag('td', ['class' => 'center'], $double); |
||
| 173 | } |
||
| 174 | break; |
||
| 175 | } |
||
| 176 | } |
||
| 177 | } |
||
| 178 | $lang = $hc->getSmartyConst('', '_EDIT'); |
||
| 179 | $double = $hc->getSmartyDoubleVar($tableSoleName, 'id'); |
||
| 180 | $src = $hc->getSmartyNoSimbol('xoModuleIcons16 edit.png'); |
||
| 181 | $img = $hc->getHtmlTag('img', ['src' => $src, 'alt' => $tableName], '', true, false); |
||
| 182 | $anchor = $hc->getHtmlTag('a', ['href' => $tableName . ".php?op=edit&{$fieldId}=" . $double, 'title' => $lang], "\n\t" . $img); |
||
| 183 | $lang = $hc->getSmartyConst('', '_DELETE'); |
||
| 184 | $double = $hc->getSmartyDoubleVar($tableSoleName, 'id'); |
||
| 185 | $src = $hc->getSmartyNoSimbol('xoModuleIcons16 delete.png'); |
||
| 186 | $img = $hc->getHtmlTag('img', ['src' => $src, 'alt' => $tableName], '', true, false); |
||
| 187 | $anchor .= $hc->getHtmlTag('a', ['href' => $tableName . ".php?op=delete&{$fieldId}=" . $double, 'title' => $lang], "\n\t" . $img); |
||
| 188 | $td .= $hc->getHtmlTag('td', ['class' => 'center width5'], "\n" . $anchor); |
||
| 189 | $cycle = $hc->getSmartyNoSimbol('cycle values=\'odd, even\''); |
||
| 190 | $tr = $hc->getHtmlTag('tr', ['class' => $cycle], $td); |
||
| 191 | $foreach = $hc->getSmartyForeach($tableSoleName, $tableName . '_list', $tr); |
||
| 192 | $tbody = $hc->getHtmlTag('tbody', [], $foreach); |
||
| 193 | |||
| 194 | return $hc->getSmartyConditions($tableName . '_count', '', '', $tbody); |
||
| 195 | } |
||
| 285 |