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