Skip to content

Commit

Permalink
[TASK] Replace getLLL
Browse files Browse the repository at this point in the history
  • Loading branch information
sypets committed Oct 27, 2024
1 parent f994d7b commit 7cd52c2
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 52 deletions.
2 changes: 1 addition & 1 deletion Classes/Controller/ManageExclusionsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ protected function getVariablesForTableHeader(array $sortActions): array
'url' => '',
'icon' => '',
];
$tableHeadData[$key]['label'] = $languageService->getLL('columnHeader.' . $key);
$tableHeadData[$key]['label'] = $languageService->sL('LLL:EXT:brofix/Resources/Private/Language/Module/locallang.xlf:columnHeader.' . $key);
if (isset($sortActions[$key])) {
// sorting available, add url
if ($this->orderBy === $key) {
Expand Down
14 changes: 7 additions & 7 deletions Classes/LinkAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function recheckUrl(string &$message, array $record, ServerRequestInterfa
-1
);
$message = sprintf(
$this->getLanguageService()->getLL('list.recheck.url.ok.removed'),
$this->getLanguageService()->sL('LLL:EXT:brofix/Resources/Private/Language/Module/locallang.xlf:list.recheck.url.ok.removed'),
$url,
$count
);
Expand Down Expand Up @@ -160,7 +160,7 @@ public function recheckUrl(string &$message, array $record, ServerRequestInterfa
$linkType
);
$message = sprintf(
$this->getLanguageService()->getLL('list.recheck.url.notok.removed'),
$this->getLanguageService()->sL('LLL:EXT:brofix/Resources/Private/Language/Module/locallang.xlf:list.recheck.url.notok.removed'),
$url,
$count
);
Expand All @@ -182,7 +182,7 @@ public function recheckUrl(string &$message, array $record, ServerRequestInterfa
$count = $this->brokenLinkRepository->updateBrokenLink($brokenLinkRecord, $identifier);
if ($linkTargetResponse->isError()) {
$message = sprintf(
$this->getLanguageService()->getLL('list.recheck.url.notok.updated'),
$this->getLanguageService()->sL('LLL:EXT:brofix/Resources/Private/Language/Module/locallang.xlf:list.recheck.url.notok.updated'),
$url,
$count
);
Expand All @@ -191,7 +191,7 @@ public function recheckUrl(string &$message, array $record, ServerRequestInterfa
}
if ($message === '') {
$message = sprintf(
$this->getLanguageService()->getLL('list.recheck.url'),
$this->getLanguageService()->sL('LLL:EXT:brofix/Resources/Private/Language/Module/locallang.xlf:list.recheck.url'),
$url
);
}
Expand Down Expand Up @@ -236,7 +236,7 @@ public function recheckLinks(

if (!$row) {
// missing record: remove existing links
$message = sprintf($this->getLanguageService()->getLL('list.recheck.message.removed'), $recordUid);
$message = sprintf($this->getLanguageService()->sL('LLL:EXT:brofix/Resources/Private/Language/Module/locallang.xlf:list.recheck.message.removed'), $recordUid);
// remove existing broken links from table
$this->brokenLinkRepository->removeBrokenLinksForRecordBeforeTime($table, $recordUid, $startTime);
return true;
Expand All @@ -252,7 +252,7 @@ public function recheckLinks(
}
if ($beforeEditedTimestamp && $timestampValue && $beforeEditedTimestamp >= $timestampValue) {
// if timestamp of record is not after $beforeEditedTimestamp: no need to recheck
$message = $this->getLanguageService()->getLL('list.recheck.message.notchanged');
$message = $this->getLanguageService()->sL('LLL:EXT:brofix/Resources/Private/Language/Module/locallang.xlf:list.recheck.message.notchanged');
if ($message) {
$message = sprintf($message, $header);
}
Expand All @@ -275,7 +275,7 @@ public function recheckLinks(
}
// remove existing broken links from table
$this->brokenLinkRepository->removeBrokenLinksForRecordBeforeTime($table, $recordUid, $startTime);
$message = sprintf($this->getLanguageService()->getLL('list.recheck.message.checked'), $header);
$message = sprintf($this->getLanguageService()->sL('LLL:EXT:brofix/Resources/Private/Language/Module/locallang.xlf:list.recheck.message.checked'), $header);
return true;
}

Expand Down
25 changes: 6 additions & 19 deletions Classes/Linktype/ExternalLinktype.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,6 @@
declare(strict_types=1);
namespace Sypets\Brofix\Linktype;

/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/

use GuzzleHttp\Cookie\CookieJar;
use GuzzleHttp\Exception\ClientException;
use GuzzleHttp\Exception\ConnectException;
Expand Down Expand Up @@ -352,11 +339,11 @@ public function getErrorMessage(?LinkTargetResponse $linkTargetResponse): string

switch ($errorType) {
case self::ERROR_TYPE_HTTP_STATUS_CODE:
$message = $lang->getLL('list.report.error.httpstatus.' . $errno);
$message = $lang->sL('LLL:EXT:brofix/Resources/Private/Language/Module/locallang.xlf:list.report.error.httpstatus.' . $errno);
if (!$message) {
if ($errno !== 0) {
// fall back to generic error message
$message = sprintf($lang->getLL('list.report.error.httpstatus.general'), (string)$errno);
$message = sprintf($lang->sL('LLL:EXT:brofix/Resources/Private/Language/Module/locallang.xlf:list.report.error.httpstatus.general'), (string)$errno);
} else {
$message = $exception;
}
Expand All @@ -367,11 +354,11 @@ public function getErrorMessage(?LinkTargetResponse $linkTargetResponse): string
$message = '';
if ($errno > 0) {
// get localized error message
$message = $lang->getLL('list.report.error.libcurl.' . $errno);
$message = $lang->sL('LLL:EXT:brofix/Resources/Private/Language/Module/locallang.xlf:list.report.error.libcurl.' . $errno);
}
if (!$message) {
// fallback to generic error message and show exception
$message = $lang->getLL('list.report.error.networkexception');
$message = $lang->sL('LLL:EXT:brofix/Resources/Private/Language/Module/locallang.xlf:list.report.error.networkexception');
if ($exception !== '') {
$message .= ' ('
. $exception
Expand All @@ -382,14 +369,14 @@ public function getErrorMessage(?LinkTargetResponse $linkTargetResponse): string

case 'loop':
$message = sprintf(
$lang->getLL('list.report.error.redirectloop'),
$lang->sL('LLL:EXT:brofix/Resources/Private/Language/Module/locallang.xlf:list.report.error.redirectloop'),
$exception,
''
);
break;

case 'tooManyRedirects':
$message = $lang->getLL('list.report.error.tooManyRedirects');
$message = $lang->sL('LLL:EXT:brofix/Resources/Private/Language/Module/locallang.xlf:list.report.error.tooManyRedirects');
break;

default:
Expand Down
17 changes: 2 additions & 15 deletions Classes/Linktype/FileLinktype.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,6 @@
declare(strict_types=1);
namespace Sypets\Brofix\Linktype;

/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/

use Sypets\Brofix\CheckLinks\LinkTargetResponse\LinkTargetResponse;
use TYPO3\CMS\Core\Resource\Exception\FileDoesNotExistException;
use TYPO3\CMS\Core\Resource\Exception\FolderDoesNotExistException;
Expand Down Expand Up @@ -89,7 +76,7 @@ public function checkLink(string $url, array $softRefEntry, int $flags = 0): Lin
*/
public function getErrorMessage(?LinkTargetResponse $linkTargetResponse): string
{
return $this->getLanguageService()->getLL('list.report.error.file.notexisting');
return $this->getLanguageService()->sL('LLL:EXT:brofix/Resources/Private/Language/Module/locallang.xlf:list.report.error.file.notexisting');
}

/**
Expand All @@ -113,6 +100,6 @@ public function getBrokenUrl(array $row): string
*/
public function getBrokenLinkText(array $row, array $additionalConfig = null): string
{
return $this->getLanguageService()->getLL('list.report.url.file');
return $this->getLanguageService()->sL('LLL:EXT:brofix/Resources/Private/Language/Module/locallang.xlf:list.report.url.file');
}
}
20 changes: 10 additions & 10 deletions Classes/Linktype/InternalLinktype.php
Original file line number Diff line number Diff line change
Expand Up @@ -317,21 +317,21 @@ public function getErrorMessage(?LinkTargetResponse $linkTargetResponse): string
if ($linkTargetResponse->getErrorType() === self::ERROR_TYPE_PAGE) {
switch ($linkTargetResponse->getErrno()) {
case self::ERROR_ERRNO_DELETED:
$errorPage = $lang->getLL('list.report.error.page.deleted');
$errorPage = $lang->sL('LLL:EXT:brofix/Resources/Private/Language/Module/locallang.xlf:list.report.error.page.deleted');
break;
case self::ERROR_ERRNO_HIDDEN:
$errorPage = $lang->getLL('list.report.error.page.notvisible');
$errorPage = $lang->sL('LLL:EXT:brofix/Resources/Private/Language/Module/locallang.xlf:list.report.error.page.notvisible');
break;
default:
$errorPage = $lang->getLL('list.report.error.page.notexisting');
$errorPage = $lang->sL('LLL:EXT:brofix/Resources/Private/Language/Module/locallang.xlf:list.report.error.page.notexisting');
}
} elseif ($linkTargetResponse->getErrorType() === self::ERROR_TYPE_CONTENT) {
switch ($linkTargetResponse->getErrno()) {
case self::ERROR_ERRNO_DELETED:
$errorContent = $lang->getLL('list.report.error.content.deleted');
$errorContent = $lang->sL('LLL:EXT:brofix/Resources/Private/Language/Module/locallang.xlf:list.report.error.content.deleted');
break;
case self::ERROR_ERRNO_HIDDEN:
$errorContent = $lang->getLL('list.report.error.content.notvisible');
$errorContent = $lang->sL('LLL:EXT:brofix/Resources/Private/Language/Module/locallang.xlf:list.report.error.content.notvisible');
break;
case self::ERROR_ERRNO_MOVED:
$errorContent = str_replace(
Expand All @@ -347,11 +347,11 @@ public function getErrorMessage(?LinkTargetResponse $linkTargetResponse): string
$custom['content']['wrongPage'] ?? '',
$custom['content']['rightPage'] ?? ''
],
$lang->getLL('list.report.error.contentmoved')
$lang->sL('LLL:EXT:brofix/Resources/Private/Language/Module/locallang.xlf:list.report.error.contentmoved')
);
break;
default:
$errorContent = $lang->getLL('list.report.error.content.notexisting');
$errorContent = $lang->sL('LLL:EXT:brofix/Resources/Private/Language/Module/locallang.xlf:list.report.error.content.notexisting');
}
}
if (isset($errorPage) && isset($errorContent)) {
Expand All @@ -362,7 +362,7 @@ public function getErrorMessage(?LinkTargetResponse $linkTargetResponse): string
$response = $errorContent;
} else {
// This should not happen
$response = $lang->getLL('list.report.noinformation');
$response = $lang->sL('LLL:EXT:brofix/Resources/Private/Language/Module/locallang.xlf:list.report.noinformation');
}
return $response;
}
Expand Down Expand Up @@ -401,13 +401,13 @@ public function getBrokenLinkText(array $row, array $additionalConfig = null): s
$pageuid = (int)($elements[0] ?? 0);
$contentUid = (int)($elements[1] ?? 0);

$message = $this->getLanguageService()->getLL('list.report.url.page') . ':';
$message = $this->getLanguageService()->sL('LLL:EXT:brofix/Resources/Private/Language/Module/locallang.xlf:list.report.url.page') . ':';
if ($pageTitle) {
$message .= (' "' . $pageTitle . '"');
}
$message .= (' [' . $pageuid . ']');
if ($contentUid != 0) {
$message .= ', ' . $this->getLanguageService()->getLL('list.report.url.element') . ':';
$message .= ', ' . $this->getLanguageService()->sL('LLL:EXT:brofix/Resources/Private/Language/Module/locallang.xlf:list.report.url.element') . ':';
if ($contentTitle) {
$message .= ' "' . $contentTitle . '"';
}
Expand Down

0 comments on commit 7cd52c2

Please sign in to comment.