Exemplo n.º 1
0
 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;
 }
Exemplo n.º 2
0
 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;
 }
Exemplo n.º 3
0
 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;
 }