| Conditions | 26 |
| Paths | > 20000 |
| Total Lines | 212 |
| Code Lines | 164 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| 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 |
||
| 166 | protected function renderL10nTable(PageTreeView $tree, ServerRequestInterface $request) |
||
| 167 | { |
||
| 168 | $lang = $this->getLanguageService(); |
||
| 169 | // Title length: |
||
| 170 | $titleLen = $this->getBackendUser()->uc['titleLen']; |
||
| 171 | // Put together the TREE: |
||
| 172 | $output = ''; |
||
| 173 | $newOL_js = []; |
||
| 174 | $langRecUids = []; |
||
| 175 | |||
| 176 | $userTsConfig = $this->getBackendUser()->getTSConfig(); |
||
| 177 | $showPageId = !empty($userTsConfig['options.']['pageTree.']['showPageIdWithTitle']); |
||
| 178 | |||
| 179 | foreach ($tree->tree as $data) { |
||
| 180 | $tCells = []; |
||
| 181 | $langRecUids[0][] = $data['row']['uid']; |
||
| 182 | $pageTitle = ($showPageId ? '[' . (int)$data['row']['uid'] . '] ' : '') . GeneralUtility::fixed_lgd_cs($data['row']['title'], $titleLen); |
||
| 183 | // Page icons / titles etc. |
||
| 184 | $tCells[] = '<td' . ($data['row']['_CSSCLASS'] ? ' class="' . $data['row']['_CSSCLASS'] . '"' : '') . '>' . |
||
| 185 | ($data['depthData'] ?: '') . |
||
| 186 | BackendUtility::wrapClickMenuOnIcon($data['HTML'], 'pages', $data['row']['uid']) . |
||
| 187 | '<a href="#" onclick="' . htmlspecialchars( |
||
| 188 | 'top.loadEditId(' . (int)$data['row']['uid'] . ',"&SET[language]=0"); return false;' |
||
| 189 | ) . '" title="' . $lang->sL('LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:lang_renderl10n_editPage') . '">' . |
||
| 190 | htmlspecialchars($pageTitle) . |
||
| 191 | '</a>' . |
||
| 192 | ((string)$data['row']['nav_title'] !== '' ? ' [Nav: <em>' . htmlspecialchars(GeneralUtility::fixed_lgd_cs($data['row']['nav_title'], $titleLen)) . '</em>]' : '') . |
||
| 193 | '</td>'; |
||
| 194 | $previewUriBuilder = PreviewUriBuilder::create((int)$data['row']['uid']); |
||
| 195 | // DEFAULT language: |
||
| 196 | // "View page" link is created: |
||
| 197 | $viewPageLink = '<a href="#" ' . $previewUriBuilder |
||
| 198 | ->withAdditionalQueryParameters('&L=###LANG_UID###') |
||
| 199 | ->serializeDispatcherAttributes() |
||
| 200 | . ' class="btn btn-default" title="' . $lang->sL('LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:lang_renderl10n_viewPage') . '">' . |
||
| 201 | $this->iconFactory->getIcon('actions-view', Icon::SIZE_SMALL)->render() . '</a>'; |
||
| 202 | $pageTranslationVisibility = new PageTranslationVisibility((int)($data['row']['l18n_cfg'] ?? 0)); |
||
| 203 | $status = $pageTranslationVisibility->shouldBeHiddenInDefaultLanguage() ? 'danger' : 'success'; |
||
| 204 | // Create links: |
||
| 205 | $editUrl = (string)$this->uriBuilder->buildUriFromRoute('record_edit', [ |
||
| 206 | 'edit' => [ |
||
| 207 | 'pages' => [ |
||
| 208 | $data['row']['uid'] => 'edit' |
||
| 209 | ] |
||
| 210 | ], |
||
| 211 | 'returnUrl' => $request->getAttribute('normalizedParams')->getRequestUri() |
||
| 212 | ]); |
||
| 213 | $info = '<a href="#" ' . $previewUriBuilder->serializeDispatcherAttributes() |
||
| 214 | . ' class="btn btn-default" title="' . $lang->sL('LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:lang_renderl10n_viewPage') . '">' . |
||
| 215 | $this->iconFactory->getIcon('actions-view-page', Icon::SIZE_SMALL)->render() . '</a>'; |
||
| 216 | $info .= '<a href="' . htmlspecialchars($editUrl) |
||
| 217 | . '" class="btn btn-default" title="' . $lang->sL( |
||
| 218 | 'LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:lang_renderl10n_editDefaultLanguagePage' |
||
| 219 | ) . '">' . $this->iconFactory->getIcon('actions-page-open', Icon::SIZE_SMALL)->render() . '</a>'; |
||
| 220 | $info .= ' '; |
||
| 221 | $info .= $pageTranslationVisibility->shouldBeHiddenInDefaultLanguage() ? '<span title="' . htmlspecialchars($lang->sL('LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.l18n_cfg.I.1')) . '">D</span>' : ' '; |
||
| 222 | $info .= $pageTranslationVisibility->shouldHideTranslationIfNoTranslatedRecordExists() ? '<span title="' . htmlspecialchars($lang->sL('LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.l18n_cfg.I.2')) . '">N</span>' : ' '; |
||
| 223 | // Put into cell: |
||
| 224 | $tCells[] = '<td class="' . $status . ' col-border-left"><div class="btn-group">' . $info . '</div></td>'; |
||
| 225 | $tCells[] = '<td class="' . $status . '" title="' . $lang->sL( |
||
| 226 | 'LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:lang_renderl10n_CEcount' |
||
| 227 | ) . '" align="center">' . $this->getContentElementCount($data['row']['uid'], 0) . '</td>'; |
||
| 228 | // Traverse system languages: |
||
| 229 | foreach ($this->siteLanguages as $siteLanguage) { |
||
| 230 | $languageId = $siteLanguage->getLanguageId(); |
||
| 231 | if ($languageId === 0) { |
||
| 232 | continue; |
||
| 233 | } |
||
| 234 | if ($this->pObj->MOD_SETTINGS['lang'] == 0 || (int)$this->pObj->MOD_SETTINGS['lang'] === $languageId) { |
||
| 235 | $row = $this->getLangStatus($data['row']['uid'], $languageId); |
||
| 236 | if ($pageTranslationVisibility->shouldBeHiddenInDefaultLanguage() || $pageTranslationVisibility->shouldHideTranslationIfNoTranslatedRecordExists()) { |
||
| 237 | $status = 'danger'; |
||
| 238 | } else { |
||
| 239 | $status = ''; |
||
| 240 | } |
||
| 241 | if (is_array($row)) { |
||
| 242 | $langRecUids[$languageId][] = $row['uid']; |
||
| 243 | if (!$row['_HIDDEN']) { |
||
| 244 | $status = 'success'; |
||
| 245 | } |
||
| 246 | $info = ($showPageId ? ' [' . (int)$row['uid'] . ']' : '') . ' ' . htmlspecialchars( |
||
| 247 | GeneralUtility::fixed_lgd_cs($row['title'], $titleLen) |
||
| 248 | ) . ((string)$row['nav_title'] !== '' ? ' [Nav: <em>' . htmlspecialchars( |
||
| 249 | GeneralUtility::fixed_lgd_cs($row['nav_title'], $titleLen) |
||
| 250 | ) . '</em>]' : '') . ($row['_COUNT'] > 1 ? '<div>' . $lang->sL( |
||
| 251 | 'LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:lang_renderl10n_badThingThereAre' |
||
| 252 | ) . '</div>' : ''); |
||
| 253 | $tCells[] = '<td class="' . $status . ' col-border-left">' . |
||
| 254 | BackendUtility::wrapClickMenuOnIcon($tree->getIcon($row), 'pages', (int)$row['uid']) . |
||
| 255 | '<a href="#" onclick="' . htmlspecialchars( |
||
| 256 | 'top.loadEditId(' . (int)$data['row']['uid'] . ',"&SET[language]=' . $languageId . '"); return false;' |
||
| 257 | ) . '" title="' . $lang->sL( |
||
| 258 | 'LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:lang_renderl10n_editPageLang' |
||
| 259 | ) . '">' . $info . '</a></td>'; |
||
| 260 | // Edit whole record: |
||
| 261 | // Create links: |
||
| 262 | $editUrl = (string)$this->uriBuilder->buildUriFromRoute('record_edit', [ |
||
| 263 | 'edit' => [ |
||
| 264 | 'pages' => [ |
||
| 265 | $row['uid'] => 'edit' |
||
| 266 | ] |
||
| 267 | ], |
||
| 268 | 'returnUrl' => $request->getAttribute('normalizedParams')->getRequestUri() |
||
| 269 | ]); |
||
| 270 | $info = str_replace('###LANG_UID###', (string)$languageId, $viewPageLink); |
||
| 271 | $info .= '<a href="' . htmlspecialchars($editUrl) |
||
| 272 | . '" class="btn btn-default" title="' . $lang->sL( |
||
| 273 | 'LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:lang_renderl10n_editLanguageOverlayRecord' |
||
| 274 | ) . '">' . $this->iconFactory->getIcon('actions-open', Icon::SIZE_SMALL)->render() . '</a>'; |
||
| 275 | $tCells[] = '<td class="' . $status . '"><div class="btn-group">' . $info . '</div></td>'; |
||
| 276 | $tCells[] = '<td class="' . $status . '" title="' . $lang->sL( |
||
| 277 | 'LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:lang_renderl10n_CEcount' |
||
| 278 | ) . '" align="center">' . $this->getContentElementCount($data['row']['uid'], $languageId) . '</td>'; |
||
| 279 | } else { |
||
| 280 | $info = '<div class="btn-group"><label class="btn btn-default btn-checkbox">'; |
||
| 281 | $info .= '<input type="checkbox" data-lang="' . $languageId . '" data-uid="' . (int)$data['row']['uid'] . '" name="newOL[' . $languageId . '][' . $data['row']['uid'] . ']" value="1" />'; |
||
| 282 | $info .= '<span class="t3-icon fa"></span></label></div>'; |
||
| 283 | $newOL_js[$languageId] .= |
||
| 284 | ' +(document.webinfoForm[' |
||
| 285 | . GeneralUtility::quoteJSvalue('newOL[' . $languageId . '][' . $data['row']['uid'] . ']') |
||
| 286 | . '].checked ? ' |
||
| 287 | . GeneralUtility::quoteJSvalue('&edit[pages][' . $data['row']['uid'] . ']=new') |
||
| 288 | . ' : \'\')' |
||
| 289 | ; |
||
| 290 | $tCells[] = '<td class="' . $status . ' col-border-left"> </td>'; |
||
| 291 | $tCells[] = '<td class="' . $status . '"> </td>'; |
||
| 292 | $tCells[] = '<td class="' . $status . '">' . $info . '</td>'; |
||
| 293 | } |
||
| 294 | } |
||
| 295 | } |
||
| 296 | $output .= ' |
||
| 297 | <tr> |
||
| 298 | ' . implode(' |
||
| 299 | ', $tCells) . ' |
||
| 300 | </tr>'; |
||
| 301 | } |
||
| 302 | // Put together HEADER: |
||
| 303 | $headerCells = []; |
||
| 304 | $headerCells[] = '<th>' . $lang->sL('LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:lang_renderl10n_page') . '</th>'; |
||
| 305 | if (is_array($langRecUids[0])) { |
||
| 306 | $editUrl = (string)$this->uriBuilder->buildUriFromRoute('record_edit', [ |
||
| 307 | 'edit' => [ |
||
| 308 | 'pages' => [ |
||
| 309 | implode(',', $langRecUids[0]) => 'edit' |
||
| 310 | ] |
||
| 311 | ], |
||
| 312 | 'columnsOnly' => 'title,nav_title,l18n_cfg,hidden', |
||
| 313 | 'returnUrl' => $request->getAttribute('normalizedParams')->getRequestUri() |
||
| 314 | ]); |
||
| 315 | $editIco = '<a href="' . htmlspecialchars($editUrl) |
||
| 316 | . '" class="btn btn-default" title="' . $lang->sL( |
||
| 317 | 'LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:lang_renderl10n_editPageProperties' |
||
| 318 | ) . '">' . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '</a>'; |
||
| 319 | } else { |
||
| 320 | $editIco = ''; |
||
| 321 | } |
||
| 322 | $headerCells[] = '<th class="col-border-left" colspan="2">' . $lang->sL( |
||
| 323 | 'LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:lang_renderl10n_default' |
||
| 324 | ) . ' ' . $editIco . '</th>'; |
||
| 325 | foreach ($this->siteLanguages as $siteLanguage) { |
||
| 326 | $languageId = $siteLanguage->getLanguageId(); |
||
| 327 | if ($languageId === 0) { |
||
| 328 | continue; |
||
| 329 | } |
||
| 330 | if ($this->pObj->MOD_SETTINGS['lang'] == 0 || (int)$this->pObj->MOD_SETTINGS['lang'] === $languageId) { |
||
| 331 | // Title: |
||
| 332 | $headerCells[] = '<th class="col-border-left">' . htmlspecialchars($siteLanguage->getTitle()) . '</th>'; |
||
| 333 | // Edit language overlay records: |
||
| 334 | if (is_array($langRecUids[$languageId])) { |
||
| 335 | $editUrl = (string)$this->uriBuilder->buildUriFromRoute('record_edit', [ |
||
| 336 | 'edit' => [ |
||
| 337 | 'pages' => [ |
||
| 338 | implode(',', $langRecUids[$languageId]) => 'edit' |
||
| 339 | ] |
||
| 340 | ], |
||
| 341 | 'columnsOnly' => 'title,nav_title,hidden', |
||
| 342 | 'returnUrl' => $request->getAttribute('normalizedParams')->getRequestUri() |
||
| 343 | ]); |
||
| 344 | $editButton = '<a href="' . htmlspecialchars($editUrl) |
||
| 345 | . '" class="btn btn-default" title="' . $lang->sL( |
||
| 346 | 'LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:lang_renderl10n_editLangOverlays' |
||
| 347 | ) . '">' . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '</a>'; |
||
| 348 | } else { |
||
| 349 | $editButton = ''; |
||
| 350 | } |
||
| 351 | // Create new overlay records: |
||
| 352 | $createLink = (string)$this->uriBuilder->buildUriFromRoute('tce_db', [ |
||
| 353 | 'redirect' => $request->getAttribute('normalizedParams')->getRequestUri() |
||
| 354 | ]); |
||
| 355 | $newButton = '<a href="' . htmlspecialchars($createLink) . '" data-edit-url="' . htmlspecialchars($createLink) . '" class="btn btn-default disabled t3js-language-new-' . $languageId . '" title="' . $lang->sL( |
||
| 356 | 'LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:lang_getlangsta_createNewTranslationHeaders' |
||
| 357 | ) . '">' . $this->iconFactory->getIcon('actions-document-new', Icon::SIZE_SMALL)->render() . '</a>'; |
||
| 358 | |||
| 359 | $headerCells[] = '<th class="btn-group">' . $editButton . $newButton . '</th>'; |
||
| 360 | $headerCells[] = '<th> </th>'; |
||
| 361 | } |
||
| 362 | } |
||
| 363 | |||
| 364 | $output = |
||
| 365 | '<div class="table-fit">' . |
||
| 366 | '<table class="table table-striped table-hover" id="langTable">' . |
||
| 367 | '<thead>' . |
||
| 368 | '<tr>' . |
||
| 369 | implode('', $headerCells) . |
||
| 370 | '</tr>' . |
||
| 371 | '</thead>' . |
||
| 372 | '<tbody>' . |
||
| 373 | $output . |
||
| 374 | '</tbody>' . |
||
| 375 | '</table>' . |
||
| 376 | '</div>'; |
||
| 377 | return $output; |
||
| 378 | } |
||
| 495 |