Beispiel #1
0
 private function replaceWidgetTags()
 {
     //Tag like {JFBCTag} {JLinkedTag} {SCTag} {JFBCTag field=value field2=value2} {JLinkedTag field=value field2=value2} {SCTag field=value field2=value2}
     $regex = '/\\{(' . $this->scTags . '|JFBC|JLinked)(.*?)}/i';
     $replace = FALSE;
     $contents = JResponse::getBody();
     if (preg_match_all($regex, $contents, $matches, PREG_SET_ORDER)) {
         $count = count($matches[0]);
         if ($count == 0) {
             return true;
         }
         $jfbcRenderKey = JFBCFactory::config()->get('social_tag_admin_key');
         foreach ($matches as $match) {
             $tagFields = explode(' ', $match[2]);
             $method = strtolower($match[1]) . strtolower($tagFields[0]);
             unset($tagFields[0]);
             $val = implode(' ', $tagFields);
             $params = SCEasyTags::_splitIntoTagParameters($val);
             $cannotRender = SCEasyTags::cannotRenderEasyTag($params, $jfbcRenderKey);
             if ($cannotRender) {
                 continue;
             }
             if (array_key_exists($method, $this->tagsToReplace)) {
                 $widgetInfo = $this->tagsToReplace[$method];
                 $fields = SCEasyTags::getTagParameters($params);
                 $widget = JFBCFactory::widget($widgetInfo['provider'], $widgetInfo['widget'], $fields);
                 $newText = $widget->render();
                 $replace = TRUE;
             } else {
                 $newText = '';
             }
             $search = '/' . preg_quote($match[0], '/') . '/';
             $contents = preg_replace($search, $newText, $contents, 1);
         }
         if ($replace) {
             JResponse::setBody($contents);
         }
     }
     return $replace;
 }