|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 2005 - 2010 Jochen Rieger (j.rieger@connecta.ag) 00006 * (c) 2010 - 2011 Michael Miousse (michael.miousse@infoglobe.ca) 00007 * All rights reserved 00008 * 00009 * This script is part of the TYPO3 project. The TYPO3 project is 00010 * free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * The GNU General Public License can be found at 00016 * http://www.gnu.org/copyleft/gpl.html. 00017 * 00018 * This script is distributed in the hope that it will be useful, 00019 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00021 * GNU General Public License for more details. 00022 * 00023 * This copyright notice MUST APPEAR in all copies of the script! 00024 ***************************************************************/ 00025 00026 /** 00027 * Module 'Linkvalidator' for the 'linkvalidator' extension. 00028 * 00029 * @author Michael Miousse <michael.miousse@infoglobe.ca> 00030 * @author Jochen Rieger <j.rieger@connecta.ag> 00031 * @package TYPO3 00032 * @subpackage linkvalidator 00033 */ 00034 class tx_linkvalidator_ModFuncReport extends t3lib_extobjbase { 00035 00036 /** 00037 * @var template 00038 */ 00039 public $doc; 00040 00041 /** 00042 * @var string 00043 */ 00044 protected $relativePath; 00045 00046 /** 00047 * Information about the current page record. 00048 * 00049 * @var array 00050 */ 00051 protected $pageRecord = array(); 00052 00053 /** 00054 * Information, if the module is accessible for the current user or not. 00055 * 00056 * @var boolean 00057 */ 00058 protected $isAccessibleForCurrentUser = FALSE; 00059 00060 /** 00061 * Depth for the recursivity of the link validation. 00062 * 00063 * @var integer 00064 */ 00065 protected $searchLevel; 00066 00067 /** 00068 * Link validation class. 00069 * 00070 * @var tx_linkvalidator_Processor 00071 */ 00072 protected $processor; 00073 00074 /** 00075 * TSconfig of the current module. 00076 * 00077 * @var array 00078 */ 00079 protected $modTS = array(); 00080 00081 /** 00082 * List of available link types to check defined in the TSconfig. 00083 * 00084 * @var array 00085 */ 00086 protected $availableOptions = array(); 00087 00088 /** 00089 * List of link types currently chosen in the Statistics table. 00090 * Used to show broken links of these types only. 00091 * 00092 * @var array 00093 */ 00094 protected $checkOpt = array(); 00095 00096 /** 00097 * Html for the button "Check Links". 00098 * 00099 * @var string 00100 */ 00101 protected $updateListHtml; 00102 00103 /** 00104 * Html for the button "Refresh Display". 00105 * 00106 * @var string 00107 */ 00108 protected $refreshListHtml; 00109 00110 /** 00111 * Html for the Statistics table with the checkboxes of the link types and the numbers of broken links for Report tab. 00112 * 00113 * @var string 00114 */ 00115 protected $checkOptHtml; 00116 00117 00118 /** 00119 * Html for the Statistics table with the checkboxes of the link types and the numbers of broken links for Check links tab. 00120 * 00121 * @var string 00122 */ 00123 protected $checkOptHtmlCheck; 00124 00125 /** 00126 * Complete content (html) to be displayed. 00127 * 00128 * @var string 00129 */ 00130 protected $content; 00131 00132 /** 00133 * Main method of modfuncreport 00134 * 00135 * @return string Module content 00136 */ 00137 public function main() { 00138 $GLOBALS['LANG']->includeLLFile('EXT:linkvalidator/modfuncreport/locallang.xml'); 00139 00140 $this->searchLevel = t3lib_div::_GP('search_levels'); 00141 00142 if (isset($this->pObj->id)) { 00143 $this->modTS = t3lib_BEfunc::getModTSconfig($this->pObj->id, 'mod.linkvalidator'); 00144 $this->modTS = $this->modTS['properties']; 00145 } 00146 $update = t3lib_div::_GP('updateLinkList'); 00147 $prefix = ''; 00148 if (!empty($update)) { 00149 $prefix = 'check'; 00150 } 00151 $set = t3lib_div::_GP($prefix . 'SET'); 00152 $this->pObj->handleExternalFunctionValue(); 00153 00154 if(isset($this->searchLevel)) { 00155 $this->pObj->MOD_SETTINGS['searchlevel'] = $this->searchLevel; 00156 } else { 00157 $this->searchLevel = $this->pObj->MOD_SETTINGS['searchlevel']; 00158 } 00159 00160 if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'])) { 00161 foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'] as $linkType => $value) { 00162 // Compile list of all available types. Used for checking with button "Check Links". 00163 if (strpos($this->modTS['linktypes'], $linkType) !== FALSE) { 00164 $this->availableOptions[$linkType] = 1; 00165 } 00166 // Compile list of types currently selected by the checkboxes. 00167 if (($this->pObj->MOD_SETTINGS[$linkType] && empty($set)) || $set[$linkType]) { 00168 $this->checkOpt[$linkType] = 1; 00169 $this->pObj->MOD_SETTINGS[$linkType] = 1; 00170 } else { 00171 $this->pObj->MOD_SETTINGS[$linkType] = 0; 00172 unset($this->checkOpt[$linkType]); 00173 } 00174 } 00175 } 00176 $GLOBALS['BE_USER']->pushModuleData('web_info', $this->pObj->MOD_SETTINGS); 00177 00178 $this->initialize(); 00179 // Setting up the context sensitive menu: 00180 $this->resPath = $this->doc->backPath . t3lib_extMgm::extRelPath('linkvalidator') . 'res/'; 00181 /** @var t3lib_pageRenderer $pageRenderer */ 00182 $this->pageRenderer = $this->doc->getPageRenderer(); 00183 00184 // Localization 00185 $this->pageRenderer->addInlineLanguageLabelFile(t3lib_extMgm::extPath('linkvalidator', 'modfuncreport/locallang.xml')); 00186 00187 // Add JS 00188 $this->pageRenderer->addJsFile($this->doc->backPath . '../t3lib/js/extjs/ux/Ext.ux.FitToParent.js'); 00189 $this->pageRenderer->addJsFile($this->doc->backPath . '../t3lib/js/extjs/ux/flashmessages.js'); 00190 $this->pageRenderer->addJsFile($this->doc->backPath . 'js/extjs/iframepanel.js'); 00191 00192 if ($this->modTS['showCheckLinkTab'] == 1) { 00193 $this->updateListHtml = '<input type="submit" name="updateLinkList" value="' . $GLOBALS['LANG']->getLL('label_update') . '"/>'; 00194 } 00195 00196 $this->refreshListHtml = '<input type="submit" name="refreshLinkList" value="' . $GLOBALS['LANG']->getLL('label_refresh') . '"/>'; 00197 00198 $this->processor = t3lib_div::makeInstance('tx_linkvalidator_Processor'); 00199 $this->updateBrokenLinks(); 00200 00201 $brokenLinkOverView = $this->processor->getLinkCounts($this->pObj->id); 00202 $this->checkOptHtml = $this->getCheckOptions($brokenLinkOverView); 00203 $this->checkOptHtmlCheck = $this->getCheckOptions($brokenLinkOverView, 'check'); 00204 $this->createTabs(); 00205 return '<div id="linkvalidator-modfuncreport"></div>'; 00206 } 00207 00208 /** 00209 * Create TabPanel to split the report and the checklinks functions 00210 * 00211 * @return void 00212 */ 00213 protected function createTabs() { 00214 $panelCheck = ''; 00215 if ($this->modTS['showCheckLinkTab'] == 1) { 00216 $panelCheck = '{ 00217 00218 title: TYPO3.lang.CheckLink, 00219 html: ' . json_encode($this->flush()) . ', 00220 }, '; 00221 } 00222 00223 $this->render(); 00224 $js = 'var panel = new Ext.TabPanel( { 00225 renderTo : "linkvalidator-modfuncreport", 00226 id: "linkvalidator-main", 00227 plain: true, 00228 activeTab: 0, 00229 autoScroll: true, 00230 bodyStyle: "padding:10px;", 00231 plugins: [new Ext.ux.plugins.FitToParent()], 00232 items : [ 00233 { 00234 title: TYPO3.lang.Report, 00235 html: ' . json_encode($this->flush(TRUE)) . ' 00236 }, 00237 ' . $panelCheck . ' 00238 ] 00239 00240 });'; 00241 $this->pageRenderer->addExtOnReadyCode($js); 00242 } 00243 00244 /** 00245 * Initializes the menu array internally. 00246 * 00247 * @return array Module menu 00248 */ 00249 public function modMenu() { 00250 $modMenu = array ( 00251 'checkAllLink' => 0, 00252 ); 00253 00254 if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'])) { 00255 foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'] as $linkType => $value) { 00256 $modMenu[$linkType] = 1; 00257 } 00258 } 00259 00260 return $modMenu; 00261 } 00262 00263 00264 /** 00265 * Initializes the Module. 00266 * 00267 * @return void 00268 */ 00269 protected function initialize() { 00270 if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'])) { 00271 foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'] as $linkType => $classRef) { 00272 $this->hookObjectsArr[$linkType] = &t3lib_div::getUserObj($classRef); 00273 } 00274 } 00275 00276 $this->doc = t3lib_div::makeInstance('template'); 00277 $this->doc->setModuleTemplate(t3lib_extMgm::extPath('linkvalidator') . 'modfuncreport/mod_template.html'); 00278 $this->doc->backPath = $GLOBALS['BACK_PATH']; 00279 00280 $this->relativePath = t3lib_extMgm::extRelPath('linkvalidator'); 00281 $this->pageRecord = t3lib_BEfunc::readPageAccess($this->pObj->id, $this->perms_clause); 00282 00283 $this->isAccessibleForCurrentUser = FALSE; 00284 if ($this->pObj->id && is_array($this->pageRecord) || !$this->pObj->id && $this->isCurrentUserAdmin()) { 00285 $this->isAccessibleForCurrentUser = TRUE; 00286 } 00287 00288 $this->loadHeaderData(); 00289 00290 // Don't access in workspace 00291 if ($GLOBALS['BE_USER']->workspace !== 0) { 00292 $this->isAccessibleForCurrentUser = FALSE; 00293 } 00294 } 00295 00296 00297 /** 00298 * Updates the table of stored broken links. 00299 * 00300 * @return void 00301 */ 00302 protected function updateBrokenLinks() { 00303 $searchFields = array(); 00304 00305 // get the searchFields from TypoScript 00306 foreach ($this->modTS['searchFields.'] as $table => $fieldList) { 00307 $fields = t3lib_div::trimExplode(',', $fieldList); 00308 foreach ($fields as $field) { 00309 if (!$searchFields || !is_array($searchFields[$table]) || array_search($field, $searchFields[$table]) == FALSE) { 00310 $searchFields[$table][] = $field; 00311 } 00312 } 00313 } 00314 // get children pages 00315 $pageList = $this->processor->extGetTreeList( 00316 $this->pObj->id, 00317 $this->searchLevel, 00318 0, 00319 $GLOBALS['BE_USER']->getPagePermsClause(1) 00320 ); 00321 $pageList .= $this->pObj->id; 00322 00323 $this->processor->init($searchFields, $pageList); 00324 00325 // check if button press 00326 $update = t3lib_div::_GP('updateLinkList'); 00327 00328 if (!empty($update)) { 00329 $this->processor->getLinkStatistics($this->checkOpt, $this->modTS['checkhidden']); 00330 } 00331 } 00332 00333 00334 /** 00335 * Renders the content of the module. 00336 * 00337 * @return void 00338 */ 00339 protected function render() { 00340 if ($this->isAccessibleForCurrentUser) { 00341 $this->content = $this->renderBrokenLinksTable(); 00342 } else { 00343 // If no access or if ID == zero 00344 $message = t3lib_div::makeInstance( 00345 't3lib_FlashMessage', 00346 $GLOBALS['LANG']->getLL('no.access'), 00347 $GLOBALS['LANG']->getLL('no.access.title'), 00348 t3lib_FlashMessage::ERROR 00349 ); 00350 $this->content .= $message->render(); 00351 } 00352 } 00353 00354 00355 /** 00356 * Flushes the rendered content to the browser. 00357 * 00358 * @param boolean $form 00359 * @return void 00360 */ 00361 protected function flush($form = FALSE) { 00362 $content = $this->doc->moduleBody( 00363 $this->pageRecord, 00364 $this->getDocHeaderButtons(), 00365 ($form) ? $this->getTemplateMarkers(): $this->getTemplateMarkersCheck() 00366 ); 00367 00368 return $content; 00369 } 00370 00371 00372 /** 00373 * Builds the selector for the level of pages to search. 00374 * 00375 * @return string Html code of that selector 00376 */ 00377 protected function getLevelSelector() { 00378 // Make level selector: 00379 $opt = array(); 00380 $parts = array( 00381 0 => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.depth_0'), 00382 1 => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.depth_1'), 00383 2 => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.depth_2'), 00384 3 => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.depth_3'), 00385 999 => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.depth_infi'), 00386 ); 00387 00388 foreach ($parts as $kv => $label) { 00389 $opt[] = '<option value="' . $kv . '"' . ($kv == intval($this->searchLevel) ? ' selected="selected"' : '') . '>' . htmlspecialchars($label) . '</option>'; 00390 } 00391 $lMenu = '<select name="search_levels">' . implode('', $opt) . '</select>'; 00392 return $lMenu; 00393 } 00394 00395 /** 00396 * Displays the table of broken links or a note if there were no broken links. 00397 * 00398 * @return html Content of the table or of the note 00399 */ 00400 protected function renderBrokenLinksTable() { 00401 $items = $brokenLinksMarker = array(); 00402 $brokenLinkItems = $brokenLinksTemplate = ''; 00403 $keyOpt = array(); 00404 00405 if (is_array($this->checkOpt)) { 00406 $keyOpt = array_keys($this->checkOpt); 00407 } 00408 00409 $pageList = $this->processor->extGetTreeList( 00410 $this->pObj->id, 00411 $this->searchLevel, 00412 0, 00413 $GLOBALS['BE_USER']->getPagePermsClause(1) 00414 ); 00415 $pageList .= $this->pObj->id; 00416 00417 if (($res = $GLOBALS['TYPO3_DB']->exec_SELECTquery( 00418 '*', 00419 'tx_linkvalidator_link', 00420 'record_pid in (' . $pageList . ') and link_type in (\'' . implode("','", $keyOpt) . '\')', 00421 '', 00422 'record_uid ASC, uid ASC') 00423 )) { 00424 // Display table with broken links 00425 if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) > 0) { 00426 $brokenLinksTemplate = t3lib_parsehtml::getSubpart($this->doc->moduleTemplate, '###BROKENLINKS_CONTENT###'); 00427 00428 $brokenLinksItemTemplate = t3lib_parsehtml::getSubpart($this->doc->moduleTemplate, '###BROKENLINKS_ITEM###'); 00429 00430 // Table header 00431 $brokenLinksMarker = $this->startTable(); 00432 00433 // Table rows containing the broken links 00434 while (($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))) { 00435 $items[] = $this->renderTableRow($row['table_name'], $row, $brokenLinksItemTemplate); 00436 } 00437 $brokenLinkItems = implode(chr(10), $items); 00438 00439 // Display note that there are no broken links to display 00440 } else { 00441 $brokenLinksTemplate = t3lib_parsehtml::getSubpart($this->doc->moduleTemplate, '###NOBROKENLINKS_CONTENT###'); 00442 00443 $brokenLinksMarker['LIST_HEADER'] = $this->doc->sectionHeader($GLOBALS['LANG']->getLL('list.header')); 00444 $message = t3lib_div::makeInstance( 00445 't3lib_FlashMessage', 00446 $GLOBALS['LANG']->getLL('list.no.broken.links'), 00447 $GLOBALS['LANG']->getLL('list.no.broken.links.title'), 00448 t3lib_FlashMessage::OK 00449 ); 00450 $brokenLinksMarker['NO_BROKEN_LINKS'] = $message->render(); 00451 } 00452 } 00453 $brokenLinksTemplate = t3lib_parsehtml::substituteMarkerArray($brokenLinksTemplate, $brokenLinksMarker, '###|###', TRUE); 00454 00455 $content = t3lib_parsehtml::substituteSubpart($brokenLinksTemplate, '###BROKENLINKS_ITEM', $brokenLinkItems); 00456 00457 return $content; 00458 } 00459 00460 00461 00462 /** 00463 * Displays the table header of the table with the broken links. 00464 * 00465 * @return string Code of content 00466 */ 00467 protected function startTable() { 00468 00469 // Listing head 00470 $makerTableHead = array(); 00471 00472 $makerTableHead['tablehead_path'] = $GLOBALS['LANG']->getLL('list.tableHead.path'); 00473 $makerTableHead['tablehead_element'] = $GLOBALS['LANG']->getLL('list.tableHead.element'); 00474 $makerTableHead['tablehead_headlink'] = $GLOBALS['LANG']->getLL('list.tableHead.headlink'); 00475 $makerTableHead['tablehead_linktarget'] = $GLOBALS['LANG']->getLL('list.tableHead.linktarget'); 00476 $makerTableHead['tablehead_linkmessage'] = $GLOBALS['LANG']->getLL('list.tableHead.linkmessage'); 00477 $makerTableHead['tablehead_lastcheck'] = $GLOBALS['LANG']->getLL('list.tableHead.lastCheck'); 00478 00479 // Add CSH to the header of each column 00480 foreach($makerTableHead as $column => $label) { 00481 $label = t3lib_BEfunc::wrapInHelp('linkvalidator', $column, $label); 00482 $makerTableHead[$column] = $label; 00483 } 00484 00485 // Add section header 00486 $makerTableHead['list_header'] = $this->doc->sectionHeader($GLOBALS['LANG']->getLL('list.header')); 00487 00488 return $makerTableHead; 00489 } 00490 00491 00492 /** 00493 * Displays one line of the broken links table. 00494 * 00495 * @param string $table Name of database table 00496 * @param array $row Record row to be processed 00497 * @param array $brokenLinksItemTemplate Markup of the template to be used 00498 * @return string HTML of the rendered row 00499 */ 00500 protected function renderTableRow($table, array $row, $brokenLinksItemTemplate) { 00501 $markerArray = array(); 00502 if (is_array($row) && !empty($row['link_type'])) { 00503 if (($hookObj = $this->hookObjectsArr[$row['link_type']])) { 00504 $brokenUrl = $hookObj->getBrokenUrl($row); 00505 } 00506 } 00507 00508 $params = '&edit[' . $table . '][' . $row['record_uid'] . ']=edit'; 00509 $actionLinks = '<a href="#" onclick="' . 00510 t3lib_BEfunc::editOnClick( 00511 $params, 00512 $GLOBALS['BACK_PATH'], 00513 t3lib_div::getIndpEnv('REQUEST_URI') . '?id=' . $this->pObj->id . '&search_levels=' . $this->searchLevel 00514 ) . '"' . 00515 ' title="' . $GLOBALS['LANG']->getLL('list.edit') . '">' . 00516 t3lib_iconWorks::getSpriteIcon('actions-document-open') . '</a>'; 00517 00518 $elementHeadline = $row['headline']; 00519 if (empty($elementHeadline)) { 00520 $elementHeadline = '<i>' . $GLOBALS['LANG']->getLL('list.no.headline') . '</i>'; 00521 } 00522 00523 // Get the language label for the field from TCA 00524 if ($GLOBALS['TCA'][$table]['columns'][$row['field']]['label']) { 00525 $fieldName = $GLOBALS['TCA'][$table]['columns'][$row['field']]['label']; 00526 $fieldName = $GLOBALS['LANG']->sL($fieldName); 00527 // Crop colon from end if present. 00528 if (substr($fieldName, '-1', '1') === ':') { 00529 $fieldName = substr($fieldName, '0', strlen($fieldName)-1); 00530 } 00531 } 00532 // Fallback, if there is no label 00533 $fieldName = $fieldName ? $fieldName : $row['field']; 00534 00535 // column "Element" 00536 $element = t3lib_iconWorks::getSpriteIconForRecord($table, $row, array('title' => $table . ':' . $row['record_uid'])); 00537 $element .= $elementHeadline; 00538 $element .= ' ' . sprintf($GLOBALS['LANG']->getLL('list.field'), $fieldName); 00539 00540 $markerArray['actionlink'] = $actionLinks; 00541 $markerArray['path'] = t3lib_BEfunc::getRecordPath($row['record_pid'], '', 0, 0); 00542 $markerArray['element'] = $element; 00543 $markerArray['headlink'] = $row['link_title']; 00544 $markerArray['linktarget'] = $brokenUrl; 00545 00546 $response = unserialize($row['url_response']); 00547 if ($response['valid']) { 00548 $linkMessage = '<span style="color: green;">' . $GLOBALS['LANG']->getLL('list.msg.ok') . '</span>'; 00549 } else { 00550 $linkMessage = '<span style="color: red;">' . $hookObj->getErrorMessage($response['errorParams']) . '</span>'; 00551 } 00552 $markerArray['linkmessage'] = $linkMessage; 00553 00554 $lastRunDate = date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'], $row['last_check']); 00555 $lastRunTime = date($GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'], $row['last_check']); 00556 $message = sprintf($GLOBALS['LANG']->getLL('list.msg.lastRun'), $lastRunDate, $lastRunTime); 00557 $markerArray['lastcheck'] = $message; 00558 00559 // Return the table html code as string 00560 return t3lib_parsehtml::substituteMarkerArray($brokenLinksItemTemplate, $markerArray, '###|###', TRUE, TRUE); 00561 } 00562 00563 00564 /** 00565 * Builds the checkboxes out of the hooks array. 00566 * 00567 * @param array $brokenLinkOverView array of broken links information 00568 * @return string code content 00569 */ 00570 protected function getCheckOptions(array $brokenLinkOverView, $prefix = '') { 00571 $markerArray = array(); 00572 00573 $checkOptionsTemplate = t3lib_parsehtml::getSubpart($this->doc->moduleTemplate, '###CHECKOPTIONS_SECTION###'); 00574 00575 $hookSectionContent = ''; 00576 $hookSectionTemplate = t3lib_parsehtml::getSubpart($checkOptionsTemplate, '###HOOK_SECTION###'); 00577 00578 $markerArray['statistics_header'] = $this->doc->sectionHeader($GLOBALS['LANG']->getLL('report.statistics.header')); 00579 00580 $totalCountLabel = $GLOBALS['LANG']->getLL('overviews.nbtotal'); 00581 $totalCountLabel = t3lib_BEfunc::wrapInHelp('linkvalidator', 'checkboxes', $totalCountLabel); 00582 $markerArray['total_count_label'] = $totalCountLabel; 00583 00584 if (empty($brokenLinkOverView['brokenlinkCount'])) { 00585 $markerArray['total_count'] = '0'; 00586 } else { 00587 $markerArray['total_count'] = $brokenLinkOverView['brokenlinkCount']; 00588 } 00589 00590 $linktypes = t3lib_div::trimExplode(',', $this->modTS['linktypes'], 1); 00591 $hookSectionContent = ''; 00592 00593 if (is_array($linktypes)) { 00594 if (!empty($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks']) 00595 && is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks']) 00596 ) { 00597 foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'] as $type => $value) { 00598 if (in_array($type, $linktypes)) { 00599 $hookSectionMarker = array(); 00600 if (empty($brokenLinkOverView[$type])) { 00601 $hookSectionMarker['count'] = '0'; 00602 } else { 00603 $hookSectionMarker['count'] = $brokenLinkOverView[$type]; 00604 } 00605 $translation = $GLOBALS['LANG']->getLL('hooks.' . $type); 00606 $translation = $translation ? $translation : $type; 00607 $option = '<input type="checkbox" id="' . $prefix . 'SET[' . $type . ']" name="' . $prefix . 'SET[' . $type . ']" value="1"' . ($this->pObj->MOD_SETTINGS[$type] ? ' checked="checked"' : '') . 00608 '/>'.'<label for="' . $prefix . 'SET[' . $type . ']">' . htmlspecialchars( $translation ) . '</label>'; 00609 $hookSectionMarker['option'] = $option; 00610 $hookSectionContent .= t3lib_parsehtml::substituteMarkerArray($hookSectionTemplate, $hookSectionMarker, '###|###', TRUE, TRUE); 00611 } 00612 } 00613 } 00614 } 00615 00616 $checkOptionsTemplate = t3lib_parsehtml::substituteSubpart($checkOptionsTemplate, '###HOOK_SECTION###', $hookSectionContent); 00617 00618 return t3lib_parsehtml::substituteMarkerArray($checkOptionsTemplate, $markerArray, '###|###', TRUE, TRUE); 00619 } 00620 00621 00622 /** 00623 * Loads data in the HTML head section (e.g. JavaScript or stylesheet information). 00624 * 00625 * @return void 00626 */ 00627 protected function loadHeaderData() { 00628 $this->doc->addStyleSheet('linkvalidator', $this->relativePath . 'res/linkvalidator.css', 'linkvalidator'); 00629 $this->doc->getPageRenderer()->addJsFile($this->doc->backPath . '../t3lib/js/extjs/ux/Ext.ux.FitToParent.js'); 00630 } 00631 00632 00633 /** 00634 * Gets the buttons that shall be rendered in the docHeader. 00635 * 00636 * @return array Available buttons for the docHeader 00637 */ 00638 protected function getDocHeaderButtons() { 00639 $buttons = array( 00640 'csh' => t3lib_BEfunc::cshItem('_MOD_web_func', '', $GLOBALS['BACK_PATH']), 00641 'shortcut' => $this->getShortcutButton(), 00642 'save' => '' 00643 ); 00644 return $buttons; 00645 } 00646 00647 00648 /** 00649 * Gets the button to set a new shortcut in the backend (if current user is allowed to). 00650 * 00651 * @return string HTML representiation of the shortcut button 00652 */ 00653 protected function getShortcutButton() { 00654 $result = ''; 00655 if ($GLOBALS['BE_USER']->mayMakeShortcut()) { 00656 $result = $this->doc->makeShortcutIcon('', 'function', $this->MCONF['name']); 00657 } 00658 return $result; 00659 } 00660 00661 00662 /** 00663 * Gets the filled markers that are used in the HTML template. 00664 * 00665 * @return array The filled marker array 00666 */ 00667 protected function getTemplateMarkers() { 00668 $markers = array( 00669 'FUNC_TITLE' => $GLOBALS['LANG']->getLL('report.func.title'), 00670 'CHECKOPTIONS_TITLE' => $GLOBALS['LANG']->getLL('report.statistics.header'), 00671 'FUNC_MENU' => $this->getLevelSelector(), 00672 'CONTENT' => $this->content, 00673 'CHECKALLLINK' => $this->checkAllHtml, 00674 'CHECKOPTIONS' => $this->checkOptHtml, 00675 'ID' => '<input type="hidden" name="id" value="' . $this->pObj->id . '" />', 00676 'REFRESH' => $this->refreshListHtml, 00677 'UPDATE' => '' 00678 ); 00679 00680 return $markers; 00681 } 00682 00683 /** 00684 * Gets the filled markers that are used in the HTML template. 00685 * 00686 * @return array The filled marker array 00687 */ 00688 protected function getTemplateMarkersCheck() { 00689 $markers = array( 00690 'FUNC_TITLE' =>$GLOBALS['LANG']->getLL('checklinks.func.title'), 00691 'CHECKOPTIONS_TITLE' =>$GLOBALS['LANG']->getLL('checklinks.statistics.header'), 00692 'FUNC_MENU' => $this->getLevelSelector(), 00693 'CONTENT' => '', 00694 'CHECKALLLINK' => $this->checkAllHtml, 00695 'CHECKOPTIONS' => $this->checkOptHtmlCheck, 00696 'ID' => '<input type="hidden" name="id" value="' . $this->pObj->id . '" />', 00697 'REFRESH' => '', 00698 'UPDATE' => $this->updateListHtml 00699 ); 00700 00701 return $markers; 00702 } 00703 00704 00705 /** 00706 * Determines whether the current user is an admin. 00707 * 00708 * @return boolean Whether the current user is admin 00709 */ 00710 protected function isCurrentUserAdmin() { 00711 return ((bool) $GLOBALS['BE_USER']->user['admin']); 00712 } 00713 } 00714 00715 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/linkvalidator/modfuncreport/class.tx_linkvalidator_modfuncreport.php'])) { 00716 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/linkvalidator/modfuncreport/class.tx_linkvalidator_modfuncreport.php']); 00717 } 00718 00719 ?>
1.8.0