From dd153b32feab2156a8ac9eeb9b8fdd9b5dca7d08 Mon Sep 17 00:00:00 2001 From: thepurpleblob Date: Thu, 28 Jul 2005 09:35:05 +0000 Subject: [PATCH] Moved filter paths to filter settings (admin) page. --- filter/tex/defaultsettings.php | 30 ++++++++++++++++++++++ filter/tex/filterconfig.html | 20 ++++++++++++++- filter/tex/latex.php | 46 ++++++---------------------------- 3 files changed, 56 insertions(+), 40 deletions(-) diff --git a/filter/tex/defaultsettings.php b/filter/tex/defaultsettings.php index d52f8a509ce..c550403b14b 100644 --- a/filter/tex/defaultsettings.php +++ b/filter/tex/defaultsettings.php @@ -19,5 +19,35 @@ set_config( 'filter_tex_density', '120' ); } + // defaults for paths - if one not set assume all not set + if (!isset($CFG->filter_tex_pathlatex)) { + // load the paths for the appropriate OS + // it would be nice to expand this + if (PHP_OS=='Linux') { + $binpath = '/usr/bin/'; + set_config( 'filter_tex_pathlatex',"{$binpath}latex" ); + set_config( 'filter_tex_pathdvips',"{$binpath}dvips" ); + set_config( 'filter_tex_pathconvert',"{$binpath}convert" ); + } + elseif (PHP_OS=='Darwin') { + $binpath = '/sw/bin/'; // most likely needs a fink install (fink.sf.net) + set_config( 'filter_tex_pathlatex',"{$binpath}latex" ); + set_config( 'filter_tex_pathdvips',"{$binpath}dvips" ); + set_config( 'filter_tex_pathconvert',"{$binpath}convert" ); + } + elseif (PHP_OS=='WINNT' or PHP_OS=='WIN32' or PHP_OS=='Windows') { + // note: you need Ghostscript installed (standard), miktex (standard) + // and ImageMagick (install at c:\ImageMagick) + set_config( 'filter_tex_pathlatex',"\"c:\\texmf\\miktex\\bin\\latex.exe\" " ); + set_config( 'filter_tex_pathdvips',"\"c:\\texmf\\miktex\\bin\\dvips.exe\" " ); + set_config( 'filter_tex_pathconvert',"\"c:\\imagemagick\\convert.exe\" " ); + } + else { + set_config( 'filter_tex_pathlatex','' ); + set_config( 'filter_tex_pathdvips','' ); + set_config( 'filter_tex_pathconvert','' ); + } + } + } ?> diff --git a/filter/tex/filterconfig.html b/filter/tex/filterconfig.html index ee58f083409..21c60c218c5 100644 --- a/filter/tex/filterconfig.html +++ b/filter/tex/filterconfig.html @@ -13,6 +13,9 @@ $txt->latexpreamble = get_string( 'latexpreamble','admin' ); $txt->backgroundcolour = get_string( 'backgroundcolour','admin' ); $txt->density = get_string( 'density','admin' ); + $txt->pathlatex = get_string( 'pathlatex','admin' ); + $txt->pathdvips = get_string( 'pathdvips','admin' ); + $txt->pathconvert = get_string( 'pathconvert','admin' ); ?> @@ -33,5 +36,20 @@ - + + + + + + + + + +
density; ?>
pathlatex; ?> +
pathdvips; ?> +
pathconvert; ?> +
diff --git a/filter/tex/latex.php b/filter/tex/latex.php index 74219a9bc16..3cffaa90a96 100644 --- a/filter/tex/latex.php +++ b/filter/tex/latex.php @@ -8,11 +8,6 @@ class latex { var $temp_dir; - var $path_latex; - var $path_dvips; - var $path_convert; - var $path_identify; - var $supported_platform; var $error; /** @@ -32,36 +27,6 @@ mkdir( $this->temp_dir, $CFG->directorypermissions ); } - // load the paths for the appropriate OS - // it would be nice to expand this - if (PHP_OS=='Linux') { - $binpath = '/usr/bin/'; - $this->path_latex = "{$binpath}latex"; - $this->path_dvips = "{$binpath}dvips"; - $this->path_convert = "{$binpath}convert"; - $this->path_identify = "{$binpath}identify"; - $this->supported_platform = true; - } - elseif (PHP_OS=='Darwin') { - $binpath = '/sw/bin/'; // most likely needs a fink install (fink.sf.net) - $this->path_latex = "{$binpath}latex"; - $this->path_dvips = "{$binpath}dvips"; - $this->path_convert = "{$binpath}convert"; - $this->path_identify = "{$binpath}identify"; - $this->supported_platform = true; - } - elseif (PHP_OS=='WINNT' or PHP_OS=='WIN32' or PHP_OS=='Windows') { - // note: you need Ghostscript installed (standard), miktex (standard) - // and ImageMagick (install at c:\ImageMagick) - $this->path_latex = "\"c:\\texmf\\miktex\\bin\\latex.exe\" "; - $this->path_dvips = "\"c:\\texmf\\miktex\\bin\\dvips.exe\" "; - $this->path_convert = "\"c:\\imagemagick\\convert.exe\" "; - $this->path_identify = "identify"; - $this->supported_platform = true; - } - else { - $this->supported_platform = false; - } } /** @@ -120,8 +85,11 @@ * @return bool true if successful */ function render( $formula, $filename, $fontsize=12, $density=240, $background='', $log=null ) { + + global $CFG; + // quick check - will this work? - if (!$this->supported_platform) { + if (empty($CFG->filter_tex_pathlatex)) { return false; } @@ -139,14 +107,14 @@ fclose( $fh ); // run latex on document - $command = "{$this->path_latex} --interaction=nonstopmode $tex"; + $command = "{$CFG->filter_tex_pathlatex} --interaction=nonstopmode $tex"; chdir( $this->temp_dir ); if ($this->execute($command, $log)) { // It allways False on Windows // return false; } // run dvips (.dvi to .ps) - $command = "{$this->path_dvips} -E $dvi -o $ps"; + $command = "{$CFG->filter_tex_pathdvips} -E $dvi -o $ps"; if ($this->execute($command, $log )) { return false; } @@ -157,7 +125,7 @@ } else { $bg_opt = ""; } - $command = "{$this->path_convert} -density $density -trim $bg_opt $ps $gif"; + $command = "{$CFG->filter_tex_pathconvert} -density $density -trim $bg_opt $ps $gif"; if ($this->execute($command, $log )) { return false; }