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