[!!!][TASK] Deprecate IconUtility
[Packages/TYPO3.CMS.git] / typo3 / sysext / linkvalidator / Classes / Report / LinkValidatorReport.php
1 <?php
2 namespace TYPO3\CMS\Linkvalidator\Report;
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
17 use TYPO3\CMS\Backend\Template\DocumentTemplate;
18 use TYPO3\CMS\Backend\Utility\BackendUtility;
19 use TYPO3\CMS\Core\Imaging\Icon;
20 use TYPO3\CMS\Core\Imaging\IconFactory;
21 use TYPO3\CMS\Core\Messaging\FlashMessage;
22 use TYPO3\CMS\Core\Service\MarkerBasedTemplateService;
23 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
24 use TYPO3\CMS\Core\Utility\GeneralUtility;
25 use TYPO3\CMS\Linkvalidator\LinkAnalyzer;
26
27 /**
28 * Module 'Linkvalidator' for the 'linkvalidator' extension
29 */
30 class LinkValidatorReport extends \TYPO3\CMS\Backend\Module\AbstractFunctionModule {
31
32 /**
33 * @var DocumentTemplate
34 */
35 public $doc;
36
37 /**
38 * Information about the current page record
39 *
40 * @var array
41 */
42 protected $pageRecord = array();
43
44 /**
45 * Information, if the module is accessible for the current user or not
46 *
47 * @var bool
48 */
49 protected $isAccessibleForCurrentUser = FALSE;
50
51 /**
52 * Depth for the recursive traversal of pages for the link validation
53 *
54 * @var int
55 */
56 protected $searchLevel;
57
58 /**
59 * Link validation class
60 *
61 * @var LinkAnalyzer
62 */
63 protected $linkAnalyzer;
64
65 /**
66 * TSconfig of the current module
67 *
68 * @var array
69 */
70 protected $modTS = array();
71
72 /**
73 * List of available link types to check defined in the TSconfig
74 *
75 * @var array
76 */
77 protected $availableOptions = array();
78
79 /**
80 * List of link types currently chosen in the statistics table
81 * Used to show broken links of these types only
82 *
83 * @var array
84 */
85 protected $checkOpt = array();
86
87 /**
88 * Html for the statistics table with the checkboxes of the link types
89 * and the numbers of broken links for report tab
90 *
91 * @var string
92 */
93 protected $checkOptionsHtml;
94
95 /**
96 * Html for the statistics table with the checkboxes of the link types
97 * and the numbers of broken links for check links tab
98 *
99 * @var string
100 */
101 protected $checkOptionsHtmlCheck;
102
103 /**
104 * Complete content (html) to be displayed
105 *
106 * @var string
107 */
108 protected $content;
109
110 /**
111 * @var \TYPO3\CMS\Linkvalidator\Linktype\LinktypeInterface[]
112 */
113 protected $hookObjectsArr = array();
114
115 /**
116 * @var string
117 */
118 protected $updateListHtml = '';
119
120 /**
121 * @var string
122 */
123 protected $refreshListHtml = '';
124
125 /**
126 * @var MarkerBasedTemplateService
127 */
128 protected $templateService;
129
130 /**
131 * Main method of modfuncreport
132 *
133 * @return string Module content
134 */
135 public function main() {
136 $this->getLanguageService()->includeLLFile('EXT:linkvalidator/Resources/Private/Language/Module/locallang.xlf');
137 $this->searchLevel = GeneralUtility::_GP('search_levels');
138 if (isset($this->pObj->id)) {
139 $this->modTS = BackendUtility::getModTSconfig($this->pObj->id, 'mod.linkvalidator');
140 $this->modTS = $this->modTS['properties'];
141 }
142 $update = GeneralUtility::_GP('updateLinkList');
143 $prefix = '';
144 if (!empty($update)) {
145 $prefix = 'check';
146 }
147 $set = GeneralUtility::_GP($prefix . 'SET');
148 $this->pObj->handleExternalFunctionValue();
149 if (isset($this->searchLevel)) {
150 $this->pObj->MOD_SETTINGS['searchlevel'] = $this->searchLevel;
151 } else {
152 $this->searchLevel = $this->pObj->MOD_SETTINGS['searchlevel'];
153 }
154 if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'])) {
155 foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'] as $linkType => $value) {
156 // Compile list of all available types. Used for checking with button "Check Links".
157 if (strpos($this->modTS['linktypes'], $linkType) !== FALSE) {
158 $this->availableOptions[$linkType] = 1;
159 }
160 // Compile list of types currently selected by the checkboxes
161 if ($this->pObj->MOD_SETTINGS[$linkType] && empty($set) || $set[$linkType]) {
162 $this->checkOpt[$linkType] = 1;
163 $this->pObj->MOD_SETTINGS[$linkType] = 1;
164 } else {
165 $this->pObj->MOD_SETTINGS[$linkType] = 0;
166 unset($this->checkOpt[$linkType]);
167 }
168 }
169 }
170 $this->getBackendUser()->pushModuleData('web_info', $this->pObj->MOD_SETTINGS);
171 $this->initialize();
172
173 // Localization
174 $this->getPageRenderer()->addInlineLanguageLabelFile(
175 ExtensionManagementUtility::extPath('linkvalidator', 'Resources/Private/Language/Module/locallang.xlf')
176 );
177
178 if ($this->modTS['showCheckLinkTab'] == 1) {
179 $this->updateListHtml = '<input class="btn btn-default" type="submit" name="updateLinkList" id="updateLinkList" value="' . $this->getLanguageService()->getLL('label_update') . '"/>';
180 }
181 $this->refreshListHtml = '<input class="btn btn-default" type="submit" name="refreshLinkList" id="refreshLinkList" value="' . $this->getLanguageService()->getLL('label_refresh') . '"/>';
182 $this->linkAnalyzer = GeneralUtility::makeInstance(LinkAnalyzer::class);
183 $this->updateBrokenLinks();
184
185 $brokenLinkOverView = $this->linkAnalyzer->getLinkCounts($this->pObj->id);
186 $this->checkOptionsHtml = $this->getCheckOptions($brokenLinkOverView);
187 $this->checkOptionsHtmlCheck = $this->getCheckOptions($brokenLinkOverView, 'check');
188 $this->render();
189
190 $pageTile = '';
191 if ($this->pObj->id) {
192 $pageRecord = BackendUtility::getRecord('pages', $this->pObj->id);
193 $pageTile = '<h1>' . htmlspecialchars(BackendUtility::getRecordTitle('pages', $pageRecord)) . '</h1>';
194 }
195
196 return '<div id="linkvalidator-modfuncreport">' . $pageTile . $this->createTabs() . '</div>';
197 }
198
199 /**
200 * Create tabs to split the report and the checkLink functions
201 *
202 * @return string
203 */
204 protected function createTabs() {
205 $menuItems = array(
206 0 => array(
207 'label' => $this->getLanguageService()->getLL('Report'),
208 'content' => $this->flush(TRUE)
209 ),
210 );
211
212 if ((bool)$this->modTS['showCheckLinkTab']) {
213 $menuItems[1] = array(
214 'label' => $this->getLanguageService()->getLL('CheckLink'),
215 'content' => $this->flush()
216 );
217 }
218
219 return $this->doc->getDynamicTabMenu($menuItems, 'report-linkvalidator');
220 }
221
222 /**
223 * Initializes the Module
224 *
225 * @return void
226 */
227 protected function initialize() {
228 if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'])) {
229 foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'] as $linkType => $classRef) {
230 $this->hookObjectsArr[$linkType] = GeneralUtility::getUserObj($classRef);
231 }
232 }
233
234 $this->doc = GeneralUtility::makeInstance(DocumentTemplate::class);
235 $this->doc->setModuleTemplate('EXT:linkvalidator/Resources/Private/Templates/mod_template.html');
236
237 $this->pageRecord = BackendUtility::readPageAccess($this->pObj->id, $this->getBackendUser()->getPagePermsClause(1));
238 if ($this->pObj->id && is_array($this->pageRecord) || !$this->pObj->id && $this->isCurrentUserAdmin()) {
239 $this->isAccessibleForCurrentUser = TRUE;
240 }
241
242 $this->doc->addStyleSheet('module', 'sysext/linkvalidator/Resources/Public/Css/styles.css');
243 $this->getPageRenderer()->loadJquery();
244 $this->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Linkvalidator/Linkvalidator');
245
246 $this->templateService = GeneralUtility::makeInstance(MarkerBasedTemplateService::class);
247
248 // Don't access in workspace
249 if ($this->getBackendUser()->workspace !== 0) {
250 $this->isAccessibleForCurrentUser = FALSE;
251 }
252 }
253
254 /**
255 * Updates the table of stored broken links
256 *
257 * @return void
258 */
259 protected function updateBrokenLinks() {
260 $searchFields = array();
261 // Get the searchFields from TypoScript
262 foreach ($this->modTS['searchFields.'] as $table => $fieldList) {
263 $fields = GeneralUtility::trimExplode(',', $fieldList, TRUE);
264 foreach ($fields as $field) {
265 if (!$searchFields || !is_array($searchFields[$table]) || array_search($field, $searchFields[$table]) === FALSE) {
266 $searchFields[$table][] = $field;
267 }
268 }
269 }
270 $rootLineHidden = $this->linkAnalyzer->getRootLineIsHidden($this->pObj->pageinfo);
271 if (!$rootLineHidden || $this->modTS['checkhidden'] == 1) {
272 // Get children pages
273 $pageList = $this->linkAnalyzer->extGetTreeList(
274 $this->pObj->id,
275 $this->searchLevel,
276 0,
277 $this->getBackendUser()->getPagePermsClause(1),
278 $this->modTS['checkhidden']
279 );
280 if ($this->pObj->pageinfo['hidden'] == 0 || $this->modTS['checkhidden']) {
281 $pageList .= $this->pObj->id;
282 }
283
284 $this->linkAnalyzer->init($searchFields, $pageList, $this->modTS);
285
286 // Check if button press
287 $update = GeneralUtility::_GP('updateLinkList');
288 if (!empty($update)) {
289 $this->linkAnalyzer->getLinkStatistics($this->checkOpt, $this->modTS['checkhidden']);
290 }
291 }
292 }
293
294 /**
295 * Renders the content of the module
296 *
297 * @return void
298 */
299 protected function render() {
300 if ($this->isAccessibleForCurrentUser) {
301 $this->content = $this->renderBrokenLinksTable();
302 } else {
303 // If no access or if ID == zero
304 /** @var FlashMessage $message */
305 $message = GeneralUtility::makeInstance(
306 FlashMessage::class,
307 $this->getLanguageService()->getLL('no.access'),
308 $this->getLanguageService()->getLL('no.access.title'),
309 FlashMessage::ERROR
310 );
311 $this->content .= $message->render();
312 }
313 }
314
315 /**
316 * Flushes the rendered content to the browser
317 *
318 * @param bool $form
319 * @return string $content
320 */
321 protected function flush($form = FALSE) {
322 return $this->doc->moduleBody(
323 $this->pageRecord,
324 $this->getDocHeaderButtons(),
325 $form ? $this->getTemplateMarkers() : $this->getTemplateMarkersCheck()
326 );
327 }
328
329 /**
330 * Builds the selector for the level of pages to search
331 *
332 * @return string Html code of that selector
333 */
334 protected function getLevelSelector() {
335 // Build level selector
336 $options = array();
337 $availableOptions = array(
338 0 => $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.depth_0'),
339 1 => $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.depth_1'),
340 2 => $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.depth_2'),
341 3 => $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.depth_3'),
342 4 => $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.depth_4'),
343 999 => $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.depth_infi')
344 );
345 foreach ($availableOptions as $optionValue => $optionLabel) {
346 $options[] = '<option value="' . $optionValue . '"' . ($optionValue === (int)$this->searchLevel ? ' selected="selected"' : '') . '>' . htmlspecialchars($optionLabel) . '</option>';
347 }
348 return '<select name="search_levels" class="form-control">' . implode('', $options) . '</select>';
349 }
350
351 /**
352 * Displays the table of broken links or a note if there were no broken links
353 *
354 * @return string Content of the table or of the note
355 */
356 protected function renderBrokenLinksTable() {
357 $brokenLinkItems = '';
358 $brokenLinksTemplate = $this->templateService->getSubpart($this->doc->moduleTemplate, '###NOBROKENLINKS_CONTENT###');
359 $keyOpt = array();
360 if (is_array($this->checkOpt)) {
361 $keyOpt = array_keys($this->checkOpt);
362 }
363
364 // Table header
365 $brokenLinksMarker = $this->startTable();
366
367 $rootLineHidden = $this->linkAnalyzer->getRootLineIsHidden($this->pObj->pageinfo);
368 if (!$rootLineHidden || (bool)$this->modTS['checkhidden']) {
369 $pageList = $this->linkAnalyzer->extGetTreeList(
370 $this->pObj->id,
371 $this->searchLevel,
372 0,
373 $this->getBackendUser()->getPagePermsClause(1),
374 $this->modTS['checkhidden']
375 );
376 // Always add the current page, because we are just displaying the results
377 $pageList .= $this->pObj->id;
378
379 $records = $this->getDatabaseConnection()->exec_SELECTgetRows(
380 '*',
381 'tx_linkvalidator_link',
382 'record_pid IN (' . $pageList . ') AND link_type IN (\'' . implode('\',\'', $keyOpt) . '\')',
383 '',
384 'record_uid ASC, uid ASC'
385 );
386 if (!empty($records)) {
387 // Display table with broken links
388 $brokenLinksTemplate = $this->templateService->getSubpart($this->doc->moduleTemplate, '###BROKENLINKS_CONTENT###');
389 $brokenLinksItemTemplate = $this->templateService->getSubpart($this->doc->moduleTemplate, '###BROKENLINKS_ITEM###');
390
391 // Table rows containing the broken links
392 $items = array();
393 foreach ($records as $record) {
394 $items[] = $this->renderTableRow($record['table_name'], $record, $brokenLinksItemTemplate);
395 }
396 $brokenLinkItems = implode(LF, $items);
397 } else {
398 $brokenLinksMarker = $this->getNoBrokenLinkMessage($brokenLinksMarker);
399 }
400 } else {
401 $brokenLinksMarker = $this->getNoBrokenLinkMessage($brokenLinksMarker);
402 }
403 $brokenLinksTemplate = $this->templateService->substituteMarkerArray(
404 $brokenLinksTemplate,
405 $brokenLinksMarker, '###|###',
406 TRUE
407 );
408 return $this->templateService->substituteSubpart($brokenLinksTemplate, '###BROKENLINKS_ITEM', $brokenLinkItems);
409 }
410
411 /**
412 * Replace $brokenLinksMarker['NO_BROKEN_LINKS] with localized flashmessage
413 *
414 * @param array $brokenLinksMarker
415 * @return array $brokenLinksMarker['NO_BROKEN_LINKS] replaced with flashmessage
416 */
417 protected function getNoBrokenLinkMessage(array $brokenLinksMarker) {
418 $brokenLinksMarker['LIST_HEADER'] = $this->doc->sectionHeader($this->getLanguageService()->getLL('list.header'));
419 /** @var $message FlashMessage */
420 $message = GeneralUtility::makeInstance(
421 FlashMessage::class,
422 $this->getLanguageService()->getLL('list.no.broken.links'),
423 $this->getLanguageService()->getLL('list.no.broken.links.title'),
424 FlashMessage::OK
425 );
426 $brokenLinksMarker['NO_BROKEN_LINKS'] = $message->render();
427 return $brokenLinksMarker;
428 }
429
430 /**
431 * Displays the table header of the table with the broken links
432 *
433 * @return string Code of content
434 */
435 protected function startTable() {
436 // Listing head
437 $makerTableHead = array(
438 'tablehead_path' => $this->getLanguageService()->getLL('list.tableHead.path'),
439 'tablehead_element' => $this->getLanguageService()->getLL('list.tableHead.element'),
440 'tablehead_headlink' => $this->getLanguageService()->getLL('list.tableHead.headlink'),
441 'tablehead_linktarget' => $this->getLanguageService()->getLL('list.tableHead.linktarget'),
442 'tablehead_linkmessage' => $this->getLanguageService()->getLL('list.tableHead.linkmessage'),
443 'tablehead_lastcheck' => $this->getLanguageService()->getLL('list.tableHead.lastCheck'),
444 );
445
446 // Add CSH to the header of each column
447 foreach ($makerTableHead as $column => $label) {
448 $makerTableHead[$column] = BackendUtility::wrapInHelp('linkvalidator', $column, $label);
449 }
450 // Add section header
451 $makerTableHead['list_header'] = $this->doc->sectionHeader($this->getLanguageService()->getLL('list.header'));
452 return $makerTableHead;
453 }
454
455 /**
456 * Displays one line of the broken links table
457 *
458 * @param string $table Name of database table
459 * @param array $row Record row to be processed
460 * @param array $brokenLinksItemTemplate Markup of the template to be used
461 * @return string HTML of the rendered row
462 */
463 protected function renderTableRow($table, array $row, $brokenLinksItemTemplate) {
464 /** @var IconFactory $iconFactory */
465 $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
466
467 $markerArray = array();
468 $fieldName = '';
469 // Restore the linktype object
470 $hookObj = $this->hookObjectsArr[$row['link_type']];
471
472 // Construct link to edit the content element
473 $requestUri = GeneralUtility::getIndpEnv('REQUEST_URI') .
474 '&id=' . $this->pObj->id .
475 '&search_levels=' . $this->searchLevel;
476 $actionLink = '<a href="#" onclick="';
477 $actionLink .= htmlspecialchars(BackendUtility::editOnClick(
478 '&edit[' . $table . '][' . $row['record_uid'] . ']=edit',
479 '',
480 $requestUri
481 ));
482 $actionLink .= '" title="' . $this->getLanguageService()->getLL('list.edit') . '">';
483 $actionLink .= $iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL);
484 $actionLink .= '</a>';
485 $elementHeadline = $row['headline'];
486 if (empty($elementHeadline)) {
487 $elementHeadline = '<i>' . $this->getLanguageService()->getLL('list.no.headline') . '</i>';
488 }
489 // Get the language label for the field from TCA
490 if ($GLOBALS['TCA'][$table]['columns'][$row['field']]['label']) {
491 $fieldName = $this->getLanguageService()->sL($GLOBALS['TCA'][$table]['columns'][$row['field']]['label']);
492 // Crop colon from end if present
493 if (substr($fieldName, '-1', '1') === ':') {
494 $fieldName = substr($fieldName, '0', strlen($fieldName) - 1);
495 }
496 }
497 // Fallback, if there is no label
498 $fieldName = !empty($fieldName) ? $fieldName : $row['field'];
499 // column "Element"
500 $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
501 $element = '<span title="' . htmlspecialchars($table . ':' . $row['record_uid']) . '">' . $iconFactory->getIconForRecord($table, $row, Icon::SIZE_SMALL)->render() . '</span>';
502 $element .= $elementHeadline;
503 $element .= ' ' . sprintf($this->getLanguageService()->getLL('list.field'), $fieldName);
504 $markerArray['actionlink'] = $actionLink;
505 $markerArray['path'] = BackendUtility::getRecordPath($row['record_pid'], '', 0, 0);
506 $markerArray['element'] = $element;
507 $markerArray['headlink'] = $row['link_title'];
508 $markerArray['linktarget'] = $hookObj->getBrokenUrl($row);
509 $response = unserialize($row['url_response']);
510 if ($response['valid']) {
511 $linkMessage = '<span class="valid">' . $this->getLanguageService()->getLL('list.msg.ok') . '</span>';
512 } else {
513 $linkMessage = '<span class="error">' . $hookObj->getErrorMessage($response['errorParams']) . '</span>';
514 }
515 $markerArray['linkmessage'] = $linkMessage;
516
517 $lastRunDate = date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'], $row['last_check']);
518 $lastRunTime = date($GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'], $row['last_check']);
519 $markerArray['lastcheck'] = sprintf($this->getLanguageService()->getLL('list.msg.lastRun'), $lastRunDate, $lastRunTime);
520
521 // Return the table html code as string
522 return $this->templateService->substituteMarkerArray($brokenLinksItemTemplate, $markerArray, '###|###', TRUE, TRUE);
523 }
524
525 /**
526 * Builds the checkboxes out of the hooks array
527 *
528 * @param array $brokenLinkOverView Array of broken links information
529 * @param string $prefix
530 * @return string code content
531 */
532 protected function getCheckOptions(array $brokenLinkOverView, $prefix = '') {
533 $markerArray = array();
534 if (!empty($prefix)) {
535 $additionalAttr = ' class="' . $prefix . '"';
536 } else {
537 $additionalAttr = ' class="refresh"';
538 }
539 $checkOptionsTemplate = $this->templateService->getSubpart($this->doc->moduleTemplate, '###CHECKOPTIONS_SECTION###');
540 $hookSectionTemplate = $this->templateService->getSubpart($checkOptionsTemplate, '###HOOK_SECTION###');
541 $markerArray['statistics_header'] = $this->doc->sectionHeader($this->getLanguageService()->getLL('report.statistics.header'));
542 $markerArray['total_count_label'] = BackendUtility::wrapInHelp('linkvalidator', 'checkboxes', $this->getLanguageService()->getLL('overviews.nbtotal'));
543 $markerArray['total_count'] = $brokenLinkOverView['brokenlinkCount'] ?: '0';
544
545 $linktypes = GeneralUtility::trimExplode(',', $this->modTS['linktypes'], TRUE);
546 $hookSectionContent = '';
547 if (is_array($linktypes)) {
548 if (
549 !empty($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'])
550 && is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'])
551 ) {
552 foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'] as $type => $value) {
553 if (in_array($type, $linktypes)) {
554 $hookSectionMarker = array(
555 'count' => $brokenLinkOverView[$type] ?: '0',
556 );
557
558 $translation = $this->getLanguageService()->getLL('hooks.' . $type) ?: $type;
559 $hookSectionMarker['option'] = '<input type="checkbox"' . $additionalAttr . ' id="' . $prefix . 'SET_' . $type . '" name="' . $prefix
560 . 'SET[' . $type . ']" value="1"' . ($this->pObj->MOD_SETTINGS[$type] ? ' checked="checked"' : '') . '/>' . '<label for="'
561 . $prefix . 'SET_' . $type . '">&nbsp;' . htmlspecialchars($translation) . '</label>';
562
563 $hookSectionContent .= $this->templateService->substituteMarkerArray(
564 $hookSectionTemplate,
565 $hookSectionMarker, '###|###',
566 TRUE,
567 TRUE
568 );
569 }
570 }
571 }
572 }
573 $checkOptionsTemplate = $this->templateService->substituteSubpart(
574 $checkOptionsTemplate,
575 '###HOOK_SECTION###',
576 $hookSectionContent
577 );
578 return $this->templateService->substituteMarkerArray($checkOptionsTemplate, $markerArray, '###|###', TRUE, TRUE);
579 }
580
581 /**
582 * Gets the buttons that shall be rendered in the docHeader
583 *
584 * @return array Available buttons for the docHeader
585 */
586 protected function getDocHeaderButtons() {
587 return array(
588 'csh' => BackendUtility::cshItem('_MOD_web_func', ''),
589 'shortcut' => $this->getShortcutButton(),
590 'save' => ''
591 );
592 }
593
594 /**
595 * Gets the button to set a new shortcut in the backend (if current user is allowed to).
596 *
597 * @return string HTML representation of the shortcut button
598 */
599 protected function getShortcutButton() {
600 $result = '';
601 if ($this->getBackendUser()->mayMakeShortcut()) {
602 $result = $this->doc->makeShortcutIcon('', 'function', $this->pObj->MCONF['name']);
603 }
604 return $result;
605 }
606
607 /**
608 * Gets the filled markers that are used in the HTML template
609 *
610 * @return array The filled marker array
611 */
612 protected function getTemplateMarkers() {
613 return array(
614 'FUNC_TITLE' => $this->getLanguageService()->getLL('report.func.title'),
615 'CHECKOPTIONS_TITLE' => $this->getLanguageService()->getLL('report.statistics.header'),
616 'FUNC_MENU' => $this->getLevelSelector(),
617 'CONTENT' => $this->content,
618 'CHECKOPTIONS' => $this->checkOptionsHtml,
619 'ID' => '<input type="hidden" name="id" value="' . $this->pObj->id . '" />',
620 'REFRESH' => '<input type="submit" class="btn btn-default" name="refreshLinkList" id="refreshLinkList" value="' . $this->getLanguageService()->getLL('label_refresh') . '" />',
621 'UPDATE' => '',
622 );
623 }
624
625 /**
626 * Gets the filled markers that are used in the HTML template
627 *
628 * @return array The filled marker array
629 */
630 protected function getTemplateMarkersCheck() {
631 return array(
632 'FUNC_TITLE' => $this->getLanguageService()->getLL('checklinks.func.title'),
633 'CHECKOPTIONS_TITLE' => $this->getLanguageService()->getLL('checklinks.statistics.header'),
634 'FUNC_MENU' => $this->getLevelSelector(),
635 'CONTENT' => '',
636 'CHECKOPTIONS' => $this->checkOptionsHtmlCheck,
637 'ID' => '<input type="hidden" name="id" value="' . $this->pObj->id . '" />',
638 'REFRESH' => '',
639 'UPDATE' => '<input type="submit" class="btn btn-default" name="updateLinkList" id="updateLinkList" value="' . $this->getLanguageService()->getLL('label_update') . '"/>',
640 );
641 }
642
643 /**
644 * Determines whether the current user is an admin
645 *
646 * @return bool Whether the current user is admin
647 */
648 protected function isCurrentUserAdmin() {
649 return $this->getBackendUser()->isAdmin();
650 }
651
652 /**
653 * Returns LanguageService
654 *
655 * @return \TYPO3\CMS\Lang\LanguageService
656 */
657 protected function getLanguageService() {
658 return $GLOBALS['LANG'];
659 }
660
661 /**
662 * Returns the current BE user.
663 *
664 * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
665 */
666 protected function getBackendUser() {
667 return $GLOBALS['BE_USER'];
668 }
669
670 /**
671 * @return \TYPO3\CMS\Core\Database\DatabaseConnection
672 */
673 protected function getDatabaseConnection() {
674 return $GLOBALS['TYPO3_DB'];
675 }
676
677 }