本文整理汇总了PHP中NNText::getContentContainingSearches方法的典型用法代码示例。如果您正苦于以下问题:PHP NNText::getContentContainingSearches方法的具体用法?PHP NNText::getContentContainingSearches怎么用?PHP NNText::getContentContainingSearches使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NNText
的用法示例。
在下文中一共展示了NNText::getContentContainingSearches方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processArticles
public function processArticles(&$string, $area = 'articles', $context = '', $art = null)
{
// Check if tags are in the text snippet used for the search component
if (strpos($context, 'com_search.') === 0) {
$limit = explode('.', $context, 2);
$limit = (int) array_pop($limit);
$string_check = substr($string, 0, $limit);
if (strpos($string_check, '{' . $this->params->article_tag) === false && strpos($string_check, '{' . $this->params->articles_tag) === false) {
return;
}
}
list($pre_string, $string, $post_string) = NNText::getContentContainingSearches($string, array('{' . $this->params->article_tag), array('{/' . $this->params->article_tag . '}'));
if ($string == '') {
$string = $pre_string . $string . $post_string;
return;
}
$regex = $this->params->regex;
if (@preg_match($regex . 'u', $string)) {
$regex .= 'u';
}
if (!preg_match_all($regex, $string, $matches, PREG_SET_ORDER) > 0) {
$string = $pre_string . $string . $post_string;
return;
}
$this->getArticlesFromTags($matches);
$matches = array();
$break = 0;
while ($break++ < 10 && strpos($string, $this->params->article_tag) !== false && preg_match_all($regex, $string, $matches, PREG_SET_ORDER) > 0) {
foreach ($matches as $match) {
$this->helpers->get('article')->replace($string, $match, $art);
}
$matches = array();
}
$string = $pre_string . $string . $post_string;
}
示例2: replace
function replace(&$string, $area = 'articles')
{
list($pre_string, $string, $post_string) = NNText::getContentContainingSearches($string, $this->params->start_tags, null, 200, 500);
if ($string == '' || !NNText::stringContains($string, $this->params->start_tags)) {
$string = $pre_string . $string . $post_string;
return;
}
$regex = $this->params->regex;
if (@preg_match($regex . 'u', $string)) {
$regex .= 'u';
}
$matches = array();
$protects = array();
if (!preg_match_all($regex, $string, $matches, PREG_SET_ORDER)) {
$string = $pre_string . $string . $post_string;
return;
}
foreach ($matches as $match) {
if (strpos($string, $match['0']) === false) {
continue;
}
if ($this->processMatch($string, $match, $area)) {
continue;
}
$protected = $this->params->protect_start . base64_encode($match['0']) . $this->params->protect_end;
$string = str_replace($match['0'], $protected, $string);
$protects[] = array($match['0'], $protected);
}
unset($matches);
foreach ($protects as $protect) {
if (strpos($string, $protect['1']) === false) {
continue;
}
$string = str_replace($protect['1'], $protect['0'], $string);
}
$string = $pre_string . $string . $post_string;
}
示例3: replaceInTheRest
function replaceInTheRest(&$string)
{
if (!is_string($string) || $string == '') {
return;
}
list($pre_string, $string, $post_string) = NNText::getContentContainingSearches($string, array('{' . $this->src_params->syntax_word), array('{/' . $this->src_params->syntax_word . '}'));
if ($string == '') {
$string = $pre_string . $string . $post_string;
return;
}
// COMPONENT
if (JFactory::getDocument()->getType() == 'feed') {
$s = '#(<item[^>]*>)#s';
$string = preg_replace($s, '\\1<!-- START: SRC_COMPONENT -->', $string);
$string = str_replace('</item>', '<!-- END: SRC_COMPONENT --></item>', $string);
}
if (strpos($string, '<!-- START: SRC_COMPONENT -->') === false) {
$this->tagArea($string, 'SRC', 'component');
}
$components = $this->getTagArea($string, 'SRC', 'component');
foreach ($components as $component) {
$this->replace($component['1'], 'components', '');
$string = str_replace($component['0'], $component['1'], $string);
}
// EVERYWHERE
$this->replace($string, 'other');
$string = $pre_string . $string . $post_string;
}