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