| Conditions | 13 |
| Paths | 42 |
| Total Lines | 86 |
| Code Lines | 74 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 1 |
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 |
||
| 144 | private function getTemplatesAdminPagesTableTBody($moduleDirname, $tableName, $tableSoleName, $tableAutoincrement, $fields) |
||
| 145 | { |
||
| 146 | $td = ''; |
||
| 147 | if (1 == $tableAutoincrement) { |
||
| 148 | $double = $this->sc->getSmartyDoubleVar($tableSoleName, 'id'); |
||
| 149 | $td .= $this->hc->getHtmlTableData($double, 'center', '',"\t\t\t\t"); |
||
| 150 | } |
||
| 151 | $fieldId = ''; |
||
| 152 | foreach (\array_keys($fields) as $f) { |
||
| 153 | $fieldName = $fields[$f]->getVar('field_name'); |
||
| 154 | $fieldElement = $fields[$f]->getVar('field_element'); |
||
| 155 | $rpFieldName = $this->getRightString($fieldName); |
||
| 156 | if (0 == $f) { |
||
| 157 | $fieldId = $fieldName; |
||
| 158 | } |
||
| 159 | if (1 == $fields[$f]->getVar('field_inlist')) { |
||
| 160 | switch ($fieldElement) { |
||
| 161 | case Constants::FIELD_ELE_TEXTAREA: |
||
| 162 | case Constants::FIELD_ELE_DHTMLTEXTAREA: |
||
| 163 | $double = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName . '_short'); |
||
| 164 | $td .= $this->hc->getHtmlTableData($double, 'center', '',"\t\t\t\t"); |
||
| 165 | break; |
||
| 166 | case Constants::FIELD_ELE_CHECKBOX: |
||
| 167 | $double = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
||
| 168 | $src = $this->sc->getSmartyNoSimbol('xoModuleIcons16') . $double . '.png'; |
||
| 169 | $img = $this->hc->getHtmlTag('img', ['src' => $src, 'alt' => $tableName], '', true,'',''); |
||
| 170 | $td .= $this->hc->getHtmlTableData($img, 'center', '',"\t\t\t\t"); |
||
| 171 | break; |
||
| 172 | case Constants::FIELD_ELE_COLORPICKER: |
||
| 173 | // This is to be reviewed, as it was initially to style = "backgroung-color: #" |
||
| 174 | // Now with HTML5 is not supported inline style in the parameters of the HTML tag |
||
| 175 | // Old code was <span style="background-color: #<{\$list.{$rpFieldName}}>;">... |
||
| 176 | $double = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
||
| 177 | $color = "<span style='background-color:{$double};'> </span>"; |
||
| 178 | $td .= $this->hc->getHtmlTableData($color, 'center', '',"\t\t\t\t"); |
||
| 179 | break; |
||
| 180 | case Constants::FIELD_ELE_IMAGELIST: |
||
| 181 | $src = $this->sc->getSmartyNoSimbol('xoModuleIcons32'); |
||
| 182 | $src .= $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
||
| 183 | $img = $this->hc->getHtmlTag('img', ['src' => $src, 'alt' => $tableName], '', true,'',''); |
||
| 184 | $td .= $this->hc->getHtmlTableData($img, 'center', '',"\t\t\t\t"); |
||
| 185 | break; |
||
| 186 | case Constants::FIELD_ELE_UPLOADIMAGE: |
||
| 187 | $single = $this->sc->getSmartySingleVar($moduleDirname . '_upload_url'); |
||
| 188 | $double = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
||
| 189 | $img = $this->hc->getHtmlTag('img', ['src' => $single . "/images/{$tableName}/" . $double, 'alt' => $tableName, 'style' => 'max-width:100px'], '', true, '', ''); |
||
| 190 | $td .= $this->hc->getHtmlTableData($img, 'center', '',"\t\t\t\t"); |
||
| 191 | break; |
||
| 192 | case Constants::FIELD_ELE_SELECTSTATUS: |
||
| 193 | $double = $this->sc->getSmartyDoubleVar($tableSoleName, 'status'); |
||
| 194 | $src = $this->sc->getSmartyNoSimbol('$modPathIcon16') . 'status' . $double . '.png'; |
||
| 195 | $imgAlt = $this->sc->getSmartyDoubleVar($tableSoleName, 'status_text'); |
||
| 196 | $img = $this->hc->getHtmlTag('img', ['src' => $src, 'alt' => $imgAlt, 'title' => $imgAlt], '', true,'',''); |
||
| 197 | $td .= $this->hc->getHtmlTableData($img, 'center', '',"\t\t\t\t"); |
||
| 198 | break; |
||
| 199 | default: |
||
| 200 | if (0 != $f) { |
||
| 201 | $double = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
||
| 202 | $td .= $this->hc->getHtmlTableData($double, 'center', '',"\t\t\t\t"); |
||
| 203 | } |
||
| 204 | break; |
||
| 205 | } |
||
| 206 | } |
||
| 207 | } |
||
| 208 | $lang = $this->sc->getSmartyConst('', '_EDIT'); |
||
| 209 | $double = $this->sc->getSmartyDoubleVar($tableSoleName, 'id'); |
||
| 210 | $src = $this->sc->getSmartyNoSimbol('xoModuleIcons16 edit.png'); |
||
| 211 | $img = $this->hc->getHtmlTag('img', ['src' => $src, 'alt' => $lang . ' ' . $tableName], '', true,'', ''); |
||
| 212 | $anchor = $this->hc->getHtmlTag('a', ['href' => $tableName . ".php?op=edit&{$fieldId}=" . $double . '&start=<{$start}>&limit=<{$limit}>', 'title' => $lang], $img, false, "\t\t\t\t\t"); |
||
| 213 | $lang = $this->sc->getSmartyConst('', '_CLONE'); |
||
| 214 | $double = $this->sc->getSmartyDoubleVar($tableSoleName, 'id'); |
||
| 215 | $src = $this->sc->getSmartyNoSimbol('xoModuleIcons16 editcopy.png'); |
||
| 216 | $img = $this->hc->getHtmlTag('img', ['src' => $src, 'alt' => $lang . ' ' . $tableName], '', true,'', ''); |
||
| 217 | $anchor .= $this->hc->getHtmlTag('a', ['href' => $tableName . ".php?op=clone&{$fieldId}_source=" . $double, 'title' => $lang], $img, false, "\t\t\t\t\t"); |
||
| 218 | $lang = $this->sc->getSmartyConst('', '_DELETE'); |
||
| 219 | $double = $this->sc->getSmartyDoubleVar($tableSoleName, 'id'); |
||
| 220 | $src = $this->sc->getSmartyNoSimbol('xoModuleIcons16 delete.png'); |
||
| 221 | $img = $this->hc->getHtmlTag('img', ['src' => $src, 'alt' => $lang . ' ' . $tableName], '', true, '', ''); |
||
| 222 | $anchor .= $this->hc->getHtmlTag('a', ['href' => $tableName . ".php?op=delete&{$fieldId}=" . $double, 'title' => $lang], $img, false, "\t\t\t\t\t"); |
||
| 223 | $td .= $this->hc->getHtmlTag('td', ['class' => 'center width5'], "\n" . $anchor . "\t\t\t\t", false, "\t\t\t\t"); |
||
| 224 | $cycle = $this->sc->getSmartyNoSimbol('cycle values=\'odd, even\''); |
||
| 225 | $tr = $this->hc->getHtmlTableRow($td, $cycle, "\t\t\t"); |
||
| 226 | $foreach = $this->sc->getSmartyForeach($tableSoleName, $tableName . '_list', $tr, '','', "\t\t\t"); |
||
| 227 | $tbody = $this->hc->getHtmlTableTbody($foreach,'' , "\t\t"); |
||
| 228 | |||
| 229 | return $this->sc->getSmartyConditions($tableName . '_count', '', '', $tbody, '', false, false, "\t\t"); |
||
| 230 | } |
||
| 315 |