Beispiel #1
0
 function replace(&$string, $area = 'articles', $article = '')
 {
     if (!is_string($string) || $string == '') {
         return;
     }
     $array = $this->stringToSplitArray($string, $this->src_params->regex);
     $array_count = count($array);
     if ($array_count <= 1) {
         return;
     }
     for ($i = 1; $i < $array_count - 1; $i++) {
         if (!fmod($i, 2) || !preg_match($this->src_params->regex, $array[$i], $match)) {
             continue;
         }
         $data = trim($match['data']);
         $content = trim($match['content']);
         $remove_html = $data !== '0';
         // Remove html tags if code is placed via the WYSIWYG editor
         if ($remove_html) {
             $this->cleanText($content);
         }
         // Add the include file if file=... or include=... is used in the {source} tag
         if ((strpos($data, 'file=') !== false || strpos($data, 'include=') !== false) && ($file = substr($data, strpos($data, '=') + 1)) && JFile::exists(JPATH_SITE . '/' . $file)) {
             $content = '<?php include JPATH_SITE . \'' . $this->src_params->include_path . $file . '\'; ?>' . $content;
         }
         $this->replaceTags($content, $area, $article);
         if (!$remove_html) {
             $array[$i] = $match['start_pre'] . $match['start_post'] . $content . $match['end_pre'] . $match['end_post'];
             continue;
         }
         $tags = NNTags::cleanSurroundingTags(array('start_pre' => $match['start_pre'], 'start_post' => $match['start_post'], 'content' => $content, 'end_pre' => $match['end_pre'], 'end_post' => $match['end_post']));
         $array[$i] = implode('', $tags);
     }
     $string = implode('', $array);
 }
Beispiel #2
0
 function processMatch(&$string, &$data, $area = 'articles')
 {
     if (!empty($this->params->message)) {
         $html = '';
         if ($this->params->place_comments) {
             $html = $this->params->message_start . $this->params->message . $this->params->message_end;
         }
         $string = str_replace($data['0'], $html, $string);
         return true;
     }
     $type = trim($data['type']);
     $id = trim($data['id']);
     // The core loadposition tag supports chrome after a comma. Modules Anywhere uses a bar.
     if ($type == 'loadposition') {
         $id = str_replace(',', '|', $id);
     }
     $chrome = '';
     $forcetitle = 0;
     $ignores = array();
     $overrides = array();
     $vars = str_replace('\\|', '[:MA_BAR:]', $id);
     $vars = explode('|', $vars);
     $id = array_shift($vars);
     foreach ($vars as $var) {
         $var = trim(str_replace('[:MA_BAR:]', '|', $var));
         if (!$var) {
             continue;
         }
         if (strpos($var, '=') === false) {
             if ($this->params->override_style) {
                 $chrome = $var;
             }
             continue;
         }
         if ($type != $this->params->module_tag) {
             continue;
         }
         list($key, $val) = explode('=', $var, 2);
         $val = str_replace(array('\\{', '\\}'), array('{', '}'), $val);
         switch ($key) {
             case 'style':
                 $chrome = $val;
                 break;
             case 'ignore_access':
             case 'ignore_state':
             case 'ignore_assignments':
             case 'ignore_caching':
                 $ignores[$key] = $val;
                 break;
             case 'showtitle':
                 $overrides['showtitle'] = $val;
                 $forcetitle = $val;
                 break;
             default:
                 break;
         }
     }
     if ($type == $this->params->module_tag) {
         if (!$chrome) {
             $chrome = $forcetitle && $this->params->style == 'none' ? 'xhtml' : $this->params->style;
         }
         // module
         $html = $this->processModule($id, $chrome, $ignores, $overrides, $area);
         if ($html == 'MA_IGNORE') {
             return false;
         }
     } else {
         if (!$chrome) {
             $chrome = $forcetitle ? 'xhtml' : '';
         }
         // module position
         $html = $this->processPosition($id, $chrome);
     }
     list($start_div, $end_div) = $this->getDivTags($data);
     $tags = NNTags::cleanSurroundingTags(array('start_div_pre' => $start_div['pre'], 'start_div_post' => $start_div['post'], 'pre' => $data['pre'], 'post' => $data['post'], 'end_div_pre' => $end_div['pre'], 'end_div_post' => $end_div['post']));
     $html = $tags['start_div_pre'] . $start_div['tag'] . $tags['start_div_post'] . $tags['pre'] . $html . $tags['post'] . $tags['end_div_pre'] . $end_div['tag'] . $tags['end_div_post'];
     if ($this->params->place_comments) {
         $html = $this->params->comment_start . $html . $this->params->comment_end;
     }
     $string = str_replace($data['0'], $html, $string);
     unset($data);
     return $id;
 }
Beispiel #3
0
 function replace(&$string, $area = 'articles', $article = '')
 {
     if (!is_string($string) || $string == '') {
         return;
     }
     $array = $this->stringToSplitArray($string, $this->src_params->regex);
     $array_count = count($array);
     if ($array_count <= 1) {
         return;
     }
     for ($i = 1; $i < $array_count - 1; $i++) {
         if (!fmod($i, 2) || !preg_match($this->src_params->regex, $array[$i], $match)) {
             continue;
         }
         $data = NNTags::getTagValues(trim($match['data']), array());
         $content = trim($match['content']);
         $remove_html = !in_array('0', $data->params);
         // Remove html tags if code is placed via the WYSIWYG editor
         if ($remove_html) {
             $this->cleanText($content);
         }
         // Add the include file if file=... or include=... is used in the {source} tag
         $file = !empty($data->file) ? $data->file : (!empty($data->include) ? $data->include : '');
         if (!empty($file) && JFile::exists(JPATH_SITE . '/' . $file)) {
             $content = '<?php include JPATH_SITE . \'' . $this->src_params->include_path . $file . '\'; ?>' . $content;
         }
         $this->replaceTags($content, $area, $article);
         if (!$remove_html) {
             $array[$i] = $match['start_pre'] . $match['start_post'] . $content . $match['end_pre'] . $match['end_post'];
             continue;
         }
         $trim = isset($data->trim) ? $data->trim : $this->src_params->trim;
         if ($trim) {
             $tags = NNTags::cleanSurroundingTags(array('start_pre' => $match['start_pre'], 'start_post' => $match['start_post']));
             $match = array_merge($match, $tags);
             $tags = NNTags::cleanSurroundingTags(array('end_pre' => $match['end_pre'], 'end_post' => $match['end_post']));
             $match = array_merge($match, $tags);
             $tags = NNTags::cleanSurroundingTags(array('start_pre' => $match['start_pre'], 'end_post' => $match['end_post']));
             $match = array_merge($match, $tags);
         }
         $tags = NNTags::cleanSurroundingTags(array('start_pre' => $match['start_pre'], 'start_post' => $match['start_post'], 'end_pre' => $match['end_pre'], 'end_post' => $match['end_post']));
         $array[$i] = $tags['start_pre'] . $tags['start_post'] . $content . $tags['end_pre'] . $tags['end_post'];
     }
     $string = implode('', $array);
 }