/** * @test * @param string $tag List of tags, comma separated. * @param string $content HTML-content * @param bool $eliminateExtraEndTags If set, excessive end tags are ignored - you should probably set this in most cases. * @param array $expected The expected result * @dataProvider splitIntoBlockDataProvider */ public function splitIntoBlock($tag, $content, $eliminateExtraEndTags, $expected) { $this->assertSame($expected, $this->subject->splitIntoBlock($tag, $content, $eliminateExtraEndTags)); }
/** * Find all supported broken links for a specific typoLink * * @param array $resultArray findRef parsed records * @param array $results Array of broken links * @param HtmlParser $htmlParser Instance of html parser * @param array $record The current record * @param string $field The current field * @param string $table The current table * @return void */ 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 = ''; $countLinkTags = count($linkTags); for ($i = 1; $i < $countLinkTags; $i += 2) { $referencedRecordType = ''; foreach ($resultArray['elements'] as $element) { $type = ''; $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; } elseif (strpos($r['recordRef'], 'tt_content') !== FALSE && (isset($wasPage) && $wasPage === TRUE)) { $referencedRecordType = $referencedRecordType . '#c' . $r['tokenValue']; $wasPage = FALSE; } else { $currentR = $r; } $title = strip_tags($linkTags[$i]); } } } /** @var $hookObj \TYPO3\CMS\Linkvalidator\Linktype\AbstractLinktype */ 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; } }