Permalink
Browse files

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.
  • Loading branch information...
1 parent 98d4782 commit e553bdecf796f6434e5cc77ef9a1f6443afa466e moodler committed Feb 24, 2004
Showing with 67 additions and 51 deletions.
  1. +38 −30 filter/algebra/pix.php
  2. +29 −21 filter/tex/pix.php
View
@@ -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<br>$cmd<br>returned status = $status<br>\n";
echo "Image not found!<br>";
- echo "Please try the <a href=\"$CFG->wwwroot/filter/algebra/algebradebug.php\">debugging script</a>";
+ echo "Please try the <a href=\"$CFG->wwwroot/filter/algebra/algebradebug.php\">debugging script</a>";
}
exit;
View
@@ -46,32 +46,40 @@
$texexp = str_replace('&gt;','>',$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<br>$cmd<br>returned status = $status<br>\n";
echo "Image not found!<br>";
- echo "Please try the <a href=\"$CFG->wwwroot/filter/tex/texdebug.php\">debugging script</a>";
+ echo "Please try the <a href=\"$CFG->wwwroot/$CFG->texfilterdir/texdebug.php\">debugging script</a>";
}
exit;

0 comments on commit e553bde

Please sign in to comment.