function ouwiki_convert_content($content, $subwiki, $cm, $internallinks = null, $xhtmlformat = FORMAT_HTML) { // Detect links. Note that changes to this code ought to be reflected // in the code in ouwiki_save_new_version which analyses to search for // links. // When displayed on one page global $ouwiki_internallinks, $ouwiki_wikilinks; // Ordinary [[links]] if ($internallinks) { $ouwiki_internallinks = $internallinks; $function = 'ouwiki_internal_re_internallinks'; } else { $ouwiki_wikilinks = (object) array('subwiki' => $subwiki, 'cm' => $cm); $function = 'ouwiki_internal_re_wikilinks'; } $content = preg_replace_callback(OUWIKI_LINKS_SQUAREBRACKETS, $function, $content); // We do not use FORMAT_MOODLE (which adds linebreaks etc) because that was // already handled manually. $options = ouwiki_format_text_options(); return '<div class="ouwiki_content">' . format_text($content, $xhtmlformat, $options) . '</div>'; }
function ouwiki_convert_content($content, $subwiki, $cm, $internallinks = null, $xhtmlformat = FORMAT_HTML) { // Detect links. Note that changes to this code ought to be reflected // in the code in ouwiki_save_new_version which analyses to search for // links. // When displayed on one page global $ouwiki_internallinks, $ouwiki_wikilinks; // Ordinary [[links]] if ($internallinks) { $ouwiki_internallinks = $internallinks; $function = 'ouwiki_internal_re_internallinks'; } else { $ouwiki_wikilinks = (object) array('subwiki' => $subwiki, 'cm' => $cm); $function = 'ouwiki_internal_re_wikilinks'; } $content = preg_replace_callback(OUWIKI_LINKS_SQUAREBRACKETS, $function, $content); // We do not use FORMAT_MOODLE (which adds linebreaks etc) because that was // already handled manually. $options = ouwiki_format_text_options(); $options->para = false; $addwrapperdivs = true; if (strpos($content, '<div class="ouwiki_content">') !== false) { // Stop adding text wrapper divs when already in data. $addwrapperdivs = false; } $toreturn = format_text($content, $xhtmlformat, $options); if ($addwrapperdivs) { $toreturn = html_writer::tag('div', $toreturn, array('class' => 'ouwiki_content')); } return $toreturn; }