]> git.mjollnir.org Git - moodle.git/commitdiff
Changed the logic around so that any binary called "mimetex" is used
authormoodler <moodler>
Tue, 24 Feb 2004 08:04:49 +0000 (08:04 +0000)
committermoodler <moodler>
Tue, 24 Feb 2004 08:04:49 +0000 (08:04 +0000)
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
filter/tex/pix.php

index ffb8cb43ca3c842c7c5aa16ecc09f37f7aa259bd..ee0eb19d0f8628f48ab78e34882b53a2f6c6e513 100644 (file)
@@ -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);
 
             $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")) {
-               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;
index 46a8ffe8304bc1c79d897b6f9a518c7fa596c443..bbd743ae63d3fbb61179a8cdacce3f8a0302174d 100644 (file)
             $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;