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