[Aimmath-commit] moodle/mod/math_assignment lib.php,1.31,1.32
Brought to you by:
gustav_delius,
npstrick
|
From: <gus...@us...> - 2003-09-29 20:54:33
|
Update of /cvsroot/aimmath/moodle/mod/math_assignment
In directory sc8-pr-cvs1:/tmp/cvs-serv11398/mod/math_assignment
Modified Files:
lib.php
Log Message:
now uses ttm on unix
Index: lib.php
===================================================================
RCS file: /cvsroot/aimmath/moodle/mod/math_assignment/lib.php,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -d -r1.31 -r1.32
*** lib.php 29 Sep 2003 19:21:59 -0000 1.31
--- lib.php 29 Sep 2003 20:54:23 -0000 1.32
***************
*** 758,765 ****
$out = preg_replace("/<table border>/", "<table border=\"1\">", $out);
$out = preg_replace("/<hr noshade(?=[\s\/])/", "<hr noshade=\"noshade\" ", $out);
// convert Latex to MathML
if (function_exists('editer') && $convertlatex) {
! $out = preg_replace_callback("/<latex>(.*?)<\/latex>/si", create_function('$matches', 'return editer($matches[1]);'), $out);
}
--- 758,768 ----
$out = preg_replace("/<table border>/", "<table border=\"1\">", $out);
$out = preg_replace("/<hr noshade(?=[\s\/])/", "<hr noshade=\"noshade\" ", $out);
+ // The following doesn't do anything for some reason GWD
+ $out = preg_replace("/width\=([\d]+)/", "width=\"$2\"", $out);
+ $out = preg_replace("/height\=([\d]+)/", "height=\"$2\"", $out);
// convert Latex to MathML
if (function_exists('editer') && $convertlatex) {
! $out = preg_replace_callback("/<latex>(.*?)<\/latex>/si", create_function('$matches', 'return tex_to_mathml($matches[1]);'), $out);
}
***************
*** 1035,1039 ****
}
! function decodeHTML($string) {
$string = strtr($string, array_flip(get_html_translation_table(HTML_ENTITIES)));
$string = preg_replace("/&#([0-9]+);/me", "chr('\\1')", $string);
--- 1038,1042 ----
}
! function decodeHTML($string) { // emulates html_entity_decode which only exists in PHP >= 4.3.0
$string = strtr($string, array_flip(get_html_translation_table(HTML_ENTITIES)));
$string = preg_replace("/&#([0-9]+);/me", "chr('\\1')", $string);
***************
*** 1041,1045 ****
}
! function copy_from_url($url, $file) {
if (!$handle = fopen($url, "rb"))
return false;
--- 1044,1048 ----
}
! function copy_from_url($url, $file) { // emulates copy which works with URLSs only in PHP >= 4.3.0
if (!$handle = fopen($url, "rb"))
return false;
***************
*** 1058,1061 ****
--- 1061,1074 ----
fclose($handle);
return true;
+ }
+
+ function tex_to_mathml($tex) {
+ if (strpos($_ENV["OS"], "Win") === false) {
+ exec("echo " . escapeshellarg($tex) . " | /usr/local/bin/ttm -r", $output);
+ return " " . implode(" ", $output). " ";
+ }
+ else
+ return editer($tex);
+ }
}
|