[BUGFIX] Correct initialisation of BACK_PATH
[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 }
477 else{
478
479 $brokenLinksMarker = $this->getNoBrokenLinkMessage($brokenLinksMarker);
480 }
481 $brokenLinksTemplate = t3lib_parsehtml::substituteMarkerArray($brokenLinksTemplate, $brokenLinksMarker, '###|###', TRUE);
482 $content = t3lib_parsehtml::substituteSubpart($brokenLinksTemplate, '###BROKENLINKS_ITEM', $brokenLinkItems);
483
484 return $content;
485 }
486
487 protected function getNoBrokenLinkMessage($brokenLinksMarker){
488 $brokenLinksMarker['LIST_HEADER'] = $this->doc->sectionHeader($GLOBALS['LANG']->getLL('list.header'));
489 $message = t3lib_div::makeInstance(
490 't3lib_FlashMessage',
491 $GLOBALS['LANG']->getLL('list.no.broken.links'),
492 $GLOBALS['LANG']->getLL('list.no.broken.links.title'),
493 t3lib_FlashMessage::OK
494 );
495 $brokenLinksMarker['NO_BROKEN_LINKS'] = $message->render();
496
497 return $brokenLinksMarker;
498 }
499
500 /**
501 * Displays the table header of the table with the broken links.
502 *
503 * @return string Code of content
504 */
505 protected function startTable() {
506
507 // Listing head
508 $makerTableHead = array();
509
510 $makerTableHead['tablehead_path'] = $GLOBALS['LANG']->getLL('list.tableHead.path');
511 $makerTableHead['tablehead_element'] = $GLOBALS['LANG']->getLL('list.tableHead.element');
512 $makerTableHead['tablehead_headlink'] = $GLOBALS['LANG']->getLL('list.tableHead.headlink');
513 $makerTableHead['tablehead_linktarget'] = $GLOBALS['LANG']->getLL('list.tableHead.linktarget');
514 $makerTableHead['tablehead_linkmessage'] = $GLOBALS['LANG']->getLL('list.tableHead.linkmessage');
515 $makerTableHead['tablehead_lastcheck'] = $GLOBALS['LANG']->getLL('list.tableHead.lastCheck');
516
517 // Add CSH to the header of each column
518 foreach($makerTableHead as $column => $label) {
519 $label = t3lib_BEfunc::wrapInHelp('linkvalidator', $column, $label);
520 $makerTableHead[$column] = $label;
521 }
522
523 // Add section header
524 $makerTableHead['list_header'] = $this->doc->sectionHeader($GLOBALS['LANG']->getLL('list.header'));
525
526 return $makerTableHead;
527 }
528
529
530 /**
531 * Displays one line of the broken links table.
532 *
533 * @param string $table Name of database table
534 * @param array $row Record row to be processed
535 * @param array $brokenLinksItemTemplate Markup of the template to be used
536 * @return string HTML of the rendered row
537 */
538 protected function renderTableRow($table, array $row, $brokenLinksItemTemplate) {
539 $markerArray = array();
540 if (is_array($row) && !empty($row['link_type'])) {
541 if (($hookObj = $this->hookObjectsArr[$row['link_type']])) {
542 $brokenUrl = $hookObj->getBrokenUrl($row);
543 }
544 }
545
546 $params = '&edit[' . $table . '][' . $row['record_uid'] . ']=edit';
547 $actionLinks = '<a href="#" onclick="' .
548 t3lib_BEfunc::editOnClick(
549 $params,
550 $GLOBALS['BACK_PATH'],
551 t3lib_div::getIndpEnv('REQUEST_URI') . '?id=' . $this->pObj->id . '&search_levels=' . $this->searchLevel
552 ) . '"' .
553 ' title="' . $GLOBALS['LANG']->getLL('list.edit') . '">' .
554 t3lib_iconWorks::getSpriteIcon('actions-document-open') . '</a>';
555
556 $elementHeadline = $row['headline'];
557 if (empty($elementHeadline)) {
558 $elementHeadline = '<i>' . $GLOBALS['LANG']->getLL('list.no.headline') . '</i>';
559 }
560
561 // Get the language label for the field from TCA
562 if ($GLOBALS['TCA'][$table]['columns'][$row['field']]['label']) {
563 $fieldName = $GLOBALS['TCA'][$table]['columns'][$row['field']]['label'];
564 $fieldName = $GLOBALS['LANG']->sL($fieldName);
565 // Crop colon from end if present.
566 if (substr($fieldName, '-1', '1') === ':') {
567 $fieldName = substr($fieldName, '0', strlen($fieldName)-1);
568 }
569 }
570 // Fallback, if there is no label
571 $fieldName = $fieldName ? $fieldName : $row['field'];
572
573 // column "Element"
574 $element = t3lib_iconWorks::getSpriteIconForRecord($table, $row, array('title' => $table . ':' . $row['record_uid']));
575 $element .= $elementHeadline;
576 $element .= ' ' . sprintf($GLOBALS['LANG']->getLL('list.field'), $fieldName);
577
578 $markerArray['actionlink'] = $actionLinks;
579 $markerArray['path'] = t3lib_BEfunc::getRecordPath($row['record_pid'], '', 0, 0);
580 $markerArray['element'] = $element;
581 $markerArray['headlink'] = $row['link_title'];
582 $markerArray['linktarget'] = $brokenUrl;
583
584 $response = unserialize($row['url_response']);
585 if ($response['valid']) {
586 $linkMessage = '<span style="color: green;">' . $GLOBALS['LANG']->getLL('list.msg.ok') . '</span>';
587 } else {
588 $linkMessage = '<span style="color: red;">' . $hookObj->getErrorMessage($response['errorParams']) . '</span>';
589 }
590 $markerArray['linkmessage'] = $linkMessage;
591
592 $lastRunDate = date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'], $row['last_check']);
593 $lastRunTime = date($GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'], $row['last_check']);
594 $message = sprintf($GLOBALS['LANG']->getLL('list.msg.lastRun'), $lastRunDate, $lastRunTime);
595 $markerArray['lastcheck'] = $message;
596
597 // Return the table html code as string
598 return t3lib_parsehtml::substituteMarkerArray($brokenLinksItemTemplate, $markerArray, '###|###', TRUE, TRUE);
599 }
600
601
602 /**
603 * Builds the checkboxes out of the hooks array.
604 *
605 * @param array $brokenLinkOverView array of broken links information
606 * @return string code content
607 */
608 protected function getCheckOptions(array $brokenLinkOverView, $prefix = '') {
609 $markerArray = array();
610 $additionalAttr = '';
611 if(!empty($prefix)) {
612 $additionalAttr = ' onclick="toggleActionButton(\'' . $prefix . '\');" class="' . $prefix . '" ';
613 }
614 else {
615 $additionalAttr = ' onclick="toggleActionButton(\'refresh\');" class="refresh" ';
616 }
617 $checkOptionsTemplate = t3lib_parsehtml::getSubpart($this->doc->moduleTemplate, '###CHECKOPTIONS_SECTION###');
618
619 $hookSectionContent = '';
620 $hookSectionTemplate = t3lib_parsehtml::getSubpart($checkOptionsTemplate, '###HOOK_SECTION###');
621
622 $markerArray['statistics_header'] = $this->doc->sectionHeader($GLOBALS['LANG']->getLL('report.statistics.header'));
623
624 $totalCountLabel = $GLOBALS['LANG']->getLL('overviews.nbtotal');
625 $totalCountLabel = t3lib_BEfunc::wrapInHelp('linkvalidator', 'checkboxes', $totalCountLabel);
626 $markerArray['total_count_label'] = $totalCountLabel;
627
628 if (empty($brokenLinkOverView['brokenlinkCount'])) {
629 $markerArray['total_count'] = '0';
630 } else {
631 $markerArray['total_count'] = $brokenLinkOverView['brokenlinkCount'];
632 }
633
634 $linktypes = t3lib_div::trimExplode(',', $this->modTS['linktypes'], 1);
635 $hookSectionContent = '';
636
637 if (is_array($linktypes)) {
638 if (!empty($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'])
639 && is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'])
640 ) {
641 foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'] as $type => $value) {
642 if (in_array($type, $linktypes)) {
643 $hookSectionMarker = array();
644 if (empty($brokenLinkOverView[$type])) {
645 $hookSectionMarker['count'] = '0';
646 } else {
647 $hookSectionMarker['count'] = $brokenLinkOverView[$type];
648 }
649 $translation = $GLOBALS['LANG']->getLL('hooks.' . $type);
650 $translation = $translation ? $translation : $type;
651 $option = '<input type="checkbox" ' . $additionalAttr . ' id="' . $prefix . 'SET_' . $type . '" name="' . $prefix . 'SET[' . $type . ']" value="1"' . ($this->pObj->MOD_SETTINGS[$type] ? ' checked="checked"' : '') .
652 '/>'.'<label for="' . $prefix . 'SET[' . $type . ']">' . htmlspecialchars( $translation ) . '</label>';
653 $hookSectionMarker['option'] = $option;
654 $hookSectionContent .= t3lib_parsehtml::substituteMarkerArray($hookSectionTemplate, $hookSectionMarker, '###|###', TRUE, TRUE);
655 }
656 }
657 }
658 }
659
660 $checkOptionsTemplate = t3lib_parsehtml::substituteSubpart($checkOptionsTemplate, '###HOOK_SECTION###', $hookSectionContent);
661
662 return t3lib_parsehtml::substituteMarkerArray($checkOptionsTemplate, $markerArray, '###|###', TRUE, TRUE);
663 }
664
665
666 /**
667 * Loads data in the HTML head section (e.g. JavaScript or stylesheet information).
668 *
669 * @return void
670 */
671 protected function loadHeaderData() {
672 $this->doc->addStyleSheet('linkvalidator', $this->relativePath . 'res/linkvalidator.css', 'linkvalidator');
673 $this->doc->getPageRenderer()->addJsFile($this->doc->backPath . '../t3lib/js/extjs/ux/Ext.ux.FitToParent.js');
674 }
675
676
677 /**
678 * Gets the buttons that shall be rendered in the docHeader.
679 *
680 * @return array Available buttons for the docHeader
681 */
682 protected function getDocHeaderButtons() {
683 $buttons = array(
684 'csh' => t3lib_BEfunc::cshItem('_MOD_web_func', '', $GLOBALS['BACK_PATH']),
685 'shortcut' => $this->getShortcutButton(),
686 'save' => ''
687 );
688 return $buttons;
689 }
690
691
692 /**
693 * Gets the button to set a new shortcut in the backend (if current user is allowed to).
694 *
695 * @return string HTML representiation of the shortcut button
696 */
697 protected function getShortcutButton() {
698 $result = '';
699 if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
700 $result = $this->doc->makeShortcutIcon('', 'function', $this->MCONF['name']);
701 }
702 return $result;
703 }
704
705
706 /**
707 * Gets the filled markers that are used in the HTML template.
708 *
709 * @return array The filled marker array
710 */
711 protected function getTemplateMarkers() {
712 $markers = array(
713 'FUNC_TITLE' => $GLOBALS['LANG']->getLL('report.func.title'),
714 'CHECKOPTIONS_TITLE' => $GLOBALS['LANG']->getLL('report.statistics.header'),
715 'FUNC_MENU' => $this->getLevelSelector(),
716 'CONTENT' => $this->content,
717 'CHECKALLLINK' => $this->checkAllHtml,
718 'CHECKOPTIONS' => $this->checkOptHtml,
719 'ID' => '<input type="hidden" name="id" value="' . $this->pObj->id . '" />',
720 'REFRESH' => $this->refreshListHtml,
721 'UPDATE' => ''
722 );
723
724 return $markers;
725 }
726
727 /**
728 * Gets the filled markers that are used in the HTML template.
729 *
730 * @return array The filled marker array
731 */
732 protected function getTemplateMarkersCheck() {
733 $markers = array(
734 'FUNC_TITLE' =>$GLOBALS['LANG']->getLL('checklinks.func.title'),
735 'CHECKOPTIONS_TITLE' =>$GLOBALS['LANG']->getLL('checklinks.statistics.header'),
736 'FUNC_MENU' => $this->getLevelSelector(),
737 'CONTENT' => '',
738 'CHECKALLLINK' => $this->checkAllHtml,
739 'CHECKOPTIONS' => $this->checkOptHtmlCheck,
740 'ID' => '<input type="hidden" name="id" value="' . $this->pObj->id . '" />',
741 'REFRESH' => '',
742 'UPDATE' => $this->updateListHtml
743 );
744
745 return $markers;
746 }
747
748
749 /**
750 * Determines whether the current user is an admin.
751 *
752 * @return boolean Whether the current user is admin
753 */
754 protected function isCurrentUserAdmin() {
755 return ((bool) $GLOBALS['BE_USER']->user['admin']);
756 }
757 }
758
759 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/linkvalidator/modfuncreport/class.tx_linkvalidator_modfuncreport.php'])) {
760 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/linkvalidator/modfuncreport/class.tx_linkvalidator_modfuncreport.php']);
761 }
762
763 ?>