예제 #1
0
파일: replace.php 프로젝트: naka211/compac
 public function replaceTags(&$string, $area = 'article')
 {
     if (!is_string($string) || $string == '') {
         return;
     }
     if (strpos($string, '{' . $this->params->article_tag) === false) {
         return;
     }
     // allow in component?
     if (($area == 'component' || $area == 'article' && JFactory::getApplication()->input->get('option') == 'com_content') && in_array(JFactory::getApplication()->input->get('option'), $this->params->disabled_components)) {
         $this->helpers->get('protect')->protect($string);
         $this->helpers->get('process')->removeAll($string, $area);
         nnProtect::unprotect($string);
         return;
     }
     $this->helpers->get('protect')->protect($string);
     $this->params->message = '';
     // COMPONENT
     if (JFactory::getDocument()->getType() == 'feed') {
         $s = '#(<item[^>]*>)#s';
         $string = preg_replace($s, '\\1<!-- START: AA_COMPONENT -->', $string);
         $string = str_replace('</item>', '<!-- END: AA_COMPONENT --></item>', $string);
     }
     if (strpos($string, '<!-- START: AA_COMPONENT -->') === false) {
         $this->helpers->get('tag')->tagArea($string, 'component');
     }
     $components = $this->helpers->get('tag')->getAreaByType($string, 'component');
     foreach ($components as $component) {
         $this->helpers->get('process')->processArticles($component['1'], 'components');
         $string = str_replace($component['0'], $component['1'], $string);
     }
     // EVERYWHERE
     $this->helpers->get('process')->processArticles($string, 'other');
     nnProtect::unprotect($string);
 }
예제 #2
0
 /**
  * onAfterRender
  */
 public function onAfterRender()
 {
     // only in html and feeds
     if (JFactory::getDocument()->getType() !== 'html' && JFactory::getDocument()->getType() !== 'feed') {
         return;
     }
     // Grab the body (but be gentle)
     $html = JResponse::getBody();
     if ($html == '') {
         return;
     }
     list($pre, $body, $post) = nnText::getBody($html);
     $this->protect($body);
     $this->replaceInTheRest($body);
     nnProtect::unprotect($body);
     $this->cleanTagsFromHead($pre);
     $html = $pre . $body . $post;
     $this->cleanLeftoverJunk($html);
     // Throw the body back (less gentle)
     JResponse::setBody($html);
 }
예제 #3
0
파일: helper.php 프로젝트: A-Bush/pprod
 function replaceTags(&$string, $area = 'article')
 {
     if (!is_string($string) || $string == '') {
         return;
     }
     if (!preg_match('#\\{' . $this->params->tags . '#', $string)) {
         return;
     }
     // allow in component?
     if ($area == 'component' && in_array(JFactory::getApplication()->input->get('option'), $this->params->disabled_components)) {
         $this->protectTags($string);
         return;
     }
     $this->protect($string);
     // COMPONENT
     if (JFactory::getDocument()->getType() == 'feed') {
         $s = '#(<item[^>]*>)#s';
         $string = preg_replace($s, '\\1<!-- START: MODA_COMPONENT -->', $string);
         $string = str_replace('</item>', '<!-- END: MODA_COMPONENT --></item>', $string);
     }
     if (strpos($string, '<!-- START: MODA_COMPONENT -->') === false) {
         $this->tagArea($string, 'MODA', 'component');
     }
     $this->params->message = '';
     $components = $this->getTagArea($string, 'MODA', 'component');
     foreach ($components as $component) {
         $this->processModules($component['1'], 'components');
         $string = str_replace($component['0'], $component['1'], $string);
     }
     // EVERYWHERE
     $this->processModules($string, 'other');
     nnProtect::unprotect($string);
 }
예제 #4
0
 /**
  * replace any protected tags to original
  */
 public static function unprotectForm(&$string, $tags = array())
 {
     // Protect entire form
     if (empty($tags)) {
         nnProtect::unprotect($string);
         return;
     }
     nnProtect::unprotectTags($string, $tags);
 }
예제 #5
0
 function replaceTags(&$string, $area = 'article')
 {
     if (!is_string($string) || $string == '') {
         return;
     }
     if ($area == 'component') {
         // allow in component?
         if (in_array(JFactory::getApplication()->input->get('option'), $this->params->disabled_components)) {
             $this->protectTags($string);
             return;
         }
     }
     if (strpos($string, '{' . $this->params->tag) === false) {
         return;
     }
     $this->protect($string);
     while (preg_match_all($this->params->regex, $string, $matches, PREG_SET_ORDER) > 0) {
         foreach ($matches as $match) {
             $snippet_html = $this->processSnippet(trim($match['2']), trim($match['3']));
             if ($this->params->place_comments) {
                 $snippet_html = $this->params->comment_start . $snippet_html . $this->params->comment_end;
             }
             if (!$match['1'] || !$match['4']) {
                 $snippet_html = trim($match['1']) . $snippet_html . trim($match['4']);
             }
             $string = str_replace($match['0'], $snippet_html, $string);
         }
     }
     nnProtect::unprotect($string);
 }