MDL-49740 Lock: Fixed task lock release bugs
[moodle.git] / filter / tex / settings.php
blobe0d5ddce68f8b4bcaf5881102bc395904eedf17b
1 <?php
2 // This file is part of Moodle - http://moodle.org/
3 //
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17 /**
18 * TeX filter settings
20 * @package filter
21 * @subpackage tex
22 * @copyright 2007 Petr Skoda {@link http://skodak.org}
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26 defined('MOODLE_INTERNAL') || die;
28 if ($ADMIN->fulltree) {
30 require_once($CFG->dirroot.'/filter/tex/lib.php');
32 $items = array();
33 $items[] = new admin_setting_heading('filter_tex/latexheading', get_string('latexsettings', 'filter_tex'), '');
34 $items[] = new admin_setting_configtextarea('filter_tex/latexpreamble', get_string('latexpreamble','filter_tex'),
35 '', "\\usepackage[latin1]{inputenc}\n\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\RequirePackage{amsmath,amssymb,latexsym}\n");
36 $items[] = new admin_setting_configtext('filter_tex/latexbackground', get_string('backgroundcolour', 'admin'), '', '#FFFFFF');
37 $items[] = new admin_setting_configtext('filter_tex/density', get_string('density', 'admin'), '', '120', PARAM_INT);
39 $default_filter_tex_pathlatex = '';
40 $default_filter_tex_pathdvips = '';
41 $default_filter_tex_pathdvisvgm = '';
42 $default_filter_tex_pathconvert = '';
43 if (PHP_OS=='Linux') {
44 $default_filter_tex_pathlatex = "/usr/bin/latex";
45 $default_filter_tex_pathdvips = "/usr/bin/dvips";
46 $default_filter_tex_pathdvisvgm = "/usr/bin/dvisvgm";
47 $default_filter_tex_pathconvert = "/usr/bin/convert";
48 } else if (PHP_OS=='Darwin') {
49 // most likely needs a fink install (fink.sf.net)
50 $default_filter_tex_pathlatex = "/sw/bin/latex";
51 $default_filter_tex_pathdvips = "/sw/bin/dvips";
52 $default_filter_tex_pathdvisvgm = "/usr/bin/dvisvgm";
53 $default_filter_tex_pathconvert = "/sw/bin/convert";
55 } else if (PHP_OS=='WINNT' or PHP_OS=='WIN32' or PHP_OS=='Windows') {
56 // note: you need Ghostscript installed (standard), miktex (standard)
57 // and ImageMagick (install at c:\ImageMagick)
58 $default_filter_tex_pathlatex = "c:\\texmf\\miktex\\bin\\latex.exe";
59 $default_filter_tex_pathdvips = "c:\\texmf\\miktex\\bin\\dvips.exe";
60 $default_filter_tex_pathdvisvgm = "c:\\texmf\\miktex\\bin\\dvisvgm.exe";
61 $default_filter_tex_pathconvert = "c:\\imagemagick\\convert.exe";
64 $pathlatex = get_config('filter_tex', 'pathlatex');
65 $pathdvips = get_config('filter_tex', 'pathdvips');
66 $pathconvert = get_config('filter_tex', 'pathconvert');
67 $pathdvisvgm = get_config('filter_tex', 'pathdvisvgm');
68 if (strrpos($pathlatex . $pathdvips . $pathconvert . $pathdvisvgm, '"') or
69 strrpos($pathlatex . $pathdvips . $pathconvert . $pathdvisvgm, "'")) {
70 set_config('pathlatex', trim($pathlatex, " '\""), 'filter_tex');
71 set_config('pathdvips', trim($pathdvips, " '\""), 'filter_tex');
72 set_config('pathconvert', trim($pathconvert, " '\""), 'filter_tex');
73 set_config('pathdvisvgm', trim($pathdvisvgm, " '\""), 'filter_tex');
76 $items[] = new admin_setting_configexecutable('filter_tex/pathlatex', get_string('pathlatex', 'filter_tex'), '', $default_filter_tex_pathlatex);
77 $items[] = new admin_setting_configexecutable('filter_tex/pathdvips', get_string('pathdvips', 'filter_tex'), '', $default_filter_tex_pathdvips);
78 $items[] = new admin_setting_configexecutable('filter_tex/pathconvert', get_string('pathconvert', 'filter_tex'), '', $default_filter_tex_pathconvert);
79 $items[] = new admin_setting_configexecutable('filter_tex/pathdvisvgm', get_string('pathdvisvgm', 'filter_tex'), '', $default_filter_tex_pathdvisvgm);
80 $items[] = new admin_setting_configexecutable('filter_tex/pathmimetex', get_string('pathmimetex', 'filter_tex'), get_string('pathmimetexdesc', 'filter_tex'), '');
82 // Even if we offer GIF, PNG and SVG formats here, in the update callback we check whether
83 // required paths actually point to executables. If they don't, we force the setting
84 // to GIF, as that's the only format mimeTeX can produce.
85 $formats = array('gif' => 'GIF', 'png' => 'PNG', 'svg' => 'SVG');
86 $items[] = new admin_setting_configselect('filter_tex/convertformat', get_string('convertformat', 'filter_tex'), get_string('configconvertformat', 'filter_tex'), 'gif', $formats);
88 foreach ($items as $item) {
89 $item->set_updatedcallback('filter_tex_updatedcallback');
90 $settings->add($item);