/** * This function converts the input string into AContent html content string * @access public * @param $input: input string * $html: whether the input is in html * @return converted AContent html content string * @author Cindy Qi Li */ public static function formatContent($input, $html = 0) { global $_base_path, $_config; if (!$html) { $input = str_replace('<', '<', $input); $input = str_replace('<?php', '<?php', $input); // for bug #2087 } elseif ($html == 2) { $output = '<iframe width="100%" frameborder="0" id="content_frame" marginheight="0" marginwidth="0" src="' . $input . '"></iframe>'; $output .= '<script type="text/javascript"> function resizeIframe() { var height = document.documentElement.clientHeight; // not sure how to get this dynamically height -= 20; /* whatever you set your body bottom margin/padding to be */ document.getElementById(\'content_frame\').style.height = height +"px"; }; document.getElementById(\'content_frame\').onload = resizeIframe; window.onresize = resizeIframe; </script>'; return $output; } /* Commented by Cindy Qi Li on Jan 12, 2010 * AContent does not support glossary // do the glossary search and replace: if (is_array($glossary)) { foreach ($glossary as $k => $v) { $k = urldecode($k); $v = str_replace("\n", '<br />', $v); $v = str_replace("\r", '', $v); // escape special characters $k = preg_quote($k); $k = str_replace('<', '<', $k); $k = str_replace('/', '\/', $k); $original_term = $k; $term = $original_term; $term = '(\s*'.$term.'\s*)'; $term = str_replace(' ','((<br \/>)*\s*)', $term); $def = htmlspecialchars($v, ENT_QUOTES, 'UTF-8'); if ($simple) { $input = preg_replace ("/(\[\?\])$term(\[\/\?\])/i", '<a href="'.$simple.'glossary.html#'.urlencode($original_term).'" target="body" class="at-term">\\2</a>', $input); } else { $input = preg_replace ("/(\[\?\])$term(\[\/\?\])/i", '\\2<sup><a class="tooltip" href="'.$_base_path.'mods/_core/glossary/index.php?g_cid='.$_SESSION['s_cid'].htmlentities(SEP).'w='.urlencode($original_term).'#term" title="'.addslashes($original_term).': '.$def.'">?</a></sup>',$input); } } } else if (!$user_glossary) { $input = str_replace(array('[?]','[/?]'), '', $input); } */ $input = str_replace('CONTENT_DIR', '', $input); if (isset($_config['latex_server']) && $_config['latex_server']) { // see: http://www.forkosh.com/mimetex.html $input = preg_replace('/\\[tex\\](.*?)\\[\\/tex\\]/sie', "'<img src=\"'.\$_config['latex_server'].rawurlencode('\$1').'\" align=\"middle\">'", $input); } if ($html) { $x = ContentUtility::formatFinalOutput($input, false); return $x; } // the following has been taken out for this: // http://atutor.ca/atutor/mantis/view.php?id=4593 // @date Oct 18, 2010 // $output = ContentUtility::formatFinalOutput($input); $output = $input; $output = '<p>' . $input . '</p>'; return $output; }