| Conditions | 17 |
| Paths | 585 |
| Total Lines | 149 |
| Code Lines | 91 |
| 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 |
||
| 136 | public function renderL10nTable(&$tree) { |
||
| 137 | // Title length: |
||
| 138 | $titleLen = $GLOBALS['BE_USER']->uc['titleLen']; |
||
| 139 | |||
| 140 | // Put together the tree: |
||
| 141 | $output = ''; |
||
| 142 | $newOL_js = array(); |
||
| 143 | $langRecUids = array(); |
||
| 144 | |||
| 145 | // Init DAO |
||
| 146 | $dao = GeneralUtility::makeInstance('AOE\\Languagevisibility\\Dao\DaoCommon'); |
||
| 147 | $elementfactory = GeneralUtility::makeInstance('AOE\\Languagevisibility\\ElementFactory', $dao); |
||
| 148 | $languageRep = GeneralUtility::makeInstance('AOE\\Languagevisibility\\LanguageRepository'); |
||
| 149 | $languageList = $languageRep->getLanguages(); |
||
| 150 | $visibility = GeneralUtility::makeInstance('AOE\\Languagevisibility\\Services\\VisibilityService'); |
||
| 151 | |||
| 152 | //traverse tree: |
||
| 153 | foreach ( $tree->tree as $data ) { |
||
| 154 | $tCells = array(); |
||
| 155 | |||
| 156 | $element = $elementfactory->getElementForTable('pages', $data['row']['uid']); |
||
| 157 | |||
| 158 | // first cell (tree): |
||
| 159 | // Page icons / titles etc. |
||
| 160 | $tCells[] = '<td' . ($data['row']['_CSSCLASS'] ? ' class="' . $data['row']['_CSSCLASS'] . '"' : '') . '>' . $data['HTML'] . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($data['row']['title'], $titleLen)) . (strcmp($data['row']['nav_title'], '') ? ' [Nav: <em>' . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($data['row']['nav_title'], $titleLen)) . '</em>]' : '') . '</td>'; |
||
| 161 | // language cells: |
||
| 162 | foreach ( $languageList as $language ) { |
||
| 163 | $info = ''; |
||
| 164 | $editUid = $data['row']['uid']; |
||
| 165 | $params = '&edit[pages][' . $editUid . ']=edit'; |
||
| 166 | $langId = $language->getUid(); |
||
| 167 | if ($visibility->isVisible($language, $element)) { |
||
| 168 | $isVisible = TRUE; |
||
| 169 | $statusVis = 'c-visible'; |
||
| 170 | } else { |
||
| 171 | $isVisible = FALSE; |
||
| 172 | $statusVis = 'c-notvisible'; |
||
| 173 | } |
||
| 174 | if ($element->hasTranslation($langId)) { |
||
| 175 | $statusTrans = 'c-translated'; |
||
| 176 | } else { |
||
| 177 | $statusTrans = 'c-nottranslated'; |
||
| 178 | } |
||
| 179 | |||
| 180 | if ($language->getUid() == 0) { |
||
| 181 | // Default |
||
| 182 | // "View page" link is created: |
||
| 183 | $viewPageLink = '<a href="#" onclick="' . htmlspecialchars(BackendUtility::viewOnClick($data['row']['uid'], $GLOBALS['BACK_PATH'], '', '', '', '&L=###LANG_UID###')) . '">' . '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/zoom.gif', 'width="12" height="12"') . ' title="' . $GLOBALS['LANG']->getLL('lang_renderl10n_viewPage', '1') . '" border="0" alt="" />' . '</a>'; |
||
|
|
|||
| 184 | $info .= '<a href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick($params, $GLOBALS['BACK_PATH'])) . '">' . '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/edit2.gif', 'width="11" height="12"') . ' title="' . $GLOBALS['LANG']->getLL('lang_renderl10n_editDefaultLanguagePage', '1') . '" border="0" alt="" />' . '</a>'; |
||
| 185 | $info .= '<a href="#" onclick="' . htmlspecialchars('top.loadEditId(' . intval($data['row']['uid']) . ',"&SET[language]=0"); return FALSE;') . '">' . '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/edit_page.gif', 'width="12" height="12"') . ' title="' . $GLOBALS['LANG']->getLL('lang_renderl10n_editPage', '1') . '" border="0" alt="" />' . '</a>'; |
||
| 186 | $info .= str_replace('###LANG_UID###', '0', $viewPageLink); |
||
| 187 | $info .= $data['row']['l18n_cfg'] & 1 ? '<span title="' . $GLOBALS['LANG']->sL('LLL:EXT:cms/locallang_tca.php:pages.l18n_cfg.I.1', '1') . '">D</span>' : ' '; |
||
| 188 | // Put into cell: |
||
| 189 | $tCells[] = '<td class="' . $statusTrans . ' c-leftLine">' . $info . '</td>'; |
||
| 190 | $tCells[] = '<td class="' . $statusTrans . '" title="' . $GLOBALS['LANG']->getLL('lang_renderl10n_CEcount', '1') . '" align="center">' . $this->getContentElementCount($data['row']['uid'], 0) . '</td>'; |
||
| 191 | |||
| 192 | } else { |
||
| 193 | // Normal Language: |
||
| 194 | if ($element->hasTranslation($langId)) { |
||
| 195 | $viewPageLink = '<a href="#" onclick="' . htmlspecialchars(BackendUtility::viewOnClick($data['row']['uid'], $GLOBALS['BACK_PATH'], '', '', '', '&L=###LANG_UID###')) . '">' . '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/zoom.gif', 'width="12" height="12"') . ' title="' . $GLOBALS['LANG']->getLL('lang_renderl10n_viewPage', '1') . '" border="0" alt="" />' . '</a>'; |
||
| 196 | |||
| 197 | $overLayRow = $element->getOverLayRecordForCertainLanguage($langId); |
||
| 198 | // add uid of overlay to list of editable records: |
||
| 199 | $langRecUids[$langId][] = $overLayRow['uid']; |
||
| 200 | $icon = IconUtility::getIconImage('pages_language_overlay', $overLayRow, $GLOBALS['BACK_PATH'], 'align="top" class="c-recIcon"'); |
||
| 201 | |||
| 202 | $info = $icon . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($overLayRow['title'], $titleLen)) . (strcmp($overLayRow['nav_title'], '') ? ' [Nav: <em>' . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($overLayRow['nav_title'], $titleLen)) . '</em>]' : '') . ($overLayRow['_COUNT'] > 1 ? '<div>' . $GLOBALS['LANG']->getLL('lang_renderl10n_badThingThereAre', '1') . '</div>' : ''); |
||
| 203 | $tCells[] = '<td class="' . $statusTrans . ' c-leftLine">' . $info . '</td>'; |
||
| 204 | |||
| 205 | // Edit whole record: |
||
| 206 | $info = ''; |
||
| 207 | $editUid = $overLayRow['uid']; |
||
| 208 | $params = '&edit[pages_language_overlay][' . $editUid . ']=edit'; |
||
| 209 | $info .= '<a href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick($params, $GLOBALS['BACK_PATH'])) . '">' . '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/edit2.gif', 'width="11" height="12"') . ' title="' . $GLOBALS['LANG']->getLL('lang_renderl10n_editLanguageOverlayRecord', '1') . '" border="0" alt="" />' . '</a>'; |
||
| 210 | |||
| 211 | $info .= '<a href="#" onclick="' . htmlspecialchars('top.loadEditId(' . intval($data['row']['uid']) . ',"&SET[language]=' . $langId . '"); return FALSE;') . '">' . '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/edit_page.gif', 'width="12" height="12"') . ' title="' . $GLOBALS['LANG']->getLL('lang_renderl10n_editPageLang', '1') . '" border="0" alt="" />' . '</a>'; |
||
| 212 | $info .= str_replace('###LANG_UID###', $langId, $viewPageLink); |
||
| 213 | |||
| 214 | $tCells[] = '<td class="' . $statusTrans . '">' . $info . '</td>'; |
||
| 215 | $tCells[] = '<td class="' . $statusTrans . '" title="' . $GLOBALS['LANG']->getLL('lang_renderl10n_CEcount', '1') . '" align="center">' . $this->getContentElementCount($data['row']['uid'], $langId) . '</td>'; |
||
| 216 | } else { |
||
| 217 | $tCells[] = '<td class="' . $statusTrans . ' c-leftLine"> </td>'; |
||
| 218 | $tCells[] = '<td class="' . $statusTrans . '"> </td>'; |
||
| 219 | //add to JS |
||
| 220 | $infoCell = '<input type="checkbox" name="newOL[' . $langId . '][' . $data['row']['uid'] . ']" value="1" />'; |
||
| 221 | $newOL_js[$langId] .= ' |
||
| 222 | +(document.webinfoForm[\'newOL[' . $langId . '][' . $data['row']['uid'] . ']\'].checked ? \'&edit[pages_language_overlay][' . $data['row']['uid'] . ']=new\' : \'\') |
||
| 223 | '; |
||
| 224 | $tCells[] = '<td class="' . $statusTrans . '">' . $infoCell . '</td>'; |
||
| 225 | |||
| 226 | } |
||
| 227 | } |
||
| 228 | //last cell show status |
||
| 229 | $tCells[] = '<td class="' . $statusVis . '">' . $this->_getStatusImage($isVisible) . '</td>'; |
||
| 230 | } |
||
| 231 | $output .= ' |
||
| 232 | <tr class="bgColor5"> |
||
| 233 | ' . implode(' |
||
| 234 | ', $tCells) . ' |
||
| 235 | </tr>'; |
||
| 236 | } |
||
| 237 | |||
| 238 | // first ROW: |
||
| 239 | $firstRowCells = array(); |
||
| 240 | $firstRowCells[] = '<td>' . $GLOBALS['LANG']->getLL('lang_renderl10n_page', '1') . ':</td>'; |
||
| 241 | foreach ( $languageList as $language ) { |
||
| 242 | $langId = $language->getUid(); |
||
| 243 | if ($this->pObj->MOD_SETTINGS['lang'] == 0 || ( int ) $this->pObj->MOD_SETTINGS['lang'] === ( int ) $langId) { |
||
| 244 | $firstRowCells[] = '<td class="c-leftLine">' . $language->getTitle() . $language->getFlagImg() . '</td>'; |
||
| 245 | if ($langId == 0) { |
||
| 246 | $firstRowCells[] = '<td></td>'; |
||
| 247 | $firstRowCells[] = '<td></td>'; |
||
| 248 | } else { |
||
| 249 | // Title: |
||
| 250 | |||
| 251 | |||
| 252 | // Edit language overlay records: |
||
| 253 | if (is_array($langRecUids[$langId])) { |
||
| 254 | $params = '&edit[pages_language_overlay][' . implode(',', $langRecUids[$langId]) . ']=edit&columnsOnly=title,nav_title,hidden'; |
||
| 255 | $firstRowCells[] = '<td><a href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick($params, $GLOBALS['BACK_PATH'])) . '"> |
||
| 256 | <img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/edit2.gif', 'width="11" height="12"') . ' title="' . $GLOBALS['LANG']->getLL('lang_renderl10n_editLangOverlays', '1') . '" border="0" alt="" /> |
||
| 257 | </a></td>'; |
||
| 258 | } else { |
||
| 259 | $firstRowCells[] = '<td> </td>'; |
||
| 260 | } |
||
| 261 | |||
| 262 | // Create new overlay records: |
||
| 263 | $params = "'" . $newOL_js[$langId] . "+'&columnsOnly=title,hidden,sys_language_uid&defVals[pages_language_overlay][sys_language_uid]=" . $langId; |
||
| 264 | $firstRowCells[] = '<td><a href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick($params, $GLOBALS['BACK_PATH'])) . '"> |
||
| 265 | <img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/new_el.gif', 'width="11" height="12"') . ' title="' . $GLOBALS['LANG']->getLL('lang_getlangsta_createNewTranslationHeaders', '1') . '" border="0" alt="" /> |
||
| 266 | </a></td>'; |
||
| 267 | $firstRowCells[] = '<td></td>'; |
||
| 268 | } |
||
| 269 | } |
||
| 270 | } |
||
| 271 | |||
| 272 | $output = ' |
||
| 273 | <tr class="bgColor4"> |
||
| 274 | ' . implode(' |
||
| 275 | ', $firstRowCells) . ' |
||
| 276 | </tr>' . $output; |
||
| 277 | |||
| 278 | $output = ' |
||
| 279 | |||
| 280 | <table border="0" cellspacing="0" cellpadding="0" id="langTable">' . $output . ' |
||
| 281 | </table>'; |
||
| 282 | |||
| 283 | return $output; |
||
| 284 | } |
||
| 285 | |||
| 314 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: