From e553bdecf796f6434e5cc77ef9a1f6443afa466e Mon Sep 17 00:00:00 2001 From: moodler Date: Tue, 24 Feb 2004 08:04:49 +0000 Subject: [PATCH] Changed the logic around so that any binary called "mimetex" is used in preference to any other pre-installed binary. This makes me happier about the FAT binary, because a leaner binary can be installed without interfering with CVS etc. --- filter/algebra/pix.php | 68 +++++++++++++++++++++++------------------- filter/tex/pix.php | 50 ++++++++++++++++++------------- 2 files changed, 67 insertions(+), 51 deletions(-) diff --git a/filter/algebra/pix.php b/filter/algebra/pix.php index ffb8cb43ca..ee0eb19d0f 100644 --- a/filter/algebra/pix.php +++ b/filter/algebra/pix.php @@ -8,8 +8,8 @@ require_once("../../config.php"); $CFG->algebrafilterdir = "filter/algebra"; - $CFG->texfilterdir = "filter/tex"; - $CFG->algebraimagedir = "filter/algebra"; + $CFG->texfilterdir = "filter/tex"; + $CFG->algebraimagedir = "filter/algebra"; error_reporting(E_ALL); @@ -47,34 +47,42 @@ $texexp = str_replace('>','>',$texexp); $texexp = preg_replace('!\r\n?!',' ',$texexp); $texexp = '\Large ' . $texexp; - switch (PHP_OS) { - case "Linux": - $cmd = "\"$CFG->dirroot/$CFG->texfilterdir/mimetex.linux\" -e \"$pathname\" ". escapeshellarg($texexp); - break; - case "WINNT": - case "WIN32": - case "Windows": - $texexp = str_replace('"','\"',$texexp); - $cmd = "$CFG->dirroot/$CFG->texfilterdir/mimetex.exe"; - $cmd = str_replace(' ','^ ',$cmd); - $cmd .= " ++ -e \"$pathname\" \"$texexp\""; - break; - case "Darwin": - $cmd = "\"$CFG->dirroot/$CFG->texfilterdir/mimetex.darwin\" -e \"$pathname\" ". escapeshellarg($texexp); - break; - default: /// To allow drop-in binaries for other platforms - if (!is_executable("$CFG->dirroot/$CFG->texfilterdir/mimetex")) { - echo "Make sure you have an appropriate MimeTeX binary here:\n\n"; - echo " $CFG->dirroot/$CFG->texfilterdir/mimetex\n\n"; - echo "and that it has the right permissions set on it as executable program.\n\n"; - echo "You can get the latest binaries for your ".PHP_OS." platform from: \n\n"; - echo " http://moodle.org/download/mimetex/"; - exit; - } - $cmd = "$CFG->dirroot/$CFG->texfilterdir/mimetex -e $pathname ". escapeshellarg($texexp); - break; + + if (is_executable("$CFG->dirroot/$CFG->texfilterdir/mimetex")) { /// Use the custom binary + + $cmd = "$CFG->dirroot/$CFG->texfilterdir/mimetex -e $pathname ". escapeshellarg($texexp); + + } else { /// Auto-detect the right TeX binary + switch (PHP_OS) { + + case "Linux": + $cmd = "\"$CFG->dirroot/$CFG->texfilterdir/mimetex.linux\" -e \"$pathname\" ". escapeshellarg($texexp); + break; + + case "WINNT": + case "WIN32": + case "Windows": + $texexp = str_replace('"','\"',$texexp); + $cmd = "$CFG->dirroot/$CFG->texfilterdir/mimetex.exe"; + $cmd = str_replace(' ','^ ',$cmd); + $cmd .= " ++ -e \"$pathname\" \"$texexp\""; + break; + + case "Darwin": + $cmd = "\"$CFG->dirroot/$CFG->texfilterdir/mimetex.darwin\" -e \"$pathname\" ". escapeshellarg($texexp); + break; + + default: /// Nothing was found, so tell them how to fix it. + echo "Make sure you have an appropriate MimeTeX binary here:\n\n"; + echo " $CFG->dirroot/$CFG->texfilterdir/mimetex\n\n"; + echo "and that it has the right permissions set on it as executable program.\n\n"; + echo "You can get the latest binaries for your ".PHP_OS." platform from: \n\n"; + echo " http://moodle.org/download/mimetex/"; + exit; + break; + } } - system($cmd, $status); + system($cmd, $status); } } @@ -91,7 +99,7 @@ } else { echo "The shell command
$cmd
returned status = $status
\n"; echo "Image not found!
"; - echo "Please try the wwwroot/filter/algebra/algebradebug.php\">debugging script"; + echo "Please try the wwwroot/filter/algebra/algebradebug.php\">debugging script"; } exit; diff --git a/filter/tex/pix.php b/filter/tex/pix.php index 46a8ffe830..bbd743ae63 100644 --- a/filter/tex/pix.php +++ b/filter/tex/pix.php @@ -46,32 +46,40 @@ $texexp = str_replace('>','>',$texexp); $texexp = preg_replace('!\r\n?!',' ',$texexp); $texexp = '\Large ' . $texexp; - switch (PHP_OS) { - case "Linux": - $cmd = "\"$CFG->dirroot/$CFG->texfilterdir/mimetex.linux\" -e \"$pathname\" ". escapeshellarg($texexp); - break; - case "WINNT": - case "WIN32": - case "Windows": - $texexp = str_replace('"','\"',$texexp); - $cmd = "$CFG->dirroot/$CFG->texfilterdir/mimetex.exe"; - $cmd = str_replace(' ','^ ',$cmd); - $cmd .= " ++ -e \"$pathname\" \"$texexp\""; - break; - case "Darwin": - $cmd = "\"$CFG->dirroot/$CFG->texfilterdir/mimetex.darwin\" -e \"$pathname\" ". escapeshellarg($texexp); - break; - default: /// To allow drop-in binaries for other platforms - if (!is_executable("$CFG->dirroot/$CFG->texfilterdir/mimetex")) { + + if (is_executable("$CFG->dirroot/$CFG->texfilterdir/mimetex")) { /// Use the custom binary + + $cmd = "$CFG->dirroot/$CFG->texfilterdir/mimetex -e $pathname ". escapeshellarg($texexp); + + } else { /// Auto-detect the right TeX binary + switch (PHP_OS) { + + case "Linux": + $cmd = "\"$CFG->dirroot/$CFG->texfilterdir/mimetex.linux\" -e \"$pathname\" ". escapeshellarg($texexp); + break; + + case "WINNT": + case "WIN32": + case "Windows": + $texexp = str_replace('"','\"',$texexp); + $cmd = "$CFG->dirroot/$CFG->texfilterdir/mimetex.exe"; + $cmd = str_replace(' ','^ ',$cmd); + $cmd .= " ++ -e \"$pathname\" \"$texexp\""; + break; + + case "Darwin": + $cmd = "\"$CFG->dirroot/$CFG->texfilterdir/mimetex.darwin\" -e \"$pathname\" ". escapeshellarg($texexp); + break; + + default: /// Nothing was found, so tell them how to fix it. echo "Make sure you have an appropriate MimeTeX binary here:\n\n"; echo " $CFG->dirroot/$CFG->texfilterdir/mimetex\n\n"; echo "and that it has the right permissions set on it as executable program.\n\n"; echo "You can get the latest binaries for your ".PHP_OS." platform from: \n\n"; echo " http://moodle.org/download/mimetex/"; exit; - } - $cmd = "$CFG->dirroot/$CFG->texfilterdir/mimetex -e $pathname ". escapeshellarg($texexp); - break; + break; + } } system($cmd, $status); } @@ -90,7 +98,7 @@ } else { echo "The shell command
$cmd
returned status = $status
\n"; echo "Image not found!
"; - echo "Please try the wwwroot/filter/tex/texdebug.php\">debugging script"; + echo "Please try the wwwroot/$CFG->texfilterdir/texdebug.php\">debugging script"; } exit; -- 2.39.5