public function processArticles(&$string, $area = 'articles', $art = null) { 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_close = '#\\{/' . $this->params->tags . '\\}#si'; if (@preg_match($regex_close . 'u', $string)) { $regex_close .= 'u'; } $regex = $this->params->regex; if (@preg_match($regex . 'u', $string)) { $regex .= 'u'; } $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; }
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; }
function replace(&$string, $regex, $area = 'articles') { list($pre_string, $string, $post_string) = nnText::getContentContainingSearches($string, $this->params->start_tags, null, 200, 500); if ($string == '') { $string = $pre_string . $string . $post_string; return; } if (@preg_match($regex . 'u', $string)) { $regex .= 'u'; } $matches = array(); $protects = array(); if (!nnText::stringContains($string, $this->params->start_tags) || !preg_match_all($regex, $string, $matches, PREG_SET_ORDER)) { $string = $pre_string . $string . $post_string; return; } foreach ($matches as $match) { 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) { $string = str_replace($protect['1'], $protect['0'], $string); } $string = $pre_string . $string . $post_string; }