Fixed regression in linkvalidator
[Packages/TYPO3.CMS.git] / typo3 / sysext / linkvalidator / modfuncreport / class.tx_linkvalidator_modfuncreport.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2005 - 2010 Jochen Rieger (j.rieger@connecta.ag)
6 * (c) 2010 - 2011 Michael Miousse (michael.miousse@infoglobe.ca)
7 * All rights reserved
8 *
9 * This script is part of the TYPO3 project. The TYPO3 project is
10 * free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * The GNU General Public License can be found at
16 * http://www.gnu.org/copyleft/gpl.html.
17 *
18 * This script is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * This copyright notice MUST APPEAR in all copies of the script!
24 ***************************************************************/
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 * @package TYPO3
32 * @subpackage linkvalidator
33 */
34 class tx_linkvalidator_ModFuncReport extends t3lib_extobjbase {
35
36 /**
37 * @var template
38 */
39 public $doc;
40
41 /**
42 * @var string
43 */
44 protected $relativePath;
45
46 /**
47 * Information about the current page record.
48 *
49 * @var array
50 */
51 protected $pageRecord = array();
52
53 /**
54 * Information, if the module is accessible for the current user or not.
55 *
56 * @var boolean
57 */
58 protected $isAccessibleForCurrentUser = FALSE;
59
60 /**
61 * Depth for the recursivity of the link validation.
62 *
63 * @var integer
64 */
65 protected $searchLevel;
66
67 /**
68 * Link validation class.
69 *
70 * @var tx_linkvalidator_Processor
71 */
72 protected $processor;
73
74 /**
75 * TSconfig of the current module.
76 *
77 * @var array
78 */
79 protected $modTS = array();
80
81 /**
82 * List of available link types to check defined in the TSconfig.
83 *
84 * @var array
85 */
86 protected $availableOptions = array();
87
88 /**
89 * List of link types currently chosen in the Statistics table.
90 * Used to show broken links of these types only.
91 *
92 * @var array
93 */
94 protected $checkOpt = array();
95
96 /**
97 * Html for the button "Check Links".
98 *
99 * @var string
100 */
101 protected $updateListHtml;
102
103 /**
104 * Html for the button "Refresh Display".
105 *
106 * @var string
107 */
108 protected $refreshListHtml;
109
110 /**
111 * Html for the Statistics table with the checkboxes of the link types and the numbers of broken links for Report tab.
112 *
113 * @var string
114 */
115 protected $checkOptHtml;
116
117
118 /**
119 * Html for the Statistics table with the checkboxes of the link types and the numbers of broken links for Check links tab.
120 *
121 * @var string
122 */
123 protected $checkOptHtmlCheck;
124
125 /**
126 * Complete content (html) to be displayed.
127 *
128 * @var string
129 */
130 protected $content;
131
132 /**
133 * Main method of modfuncreport
134 *
135 * @return string Module content
136 */
137 public function main() {
138 $GLOBALS['LANG']->includeLLFile('EXT:linkvalidator/modfuncreport/locallang.xml');
139
140 $this->searchLevel = t3lib_div::_GP('search_levels');
141
142 if (isset($this->pObj->id)) {
143 $this->modTS = t3lib_BEfunc::getModTSconfig($this->pObj->id, 'mod.linkvalidator');
144 $this->modTS = $this->modTS['properties'];
145 }
146 $update = t3lib_div::_GP('updateLinkList');
147 $prefix = '';
148 if (!empty($update)) {
149 $prefix = 'check';
150 }
151 $set = t3lib_div::_GP($prefix . 'SET');
152 $this->pObj->handleExternalFunctionValue();
153
154 if(isset($this->searchLevel)) {
155 $this->pObj->MOD_SETTINGS['searchlevel'] = $this->searchLevel;
156 } else {
157 $this->searchLevel = $this->pObj->MOD_SETTINGS['searchlevel'];
158 }
159
160 if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'])) {
161 foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'] as $linkType => $value) {
162 // Compile list of all available types. Used for checking with button "Check Links".
163 if (strpos($this->modTS['linktypes'], $linkType) !== FALSE) {
164 $this->availableOptions[$linkType] = 1;
165 }
166 // Compile list of types currently selected by the checkboxes.
167 if (($this->pObj->MOD_SETTINGS[$linkType] && empty($set)) || $set[$linkType]) {
168 $this->checkOpt[$linkType] = 1;
169 $this->pObj->MOD_SETTINGS[$linkType] = 1;
170 } else {
171 $this->pObj->MOD_SETTINGS[$linkType] = 0;
172 unset($this->checkOpt[$linkType]);
173 }
174 }
175 }
176 $GLOBALS['BE_USER']->pushModuleData('web_info', $this->pObj->MOD_SETTINGS);
177
178 $this->initialize();
179 // Setting up the context sensitive menu:
180 $this->resPath = $this->doc->backPath . t3lib_extMgm::extRelPath('linkvalidator') . 'res/';
181 /** @var t3lib_pageRenderer $pageRenderer */
182 $this->pageRenderer = $this->doc->getPageRenderer();
183
184 // Localization
185 $this->pageRenderer->addInlineLanguageLabelFile(t3lib_extMgm::extPath('linkvalidator', 'modfuncreport/locallang.xml'));
186
187 // Add JS
188 $this->pageRenderer->addJsFile($this->doc->backPath . '../t3lib/js/extjs/ux/Ext.ux.FitToParent.js');
189 $this->pageRenderer->addJsFile($this->doc->backPath . '../t3lib/js/extjs/ux/flashmessages.js');
190 $this->pageRenderer->addJsFile($this->doc->backPath . 'js/extjs/iframepanel.js');
191
192 if ($this->modTS['showCheckLinkTab'] == 1) {
193 $this->updateListHtml = '<input type="submit" name="updateLinkList" value="' . $GLOBALS['LANG']->getLL('label_update') . '"/>';
194 }
195
196 $this->refreshListHtml = '<input type="submit" name="refreshLinkList" value="' . $GLOBALS['LANG']->getLL('label_refresh') . '"/>';
197
198 $this->processor = t3lib_div::makeInstance('tx_linkvalidator_Processor');
199 $this->updateBrokenLinks();
200
201 $brokenLinkOverView = $this->processor->getLinkCounts($this->pObj->id);
202 $this->checkOptHtml = $this->getCheckOptions($brokenLinkOverView);
203 $this->checkOptHtmlCheck = $this->getCheckOptions($brokenLinkOverView, 'check');
204 $this->createTabs();
205 return '<div id="linkvalidator-modfuncreport"></div>';
206 }
207
208 /**
209 * Create TabPanel to split the report and the checklinks functions
210 *
211 * @return void
212 */
213 protected function createTabs() {
214 $panelCheck = '';
215 if ($this->modTS['showCheckLinkTab'] == 1) {
216 $panelCheck = '{
217
218 title: TYPO3.lang.CheckLink,
219 html: ' . json_encode($this->flush()) . ',
220 }, ';
221 }
222
223 $this->render();
224 $js = 'var panel = new Ext.TabPanel( {
225 renderTo : "linkvalidator-modfuncreport",
226 id: "linkvalidator-main",
227 plain: true,
228 activeTab: 0,
229 autoScroll: true,
230 bodyStyle: "padding:10px;",
231 plugins: [new Ext.ux.plugins.FitToParent()],
232 items : [
233 {
234 title: TYPO3.lang.Report,
235 html: ' . json_encode($this->flush(TRUE)) . '
236 },
237 ' . $panelCheck . '
238 ]
239
240 });';
241 $this->pageRenderer->addExtOnReadyCode($js);
242 }
243
244 /**
245 * Initializes the menu array internally.
246 *
247 * @return array Module menu
248 */
249 public function modMenu() {
250 $modMenu = array (
251 'checkAllLink' => 0,
252 );
253
254 if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'])) {
255 foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'] as $linkType => $value) {
256 $modMenu[$linkType] = 1;
257 }
258 }
259
260 return $modMenu;
261 }
262
263
264 /**
265 * Initializes the Module.
266 *
267 * @return void
268 */
269 protected function initialize() {
270 if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'])) {
271 foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'] as $linkType => $classRef) {
272 $this->hookObjectsArr[$linkType] = &t3lib_div::getUserObj($classRef);
273 }
274 }
275
276 $this->doc = t3lib_div::makeInstance('template');
277 $this->doc->setModuleTemplate(t3lib_extMgm::extPath('linkvalidator') . 'modfuncreport/mod_template.html');
278 $this->doc->backPath = $GLOBALS['BACK_PATH'];
279
280 $this->relativePath = t3lib_extMgm::extRelPath('linkvalidator');
281 $this->pageRecord = t3lib_BEfunc::readPageAccess($this->pObj->id, $this->perms_clause);
282
283 $this->isAccessibleForCurrentUser = FALSE;
284 if ($this->pObj->id && is_array($this->pageRecord) || !$this->pObj->id && $this->isCurrentUserAdmin()) {
285 $this->isAccessibleForCurrentUser = TRUE;
286 }
287
288 $this->loadHeaderData();
289
290 // Don't access in workspace
291 if ($GLOBALS['BE_USER']->workspace !== 0) {
292 $this->isAccessibleForCurrentUser = FALSE;
293 }
294 }
295
296
297 /**
298 * Updates the table of stored broken links.
299 *
300 * @return void
301 */
302 protected function updateBrokenLinks() {
303 $searchFields = array();
304
305 // get the searchFields from TypoScript
306 foreach ($this->modTS['searchFields.'] as $table => $fieldList) {
307 $fields = t3lib_div::trimExplode(',', $fieldList);
308 foreach ($fields as $field) {
309 if (!$searchFields || !is_array($searchFields[$table]) || array_search($field, $searchFields[$table]) == FALSE) {
310 $searchFields[$table][] = $field;
311 }
312 }
313 }
314 // get children pages
315 $pageList = $this->processor->extGetTreeList(
316 $this->pObj->id,
317 $this->searchLevel,
318 0,
319 $GLOBALS['BE_USER']->getPagePermsClause(1)
320 );
321 $pageList .= $this->pObj->id;
322
323 $this->processor->init($searchFields, $pageList);
324
325 // check if button press
326 $update = t3lib_div::_GP('updateLinkList');
327
328 if (!empty($update)) {
329 $this->processor->getLinkStatistics($this->checkOpt, $this->modTS['checkhidden']);
330 }
331 }
332
333
334 /**
335 * Renders the content of the module.
336 *
337 * @return void
338 */
339 protected function render() {
340 if ($this->isAccessibleForCurrentUser) {
341 $this->content = $this->renderBrokenLinksTable();
342 } else {
343 // If no access or if ID == zero
344 $message = t3lib_div::makeInstance(
345 't3lib_FlashMessage',
346 $GLOBALS['LANG']->getLL('no.access'),
347 $GLOBALS['LANG']->getLL('no.access.title'),
348 t3lib_FlashMessage::ERROR
349 );
350 $this->content .= $message->render();
351 }
352 }
353
354
355 /**
356 * Flushes the rendered content to the browser.
357 *
358 * @param boolean $form
359 * @return void
360 */
361 protected function flush($form = FALSE) {
362 $content = $this->doc->moduleBody(
363 $this->pageRecord,
364 $this->getDocHeaderButtons(),
365 ($form) ? $this->getTemplateMarkers(): $this->getTemplateMarkersCheck()
366 );
367
368 return $content;
369 }
370
371
372 /**
373 * Builds the selector for the level of pages to search.
374 *
375 * @return string Html code of that selector
376 */
377 protected function getLevelSelector() {
378 // Make level selector:
379 $opt = array();
380 $parts = array(
381 0 => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.depth_0'),
382 1 => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.depth_1'),
383 2 => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.depth_2'),
384 3 => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.depth_3'),
385 999 => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.depth_infi'),
386 );
387
388 foreach ($parts as $kv => $label) {
389 $opt[] = '<option value="' . $kv . '"' . ($kv == intval($this->searchLevel) ? ' selected="selected"' : '') . '>' . htmlspecialchars($label) . '</option>';
390 }
391 $lMenu = '<select name="search_levels">' . implode('', $opt) . '</select>';
392 return $lMenu;
393 }
394
395 /**
396 * Displays the table of broken links or a note if there were no broken links.
397 *
398 * @return html Content of the table or of the note
399 */
400 protected function renderBrokenLinksTable() {
401 $items = $brokenLinksMarker = array();
402 $brokenLinkItems = $brokenLinksTemplate = '';
403 $keyOpt = array();
404
405 if (is_array($this->checkOpt)) {
406 $keyOpt = array_keys($this->checkOpt);
407 }
408
409 $pageList = $this->processor->extGetTreeList(
410 $this->pObj->id,
411 $this->searchLevel,
412 0,
413 $GLOBALS['BE_USER']->getPagePermsClause(1)
414 );
415 $pageList .= $this->pObj->id;
416
417 if (($res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
418 '*',
419 'tx_linkvalidator_link',
420 'record_pid in (' . $pageList . ') and link_type in (\'' . implode("','", $keyOpt) . '\')',
421 '',
422 'record_uid ASC, uid ASC')
423 )) {
424 // Display table with broken links
425 if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) > 0) {
426 $brokenLinksTemplate = t3lib_parsehtml::getSubpart($this->doc->moduleTemplate, '###BROKENLINKS_CONTENT###');
427
428 $brokenLinksItemTemplate = t3lib_parsehtml::getSubpart($this->doc->moduleTemplate, '###BROKENLINKS_ITEM###');
429
430 // Table header
431 $brokenLinksMarker = $this->startTable();
432
433 // Table rows containing the broken links
434 while (($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))) {
435 $items[] = $this->renderTableRow($row['table_name'], $row, $brokenLinksItemTemplate);
436 }
437 $brokenLinkItems = implode(chr(10), $items);
438
439 // Display note that there are no broken links to display
440 } else {
441 $brokenLinksTemplate = t3lib_parsehtml::getSubpart($this->doc->moduleTemplate, '###NOBROKENLINKS_CONTENT###');
442
443 $brokenLinksMarker['LIST_HEADER'] = $this->doc->sectionHeader($GLOBALS['LANG']->getLL('list.header'));
444 $message = t3lib_div::makeInstance(
445 't3lib_FlashMessage',
446 $GLOBALS['LANG']->getLL('list.no.broken.links'),
447 $GLOBALS['LANG']->getLL('list.no.broken.links.title'),
448 t3lib_FlashMessage::OK
449 );
450 $brokenLinksMarker['NO_BROKEN_LINKS'] = $message->render();
451 }
452 }
453 $brokenLinksTemplate = t3lib_parsehtml::substituteMarkerArray($brokenLinksTemplate, $brokenLinksMarker, '###|###', TRUE);
454
455 $content = t3lib_parsehtml::substituteSubpart($brokenLinksTemplate, '###BROKENLINKS_ITEM', $brokenLinkItems);
456
457 return $content;
458 }
459
460
461
462 /**
463 * Displays the table header of the table with the broken links.
464 *
465 * @return string Code of content
466 */
467 protected function startTable() {
468
469 // Listing head
470 $makerTableHead = array();
471
472 $makerTableHead['tablehead_path'] = $GLOBALS['LANG']->getLL('list.tableHead.path');
473 $makerTableHead['tablehead_element'] = $GLOBALS['LANG']->getLL('list.tableHead.element');
474 $makerTableHead['tablehead_headlink'] = $GLOBALS['LANG']->getLL('list.tableHead.headlink');
475 $makerTableHead['tablehead_linktarget'] = $GLOBALS['LANG']->getLL('list.tableHead.linktarget');
476 $makerTableHead['tablehead_linkmessage'] = $GLOBALS['LANG']->getLL('list.tableHead.linkmessage');
477 $makerTableHead['tablehead_lastcheck'] = $GLOBALS['LANG']->getLL('list.tableHead.lastCheck');
478
479 // Add CSH to the header of each column
480 foreach($makerTableHead as $column => $label) {
481 $label = t3lib_BEfunc::wrapInHelp('linkvalidator', $column, $label);
482 $makerTableHead[$column] = $label;
483 }
484
485 // Add section header
486 $makerTableHead['list_header'] = $this->doc->sectionHeader($GLOBALS['LANG']->getLL('list.header'));
487
488 return $makerTableHead;
489 }
490
491
492 /**
493 * Displays one line of the broken links table.
494 *
495 * @param string $table Name of database table
496 * @param array $row Record row to be processed
497 * @param array $brokenLinksItemTemplate Markup of the template to be used
498 * @return string HTML of the rendered row
499 */
500 protected function renderTableRow($table, array $row, $brokenLinksItemTemplate) {
501 $markerArray = array();
502 if (is_array($row) && !empty($row['link_type'])) {
503 if (($hookObj = $this->hookObjectsArr[$row['link_type']])) {
504 $brokenUrl = $hookObj->getBrokenUrl($row);
505 }
506 }
507
508 $params = '&edit[' . $table . '][' . $row['record_uid'] . ']=edit';
509 $actionLinks = '<a href="#" onclick="' .
510 t3lib_BEfunc::editOnClick(
511 $params,
512 $GLOBALS['BACK_PATH'],
513 t3lib_div::getIndpEnv('REQUEST_URI') . '?id=' . $this->pObj->id . '&search_levels=' . $this->searchLevel
514 ) . '"' .
515 ' title="' . $GLOBALS['LANG']->getLL('list.edit') . '">' .
516 t3lib_iconWorks::getSpriteIcon('actions-document-open') . '</a>';
517
518 $elementHeadline = $row['headline'];
519 if (empty($elementHeadline)) {
520 $elementHeadline = '<i>' . $GLOBALS['LANG']->getLL('list.no.headline') . '</i>';
521 }
522
523 // Get the language label for the field from TCA
524 if ($GLOBALS['TCA'][$table]['columns'][$row['field']]['label']) {
525 $fieldName = $GLOBALS['TCA'][$table]['columns'][$row['field']]['label'];
526 $fieldName = $GLOBALS['LANG']->sL($fieldName);
527 // Crop colon from end if present.
528 if (substr($fieldName, '-1', '1') === ':') {
529 $fieldName = substr($fieldName, '0', strlen($fieldName)-1);
530 }
531 }
532 // Fallback, if there is no label
533 $fieldName = $fieldName ? $fieldName : $row['field'];
534
535 // column "Element"
536 $element = t3lib_iconWorks::getSpriteIconForRecord($table, $row, array('title' => $table . ':' . $row['record_uid']));
537 $element .= $elementHeadline;
538 $element .= ' ' . sprintf($GLOBALS['LANG']->getLL('list.field'), $fieldName);
539
540 $markerArray['actionlink'] = $actionLinks;
541 $markerArray['path'] = t3lib_BEfunc::getRecordPath($row['record_pid'], '', 0, 0);
542 $markerArray['element'] = $element;
543 $markerArray['headlink'] = $row['link_title'];
544 $markerArray['linktarget'] = $brokenUrl;
545
546 $response = unserialize($row['url_response']);
547 if ($response['valid']) {
548 $linkMessage = '<span style="color: green;">' . $GLOBALS['LANG']->getLL('list.msg.ok') . '</span>';
549 } else {
550 $linkMessage = '<span style="color: red;">' . $hookObj->getErrorMessage($response['errorParams']) . '</span>';
551 }
552 $markerArray['linkmessage'] = $linkMessage;
553
554 $lastRunDate = date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'], $row['last_check']);
555 $lastRunTime = date($GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'], $row['last_check']);
556 $message = sprintf($GLOBALS['LANG']->getLL('list.msg.lastRun'), $lastRunDate, $lastRunTime);
557 $markerArray['lastcheck'] = $message;
558
559 // Return the table html code as string
560 return t3lib_parsehtml::substituteMarkerArray($brokenLinksItemTemplate, $markerArray, '###|###', TRUE, TRUE);
561 }
562
563
564 /**
565 * Builds the checkboxes out of the hooks array.
566 *
567 * @param array $brokenLinkOverView array of broken links information
568 * @return string code content
569 */
570 protected function getCheckOptions(array $brokenLinkOverView, $prefix = '') {
571 $markerArray = array();
572
573 $checkOptionsTemplate = t3lib_parsehtml::getSubpart($this->doc->moduleTemplate, '###CHECKOPTIONS_SECTION###');
574
575 $hookSectionContent = '';
576 $hookSectionTemplate = t3lib_parsehtml::getSubpart($checkOptionsTemplate, '###HOOK_SECTION###');
577
578 $markerArray['statistics_header'] = $this->doc->sectionHeader($GLOBALS['LANG']->getLL('report.statistics.header'));
579
580 $totalCountLabel = $GLOBALS['LANG']->getLL('overviews.nbtotal');
581 $totalCountLabel = t3lib_BEfunc::wrapInHelp('linkvalidator', 'checkboxes', $totalCountLabel);
582 $markerArray['total_count_label'] = $totalCountLabel;
583
584 if (empty($brokenLinkOverView['brokenlinkCount'])) {
585 $markerArray['total_count'] = '0';
586 } else {
587 $markerArray['total_count'] = $brokenLinkOverView['brokenlinkCount'];
588 }
589
590 $linktypes = t3lib_div::trimExplode(',', $this->modTS['linktypes'], 1);
591 $hookSectionContent = '';
592
593 if (is_array($linktypes)) {
594 if (!empty($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'])
595 && is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'])
596 ) {
597 foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'] as $type => $value) {
598 if (in_array($type, $linktypes)) {
599 $hookSectionMarker = array();
600 if (empty($brokenLinkOverView[$type])) {
601 $hookSectionMarker['count'] = '0';
602 } else {
603 $hookSectionMarker['count'] = $brokenLinkOverView[$type];
604 }
605 $translation = $GLOBALS['LANG']->getLL('hooks.' . $type);
606 $translation = $translation ? $translation : $type;
607 $option = '<input type="checkbox" id="' . $prefix . 'SET[' . $type . ']" name="' . $prefix . 'SET[' . $type . ']" value="1"' . ($this->pObj->MOD_SETTINGS[$type] ? ' checked="checked"' : '') .
608 '/>'.'<label for="' . $prefix . 'SET[' . $type . ']">' . htmlspecialchars( $translation ) . '</label>';
609 $hookSectionMarker['option'] = $option;
610 $hookSectionContent .= t3lib_parsehtml::substituteMarkerArray($hookSectionTemplate, $hookSectionMarker, '###|###', TRUE, TRUE);
611 }
612 }
613 }
614 }
615
616 $checkOptionsTemplate = t3lib_parsehtml::substituteSubpart($checkOptionsTemplate, '###HOOK_SECTION###', $hookSectionContent);
617
618 return t3lib_parsehtml::substituteMarkerArray($checkOptionsTemplate, $markerArray, '###|###', TRUE, TRUE);
619 }
620
621
622 /**
623 * Loads data in the HTML head section (e.g. JavaScript or stylesheet information).
624 *
625 * @return void
626 */
627 protected function loadHeaderData() {
628 $this->doc->addStyleSheet('linkvalidator', $this->relativePath . 'res/linkvalidator.css', 'linkvalidator');
629 $this->doc->getPageRenderer()->addJsFile($this->doc->backPath . '../t3lib/js/extjs/ux/Ext.ux.FitToParent.js');
630 }
631
632
633 /**
634 * Gets the buttons that shall be rendered in the docHeader.
635 *
636 * @return array Available buttons for the docHeader
637 */
638 protected function getDocHeaderButtons() {
639 $buttons = array(
640 'csh' => t3lib_BEfunc::cshItem('_MOD_web_func', '', $GLOBALS['BACK_PATH']),
641 'shortcut' => $this->getShortcutButton(),
642 'save' => ''
643 );
644 return $buttons;
645 }
646
647
648 /**
649 * Gets the button to set a new shortcut in the backend (if current user is allowed to).
650 *
651 * @return string HTML representiation of the shortcut button
652 */
653 protected function getShortcutButton() {
654 $result = '';
655 if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
656 $result = $this->doc->makeShortcutIcon('', 'function', $this->MCONF['name']);
657 }
658 return $result;
659 }
660
661
662 /**
663 * Gets the filled markers that are used in the HTML template.
664 *
665 * @return array The filled marker array
666 */
667 protected function getTemplateMarkers() {
668 $markers = array(
669 'FUNC_TITLE' => $GLOBALS['LANG']->getLL('report.func.title'),
670 'CHECKOPTIONS_TITLE' => $GLOBALS['LANG']->getLL('report.statistics.header'),
671 'FUNC_MENU' => $this->getLevelSelector(),
672 'CONTENT' => $this->content,
673 'CHECKALLLINK' => $this->checkAllHtml,
674 'CHECKOPTIONS' => $this->checkOptHtml,
675 'ID' => '<input type="hidden" name="id" value="' . $this->pObj->id . '" />',
676 'REFRESH' => $this->refreshListHtml,
677 'UPDATE' => ''
678 );
679
680 return $markers;
681 }
682
683 /**
684 * Gets the filled markers that are used in the HTML template.
685 *
686 * @return array The filled marker array
687 */
688 protected function getTemplateMarkersCheck() {
689 $markers = array(
690 'FUNC_TITLE' =>$GLOBALS['LANG']->getLL('checklinks.func.title'),
691 'CHECKOPTIONS_TITLE' =>$GLOBALS['LANG']->getLL('checklinks.statistics.header'),
692 'FUNC_MENU' => $this->getLevelSelector(),
693 'CONTENT' => '',
694 'CHECKALLLINK' => $this->checkAllHtml,
695 'CHECKOPTIONS' => $this->checkOptHtmlCheck,
696 'ID' => '<input type="hidden" name="id" value="' . $this->pObj->id . '" />',
697 'REFRESH' => '',
698 'UPDATE' => $this->updateListHtml
699 );
700
701 return $markers;
702 }
703
704
705 /**
706 * Determines whether the current user is an admin.
707 *
708 * @return boolean Whether the current user is admin
709 */
710 protected function isCurrentUserAdmin() {
711 return ((bool) $GLOBALS['BE_USER']->user['admin']);
712 }
713 }
714
715 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/linkvalidator/modfuncreport/class.tx_linkvalidator_modfuncreport.php'])) {
716 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/linkvalidator/modfuncreport/class.tx_linkvalidator_modfuncreport.php']);
717 }
718
719 ?>