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)); }