Bug #10989 » 10989_v5.diff
classes/class.tx_linkvalidator_processing.php (working copy) | ||
---|---|---|
$record['linktitle'] = $entryValue['linktitle'];
|
||
$record['field'] = $entryValue['field'];
|
||
$record['lastcheck'] = time();
|
||
$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'];
|
||
}
|
||
$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;
|
||
|
||
... | ... | |
// 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']);
|
||
}
|
||
for ($i = 1; $i < count($linkTags); $i += 2) {
|
||
$referencedRecordType = '';
|
||
foreach($resultArray['elements'] as $element) {
|
||
$r = $element['subst'];
|
||
if (!empty($r['tokenID'])) {
|
||
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 . '#c' . $r['tokenValue'];
|
||
$wasPage = FALSE;
|
||
} else {
|
||
$currentR = $r;
|
||
}
|
||
$title = strip_tags($linkTags[$i]);
|
||
}
|
||
}
|
||
}
|
||
foreach ($this->hookObjectsArr as $keyArr => $hookObj) {
|
||
$type = $hookObj->fetchType($currentR, $type, $keyArr);
|
||
}
|
||
$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 = '';
|
||
foreach ($resultArray['elements'] as $element) {
|
||
$r = $element['subst'];
|
||
if (!empty($r)) {
|
||
// Parse string for special TYPO3 <link> tag:
|
||
$title = '';
|
||
$type = '';
|
||
foreach ($this->hookObjectsArr as $keyArr => $hookObj) {
|
||
$type = $hookObj->fetchType($r, $type, $keyArr);
|
||
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);
|
||
}
|
||
}
|
||
$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;
|
||
}
|
||
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;
|
||
$results[$type][$table . ':' . $field . ':' . $idRecord . ':' . $r["tokenID"]]["linktitle"] = $title;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
/**
|
||
* 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';
|
||
const NOTEXISTING = 'notExisting';
|
||
var $errorParams = array();
|
||
var $responsePage = TRUE;
|
||
var $responseContent = TRUE;
|
||
/**
|
||
* Checks a given URL + /path/filename.ext for validity
|
||
*
|
||
* @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 string $url: url 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 checkLink($url, $softRefEntry, $reference) {
|
||
$page = '';
|
||
$anchor = '';
|
||
$response = TRUE;
|
||
$this->responseContent = TRUE;
|
||
// Might already contain values - empty it.
|
||
unset($this->errorParams);
|
||
// defines the linked page and anchor (if any).
|
||
if (strpos($url, '#c') !== FALSE) {
|
||
$parts = explode('#c', $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) {
|
||
// Check if the content element is OK.
|
||
$this->responseContent = $this->checkContent($page, $anchor, $softRefEntry, $reference);
|
||
}
|
||
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($page)
|
||
'uid = ' . intval($url)
|
||
);
|
||
$this->responsePage = TRUE;
|
||
$response = TRUE;
|
||
$errorParams = array();
|
||
if ($rows[0]) {
|
||
if ($rows[0]['deleted'] == '1') {
|
||
$this->errorParams['errorType']['page'] = DELETED;
|
||
$this->errorParams['page']['title'] = $rows[0]['title'];
|
||
$this->errorParams['page']['uid'] = $rows[0]['uid'];
|
||
$this->responsePage = FALSE;
|
||
$errorParams['errorType'] = DELETED;
|
||
$errorParams['title'] = $rows[0]['title'];
|
||
$errorParams['uid'] = $rows[0]['uid'];
|
||
$response = 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']['page'] = HIDDEN;
|
||
$this->errorParams['page']['title'] = $rows[0]['title'];
|
||
$this->errorParams['page']['uid'] = $rows[0]['uid'];
|
||
$this->responsePage = FALSE;
|
||
$errorParams['errorType'] = HIDDEN;
|
||
$errorParams['title'] = $rows[0]['title'];
|
||
$errorParams['uid'] = $rows[0]['uid'];
|
||
$response = FALSE;
|
||
}
|
||
} else {
|
||
$this->errorParams['errorType']['page'] = NOTEXISTING;
|
||
$this->errorParams['page']['uid'] = intval($page);
|
||
$this->responsePage = FALSE;
|
||
$errorParams['errorType'] = 'notExisting';
|
||
$errorParams['uid'] = intval($url);
|
||
$response = FALSE;
|
||
}
|
||
return $this->responsePage;
|
||
}
|
||
/**
|
||
* Checks a given content uid for validity
|
||
*
|
||
* @param string $page: uid of the page to which the link is pointing
|
||
* @param string $anchor: uid of the content element 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 checkContent($page, $anchor, $softRefEntry, $reference) {
|
||
// Get page ID on which the content element in fact is located
|
||
$res = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
|
||
'uid, pid, header, deleted, hidden, starttime, endtime',
|
||
'tt_content',
|
||
'uid = ' . intval($anchor)
|
||
);
|
||
$this->responseContent = TRUE;
|
||
// this content element exists
|
||
if ($res[0]) {
|
||
// page ID on which this CE is in fact located.
|
||
$correctPageID = $res[0]['pid'];
|
||
// check if the element is on the linked page
|
||
// (the element might have been moved to another page)
|
||
if (!($correctPageID === $page)) {
|
||
$this->errorParams['errorType']['content'] = MOVED;
|
||
$this->errorParams['content']['uid'] = intval($anchor);
|
||
$this->errorParams['content']['wrongPage'] = intval($page);
|
||
$this->errorParams['content']['rightPage'] = intval($correctPageID);
|
||
$this->responseContent = FALSE;
|
||
} else {
|
||
// the element is located on the page to which the link is pointing
|
||
if ($res[0]['deleted'] == '1') {
|
||
$this->errorParams['errorType']['content'] = DELETED;
|
||
$this->errorParams['content']['title'] = $res[0]['header'];
|
||
$this->errorParams['content']['uid'] = $res[0]['uid'];
|
||
$this->responseContent = FALSE;
|
||
} elseif ($res[0]['hidden'] == '1'
|
||
|| $GLOBALS['EXEC_TIME'] < intval($res[0]['starttime'])
|
||
|| ($res[0]['endtime'] && intval($res[0]['endtime']) < $GLOBALS['EXEC_TIME'])) {
|
||
$this->errorParams['errorType']['content'] = HIDDEN;
|
||
$this->errorParams['content']['title'] = $res[0]['header'];
|
||
$this->errorParams['content']['uid'] = $res[0]['uid'];
|
||
$this->responseContent = FALSE;
|
||
}
|
||
}
|
||
} else {
|
||
// content element does not exist
|
||
$this->errorParams['errorType']['content'] = NOTEXISTING;
|
||
$this->errorParams['content']['uid'] = intval($anchor);
|
||
$this->responseContent = FALSE;
|
||
if (is_array($errorParams) && !$response) {
|
||
$this->setErrorParams($errorParams);
|
||
}
|
||
return $this->responseContent;
|
||
return $response;
|
||
}
|
||
/**
|
||
... | ... | |
*/
|
||
public function getErrorMessage($errorParams) {
|
||
$errorType = $errorParams['errorType'];
|
||
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;
|
||
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;
|
||
|
||
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;
|
||
default:
|
||
$response = $GLOBALS['LANG']->getLL('list.report.pagenotexisting');
|
||
$response = str_replace('###uid###', $errorParams['uid'], $response);
|
||
break;
|
||
}
|
||
return $response;
|
modfunc1/locallang.xml (working copy) | ||
---|---|---|
<label index="list.edit">Edit element containing this broken link</label>
|
||
<label index="list.field">(Field: %s)</label>
|
||
<label index="list.no.headline">no headline</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.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>
|
- « Previous
- 1
- …
- 3
- 4
- 5
- Next »