/** * Prior to outputting the value of the textarea, convert a couple * entities that wouldn't be able to be seen, into HTML. This is * done on the fly, so that the XML stored in the DB is correct. * * @param string $content * @return void */ function anno_process_editor_content($content) { // Break to BR $content = str_replace('<break />', '<br />', $content); // Load the XML source $xml = new DOMDocument(); $xml->loadXML('<textorum>' . $content . '</textorum>'); $xsl = new DOMDocument(); $xsl->load(trailingslashit(get_template_directory()) . 'js/textorum/dist/textorum/xsl/xml2cke.xsl'); // Configure the transformer $proc = new XSLTProcessor(); $proc->importStyleSheet($xsl); // attach the xsl rules $proc->setParameter(null, 'inlineelements', 'named-content,ext-link,inline-graphic,alt-text,lbl,long-desc,copyright-statement,permissions,copyright-holder,license,license-p,attrib,inline-formula,xref'); $proc->setParameter(null, 'bold', 'bold'); $proc->setParameter(null, 'italic', 'italic'); $proc->setParameter(null, 'monospace', 'monospace'); $proc->setParameter(null, 'underline', 'underline'); $proc->setParameter(null, 'fixedelements', 'textorum,table,thead,tbody,td,tr,th,sub,sup'); $content = $proc->transformToXML($xml); $content = preg_replace('/<\\/?textorum[^>]*>/', '', $content); return $content; phpQuery::newDocument($content); // Convert inline-graphics to <img> tags so they display anno_xml_to_html_replace_inline_graphics($content); // Convert caption to cap anno_replace_caption_tag($content); // Convert label to lbl anno_replace_label_tag($content); // Remove p tags wrapping list items anno_remove_p_from_list_items($content); // Remove p tags from disp-quotes //anno_remove_p_from_disp_quote_items($content); // We need a clearfix for floated images. $figs = pq('fig'); foreach ($figs as $fig) { $fig = pq($fig); $img_src = ''; // Check if we're using bugged version of libxml if (version_compare(LIBXML_DOTTED_VERSION, '2.6.29', '<')) { $img_src = anno_get_attribute_value_regex($fig, 'media', 'xlink:href'); } else { $img_src = $fig->find('media')->attr('xlink:href'); } $fig->prepend('<img src="' . $img_src . '" />'); // _mce_bogus stripped by tinyMCE on save $fig->append('<div _mce_bogus="1" class="clearfix"></div>'); } return phpQuery::getDocument(); }
/** * Prior to outputting the value of the textarea, convert a couple * entities that wouldn't be able to be seen, into HTML. This is * done on the fly, so that the XML stored in the DB is correct. * * @param string $content * @return void */ function anno_process_editor_content($content) { // Break to BR $content = str_replace('<break />', '<br />', $content); phpQuery::newDocument($content); // Convert inline-graphics to <img> tags so they display anno_xml_to_html_replace_inline_graphics($content); // Convert caption to cap anno_replace_caption_tag($content); // Convert p to para anno_replace_p_tag($content); // Convert label to lbl anno_replace_label_tag($content); // Convert title to heading anno_replace_title_tag($content); // Remove p tags wrapping list items anno_remove_p_from_list_items($content); // Remove p tags from disp-quotes anno_remove_p_from_disp_quote_items($content); // We need a clearfix for floated images. $figs = pq('fig'); foreach ($figs as $fig) { $fig = pq($fig); $img_src = ''; // Check if we're using bugged version of libxml if (version_compare(LIBXML_DOTTED_VERSION, '2.6.29', '<')) { $img_src = anno_get_attribute_value_regex($fig, 'media', 'xlink:href'); } else { $img_src = $fig->find('media')->attr('xlink:href'); } $fig->prepend('<img src="' . $img_src . '" />'); // _mce_bogus stripped by tinyMCE on save $fig->append('<div _mce_bogus="1" class="clearfix"></div>'); } return phpQuery::getDocument(); }