本文整理汇总了PHP中ApacheSolrForTypo3\Solr\Util::containsOneOfTheStrings方法的典型用法代码示例。如果您正苦于以下问题:PHP Util::containsOneOfTheStrings方法的具体用法?PHP Util::containsOneOfTheStrings怎么用?PHP Util::containsOneOfTheStrings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ApacheSolrForTypo3\Solr\Util
的用法示例。
在下文中一共展示了Util::containsOneOfTheStrings方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: excludeContentByClass
/**
* Exclude some html parts by class inside content wrapped with TYPO3SEARCH_begin and TYPO3SEARCH_end
* markers.
*
* @param string $indexableContent HTML markup
* @return string HTML
*/
public function excludeContentByClass($indexableContent)
{
if (empty(trim($indexableContent))) {
return html_entity_decode($indexableContent);
}
$excludeClasses = $this->getConfiguration()->getIndexQueuePagesExcludeContentByClassArray();
if (count($excludeClasses) === 0) {
return html_entity_decode($indexableContent);
}
$isInContent = Util::containsOneOfTheStrings($indexableContent, $excludeClasses);
if (!$isInContent) {
return html_entity_decode($indexableContent);
}
$doc = new \DOMDocument('1.0', 'UTF-8');
libxml_use_internal_errors(true);
$doc->loadHTML('<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL . $indexableContent);
$xpath = new \DOMXPath($doc);
foreach ($excludeClasses as $excludePart) {
$elements = $xpath->query("//*[contains(@class,'" . $excludePart . "')]");
if (count($elements) == 0) {
continue;
}
foreach ($elements as $element) {
$element->parentNode->removeChild($element);
}
}
$html = $doc->saveHTML($doc->documentElement->parentNode);
// remove XML-Preamble, newlines and doctype
$html = preg_replace('/(<\\?xml[^>]+\\?>|\\r?\\n|<!DOCTYPE.+?>)/imS', '', $html);
$html = str_replace(array('<html>', '</html>', '<body>', '</body>'), array('', '', '', ''), $html);
return $html;
}