TYPO3 CMS  TYPO3_6-2
ServicesListReport.php
Go to the documentation of this file.
1 <?php
3 
23 
29  protected $reportsModule;
30 
36  public function __construct(\TYPO3\CMS\Reports\Controller\ReportController $reportsModule) {
37  $this->reportsModule = $reportsModule;
38  $GLOBALS['LANG']->includeLLFile('EXT:sv/Resources/Private/Language/locallang.xlf');
39  }
40 
46  public function getReport() {
47  $content = '';
48  $content .= $this->renderHelp();
49  $content .= $this->renderServicesList();
50  $content .= $this->renderExecutablesSearchPathList();
51  return $content;
52  }
53 
59  protected function renderHelp() {
60  $help = '<p class="help">' . $GLOBALS['LANG']->getLL('report_explanation') . '</p>';
61  $help .= '<p class="help">' . $GLOBALS['LANG']->getLL('externals_explanation') . '</p><br />';
62  return $help;
63  }
64 
70  protected function renderServicesList() {
71  $servicesList = '';
72  $services = $this->getInstalledServices();
73  foreach ($services as $serviceType => $installedServices) {
74  $servicesList .= $this->renderServiceTypeList($serviceType, $installedServices);
75  }
76  return $servicesList;
77  }
78 
86  protected function renderServiceTypeList($serviceType, $services) {
87  $header = '<h4>' . sprintf($GLOBALS['LANG']->getLL('service_type'), $serviceType) . '</h4>';
88  $serviceList = '
89  <table cellspacing="1" cellpadding="2" border="0" class="tx_sv_reportlist services">
90  <tr class="t3-row-header">
91  <td style="width: 35%">' . $GLOBALS['LANG']->getLL('service') . '</td>
92  <td>' . $GLOBALS['LANG']->getLL('priority') . '</td>
93  <td>' . $GLOBALS['LANG']->getLL('quality') . '</td>
94  <td style="width: 35%">' . $GLOBALS['LANG']->getLL('subtypes') . '</td>
95  <td>' . $GLOBALS['LANG']->getLL('os') . '</td>
96  <td>' . $GLOBALS['LANG']->getLL('externals') . '</td>
97  <td>' . $GLOBALS['LANG']->getLL('available') . '</td>
98  </tr>';
99  foreach ($services as $serviceKey => $serviceInformation) {
100  $serviceList .= $this->renderServiceRow($serviceKey, $serviceInformation);
101  }
102  $serviceList .= '
103  </table>
104  ';
105  return $header . $serviceList;
106  }
107 
115  protected function renderServiceRow($serviceKey, $serviceInformation) {
116  $serviceDescription = '
117  <p class="service-header">
118  <span class="service-title">' . $serviceInformation['title'] . '</span> (' . $serviceInformation['extKey'] . ': ' . $serviceKey . ')
119  </p>';
120  if (!empty($serviceInformation['description'])) {
121  $serviceDescription .= '<p class="service-description">' . $serviceInformation['description'] . '</p>';
122  }
123  $serviceSubtypes = $serviceInformation['serviceSubTypes'] ? implode(', ', $serviceInformation['serviceSubTypes']) : '-';
124  $serviceOperatingSystem = $serviceInformation['os'] ?: $GLOBALS['LANG']->getLL('any');
125  $serviceRequiredExecutables = $serviceInformation['exec'] ?: '-';
126  $serviceAvailabilityClass = 'typo3-message message-error';
127  $serviceAvailable = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xlf:no');
128  try {
130  if ($serviceDetails['available']) {
131  $serviceAvailabilityClass = 'typo3-message message-ok';
132  $serviceAvailable = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xlf:yes');
133  }
134  } catch (\TYPO3\CMS\Core\Exception $e) {
135 
136  }
137  $serviceRow = '
138  <tr class="service">
139  <td class="first-cell ' . $serviceAvailabilityClass . '">' . $serviceDescription . '</td>
140  <td class="cell ' . $serviceAvailabilityClass . '">' . $serviceInformation['priority'] . '</td>
141  <td class="cell ' . $serviceAvailabilityClass . '">' . $serviceInformation['quality'] . '</td>
142  <td class="cell ' . $serviceAvailabilityClass . '">' . $serviceSubtypes . '</td>
143  <td class="cell ' . $serviceAvailabilityClass . '">' . $serviceOperatingSystem . '</td>
144  <td class="cell ' . $serviceAvailabilityClass . '">' . $serviceRequiredExecutables . '</td>
145  <td class="last-cell ' . $serviceAvailabilityClass . '">' . $serviceAvailable . '</td>
146  </tr>';
147  return $serviceRow;
148  }
149 
155  protected function renderExecutablesSearchPathList() {
157  $content = '<br /><h3 class="divider">' . $GLOBALS['LANG']->getLL('search_paths') . '</h3>';
158  if (count($searchPaths) == 0) {
159  $content .= '<p>' . $GLOBALS['LANG']->getLL('no_search_paths') . '</p>';
160  } else {
161  $content .= '
162  <table cellspacing="1" cellpadding="2" border="0" class="tx_sv_reportlist paths">
163  <thead>
164  <tr class="t3-row-header">
165  <td>' . $GLOBALS['LANG']->getLL('path') . '</td>
166  <td>' . $GLOBALS['LANG']->getLL('valid') . '</td>
167  </tr>
168  </thead>
169  <tbody>';
170  foreach ($searchPaths as $path => $isValid) {
171  $pathAccessibleClass = 'typo3-message message-error';
172  $pathAccessible = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xlf:no');
173  if ($isValid) {
174  $pathAccessibleClass = 'typo3-message message-ok';
175  $pathAccessible = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xlf:yes');
176  }
177  $content .= '
178  <tr>
179  <td class="first-cell ' . $pathAccessibleClass . '">' . \TYPO3\CMS\Core\Utility\GeneralUtility::fixWindowsFilePath($path) . '</td>
180  <td class="last-cell ' . $pathAccessibleClass . '">' . $pathAccessible . '</td>
181  </tr>';
182  }
183  $content .= '
184  </tbody>
185  </table>';
186  }
187  return $content;
188  }
189 
203  protected function getInstalledServices() {
204  $filteredServices = array();
205  foreach ($GLOBALS['T3_SERVICES'] as $serviceType => $serviceList) {
206  // If the (first) key of the service list is not the same as the service type,
207  // it's a "true" service type. Keep it and sort it.
208  if (key($serviceList) !== $serviceType) {
209  uasort($serviceList, array($this, 'sortServices'));
210  $filteredServices[$serviceType] = $serviceList;
211  }
212  }
213  return $filteredServices;
214  }
215 
224  protected function sortServices(array $a, array $b) {
225  $result = 0;
226  // If priorities are the same, test quality
227  if ($a['priority'] == $b['priority']) {
228  if ($a['quality'] != $b['quality']) {
229  // Service with highest quality should come first,
230  // thus it must be marked as smaller
231  $result = $a['quality'] > $b['quality'] ? -1 : 1;
232  }
233  } else {
234  // Service with highest priority should come first,
235  // thus it must be marked as smaller
236  $result = $a['priority'] > $b['priority'] ? -1 : 1;
237  }
238  return $result;
239  }
240 
241 }
renderServiceTypeList($serviceType, $services)
__construct(\TYPO3\CMS\Reports\Controller\ReportController $reportsModule)
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren&#39;t numeric.
static getPaths($addInvalid=FALSE)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
renderServiceRow($serviceKey, $serviceInformation)