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