function format_content($input, $html = 0, $glossary, $simple = false) { 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; } /* 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); $k = str_replace('<', '<', $k); $original_term = str_replace('/', '\/', $k);; $term = $k; if (!$html) { $term = str_replace('<', '<', $term); } /* escape special characters */ $term = preg_quote($term, "/"); $term = '(\s*'.$term.'\s*)'; $term = str_replace(' ','((<br \/>)*\s*)', $term); // Uncomment the line below and comment the following line // when the jquery UI tooltip supports the html display. //$def = htmlspecialchars($v, ENT_QUOTES, 'UTF-8'); $def = htmlspecialchars(strip_tags($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", '<a class="tooltip" href="'.$_base_path.'mods/_core/glossary/index.php?g_cid='.$_SESSION['s_cid'].htmlentities(SEP).'w='.urlencode($original_term).'#term" title="'.htmlentities_utf8($original_term).': '.$def.'">\\2</a>',$input); } } } else if (!$user_glossary) { $input = str_replace(array('[?]','[/?]'), '', $input); } $input = str_replace('CONTENT_DIR', '', $input); if (isset($_config['latex_server']) && $_config['latex_server']) { $input = preg_replace('/\[tex\](.*?)\[\/tex\]/sie', "'<img src=\"'.\$_config['latex_server'].rawurlencode('$1').'\" align=\"middle\" alt=\"'.'$1'.'\" title=\"'.'$1'.'\">'", $input); } if ($html) { $x = apply_customized_format(format_final_output($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 = apply_customized_format(format_final_output($input)); $output = $input; $output = '<p>'.$output.'</p>'; return $output; }
function format_content($input, $html = 0, $glossary, $simple = false) { global $_base_path, $_config_defaults; if (!$html) { $input = str_replace('<', '<', $input); $input = str_replace('<?php', '<?php', $input); // for bug #2087 } /* 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); 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 href="' . $_base_path . 'glossary/index.php?g_cid=' . $_SESSION['s_cid'] . SEP . 'w=' . urlencode($original_term) . '#term" onmouseover="return overlib(\'' . $def . '\', CAPTION, \'' . addslashes($original_term) . '\', AUTOSTATUS);" onmouseout="return nd();" onfocus="return overlib(\'' . $def . '\', CAPTION, \'' . addslashes($original_term) . '\', AUTOSTATUS);" onblur="return nd();"><span style="color: blue; text-decoration: none;font-size:small; font-weight:bolder;">?</span></a></sup>', $input); } } } else { if (!$user_glossary) { $input = str_replace(array('[?]', '[/?]'), '', $input); } } $input = str_replace('CONTENT_DIR', '', $input); if (isset($_config_defaults['latex_server']) && $_config_defaults['latex_server']) { // see: http://www.forkosh.com/mimetex.html $input = preg_replace('/\\[tex\\](.*?)\\[\\/tex\\]/sie', "'<img src=\"'.\$_config_defaults['latex_server'].rawurlencode('\$1').'\" align=\"middle\">'", $input); } if ($html) { $x = format_final_output($input, false); return $x; } $output = format_final_output($input); $output = '<p>' . $output . '</p>'; return $output; }