Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 11 additions & 16 deletions Classes/Form/Element/ShowDeleteFiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,17 @@

class ShowDeleteFiles extends AbstractFormElement
{
/**
* Container objects give $nodeFactory down to other containers.
*
* @param FileRepository $fileRepository
* @param LanguageService $languageService
*/
public function __construct(
protected readonly FileRepository $fileRepository,
protected readonly LanguageService $languageService
) {
}


/**
* @return array
*/
public function render(): array
{
$result = $this->initializeResultArray();

$rows = $this->fileRepository->countByIdentifier($this->data['vanillaUid']);
$languageService = $this->instanceLanguageService();
$fileRepository = GeneralUtility::makeInstance(FileRepository::class);
$rows = $fileRepository->countByIdentifier($this->data['vanillaUid']);

// TODO https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/13.0/Breaking-97330-FormEngineElementClassesMustCreateLabelOrLegend.html

Expand All @@ -54,7 +45,7 @@ public function render(): array

if (empty($rows)) {
$html[] = '<span class="badge badge-success">'
. $this->languageService->sL('LLL:EXT:filefill/Resources/Private/Language/locallang_db.xlf:sys_file_storage.filefill.no_delete')
. $languageService->sL('LLL:EXT:filefill/Resources/Private/Language/locallang_db.xlf:sys_file_storage.filefill.no_delete')
. '</span>';
} else {
$iconFactory = GeneralUtility::makeInstance(IconFactory::class);
Expand All @@ -65,9 +56,9 @@ public function render(): array
$html[] = '<a class="btn btn-default t3js-editform-submitButton" data-name="_save_tx_filefill_delete" data-form="EditDocumentController" data-value="' . $row['tx_filefill_identifier'] . '">';
$html[] = $iconFactory->getIcon('actions-edit-delete', IconSize::SMALL);
$html[] = ' ' . sprintf(
$this->languageService->sL('LLL:EXT:filefill/Resources/Private/Language/locallang_db.xlf:sys_file_storage.filefill.delete_files'),
$languageService->sL('LLL:EXT:filefill/Resources/Private/Language/locallang_db.xlf:sys_file_storage.filefill.delete_files'),
$row['count'],
$this->languageService->sL($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['filefill']['resourceHandler'][$row['tx_filefill_identifier']]['title'] ?? $row['tx_filefill_identifier'])
$languageService->sL($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['filefill']['resourceHandler'][$row['tx_filefill_identifier']]['title'] ?? $row['tx_filefill_identifier'])
);
$html[] = '</a>';
}
Expand All @@ -78,4 +69,8 @@ public function render(): array

return $result;
}
private function instanceLanguageService(): LanguageService
{
return $GLOBALS['LANG'];
}
}
22 changes: 9 additions & 13 deletions Classes/Form/Element/ShowMissingFiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,14 @@

class ShowMissingFiles extends AbstractFormElement
{
/**
* Container objects give $nodeFactory down to other containers.
*
* @param LanguageService|null $languageService
* @throws \InvalidArgumentException
*/
public function __construct(protected readonly LanguageService $languageService)
{
}

/**
* @return array
*/
public function render(): array
{
$result = $this->initializeResultArray();

$languageService = $this->instanceLanguageService();
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_file');
$expressionBuilder = $queryBuilder->expr();
$count = $queryBuilder->count('*')
Expand All @@ -68,21 +59,21 @@ public function render(): array

if ($count === 0) {
$html[] = '<span class="badge badge-success">'
. $this->languageService->sL('LLL:EXT:filefill/Resources/Private/Language/locallang_db.xlf:sys_file_storage.filefill.no_missing')
. $languageService->sL('LLL:EXT:filefill/Resources/Private/Language/locallang_db.xlf:sys_file_storage.filefill.no_missing')
. '</span>';
} else {
$iconFactory = GeneralUtility::makeInstance(IconFactory::class);
$html[] = '<span class="badge badge-danger">'
. sprintf(
$this->languageService->sL('LLL:EXT:filefill/Resources/Private/Language/locallang_db.xlf:sys_file_storage.filefill.missing_files'),
$languageService->sL('LLL:EXT:filefill/Resources/Private/Language/locallang_db.xlf:sys_file_storage.filefill.missing_files'),
$count
)
. '</span>';
$html[] = '</div>';
$html[] = '<div class="form-control-wrap t3js-module-docheader">';
$html[] = '<a class="btn btn-default t3js-editform-submitButton" data-name="_save_tx_filefill_missing" data-form="EditDocumentController" data-value="1">';
$html[] = $iconFactory->getIcon('actions-database-reload', IconSize::SMALL);
$html[] = ' ' . $this->languageService->sL('LLL:EXT:filefill/Resources/Private/Language/locallang_db.xlf:sys_file_storage.filefill.reset');
$html[] = ' ' . $languageService->sL('LLL:EXT:filefill/Resources/Private/Language/locallang_db.xlf:sys_file_storage.filefill.reset');
$html[] = '</a>';
}

Expand All @@ -92,4 +83,9 @@ public function render(): array

return $result;
}

private function instanceLanguageService(): LanguageService
{
return $GLOBALS['LANG'];
}
}