[TASK] Fix CGL violations against DoubleQuoteUsage
[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 recursive traversal of pages for 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
112 * and the numbers of broken links for report tab
113 *
114 * @var string
115 */
116 protected $checkOptHtml;
117
118
119 /**
120 * Html for the statistics table with the checkboxes of the link types
121 * and the numbers of broken links for check links tab
122 *
123 * @var string
124 */
125 protected $checkOptHtmlCheck;
126
127 /**
128 * Complete content (html) to be displayed
129 *
130 * @var string
131 */
132 protected $content;
133
134 /** @var t3lib_pageRenderer $pageRenderer */
135 protected $pageRenderer;
136
137 /** @var string $resPath Path to "linkvalidator/res/" to be used in pageRenderer */
138 protected $resPath = '';
139
140 /** @var tx_linkvalidator_linktype_Interface[] $hookObjectsArr */
141 protected $hookObjectsArr = array();
142
143 /** @var string $checkAllHtml */
144 protected $checkAllHtml = '';
145
146 /**
147 * Main method of modfuncreport
148 *
149 * @return string Module content
150 */
151 public function main() {
152 $GLOBALS['LANG']->includeLLFile('EXT:linkvalidator/modfuncreport/locallang.xml');
153
154 $this->searchLevel = t3lib_div::_GP('search_levels');
155
156 if (isset($this->pObj->id)) {
157 $this->modTS = t3lib_BEfunc::getModTSconfig($this->pObj->id, 'mod.linkvalidator');
158 $this->modTS = $this->modTS['properties'];
159 }
160 $update = t3lib_div::_GP('updateLinkList');
161 $prefix = '';
162 if (!empty($update)) {
163 $prefix = 'check';
164 }
165 $set = t3lib_div::_GP($prefix . 'SET');
166 $this->pObj->handleExternalFunctionValue();
167
168 if (isset($this->searchLevel)) {
169 $this->pObj->MOD_SETTINGS['searchlevel'] = $this->searchLevel;
170 } else {
171 $this->searchLevel = $this->pObj->MOD_SETTINGS['searchlevel'];
172 }
173
174 if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'])) {
175 foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'] as $linkType => $value) {
176 // Compile list of all available types. Used for checking with button "Check Links".
177 if (strpos($this->modTS['linktypes'], $linkType) !== FALSE) {
178 $this->availableOptions[$linkType] = 1;
179 }
180 // Compile list of types currently selected by the checkboxes
181 if (($this->pObj->MOD_SETTINGS[$linkType] && empty($set)) || $set[$linkType]) {
182 $this->checkOpt[$linkType] = 1;
183 $this->pObj->MOD_SETTINGS[$linkType] = 1;
184 } else {
185 $this->pObj->MOD_SETTINGS[$linkType] = 0;
186 unset($this->checkOpt[$linkType]);
187 }
188 }
189 }
190 $GLOBALS['BE_USER']->pushModuleData('web_info', $this->pObj->MOD_SETTINGS);
191
192 $this->initialize();
193 // Setting up the context sensitive menu
194 $this->resPath = $this->doc->backPath . t3lib_extMgm::extRelPath('linkvalidator') . 'res/';
195 $this->pageRenderer = $this->doc->getPageRenderer();
196
197 // Localization
198 $this->pageRenderer->addInlineLanguageLabelFile(t3lib_extMgm::extPath('linkvalidator', 'modfuncreport/locallang.xml'));
199
200
201 $this->pageRenderer->addJsInlineCode('linkvalidator', 'function toggleActionButton(prefix) {
202 var buttonDisable = true;
203 Ext.select(\'.\' + prefix ,false).each(function(checkBox,i){
204 checkDom = checkBox.dom;
205 if (checkDom.checked){
206 buttonDisable = false;
207 }
208
209 });
210 if (prefix == \'check\'){
211 checkSub = document.getElementById(\'updateLinkList\');
212 } else {
213 checkSub = document.getElementById(\'refreshLinkList\');
214 }
215 checkSub.disabled = buttonDisable;
216 }');
217
218 // Add JS
219 $this->pageRenderer->addJsFile($this->doc->backPath . '../t3lib/js/extjs/ux/Ext.ux.FitToParent.js');
220 $this->pageRenderer->addJsFile($this->doc->backPath . '../t3lib/js/extjs/ux/flashmessages.js');
221 $this->pageRenderer->addJsFile($this->doc->backPath . 'js/extjs/iframepanel.js');
222
223 if ($this->modTS['showCheckLinkTab'] == 1) {
224 $this->updateListHtml = '<input type="submit" name="updateLinkList" id="updateLinkList" value="'
225 . $GLOBALS['LANG']->getLL('label_update') . '"/>';
226 }
227
228 $this->refreshListHtml = '<input type="submit" name="refreshLinkList" id="refreshLinkList" value="'
229 . $GLOBALS['LANG']->getLL('label_refresh') . '"/>';
230
231 $this->processor = t3lib_div::makeInstance('tx_linkvalidator_Processor');
232 $this->updateBrokenLinks();
233
234 $brokenLinkOverView = $this->processor->getLinkCounts($this->pObj->id);
235 $this->checkOptHtml = $this->getCheckOptions($brokenLinkOverView);
236 $this->checkOptHtmlCheck = $this->getCheckOptions($brokenLinkOverView, 'check');
237 $this->createTabs();
238 return '<div id="linkvalidator-modfuncreport"></div>';
239 }
240
241 /**
242 * Create TabPanel to split the report and the checkLink functions
243 *
244 * @return void
245 */
246 protected function createTabs() {
247 $panelCheck = '';
248 if ($this->modTS['showCheckLinkTab'] == 1) {
249 $panelCheck = "{
250 title: TYPO3.l10n.localize('CheckLink'),
251 html: " . json_encode($this->flush()) . ',
252 }';
253 }
254
255 $this->render();
256 $js = "var panel = new Ext.TabPanel( {
257 renderTo: 'linkvalidator-modfuncreport',
258 id: 'linkvalidator-main',
259 plain: true,
260 activeTab: 0,
261 bodyStyle: 'padding:10px;',
262 items : [
263 {
264 autoHeight: true,
265 title: TYPO3.l10n.localize('Report'),
266 html: " . json_encode($this->flush(TRUE)) . '
267 },
268 ' . $panelCheck . '
269 ]
270
271 });
272 ';
273 $this->pageRenderer->addExtOnReadyCode($js);
274 }
275
276 /**
277 * Initializes the menu array internally
278 *
279 * @return array Module menu
280 */
281 public function modMenu() {
282 $modMenu = array(
283 'checkAllLink' => 0,
284 );
285
286 if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'])) {
287 foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'] as $linkType => $value) {
288 $modMenu[$linkType] = 1;
289 }
290 }
291
292 return $modMenu;
293 }
294
295
296 /**
297 * Initializes the Module
298 *
299 * @return void
300 */
301 protected function initialize() {
302 if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'])) {
303 foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'] as $linkType => $classRef) {
304 $this->hookObjectsArr[$linkType] = t3lib_div::getUserObj($classRef);
305 }
306 }
307
308 $this->doc = t3lib_div::makeInstance('template');
309 $this->doc->backPath = $GLOBALS['BACK_PATH'];
310 $this->doc->setModuleTemplate(t3lib_extMgm::extPath('linkvalidator') . 'modfuncreport/mod_template.html');
311
312 $this->relativePath = t3lib_extMgm::extRelPath('linkvalidator');
313 $this->pageRecord = t3lib_BEfunc::readPageAccess($this->pObj->id, $GLOBALS['BE_USER']->getPagePermsClause(1));
314
315 $this->isAccessibleForCurrentUser = FALSE;
316 if ($this->pObj->id && is_array($this->pageRecord) || !$this->pObj->id && $this->isCurrentUserAdmin()) {
317 $this->isAccessibleForCurrentUser = TRUE;
318 }
319
320 $this->loadHeaderData();
321
322 // Don't access in workspace
323 if ($GLOBALS['BE_USER']->workspace !== 0) {
324 $this->isAccessibleForCurrentUser = FALSE;
325 }
326 }
327
328
329 /**
330 * Updates the table of stored broken links
331 *
332 * @return void
333 */
334 protected function updateBrokenLinks() {
335 $searchFields = array();
336
337 // Get the searchFields from TypoScript
338 foreach ($this->modTS['searchFields.'] as $table => $fieldList) {
339 $fields = t3lib_div::trimExplode(',', $fieldList);
340 foreach ($fields as $field) {
341 if (!$searchFields || !is_array($searchFields[$table]) || array_search($field, $searchFields[$table]) == FALSE) {
342 $searchFields[$table][] = $field;
343 }
344 }
345 }
346 $rootLineHidden = $this->processor->getRootLineIsHidden($this->pObj->pageinfo);
347 if (!$rootLineHidden || $this->modTS['checkhidden'] == 1) {
348 // Get children pages
349 $pageList = $this->processor->extGetTreeList(
350 $this->pObj->id,
351 $this->searchLevel,
352 0,
353 $GLOBALS['BE_USER']->getPagePermsClause(1),
354 $this->modTS['checkhidden']
355 );
356
357
358 if ($this->pObj->pageinfo['hidden'] == 0 || $this->modTS['checkhidden'] == 1) {
359 $pageList .= $this->pObj->id;
360 }
361
362
363 $this->processor->init($searchFields, $pageList);
364
365 // Check if button press
366 $update = t3lib_div::_GP('updateLinkList');
367
368 if (!empty($update)) {
369 $this->processor->getLinkStatistics($this->checkOpt, $this->modTS['checkhidden']);
370 }
371 }
372 }
373
374 /**
375 * Renders the content of the module
376 *
377 * @return void
378 */
379 protected function render() {
380 if ($this->isAccessibleForCurrentUser) {
381 $this->content = $this->renderBrokenLinksTable();
382 } else {
383 // If no access or if ID == zero
384 /** @var t3lib_FlashMessage $message */
385 $message = t3lib_div::makeInstance(
386 't3lib_FlashMessage',
387 $GLOBALS['LANG']->getLL('no.access'),
388 $GLOBALS['LANG']->getLL('no.access.title'),
389 t3lib_FlashMessage::ERROR
390 );
391 $this->content .= $message->render();
392 }
393 }
394
395
396 /**
397 * Flushes the rendered content to the browser
398 *
399 * @param boolean $form
400 * @return string $content
401 */
402 protected function flush($form = FALSE) {
403 $content = $this->doc->moduleBody(
404 $this->pageRecord,
405 $this->getDocHeaderButtons(),
406 ($form) ? $this->getTemplateMarkers() : $this->getTemplateMarkersCheck()
407 );
408
409 return $content;
410 }
411
412
413 /**
414 * Builds the selector for the level of pages to search
415 *
416 * @return string Html code of that selector
417 */
418 protected function getLevelSelector() {
419 // Build level selector
420 $opt = array();
421 $parts = array(
422 0 => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.depth_0'),
423 1 => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.depth_1'),
424 2 => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.depth_2'),
425 3 => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.depth_3'),
426 999 => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.depth_infi'),
427 );
428
429 foreach ($parts as $kv => $label) {
430 $opt[] = '<option value="' . $kv . '"'
431 . ($kv == intval($this->searchLevel)
432 ? ' selected="selected"'
433 : '') . '>' . htmlspecialchars($label)
434 . '</option>';
435 }
436 $lMenu = '<select name="search_levels">' . implode('', $opt) . '</select>';
437 return $lMenu;
438 }
439
440 /**
441 * Displays the table of broken links or a note if there were no broken links
442 *
443 * @return string Content of the table or of the note
444 */
445 protected function renderBrokenLinksTable() {
446 $items = $brokenLinksMarker = array();
447 $brokenLinkItems = '';
448 $brokenLinksTemplate = t3lib_parsehtml::getSubpart($this->doc->moduleTemplate, '###NOBROKENLINKS_CONTENT###');
449 $keyOpt = array();
450
451 if (is_array($this->checkOpt)) {
452 $keyOpt = array_keys($this->checkOpt);
453 }
454 $rootLineHidden = $this->processor->getRootLineIsHidden($this->pObj->pageinfo);
455 if (!$rootLineHidden || $this->modTS['checkhidden'] == 1) {
456 $pageList = $this->processor->extGetTreeList(
457 $this->pObj->id,
458 $this->searchLevel,
459 0,
460 $GLOBALS['BE_USER']->getPagePermsClause(1),
461 $this->modTS['checkhidden']
462 );
463
464 // Always add the current page, because we are just displaying the results
465 $pageList .= $this->pObj->id;
466
467 if (($res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
468 '*',
469 'tx_linkvalidator_link',
470 'record_pid in (' . $pageList . ') and link_type in (\'' . implode("','", $keyOpt) . '\')',
471 '',
472 'record_uid ASC, uid ASC')
473 )) {
474 // Display table with broken links
475 if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) > 0) {
476 $brokenLinksTemplate = t3lib_parsehtml::getSubpart($this->doc->moduleTemplate, '###BROKENLINKS_CONTENT###');
477
478 $brokenLinksItemTemplate = t3lib_parsehtml::getSubpart($this->doc->moduleTemplate, '###BROKENLINKS_ITEM###');
479
480 // Table header
481 $brokenLinksMarker = $this->startTable();
482
483 // Table rows containing the broken links
484 while (($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) !== FALSE) {
485 $items[] = $this->renderTableRow($row['table_name'], $row, $brokenLinksItemTemplate);
486 }
487 $brokenLinkItems = implode(chr(10), $items);
488
489 // Display note that there are no broken links to display
490 } else {
491 $brokenLinksMarker = $this->getNoBrokenLinkMessage($brokenLinksMarker);
492 }
493 }
494 } else {
495
496 $brokenLinksMarker = $this->getNoBrokenLinkMessage($brokenLinksMarker);
497 }
498 $brokenLinksTemplate = t3lib_parsehtml::substituteMarkerArray($brokenLinksTemplate, $brokenLinksMarker, '###|###', TRUE);
499 $content = t3lib_parsehtml::substituteSubpart($brokenLinksTemplate, '###BROKENLINKS_ITEM', $brokenLinkItems);
500
501 return $content;
502 }
503
504 /**
505 * Replace $brokenLinksMarker['NO_BROKEN_LINKS] with localized flashmessage
506 *
507 * @param array $brokenLinksMarker
508 * @return array $brokenLinksMarker['NO_BROKEN_LINKS] replaced with flashmessage
509 */
510 protected function getNoBrokenLinkMessage(array $brokenLinksMarker) {
511 $brokenLinksMarker['LIST_HEADER'] = $this->doc->sectionHeader($GLOBALS['LANG']->getLL('list.header'));
512 /** @var t3lib_FlashMessage $message */
513 $message = t3lib_div::makeInstance(
514 't3lib_FlashMessage',
515 $GLOBALS['LANG']->getLL('list.no.broken.links'),
516 $GLOBALS['LANG']->getLL('list.no.broken.links.title'),
517 t3lib_FlashMessage::OK
518 );
519 $brokenLinksMarker['NO_BROKEN_LINKS'] = $message->render();
520
521 return $brokenLinksMarker;
522 }
523
524 /**
525 * Displays the table header of the table with the broken links
526 *
527 * @return string Code of content
528 */
529 protected function startTable() {
530
531 // Listing head
532 $makerTableHead = array();
533
534 $makerTableHead['tablehead_path'] = $GLOBALS['LANG']->getLL('list.tableHead.path');
535 $makerTableHead['tablehead_element'] = $GLOBALS['LANG']->getLL('list.tableHead.element');
536 $makerTableHead['tablehead_headlink'] = $GLOBALS['LANG']->getLL('list.tableHead.headlink');
537 $makerTableHead['tablehead_linktarget'] = $GLOBALS['LANG']->getLL('list.tableHead.linktarget');
538 $makerTableHead['tablehead_linkmessage'] = $GLOBALS['LANG']->getLL('list.tableHead.linkmessage');
539 $makerTableHead['tablehead_lastcheck'] = $GLOBALS['LANG']->getLL('list.tableHead.lastCheck');
540
541 // Add CSH to the header of each column
542 foreach ($makerTableHead as $column => $label) {
543 $label = t3lib_BEfunc::wrapInHelp('linkvalidator', $column, $label);
544 $makerTableHead[$column] = $label;
545 }
546
547 // Add section header
548 $makerTableHead['list_header'] = $this->doc->sectionHeader($GLOBALS['LANG']->getLL('list.header'));
549
550 return $makerTableHead;
551 }
552
553
554 /**
555 * Displays one line of the broken links table
556 *
557 * @param string $table Name of database table
558 * @param array $row Record row to be processed
559 * @param array $brokenLinksItemTemplate Markup of the template to be used
560 * @return string HTML of the rendered row
561 */
562 protected function renderTableRow($table, array $row, $brokenLinksItemTemplate) {
563 $markerArray = array();
564 $fieldName = '';
565 // Restore the linktype object
566 $hookObj = $this->hookObjectsArr[$row['link_type']];
567 $brokenUrl = $hookObj->getBrokenUrl($row);
568
569 $params = '&edit[' . $table . '][' . $row['record_uid'] . ']=edit';
570 $actionLinks = '<a href="#" onclick="' .
571 t3lib_BEfunc::editOnClick(
572 $params,
573 $GLOBALS['BACK_PATH'],
574 t3lib_div::getIndpEnv('REQUEST_URI') . '?id=' . $this->pObj->id . '&search_levels=' . $this->searchLevel
575 ) . '"' .
576 ' title="' . $GLOBALS['LANG']->getLL('list.edit') . '">' .
577 t3lib_iconWorks::getSpriteIcon('actions-document-open') . '</a>';
578
579 $elementHeadline = $row['headline'];
580 if (empty($elementHeadline)) {
581 $elementHeadline = '<i>' . $GLOBALS['LANG']->getLL('list.no.headline') . '</i>';
582 }
583
584 // Get the language label for the field from TCA
585 if ($GLOBALS['TCA'][$table]['columns'][$row['field']]['label']) {
586 $fieldName = $GLOBALS['TCA'][$table]['columns'][$row['field']]['label'];
587 $fieldName = $GLOBALS['LANG']->sL($fieldName);
588 // Crop colon from end if present
589 if (substr($fieldName, '-1', '1') === ':') {
590 $fieldName = substr($fieldName, '0', strlen($fieldName) - 1);
591 }
592 }
593 // Fallback, if there is no label
594 $fieldName = !empty($fieldName) ? $fieldName : $row['field'];
595
596 // column "Element"
597 $element = t3lib_iconWorks::getSpriteIconForRecord($table, $row, array('title' => $table . ':' . $row['record_uid']));
598 $element .= $elementHeadline;
599 $element .= ' ' . sprintf($GLOBALS['LANG']->getLL('list.field'), $fieldName);
600
601 $markerArray['actionlink'] = $actionLinks;
602 $markerArray['path'] = t3lib_BEfunc::getRecordPath($row['record_pid'], '', 0, 0);
603 $markerArray['element'] = $element;
604 $markerArray['headlink'] = $row['link_title'];
605 $markerArray['linktarget'] = $brokenUrl;
606
607 $response = unserialize($row['url_response']);
608 if ($response['valid']) {
609 $linkMessage = '<span style="color: green;">' . $GLOBALS['LANG']->getLL('list.msg.ok') . '</span>';
610 } else {
611 $linkMessage = '<span style="color: red;">' . $hookObj->getErrorMessage($response['errorParams']) . '</span>';
612 }
613 $markerArray['linkmessage'] = $linkMessage;
614
615 $lastRunDate = date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'], $row['last_check']);
616 $lastRunTime = date($GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'], $row['last_check']);
617 $message = sprintf($GLOBALS['LANG']->getLL('list.msg.lastRun'), $lastRunDate, $lastRunTime);
618 $markerArray['lastcheck'] = $message;
619
620 // Return the table html code as string
621 return t3lib_parsehtml::substituteMarkerArray($brokenLinksItemTemplate, $markerArray, '###|###', TRUE, TRUE);
622 }
623
624
625 /**
626 * Builds the checkboxes out of the hooks array
627 *
628 * @param array $brokenLinkOverView Array of broken links information
629 * @param string $prefix
630 * @return string code content
631 */
632 protected function getCheckOptions(array $brokenLinkOverView, $prefix = '') {
633 $markerArray = array();
634 $additionalAttr = '';
635 if (!empty($prefix)) {
636 $additionalAttr = ' onclick="toggleActionButton(\'' . $prefix . '\');" class="' . $prefix . '" ';
637 }
638 else {
639 $additionalAttr = ' onclick="toggleActionButton(\'refresh\');" class="refresh" ';
640 }
641 $checkOptionsTemplate = t3lib_parsehtml::getSubpart($this->doc->moduleTemplate, '###CHECKOPTIONS_SECTION###');
642
643 $hookSectionTemplate = t3lib_parsehtml::getSubpart($checkOptionsTemplate, '###HOOK_SECTION###');
644
645 $markerArray['statistics_header'] = $this->doc->sectionHeader($GLOBALS['LANG']->getLL('report.statistics.header'));
646
647 $totalCountLabel = $GLOBALS['LANG']->getLL('overviews.nbtotal');
648 $totalCountLabel = t3lib_BEfunc::wrapInHelp('linkvalidator', 'checkboxes', $totalCountLabel);
649 $markerArray['total_count_label'] = $totalCountLabel;
650
651 if (empty($brokenLinkOverView['brokenlinkCount'])) {
652 $markerArray['total_count'] = '0';
653 } else {
654 $markerArray['total_count'] = $brokenLinkOverView['brokenlinkCount'];
655 }
656
657 $linktypes = t3lib_div::trimExplode(',', $this->modTS['linktypes'], 1);
658 $hookSectionContent = '';
659
660 if (is_array($linktypes)) {
661 if (!empty($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'])
662 && is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'])
663 ) {
664 foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'] as $type => $value) {
665 if (in_array($type, $linktypes)) {
666 $hookSectionMarker = array();
667 if (empty($brokenLinkOverView[$type])) {
668 $hookSectionMarker['count'] = '0';
669 } else {
670 $hookSectionMarker['count'] = $brokenLinkOverView[$type];
671 }
672 $translation = $GLOBALS['LANG']->getLL('hooks.' . $type);
673 $translation = $translation ? $translation : $type;
674 $option = '<input type="checkbox" ' . $additionalAttr . ' id="' . $prefix . 'SET_' . $type
675 . '" name="' . $prefix . 'SET[' . $type . ']" value="1"' . ($this->pObj->MOD_SETTINGS[$type]
676 ? ' checked="checked"' : '') . '/>' . '<label for="' . $prefix . 'SET[' . $type . ']">'
677 . htmlspecialchars($translation) . '</label>';
678 $hookSectionMarker['option'] = $option;
679 $hookSectionContent .= t3lib_parsehtml::substituteMarkerArray($hookSectionTemplate, $hookSectionMarker, '###|###', TRUE, TRUE);
680 }
681 }
682 }
683 }
684
685 $checkOptionsTemplate = t3lib_parsehtml::substituteSubpart($checkOptionsTemplate, '###HOOK_SECTION###', $hookSectionContent);
686
687 return t3lib_parsehtml::substituteMarkerArray($checkOptionsTemplate, $markerArray, '###|###', TRUE, TRUE);
688 }
689
690
691 /**
692 * Loads data in the HTML head section (e.g. JavaScript or stylesheet information)
693 *
694 * @return void
695 */
696 protected function loadHeaderData() {
697 $this->doc->addStyleSheet('linkvalidator', $this->relativePath . 'res/linkvalidator.css', 'linkvalidator');
698 $this->doc->getPageRenderer()->addJsFile($this->doc->backPath . '../t3lib/js/extjs/ux/Ext.ux.FitToParent.js');
699 }
700
701
702 /**
703 * Gets the buttons that shall be rendered in the docHeader
704 *
705 * @return array Available buttons for the docHeader
706 */
707 protected function getDocHeaderButtons() {
708 $buttons = array(
709 'csh' => t3lib_BEfunc::cshItem('_MOD_web_func', '', $GLOBALS['BACK_PATH']),
710 'shortcut' => $this->getShortcutButton(),
711 'save' => ''
712 );
713 return $buttons;
714 }
715
716
717 /**
718 * Gets the button to set a new shortcut in the backend (if current user is allowed to).
719 *
720 * @return string HTML representation of the shortcut button
721 */
722 protected function getShortcutButton() {
723 $result = '';
724 if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
725 $result = $this->doc->makeShortcutIcon('', 'function', $this->MCONF['name']);
726 }
727 return $result;
728 }
729
730
731 /**
732 * Gets the filled markers that are used in the HTML template
733 *
734 * @return array The filled marker array
735 */
736 protected function getTemplateMarkers() {
737 $markers = array(
738 'FUNC_TITLE' => $GLOBALS['LANG']->getLL('report.func.title'),
739 'CHECKOPTIONS_TITLE' => $GLOBALS['LANG']->getLL('report.statistics.header'),
740 'FUNC_MENU' => $this->getLevelSelector(),
741 'CONTENT' => $this->content,
742 'CHECKALLLINK' => $this->checkAllHtml,
743 'CHECKOPTIONS' => $this->checkOptHtml,
744 'ID' => '<input type="hidden" name="id" value="' . $this->pObj->id . '" />',
745 'REFRESH' => $this->refreshListHtml,
746 'UPDATE' => ''
747 );
748
749 return $markers;
750 }
751
752 /**
753 * Gets the filled markers that are used in the HTML template
754 *
755 * @return array The filled marker array
756 */
757 protected function getTemplateMarkersCheck() {
758 $markers = array(
759 'FUNC_TITLE' => $GLOBALS['LANG']->getLL('checklinks.func.title'),
760 'CHECKOPTIONS_TITLE' => $GLOBALS['LANG']->getLL('checklinks.statistics.header'),
761 'FUNC_MENU' => $this->getLevelSelector(),
762 'CONTENT' => '',
763 'CHECKALLLINK' => $this->checkAllHtml,
764 'CHECKOPTIONS' => $this->checkOptHtmlCheck,
765 'ID' => '<input type="hidden" name="id" value="' . $this->pObj->id . '" />',
766 'REFRESH' => '',
767 'UPDATE' => $this->updateListHtml
768 );
769
770 return $markers;
771 }
772
773
774 /**
775 * Determines whether the current user is an admin
776 *
777 * @return boolean Whether the current user is admin
778 */
779 protected function isCurrentUserAdmin() {
780 return ((bool)$GLOBALS['BE_USER']->user['admin']);
781 }
782 }
783
784 ?>