1<?php
2// This file reads the configuration of the jsmath plugin
3// and then installs the jsMath Library on the JavaScript level.
4// It is invoked from script.js
5
6// First read default value
7include('conf/default.php');
8$backend = $conf['backend'];
9$backend_url = $conf['backend_url'];
10
11// if available load a preload config file
12$preload = '../../../inc/preload.php';
13if (@file_exists($preload)) include($preload);
14if(!defined('DOKU_CONF')) define('DOKU_CONF','../../../conf/');
15
16// Then overwrite with actual value (if present in local.php)
17include(DOKU_CONF.'local.php');
18if(isset($conf['plugin']['jsmath']['backend']))
19{
20  $backend = $conf['plugin']['jsmath']['backend'];
21}
22if(isset($conf['plugin']['jsmath']['backend_url']))
23{
24  $backend_url = $conf['plugin']['jsmath']['backend_url'];
25}
26
27// Now, depending on the backend, write the necessary javascript code.
28//
29// backend == jsMath ?
30if ($backend != 'MathJax')
31{
32?>
33document.write('<script type="text/javascript">jsMath = {Controls: {cookie: {scale: 120}}}</script>');
34document.write('<script type="text/javascript" src="<?php echo($backend_url); ?>/plugins/noImageFonts.js"></script>');
35document.write('<script type="text/javascript" src="<?php echo($backend_url); ?>/jsMath.js"></script>');
36
37function installJsMath()
38{
39    jsMath.Process(document);
40}
41
42addInitEvent(installJsMath);
43
44<?php
45}
46else // backend == MathJax
47{
48?>
49document.write('<script type="text/javascript" src="<?php echo($backend_url); ?>/MathJax.js">MathJax.Hub.Config({extensions: ["jsMath2jax.js"], jax: ["input/TeX", "output/HTML-CSS"] });</script>');
50<?php
51}
52?>
53