‪TYPO3CMS  10.4
FalStatus.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
23 use ‪TYPO3\CMS\Reports\Status as ReportStatus;
25 
30 {
36  public function ‪getStatus()
37  {
38  $statuses = [
39  'MissingFiles' => $this->‪getMissingFilesStatus(),
40  ];
41  return $statuses;
42  }
43 
49  protected function ‪getMissingFilesStatus()
50  {
51  $value = $this->‪getLanguageService()->‪getLL('status_none');
52  $count = 0;
53  $maxFilesToShow = 100;
54  $message = '';
55  $severity = ReportStatus::OK;
56 
58  $storageRepository = GeneralUtility::makeInstance(StorageRepository::class);
59  $storageObjects = $storageRepository->findAll();
60  $storages = [];
61 
63  foreach ($storageObjects as $storageObject) {
64 
65  // We only check missing files for storages that are online
66  if ($storageObject->isOnline()) {
67  $storages[$storageObject->getUid()] = $storageObject;
68  }
69  }
70 
71  $queryBuilder = null;
72  if (!empty($storages)) {
73  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_file');
74 
75  $count = $queryBuilder
76  ->count('*')
77  ->from('sys_file')
78  ->where(
79  $queryBuilder->expr()->eq(
80  'missing',
81  $queryBuilder->createNamedParameter(1, \PDO::PARAM_INT)
82  ),
83  $queryBuilder->expr()->in(
84  'storage',
85  $queryBuilder->createNamedParameter(array_keys($storages), Connection::PARAM_INT_ARRAY)
86  )
87  )
88  ->execute()
89  ->fetchColumn(0);
90  }
91 
92  if ($count) {
93  $value = sprintf($this->‪getLanguageService()->getLL('status_missingFilesCount'), $count);
94  $severity = ReportStatus::WARNING;
95 
96  $queryBuilder->resetQueryParts();
97  $files = $queryBuilder
98  ->select('identifier', 'storage')
99  ->from('sys_file')
100  ->where(
101  $queryBuilder->expr()->eq(
102  'missing',
103  $queryBuilder->createNamedParameter(1, \PDO::PARAM_INT)
104  ),
105  $queryBuilder->expr()->in(
106  'storage',
107  $queryBuilder->createNamedParameter(array_keys($storages), Connection::PARAM_INT_ARRAY)
108  )
109  )
110  ->setMaxResults($maxFilesToShow)
111  ->execute()
112  ->fetchAll();
113 
114  $message = '<p>' . $this->‪getLanguageService()->‪getLL('status_missingFilesMessage') . '</p>';
115  foreach ($files as $file) {
116  $message .= $storages[$file['storage']]->getName() . ' ' . $file['identifier'] . '<br />';
117  }
118 
119  if ($count > $maxFilesToShow) {
120  $message .= '...<br />';
121  }
122  }
123 
124  return GeneralUtility::makeInstance(ReportStatus::class, $this->‪getLanguageService()->getLL('status_missingFiles'), $value, $message, $severity);
125  }
126 
130  protected function ‪getLanguageService()
131  {
132  return ‪$GLOBALS['LANG'];
133  }
134 }
‪TYPO3\CMS\Reports\StatusProviderInterface
Definition: StatusProviderInterface.php:22
‪TYPO3\CMS\Reports\Report\Status\FalStatus\getLanguageService
‪LanguageService getLanguageService()
Definition: FalStatus.php:130
‪TYPO3\CMS\Reports\Status
Definition: Status.php:24
‪TYPO3\CMS\Reports\Report\Status\FalStatus\getStatus
‪array getStatus()
Definition: FalStatus.php:36
‪TYPO3\CMS\Reports\Report\Status\FalStatus\getMissingFilesStatus
‪TYPO3 CMS Reports Status getMissingFilesStatus()
Definition: FalStatus.php:49
‪TYPO3\CMS\Core\Resource\StorageRepository
Definition: StorageRepository.php:31
‪TYPO3\CMS\Core\Database\Connection
Definition: Connection.php:36
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Reports\Report\Status
Definition: ConfigurationStatus.php:16
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:42
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:46
‪TYPO3\CMS\Core\Localization\LanguageService\getLL
‪string getLL($index)
Definition: LanguageService.php:154
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Reports\Report\Status\FalStatus
Definition: FalStatus.php:30