ILIAS  release_7 Revision v7.30-3-g800a261c036
latex.php
Go to the documentation of this file.
1<?php
2
4while (!file_exists('ilias.ini.php')) {
5 chdir('..');
6 ++$steps;
7}
8
9require_once 'Services/Init/classes/class.ilInitialisation.php';
11
16global $DIC;
17$ilIliasIniFile = $DIC['ilIliasIniFile'];
18$ilUser = $DIC['ilUser'];
19
20global $DIC;
21
22$htdocs = $ilIliasIniFile->readVariable('server', 'absolute_path') . '/';
23$weburl = $ilIliasIniFile->readVariable('server', 'absolute_path') . '/';
24if (defined('ILIAS_HTTP_PATH')) {
25 $weburl = substr(ILIAS_HTTP_PATH, 0, strrpos(ILIAS_HTTP_PATH, '/node_modules')) . '/';
26}
28
29if ($DIC->http()->request()->getMethod() == "GET" && isset($DIC->http()->request()->getQueryParams()['tex'])) {
31 '[tex]' .
32 ilUtil::stripSlashes((string) $DIC->http()->request()->getQueryParams()['tex'] ?? '') .
33 '[/tex]'
34 );
35 $responseStream = \ILIAS\Filesystem\Stream\Streams::ofString($text);
36 $DIC->http()->saveResponse($DIC->http()->response()->withBody($responseStream));
37 $DIC->http()->sendResponse();
38 $DIC->http()->close();
39}
40
41$tpl = new ilRTEGlobalTemplate(dirname(__FILE__) . '/tpl.latex.html', true, true);
42$tpl->setVariable("ILIAS_INST_PATH", $iliasHttpPath);
43
44$tpl->resetJavascript();
45
46require_once 'Services/jQuery/classes/class.iljQueryUtil.php';
48if (strpos($jquery_path, './') === 0) {
49 $jquery_path = substr($jquery_path, 2);
50} elseif (strpos($jquery_path, '.') === 0) {
51 $jquery_path = substr($jquery_path, 1);
52}
53
54$mathJaxSetting = new ilSetting('MathJax');
55if ($mathJaxSetting->get('enable_server') && $mathJaxSetting->get('server_for_browser')) {
56 $tpl->setCurrentBlock('js_on_change_server_math_jax');
57 $tpl->touchBlock('js_on_change_server_math_jax');
58 $tpl->parseCurrentBlock();
59} elseif ($mathJaxSetting->get('enable')) {
60 $pathToMathJax = $mathJaxSetting->get('path_to_mathjax');
61 if (
62 false === strpos($pathToMathJax, '//') &&
63 false === strpos($pathToMathJax, 'https://') &&
64 false === strpos($pathToMathJax, 'http://')
65 ) {
66 $pathToMathJax = str_repeat('../', $steps) . $pathToMathJax;
67 }
68 $tpl->addJavaScript($pathToMathJax);
69
70 $tpl->setCurrentBlock('js_on_change_math_jax');
71 $tpl->setVariable('DELIMITER', (int) $mathJaxSetting->get('limiter'));
72 $tpl->parseCurrentBlock();
73} elseif (strlen($ilIliasIniFile->readVariable('tools', 'latex'))) {
74 $tpl->setCurrentBlock('js_on_change_latex');
75 $tpl->setVariable('LATEX_URL', $ilIliasIniFile->readVariable('tools', 'latex'));
76 $tpl->parseCurrentBlock();
77}
78
79$tpl->addJavaScript(str_repeat('../', $steps) . $jquery_path, true, 1);
80$tpl->fillJavaScriptFiles(true);
81$tpl->printToStdout('DEFAULT', false, true);
An exception for terminatinating execution or to throw for unit testing.
static ofString($string)
Creates a new stream with an initial value.
Definition: Streams.php:25
static initILIAS()
ilias initialisation
special template class to simplify handling of ITX/PEAR
ILIAS Setting Class.
static insertLatexImages($a_text, $a_start='[tex]', $a_end='[/tex]')
replace [tex]...[/tex] tags with formula image code
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static getLocaljQueryPath()
if(defined('ILIAS_HTTP_PATH')) $iliasHttpPath
Definition: latex.php:27
$weburl
Definition: latex.php:23
$ilIliasIniFile
Definition: latex.php:17
global $DIC
Definition: latex.php:16
if(strpos( $jquery_path, './')===0) elseif(strpos($jquery_path, '.')===0) $mathJaxSetting
Definition: latex.php:54
$htdocs
Definition: latex.php:22
$steps
Definition: latex.php:3
$jquery_path
Definition: latex.php:47
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
$ilUser
Definition: latex.php:18