public function actionParseWysiwyg() { $options = array(); $attachments = array(); // if this is an existing node, we need to fetch attachments so converting from source mode to // wysiwyg mode displays attachments. If attachments are not passed, they won't be set in the // vB5_Template_BbCode_Wysiwyg instance. See vB5_Template_BbCode's setAttachments() function. if (isset($_POST['nodeid']) and intval($_POST['nodeid'])) { $attachments = Api_InterfaceAbstract::instance()->callApi('node', 'getNodeAttachments', array(intval($_POST['nodeid']))); } // eventually goes through vB5_Template_BbCode_Wysiwyg's doParse() $data = vB5_Frontend_Controller_Bbcode::parseWysiwyg($_POST['data'], $options, $attachments); /* * we might have some placeholders from bbcode parser. Replace them before we send it back. * I added this call because the parser was adding placeholders for the 'image_larger_version_x_y_z' phrase * in the image alt texts for images that didn't get titles set, and ckeditor was having a field day with the * placeholder, not to mention causing issues with wysiwyghtmlparser's parseUnmatchedTags() (the regex fails * to match image tags if any attribute before src has a > character). * While parseUnmatchedTags() will still have problems* if the alt text (or any attribute before src) contains * a >, getting rid of the placeholder at least prevents the problem from being caused by the parser itself. * * see VBV-12308 */ $phraseCache = vB5_Template_Phrase::instance(); $phraseCache->replacePlaceholders($data); return $this->sendAsJson(array('data' => $data)); }
protected function parseBbCodeForPreview($rawText, $options = array()) { $results = array(); if (empty($rawText)) { $results['parsedText'] = $rawText; return $results; } // parse bbcode in text try { $results['parsedText'] = vB5_Frontend_Controller_Bbcode::parseWysiwygForPreview($rawText, $options); } catch (Exception $e) { $results['error'] = 'error_parsing_bbcode_for_preview'; if (vB5_Config::instance()->debug) { $results['error_trace'] = (string) $e; } } return $results; }
/** * Handle any delayed rendering. Currently delayed urls and node texts. * * @param string * @param boolean true if we are rendering for a call to /ajax/render/ and we want CSS <link>s separate * * @return string */ protected function renderDelayed(&$final_rendered_orig, $isAjaxTemplateRender = false) { $javascript = vB5_Template_Javascript::instance(); $javascript->insertJs($final_rendered_orig); $javascript->resetPending(); $stylesheet = vB5_Template_Stylesheet::instance(); $stylesheet->insertCss($final_rendered_orig, $isAjaxTemplateRender); $stylesheet->resetPending(); $link = vB5_Template_Headlink::instance(); $link->insertLinks($final_rendered_orig); $link->resetPending(); $phrase = vB5_Template_Phrase::instance(); $phrase->replacePlaceholders($final_rendered_orig); $phrase->resetPending(); // we do not reset pending urls, since they may be required by nodetext vB5_Template_Url::instance()->replacePlaceholders($final_rendered_orig); $nodeText = vB5_Template_NodeText::instance(); $nodeText->replacePlaceholders($final_rendered_orig); $nodeText->resetPending(); $templateCache = vB5_Template_Cache::instance(); $templateCache->replaceTextOnly($final_rendered_orig); //We should keep the debug info for truly last. if (vB5_Frontend_Controller_Bbcode::needDebug()) { $config = vB5_Config::instance(); if (!$config->debug) { return $final_rendered_orig; } self::$renderedTemplateNames[] = 'debug_info'; self::$renderedTemplates[] = array('templateName' => 'debug_info', 'isParentTemplate' => (bool) 0, 'indent' => str_repeat('|----', 2)); $user = vB5_User::instance(); $this->register('user', $user, true); extract(self::$globalRegistered, EXTR_SKIP | EXTR_REFS); extract($this->registered, EXTR_OVERWRITE | EXTR_REFS); $vboptions = vB5_Template_Options::instance()->getOptions(); $vboptions = $vboptions['options']; $renderedTemplates = array('count' => count(self::$renderedTemplates), 'countUnique' => count(array_unique(self::$renderedTemplateNames)), 'templates' => self::$renderedTemplates, 'styleid' => vB5_Template_Stylevar::instance()->getPreferredStyleId()); $cssDebugLog = vB5_Template_Stylesheet::getDebugLog(); $jsDebugLog = vB5_Template_Javascript::instance()->getDebugLog(); $templateCode = $templateCache->getTemplate('debug_info'); if ($templateCache->isTemplateText()) { @eval($templateCode); } else { @(include $templateCode); } $phrase->replacePlaceholders($final_rendered); $phrase->resetPending(); $final_rendered_orig = str_replace('<!-DebugInfo-->', $final_rendered, $final_rendered_orig); } }
/** returns a placeholder for the debug information. * * @return string */ public static function debugInfo() { self::$needDebug = true; return '<!-DebugInfo-->'; }