Bug #10989 » 10989_v2.diff
classes/class.tx_linkvalidator_processing.php (working copy) | ||
---|---|---|
foreach ($this->hookObjectsArr as $key => $hookObj) {
|
||
if ((is_array($results[$key])) && empty($checkOptions) || (is_array($results[$key]) && $checkOptions[$key])) {
|
||
// check'em!
|
||
// check'em!
|
||
foreach ($results[$key] as $entryKey => $entryValue) {
|
||
$table = $entryValue['table'];
|
||
$record = array();
|
||
... | ... | |
$record['linktitle'] = $entryValue['linktitle'];
|
||
$record['field'] = $entryValue['field'];
|
||
$record['lastcheck'] = time();
|
||
$url = $entryValue['substr']['tokenValue'];
|
||
$this->recordReference = $entryValue['substr']['recordRef'];
|
||
$this->pageWithAnchor = $entryValue['pageAndAnchor'];
|
||
|
||
if (!empty($this->pageWithAnchor)) {
|
||
// page with anchor, e.g. 18#1580
|
||
$url = $this->pageWithAnchor;
|
||
} else {
|
||
$url = $entryValue['substr']['tokenValue'];
|
||
}
|
||
$this->linkCounts[$table]++;
|
||
$checkURL = $hookObj->checkLink($url, $entryValue, $this);
|
||
// broken link found!
|
||
... | ... | |
// array to store urls from relevant field contents
|
||
$urls = array();
|
||
$referencedRecordType = '';
|
||
// last-parsed link element was a page.
|
||
$wasPage = TRUE;
|
||
// flag whether row contains a broken link in some field or not
|
||
$rowContainsBrokenLink = FALSE;
|
||
|
||
... | ... | |
foreach ($softRefs as $spKey => $spParams) {
|
||
// create / get object
|
||
$softRefObj = &t3lib_BEfunc::softRefParserObj($spKey);
|
||
$referencedRecordType='';
|
||
// If there was an object returned...:
|
||
if (is_object($softRefObj)) {
|
||
// Do processing
|
||
|
||
$resultArray = $softRefObj->findRef($table, $field, $idRecord, $valueField, $spKey, $spParams);
|
||
if (!empty($resultArray['elements'])) {
|
||
if ($spKey == 'typolink_tag') {
|
||
$linkTags = $htmlParser->splitIntoBlock('link', $resultArray['content']);
|
||
}
|
||
foreach ($resultArray['elements'] as $element) {
|
||
$r = $element['subst'];
|
||
$title = '';
|
||
$type = '';
|
||
if (!empty($r)) {
|
||
// Parse string for special TYPO3 <link> tag:
|
||
if ($spKey == 'typolink_tag') {
|
||
foreach ($linkTags as $textPart) {
|
||
if (substr_count($textPart, $r['tokenID'])) {
|
||
$title = strip_tags($textPart);
|
||
|
||
for ($i = 1; $i < count($linkTags); $i += 2) {
|
||
$referencedRecordType = '';
|
||
foreach($resultArray['elements'] as $element) {
|
||
$r = $element['subst'];
|
||
|
||
if (substr_count($linkTags[$i], $r['tokenID'])) {
|
||
// Type of referenced record
|
||
if (strpos($r['recordRef'], 'pages') !== FALSE) {
|
||
$currentR = $r;
|
||
// contains number of the page
|
||
$referencedRecordType = $r['tokenValue'];
|
||
$wasPage = TRUE;
|
||
}
|
||
// append number of content element to the page saved in the last loop
|
||
elseif ((strpos($r['recordRef'], 'tt_content') !== FALSE) && ($wasPage === TRUE)) {
|
||
$referencedRecordType = $referencedRecordType . '#' . $r['tokenValue'];
|
||
$wasPage = FALSE;
|
||
}
|
||
else{
|
||
$currentR = $r;
|
||
}
|
||
$title = strip_tags($linkTags[$i]);
|
||
}
|
||
}
|
||
}
|
||
foreach ($this->hookObjectsArr as $keyArr => $hookObj) {
|
||
$type = $hookObj->fetchType($r, $type, $keyArr);
|
||
$type = $hookObj->fetchType($currentR, $type, $keyArr);
|
||
}
|
||
$results[$type][$table . ':' . $field . ':' . $idRecord . ':' . $r["tokenID"]]["substr"] = $r;
|
||
$results[$type][$table . ':' . $field . ':' . $idRecord . ':' . $r["tokenID"]]["row"] = $record;
|
||
$results[$type][$table . ':' . $field . ':' . $idRecord . ':' . $r["tokenID"]]["table"] = $table;
|
||
$results[$type][$table . ':' . $field . ':' . $idRecord . ':' . $r["tokenID"]]["field"] = $field;
|
||
$results[$type][$table . ':' . $field . ':' . $idRecord . ':' . $r["tokenID"]]["uid"] = $idRecord;
|
||
$results[$type][$table . ':' . $field . ':' . $idRecord . ':' . $r["tokenID"]]["linktitle"] = $title;
|
||
}
|
||
$results[$type][$table . ':' . $field . ':' . $idRecord . ':' . $currentR["tokenID"]]["substr"] = $currentR;
|
||
$results[$type][$table . ':' . $field . ':' . $idRecord . ':' . $currentR["tokenID"]]["row"] = $record;
|
||
$results[$type][$table . ':' . $field . ':' . $idRecord . ':' . $currentR["tokenID"]]["table"] = $table;
|
||
$results[$type][$table . ':' . $field . ':' . $idRecord . ':' . $currentR["tokenID"]]["field"] = $field;
|
||
$results[$type][$table . ':' . $field . ':' . $idRecord . ':' . $currentR["tokenID"]]["uid"] = $idRecord;
|
||
$results[$type][$table . ':' . $field . ':' . $idRecord . ':' . $currentR["tokenID"]]["linktitle"] = $title;
|
||
$results[$type][$table . ':' . $field . ':' . $idRecord . ':' . $currentR["tokenID"]]["pageAndAnchor"] = $referencedRecordType;
|
||
|
||
}
|
||
}
|
||
else{
|
||
|
||
|
||
foreach ($resultArray['elements'] as $element) {
|
||
$r = $element['subst'];
|
||
$title = '';
|
||
$type = '';
|
||
|
||
if (!empty($r)) {
|
||
// Parse string for special TYPO3 <link> tag:
|
||
|
||
foreach ($this->hookObjectsArr as $keyArr => $hookObj) {
|
||
$type = $hookObj->fetchType($r, $type, $keyArr);
|
||
}
|
||
$results[$type][$table . ':' . $field . ':' . $idRecord . ':' . $r["tokenID"]]["substr"] = $r;
|
||
$results[$type][$table . ':' . $field . ':' . $idRecord . ':' . $r["tokenID"]]["row"] = $record;
|
||
$results[$type][$table . ':' . $field . ':' . $idRecord . ':' . $r["tokenID"]]["table"] = $table;
|
||
$results[$type][$table . ':' . $field . ':' . $idRecord . ':' . $r["tokenID"]]["field"] = $field;
|
||
$results[$type][$table . ':' . $field . ':' . $idRecord . ':' . $r["tokenID"]]["uid"] = $idRecord;
|
||
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
/**
|
||
* Fill a markerarray with the number of links found in a list of pages.
|
||
*
|
classes/linktypes/class.tx_linkvalidator_linktypes_internal.php (working copy) | ||
---|---|---|
const DELETED = 'deleted';
|
||
const HIDDEN = 'hidden';
|
||
const MOVED = 'moved';
|
||
var $errorParams = array();
|
||
var $responsePage = TRUE;
|
||
var $responseContent = TRUE;
|
||
/**
|
||
* Checks a given URL + /path/filename.ext for validity
|
||
*
|
||
* @param string $url: url to check
|
||
* @param string $url: url to check as page-id or page-id#anchor (if anchor is present)
|
||
* @param array $softRefEntry: the softref entry which builds the context of that url
|
||
* @param object $reference: parent instance of tx_linkvalidator_processing
|
||
* @return string TRUE on success or FALSE on error
|
||
*/
|
||
public function checkLink($url, $softRefEntry, $reference) {
|
||
$page = '';
|
||
$anchor = '';
|
||
$response = TRUE;
|
||
// Might already contain values - empty it.
|
||
unset($this->errorParams);
|
||
// defines the linked page and anchor (if any).
|
||
if (strpos($url, '#') !== FALSE) {
|
||
$parts = explode('#', $url);
|
||
$page = $parts[0];
|
||
$anchor = $parts[1];
|
||
} else {
|
||
$page = $url;
|
||
}
|
||
// Check if the linked page is OK.
|
||
$this->responsePage = $this->checkPage($page, $softRefEntry, $reference);
|
||
// Check if the linked content element is OK.
|
||
if ($anchor) {
|
||
// Get page ID on which the content element is located
|
||
$res = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
|
||
'pid',
|
||
'tt_content',
|
||
'uid = ' . intval($anchor)
|
||
);
|
||
// this content element exists
|
||
if ($res[0]) {
|
||
// pageID on which this CE is in fact located.
|
||
$pageID = $res[0]['pid'];
|
||
// the element might have been moved to another page.
|
||
if (!($pageID === $page)) {
|
||
$this->errorParams['errorType']['content'] = MOVED;
|
||
$this->errorParams['content']['uid'] = intval($anchor);
|
||
$this->errorParams['content']['wrongPage'] = intval($page);
|
||
$this->errorParams['content']['rightPage'] = intval($pageID);
|
||
$this->responseContent = FALSE;
|
||
} else {
|
||
// Check if the content element is OK. Can be TRUE or FALSE
|
||
$this->responseContent = $this->checkContent($url, $pageID, $softRefEntry, $reference);
|
||
}
|
||
} else {
|
||
// content element does not exist
|
||
$this->errorParams['errorType']['content'] = 'notExisting';
|
||
$this->errorParams['content']['uid'] = intval($anchor);
|
||
$this->responseContent = FALSE;
|
||
}
|
||
}
|
||
if ((is_array($this->errorParams['page']) && !$this->responsePage)
|
||
|| (is_array($this->errorParams['content']) && !$this->responseContent)) {
|
||
$this->setErrorParams($this->errorParams);
|
||
}
|
||
if (($this->responsePage === TRUE) && ($this->responseContent === TRUE)) {
|
||
$response = TRUE;
|
||
} else {
|
||
$response = FALSE;
|
||
}
|
||
return $response;
|
||
}
|
||
/**
|
||
* Checks a given page uid for validity
|
||
*
|
||
* @param string $page: page uid to check
|
||
* @param array $softRefEntry: the softref entry which builds the context of that url
|
||
* @param object $reference: parent instance of tx_linkvalidator_processing
|
||
* @return string TRUE on success or FALSE on error
|
||
*/
|
||
public function checkPage($page, $softRefEntry, $reference) {
|
||
$rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
|
||
'uid, title, deleted, hidden, starttime, endtime',
|
||
'pages',
|
||
'uid = ' . intval($url)
|
||
'uid = ' . intval($page)
|
||
);
|
||
$this->responsePage = TRUE;
|
||
$response = TRUE;
|
||
$errorParams = array();
|
||
if ($rows[0]) {
|
||
if ($rows[0]['deleted'] == '1') {
|
||
$errorParams['errorType'] = DELETED;
|
||
$errorParams['title'] = $rows[0]['title'];
|
||
$errorParams['uid'] = $rows[0]['uid'];
|
||
$response = FALSE;
|
||
$this->errorParams['errorType']['page'] = DELETED;
|
||
$this->errorParams['page']['title'] = $rows[0]['title'];
|
||
$this->errorParams['page']['uid'] = $rows[0]['uid'];
|
||
$this->responsePage = FALSE;
|
||
} elseif ($rows[0]['hidden'] == '1'
|
||
|| $GLOBALS['EXEC_TIME'] < intval($rows[0]['starttime'])
|
||
|| ($rows[0]['endtime'] && intval($rows[0]['endtime']) < $GLOBALS['EXEC_TIME'])) {
|
||
$errorParams['errorType'] = HIDDEN;
|
||
$errorParams['title'] = $rows[0]['title'];
|
||
$errorParams['uid'] = $rows[0]['uid'];
|
||
$response = FALSE;
|
||
$this->errorParams['errorType']['page'] = HIDDEN;
|
||
$this->errorParams['page']['title'] = $rows[0]['title'];
|
||
$this->errorParams['page']['uid'] = $rows[0]['uid'];
|
||
$this->responsePage = FALSE;
|
||
}
|
||
} else {
|
||
$errorParams['errorType'] = 'notExisting';
|
||
$errorParams['uid'] = intval($url);
|
||
$response = FALSE;
|
||
$this->errorParams['errorType']['page'] = 'notExisting';
|
||
$this->errorParams['page']['uid'] = intval($page);
|
||
$this->responsePage = FALSE;
|
||
}
|
||
if (is_array($errorParams) && !$response) {
|
||
$this->setErrorParams($errorParams);
|
||
return $this->responsePage;
|
||
}
|
||
/**
|
||
* Checks a given content uid for validity
|
||
*
|
||
* @param string $url: content uid to check
|
||
* @param string $pageID: uid of the page containing the element
|
||
* @param array $softRefEntry: the softref entry which builds the context of that url
|
||
* @param object $reference: parent instance of tx_linkvalidator_processing
|
||
* @return string TRUE on success or FALSE on error
|
||
*/
|
||
public function checkContent($url, $pageID, $softRefEntry, $reference) {
|
||
$rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
|
||
'uid, header, deleted, hidden, starttime, endtime',
|
||
'tt_content',
|
||
'uid = ' . intval($url)
|
||
);
|
||
$this->responseContent = TRUE;
|
||
if ($rows[0]) {
|
||
if ($rows[0]['deleted'] == '1') {
|
||
$this->errorParams['errorType']['content'] = DELETED;
|
||
$this->errorParams['content']['title'] = $rows[0]['header'];
|
||
$this->errorParams['content']['uid'] = $rows[0]['uid'];
|
||
$this->responseContent = FALSE;
|
||
} elseif ($rows[0]['hidden'] == '1'
|
||
|| $GLOBALS['EXEC_TIME'] < intval($rows[0]['starttime'])
|
||
|| ($rows[0]['endtime'] && intval($rows[0]['endtime']) < $GLOBALS['EXEC_TIME'])) {
|
||
$this->errorParams['errorType']['content'] = HIDDEN;
|
||
$this->errorParams['content']['title'] = $rows[0]['header'];
|
||
$this->errorParams['content']['uid'] = $rows[0]['uid'];
|
||
$this->responseContent = FALSE;
|
||
}
|
||
} else {
|
||
$this->errorParams['errorType']['content'] = 'notExisting';
|
||
$this->errorParams['content']['uid'] = intval($url);
|
||
$this->responseContent = FALSE;
|
||
}
|
||
return $response;
|
||
return $this->responseContent;
|
||
}
|
||
/**
|
||
... | ... | |
*/
|
||
public function getErrorMessage($errorParams) {
|
||
$errorType = $errorParams['errorType'];
|
||
switch ($errorType) {
|
||
case DELETED:
|
||
$response = $GLOBALS['LANG']->getLL('list.report.pagedeleted');
|
||
$response = str_replace('###title###', $errorParams['title'], $response);
|
||
$response = str_replace('###uid###', $errorParams['uid'], $response);
|
||
break;
|
||
case HIDDEN:
|
||
$response = $GLOBALS['LANG']->getLL('list.report.pagenotvisible');
|
||
$response = str_replace('###title###', $errorParams['title'], $response);
|
||
$response = str_replace('###uid###', $errorParams['uid'], $response);
|
||
break;
|
||
if (is_array($errorParams['page'])) {
|
||
switch ($errorType['page']) {
|
||
case DELETED:
|
||
$errorPage = $GLOBALS['LANG']->getLL('list.report.pagedeleted');
|
||
$errorPage = str_replace('###title###', $errorParams['page']['title'], $errorPage);
|
||
$errorPage = str_replace('###uid###', $errorParams['page']['uid'], $errorPage);
|
||
break;
|
||
case HIDDEN:
|
||
$errorPage = $GLOBALS['LANG']->getLL('list.report.pagenotvisible');
|
||
$errorPage = str_replace('###title###', $errorParams['page']['title'], $errorPage);
|
||
$errorPage = str_replace('###uid###', $errorParams['page']['uid'], $errorPage);
|
||
break;
|
||
|
||
default:
|
||
$response = $GLOBALS['LANG']->getLL('list.report.pagenotexisting');
|
||
$response = str_replace('###uid###', $errorParams['uid'], $response);
|
||
break;
|
||
default:
|
||
$errorPage = $GLOBALS['LANG']->getLL('list.report.pagenotexisting');
|
||
$errorPage = str_replace('###uid###', $errorParams['page']['uid'], $errorPage);
|
||
break;
|
||
}
|
||
}
|
||
if (is_array($errorParams['content'])) {
|
||
switch ($errorType['content']) {
|
||
case DELETED:
|
||
$errorContent = $GLOBALS['LANG']->getLL('list.report.contentdeleted');
|
||
$errorContent = str_replace('###title###', $errorParams['content']['title'], $errorContent);
|
||
$errorContent = str_replace('###uid###', $errorParams['content']['uid'], $errorContent);
|
||
break;
|
||
case HIDDEN:
|
||
$errorContent = $GLOBALS['LANG']->getLL('list.report.contentnotvisible');
|
||
$errorContent = str_replace('###title###', $errorParams['content']['title'], $errorContent);
|
||
$errorContent = str_replace('###uid###', $errorParams['content']['uid'], $errorContent);
|
||
break;
|
||
case MOVED:
|
||
$errorContent = $GLOBALS['LANG']->getLL('list.report.contentmoved');
|
||
$errorContent = str_replace('###title###', $errorParams['content']['title'], $errorContent);
|
||
$errorContent = str_replace('###uid###', $errorParams['content']['uid'], $errorContent);
|
||
$errorContent = str_replace('###wrongpage###', $errorParams['content']['wrongPage'], $errorContent);
|
||
$errorContent = str_replace('###rightpage###', $errorParams['content']['rightPage'], $errorContent);
|
||
break;
|
||
default:
|
||
$errorContent = $GLOBALS['LANG']->getLL('list.report.contentnotexisting');
|
||
$errorContent = str_replace('###uid###', $errorParams['content']['uid'], $errorContent);
|
||
break;
|
||
}
|
||
}
|
||
if ($errorPage && $errorContent) {
|
||
$response = $errorPage . '<br />' . $errorContent;
|
||
} elseif ($errorPage) {
|
||
$response = $errorPage;
|
||
} elseif ($errorContent) {
|
||
$response = $errorContent;
|
||
}
|
||
return $response;
|
modfunc1/locallang.xml (working copy) | ||
---|---|---|
<label index="list.report.pagedeleted">Page '###title###' (###uid###) is deleted.</label>
|
||
<label index="list.report.pagenotexisting">Page (###uid###) does not exist.</label>
|
||
<label index="list.report.pagenotvisible">Page '###title###' (###uid###) is not visible.</label>
|
||
<label index="list.report.contentdeleted">Element '###title###' (###uid###) is deleted.</label>
|
||
<label index="list.report.contentnotexisting">Element (###uid###) does not exist.</label>
|
||
<label index="list.report.contentnotvisible">Element '###title###' (###uid###) is not visible.</label>
|
||
<label index="list.report.contentmoved">Element '###title###' (###uid###) is not located on page ###wrongpage###, but on page ###rightpage###.</label>
|
||
<label index="list.report.rowdeleted">###title### row (###uid###) is deleted.</label>
|
||
<label index="list.report.rowdeleted.default.title">Linked</label>
|
||
<label index="list.report.rownotexisting">Row (###uid###) does not exist.</label>
|