Bug #13828 ยป 13828.diff
classes/class.tx_linkvalidator_processor.php (copie de travail) | ||
---|---|---|
* @param string Perms clause
|
||
* @return string Returns the list with a comma in the end (if any pages selected!)
|
||
*/
|
||
public function extGetTreeList($id, $depth, $begin = 0, $permsClause) {
|
||
public function extGetTreeList($id, $depth, $begin = 0, $permsClause, $considerHidden = FALSE) {
|
||
$depth = intval($depth);
|
||
$begin = intval($begin);
|
||
$id = intval($id);
|
||
... | ... | |
if ($depth > 0) {
|
||
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
|
||
'uid,title',
|
||
'uid,title,hidden,extendToSubpages',
|
||
'pages',
|
||
'pid=' . $id . ' AND deleted=0 AND ' . $permsClause
|
||
);
|
||
|
||
while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
|
||
if ($begin <= 0) {
|
||
if ($begin <= 0 && ($row['hidden']==0 || $considerHidden == 1)) {
|
||
$theList .= $row['uid'] . ',';
|
||
$this->extPageInTreeInfo[] = array($row['uid'], htmlspecialchars($row['title'], $depth));
|
||
}
|
||
if ($depth > 1) {
|
||
$theList .= $this->extGetTreeList($row['uid'], $depth - 1, $begin - 1, $permsClause);
|
||
if ($depth > 1 && (!($row['hidden']==1 && $row['extendToSubpages']==1) || $considerHidden == 1)) {
|
||
$theList .= $this->extGetTreeList($row['uid'], $depth - 1, $begin - 1, $permsClause, $considerHidden);
|
||
}
|
||
}
|
||
}
|
||
return $theList;
|
||
}
|
||
public function getRootLineIsHidden($pageInfo){
|
||
$hidden = FALSE;
|
||
if($pageInfo['extendToSubpages'] == 1 && $pageInfo['hidden'] == 1){
|
||
$hidden = TRUE;
|
||
}
|
||
else{
|
||
if($pageInfo['pid'] > 0) {
|
||
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
|
||
'uid,title,hidden,extendToSubpages',
|
||
'pages',
|
||
'uid=' . $pageInfo['pid']
|
||
);
|
||
|
||
while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
|
||
$hidden = $this->getRootLineIsHidden($row);
|
||
}
|
||
}
|
||
else {
|
||
$hidden = FALSE;
|
||
}
|
||
}
|
||
return $hidden;
|
||
|
||
}
|
||
}
|
||
classes/tasks/class.tx_linkvalidator_tasks_validator.php (copie de travail) | ||
---|---|---|
$searchFields = $this->getSearchField($modTS);
|
||
$linkTypes = $this->getLinkTypes($modTS);
|
||
$processor = t3lib_div::makeInstance('tx_linkvalidator_Processor');
|
||
$pageIds = $processor->extGetTreeList($page, $this->depth, 0, '1=1');
|
||
$pageIds .= $page;
|
||
$processor->init($searchFields, $pageIds);
|
||
if (!empty($this->email)) {
|
||
$oldLinkCounts = $processor->getLinkCounts($page);
|
||
$this->oldTotalBrokenLink += $oldLinkCounts['brokenlinkCount'];
|
||
$pageRow = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('*', 'pages', 'uid=' . $page);
|
||
$rootLineHidden = $processor->getRootLineIsHidden($pageRow);
|
||
if(!$rootLineHidden || $modTS['checkhidden']==1) {
|
||
$pageIds = $processor->extGetTreeList($page, $this->depth, 0, '1=1', $modTS['checkhidden']);
|
||
if($pageRow['hidden'] == 0 || $modTS['checkhidden']==1){
|
||
$pageIds .= $page;
|
||
}
|
||
|
||
$processor->init($searchFields, $pageIds);
|
||
if (!empty($this->email)) {
|
||
$oldLinkCounts = $processor->getLinkCounts($page);
|
||
$this->oldTotalBrokenLink += $oldLinkCounts['brokenlinkCount'];
|
||
}
|
||
|
||
$processor->getLinkStatistics($array, $modTS['checkhidden']);
|
||
|
||
if (!empty($this->email)) {
|
||
$linkCounts = $processor->getLinkCounts($page);
|
||
$this->totalBrokenLink += $linkCounts['brokenlinkCount'];
|
||
$pageSections = $this->buildMail($page, $pageIds, $linkCounts, $oldLinkCounts);
|
||
}
|
||
}
|
||
$processor->getLinkStatistics($linkTypes, $modTS['checkhidden']);
|
||
... | ... | |
* @return array $searchFields: list of fields.
|
||
*/
|
||
protected function getSearchField($modTS) {
|
||
// get the searchFields from TCA
|
||
foreach ($GLOBALS['TCA'] as $tableName => $table) {
|
||
if (!empty($table['columns'])) {
|
||
foreach ($table['columns'] as $columnName => $column) {
|
||
if ($column['config']['type'] == 'text' || $column['config']['type'] == 'input') {
|
||
if (!empty($column['config']['softref']) && (stripos($column['config']['softref'], "typolink")
|
||
!== FALSE || stripos($column['config']['softref'], "url") !== FALSE)) {
|
||
$searchFields[$tableName][] = $columnName;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
// get the searchFields from TypoScript
|
||
foreach ($modTS['searchFields.'] as $table => $fieldList) {
|
||
$fields = t3lib_div::trimExplode(',', $fieldList);
|
||
foreach ($fields as $field) {
|
||
if (is_array($searchFields[$table])) {
|
||
if (array_search($field, $searchFields[$table]) === FALSE) {
|
||
$searchFields[$table][] = $field;
|
||
}
|
||
}
|
||
$searchFields[$table][] = $field;
|
||
}
|
||
}
|
||
return $searchFields;
|
modfuncreport/class.tx_linkvalidator_modfuncreport.php (copie de travail) | ||
---|---|---|
}
|
||
}
|
||
}
|
||
// get children pages
|
||
$pageList = $this->processor->extGetTreeList(
|
||
$this->pObj->id,
|
||
$this->searchLevel,
|
||
0,
|
||
$GLOBALS['BE_USER']->getPagePermsClause(1)
|
||
);
|
||
$pageList .= $this->pObj->id;
|
||
$rootLineHidden = $this->processor->getRootLineIsHidden($this->pObj->pageinfo);
|
||
if(!$rootLineHidden || $this->modTS['checkhidden']==1) {
|
||
// get children pages
|
||
$pageList = $this->processor->extGetTreeList(
|
||
$this->pObj->id,
|
||
$this->searchLevel,
|
||
0,
|
||
$GLOBALS['BE_USER']->getPagePermsClause(1),
|
||
$this->modTS['checkhidden']
|
||
);
|
||
|
||
|
||
if($this->pObj->pageinfo['hidden'] == 0 || $this->modTS['checkhidden']==1){
|
||
$pageList .= $this->pObj->id;
|
||
}
|
||
|
||
$this->processor->init($searchFields, $pageList);
|
||
// check if button press
|
||
$update = t3lib_div::_GP('updateLinkList');
|
||
if (!empty($update)) {
|
||
$this->processor->getLinkStatistics($this->checkOpt, $this->modTS['checkhidden']);
|
||
$this->processor->init($searchFields, $pageList);
|
||
|
||
// check if button press
|
||
$update = t3lib_div::_GP('updateLinkList');
|
||
|
||
if (!empty($update)) {
|
||
$this->processor->getLinkStatistics($this->checkOpt, $this->modTS['checkhidden']);
|
||
}
|
||
}
|
||
}
|
||
/**
|
||
* Renders the content of the module.
|
||
*
|
||
... | ... | |
protected function renderBrokenLinksTable() {
|
||
$items = $brokenLinksMarker = array();
|
||
$brokenLinkItems = $brokenLinksTemplate = '';
|
||
$brokenLinksTemplate = t3lib_parsehtml::getSubpart($this->doc->moduleTemplate, '###NOBROKENLINKS_CONTENT###');
|
||
$keyOpt = array();
|
||
if (is_array($this->checkOpt)) {
|
||
$keyOpt = array_keys($this->checkOpt);
|
||
}
|
||
$pageList = $this->processor->extGetTreeList(
|
||
$this->pObj->id,
|
||
$this->searchLevel,
|
||
0,
|
||
$GLOBALS['BE_USER']->getPagePermsClause(1)
|
||
);
|
||
$pageList .= $this->pObj->id;
|
||
if (($res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
|
||
'*',
|
||
'tx_linkvalidator_link',
|
||
'record_pid in (' . $pageList . ') and link_type in (\'' . implode("','", $keyOpt) . '\')',
|
||
'',
|
||
'record_uid ASC, uid ASC')
|
||
)) {
|
||
$rootLineHidden = $this->processor->getRootLineIsHidden($this->pObj->pageinfo);
|
||
if(!$rootLineHidden || $this->modTS['checkhidden']==1) {
|
||
$pageList = $this->processor->extGetTreeList(
|
||
$this->pObj->id,
|
||
$this->searchLevel,
|
||
0,
|
||
$GLOBALS['BE_USER']->getPagePermsClause(1),
|
||
$this->modTS['checkhidden']
|
||
);
|
||
if($this->pObj->pageinfo['hidden'] == 0 || $this->modTS['checkhidden']==1){
|
||
$pageList .= $this->pObj->id;
|
||
}
|
||
|
||
if (($res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
|
||
'*',
|
||
'tx_linkvalidator_link',
|
||
'record_pid in (' . $pageList . ') and link_type in (\'' . implode("','", $keyOpt) . '\')',
|
||
'',
|
||
'record_uid ASC, uid ASC')
|
||
)) {
|
||
// Display table with broken links
|
||
if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) > 0) {
|
||
$brokenLinksTemplate = t3lib_parsehtml::getSubpart($this->doc->moduleTemplate, '###BROKENLINKS_CONTENT###');
|
||
$brokenLinksItemTemplate = t3lib_parsehtml::getSubpart($this->doc->moduleTemplate, '###BROKENLINKS_ITEM###');
|
||
// Table header
|
||
$brokenLinksMarker = $this->startTable();
|
||
// Table rows containing the broken links
|
||
while (($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))) {
|
||
$items[] = $this->renderTableRow($row['table_name'], $row, $brokenLinksItemTemplate);
|
||
if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) > 0) {
|
||
$brokenLinksTemplate = t3lib_parsehtml::getSubpart($this->doc->moduleTemplate, '###BROKENLINKS_CONTENT###');
|
||
|
||
$brokenLinksItemTemplate = t3lib_parsehtml::getSubpart($this->doc->moduleTemplate, '###BROKENLINKS_ITEM###');
|
||
|
||
// Table header
|
||
$brokenLinksMarker = $this->startTable();
|
||
|
||
// Table rows containing the broken links
|
||
while (($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))) {
|
||
$items[] = $this->renderTableRow($row['table_name'], $row, $brokenLinksItemTemplate);
|
||
}
|
||
$brokenLinkItems = implode(chr(10), $items);
|
||
|
||
// Display note that there are no broken links to display
|
||
} else {
|
||
$brokenLinksMarker = $this->getNoBrokenLinkMessage($brokenLinksMarker);
|
||
}
|
||
$brokenLinkItems = implode(chr(10), $items);
|
||
// Display note that there are no broken links to display
|
||
} else {
|
||
$brokenLinksTemplate = t3lib_parsehtml::getSubpart($this->doc->moduleTemplate, '###NOBROKENLINKS_CONTENT###');
|
||
$brokenLinksMarker['LIST_HEADER'] = $this->doc->sectionHeader($GLOBALS['LANG']->getLL('list.header'));
|
||
$message = t3lib_div::makeInstance(
|
||
't3lib_FlashMessage',
|
||
$GLOBALS['LANG']->getLL('list.no.broken.links'),
|
||
$GLOBALS['LANG']->getLL('list.no.broken.links.title'),
|
||
t3lib_FlashMessage::OK
|
||
);
|
||
$brokenLinksMarker['NO_BROKEN_LINKS'] = $message->render();
|
||
}
|
||
}
|
||
else{
|
||
|
||
$brokenLinksMarker = $this->getNoBrokenLinkMessage($brokenLinksMarker);
|
||
}
|
||
$brokenLinksTemplate = t3lib_parsehtml::substituteMarkerArray($brokenLinksTemplate, $brokenLinksMarker, '###|###', TRUE);
|
||
$content = t3lib_parsehtml::substituteSubpart($brokenLinksTemplate, '###BROKENLINKS_ITEM', $brokenLinkItems);
|
||
return $content;
|
||
}
|
||
protected function getNoBrokenLinkMessage($brokenLinksMarker){
|
||
$brokenLinksMarker['LIST_HEADER'] = $this->doc->sectionHeader($GLOBALS['LANG']->getLL('list.header'));
|
||
$message = t3lib_div::makeInstance(
|
||
't3lib_FlashMessage',
|
||
$GLOBALS['LANG']->getLL('list.no.broken.links'),
|
||
$GLOBALS['LANG']->getLL('list.no.broken.links.title'),
|
||
t3lib_FlashMessage::OK
|
||
);
|
||
$brokenLinksMarker['NO_BROKEN_LINKS'] = $message->render();
|
||
|
||
return $brokenLinksMarker;
|
||
}
|
||
/**
|
||
* Displays the table header of the table with the broken links.
|
||
*
|