* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
+$GLOBALS['LANG']->includeLLFile('EXT:linkvalidator/modfuncreport/locallang.xml');
+
/**
* This class provides Processing plugin implementation
*
* @package TYPO3
* @subpackage linkvalidator
*/
-
-$GLOBALS['LANG']->includeLLFile('EXT:linkvalidator/modfuncreport/locallang.xml');
-
class tx_linkvalidator_Processor {
/**
/**
* Array for hooks for own checks
*
- * @var array
+ * @var tx_linkvalidator_linktype_Abstract[]
*/
protected $hookObjectsArr = array();
*/
protected $extPageInTreeInfo = array();
+ /**
+ * Reference to the current element with table:uid, e.g. pages:85
+ *
+ * @var string
+ */
+ protected $recordReference = '';
+
+ /**
+ * Linked page together with a possible anchor, e.g. 85#c105
+ *
+ * @var string
+ */
+ protected $pageWithAnchor = '';
+
/**
* Fill hookObjectsArr with different link types and possible XClasses.
*/
// Hook to handle own checks
if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'])) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'] as $key => $classRef) {
- $this->hookObjectsArr[$key] = &t3lib_div::getUserObj($classRef);
+ $this->hookObjectsArr[$key] = t3lib_div::getUserObj($classRef);
}
}
}
*/
public function analyzeRecord(array &$results, $table, array $fields, array $record) {
- // 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;
-
// Put together content of all relevant fields
$haystack = '';
+ /** @var t3lib_parsehtml $htmlParser */
$htmlParser = t3lib_div::makeInstance('t3lib_parsehtml');
$idRecord = $record['uid'];
$softRefs = t3lib_BEfunc::explodeSoftRefParserList($conf['softref']);
// Traverse soft references
foreach ($softRefs as $spKey => $spParams) {
- // create / get object
+ /** @var t3lib_softrefproc $softRefObj Create or get the soft reference object */
$softRefObj = &t3lib_BEfunc::softRefParserObj($spKey);
// If there is an object returned...
* @param string $table The current table
* @return void
*/
- private function analyseLinks(array $resultArray, array &$results, array $record, $field, $table) {
+ protected function analyseLinks(array $resultArray, array &$results, array $record, $field, $table) {
foreach ($resultArray['elements'] as $element) {
$r = $element['subst'];
$type = '';
$idRecord = $record['uid'];
if (!empty($r)) {
- // Parse string for special TYPO3 <link> tag:
+ /** @var tx_linkvalidator_linktype_Abstract $hookObj */
foreach ($this->hookObjectsArr as $keyArr => $hookObj) {
$type = $hookObj->fetchType($r, $type, $keyArr);
+ // Store the type that was found
+ // This prevents overriding by internal validator
+ if (!empty($type)) {
+ $r['type'] = $type;
+ }
}
- $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']]['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;
}
}
* @param string $table The current table
* @return void
*/
- private function analyseTypoLinks(array $resultArray, array &$results, $htmlParser, array $record, $field, $table) {
+ protected function analyseTypoLinks(array $resultArray, array &$results, $htmlParser, array $record, $field, $table) {
$currentR = array();
$linkTags = $htmlParser->splitIntoBlock('link', $resultArray['content']);
$idRecord = $record['uid'];
+ $type = '';
+ $title = '';
for ($i = 1; $i < count($linkTags); $i += 2) {
$referencedRecordType = '';
foreach ($resultArray['elements'] as $element) {
}
}
}
+ /** @var tx_linkvalidator_linktype_Abstract $hookObj */
foreach ($this->hookObjectsArr as $keyArr => $hookObj) {
$type = $hookObj->fetchType($currentR, $type, $keyArr);
+ // Store the type that was found
+ // This prevents overriding by internal validator
+ if (!empty($type)) {
+ $currentR['type'] = $type;
+ }
}
- $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"]]["link_title"] = $title;
- $results[$type][$table . ':' . $field . ':' . $idRecord . ':' . $currentR["tokenID"]]["pageAndAnchor"] = $referencedRecordType;
+ $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']]['link_title'] = $title;
+ $results[$type][$table . ':' . $field . ':' . $idRecord . ':' . $currentR['tokenID']]['pageAndAnchor'] = $referencedRecordType;
}
}
$theList .= $this->extGetTreeList($row['uid'], $depth - 1, $begin - 1, $permsClause, $considerHidden);
}
}
+ $GLOBALS['TYPO3_DB']->sql_free_result($res);
}
- $GLOBALS['TYPO3_DB']->sql_free_result($res);
return $theList;
}
}
-if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/linkvalidator/classes/class.tx_linkvalidator_processor.php'])) {
- include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/linkvalidator/classes/class.tx_linkvalidator_processor.php']);
-}
?>
\ No newline at end of file