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