TYPO3 CMS  TYPO3_7-6
ServicesListReport.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 
23 
29 {
35  protected $reportsModule;
36 
43  {
44  $this->reportsModule = $reportsModule;
45  $this->getLanguageService()->includeLLFile('EXT:sv/Resources/Private/Language/locallang.xlf');
46  }
47 
53  public function getReport()
54  {
55  $content = '';
56  $content .= $this->renderHelp();
57  $content .= $this->renderServicesList();
58  $content .= $this->renderExecutablesSearchPathList();
59  return $content;
60  }
61 
67  protected function renderHelp()
68  {
69  $help = '<p class="lead">' . $this->getLanguageService()->getLL('report_explanation') . '</p>';
70  $help .= '<p class="help">' . $this->getLanguageService()->getLL('externals_explanation') . '</p>';
71  return $help;
72  }
73 
79  protected function renderServicesList()
80  {
81  $servicesList = '';
82  $services = $this->getInstalledServices();
83  foreach ($services as $serviceType => $installedServices) {
84  $servicesList .= $this->renderServiceTypeList($serviceType, $installedServices);
85  }
86  return $servicesList;
87  }
88 
96  protected function renderServiceTypeList($serviceType, $services)
97  {
98  $lang = $this->getLanguageService();
99  $header = '<h3>' . sprintf($lang->getLL('service_type'), $serviceType) . '</h3>';
100  $serviceList = '
101  <table class="table table-striped table-hover tx_sv_reportlist">
102  <thead>
103  <tr>
104  <td style="width: 35%">' . $lang->getLL('service') . '</td>
105  <td>' . $lang->getLL('priority') . '</td>
106  <td>' . $lang->getLL('quality') . '</td>
107  <td style="width: 35%">' . $lang->getLL('subtypes') . '</td>
108  <td>' . $lang->getLL('os') . '</td>
109  <td>' . $lang->getLL('externals') . '</td>
110  <td>' . $lang->getLL('available') . '</td>
111  </tr>
112  </thead>
113  <tbody>';
114 
115  foreach ($services as $serviceKey => $serviceInformation) {
116  $serviceList .= $this->renderServiceRow($serviceKey, $serviceInformation);
117  }
118 
119  $serviceList .= '
120  </tbody>
121  </table>
122  ';
123  return $header . $serviceList;
124  }
125 
133  protected function renderServiceRow($serviceKey, $serviceInformation)
134  {
135  $serviceDescription = '
136  <p class="service-header">
137  <span class="service-title">' . $serviceInformation['title'] . '</span> (' . $serviceInformation['extKey'] . ': ' . $serviceKey . ')
138  </p>';
139  if (!empty($serviceInformation['description'])) {
140  $serviceDescription .= '<p class="service-description">' . $serviceInformation['description'] . '</p>';
141  }
142  $serviceSubtypes = $serviceInformation['serviceSubTypes'] ? implode(', ', $serviceInformation['serviceSubTypes']) : '-';
143  $serviceOperatingSystem = $serviceInformation['os'] ?: $this->getLanguageService()->getLL('any');
144  $serviceRequiredExecutables = $serviceInformation['exec'] ?: '-';
145  $serviceAvailabilityClass = 'danger';
146  $serviceAvailable = $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:no');
147  try {
148  $serviceDetails = ExtensionManagementUtility::findServiceByKey($serviceKey);
149  if ($serviceDetails['available']) {
150  $serviceAvailabilityClass = 'success';
151  $serviceAvailable = $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:yes');
152  }
153  } catch (Exception $e) {
154  }
155  $serviceRow = '
156  <tr class="service ' . $serviceAvailabilityClass . '">
157  <td class="first-cell">' . $serviceDescription . '</td>
158  <td class="cell">' . $serviceInformation['priority'] . '</td>
159  <td class="cell">' . $serviceInformation['quality'] . '</td>
160  <td class="cell">' . $serviceSubtypes . '</td>
161  <td class="cell">' . $serviceOperatingSystem . '</td>
162  <td class="cell">' . $serviceRequiredExecutables . '</td>
163  <td class="last-cell">' . $serviceAvailable . '</td>
164  </tr>';
165  return $serviceRow;
166  }
167 
173  protected function renderExecutablesSearchPathList()
174  {
175  $searchPaths = CommandUtility::getPaths(true);
176  $content = '<h3>' . $this->getLanguageService()->getLL('search_paths') . '</h3>';
177  if (empty($searchPaths)) {
178  $content .= '<p>' . $this->getLanguageService()->getLL('no_search_paths') . '</p>';
179  } else {
180  $content .= '
181  <table class="table table-striped table-hover tx_sv_reportlist">
182  <thead>
183  <tr>
184  <td>' . $this->getLanguageService()->getLL('path') . '</td>
185  <td>' . $this->getLanguageService()->getLL('valid') . '</td>
186  </tr>
187  </thead>
188  <tbody>';
189  foreach ($searchPaths as $path => $isValid) {
190  $pathAccessibleClass = 'danger';
191  $pathAccessible = $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:no');
192  if ($isValid) {
193  $pathAccessibleClass = 'success';
194  $pathAccessible = $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:yes');
195  }
196  $content .= '
197  <tr class="' . $pathAccessibleClass . '">
198  <td class="first-cell">' . GeneralUtility::fixWindowsFilePath($path) . '</td>
199  <td class="last-cell">' . $pathAccessible . '</td>
200  </tr>';
201  }
202  $content .= '
203  </tbody>
204  </table>';
205  }
206  return $content;
207  }
208 
222  protected function getInstalledServices()
223  {
224  $filteredServices = [];
225  foreach ($GLOBALS['T3_SERVICES'] as $serviceType => $serviceList) {
226  // If the (first) key of the service list is not the same as the service type,
227  // it's a "true" service type. Keep it and sort it.
228  if (key($serviceList) !== $serviceType) {
229  uasort($serviceList, [$this, 'sortServices']);
230  $filteredServices[$serviceType] = $serviceList;
231  }
232  }
233  return $filteredServices;
234  }
235 
244  protected function sortServices(array $a, array $b)
245  {
246  $result = 0;
247  // If priorities are the same, test quality
248  if ($a['priority'] == $b['priority']) {
249  if ($a['quality'] != $b['quality']) {
250  // Service with highest quality should come first,
251  // thus it must be marked as smaller
252  $result = $a['quality'] > $b['quality'] ? -1 : 1;
253  }
254  } else {
255  // Service with highest priority should come first,
256  // thus it must be marked as smaller
257  $result = $a['priority'] > $b['priority'] ? -1 : 1;
258  }
259  return $result;
260  }
261 
267  protected function getLanguageService()
268  {
269  return $GLOBALS['LANG'];
270  }
271 }
renderServiceTypeList($serviceType, $services)
__construct(ReportController $reportsModule)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']
static getPaths($addInvalid=false)
renderServiceRow($serviceKey, $serviceInformation)