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