Edit the MathJax settings.
87 $testcode =
'f(x)=\int_{-\infty}^x e^{-t^2}dt';
90 $factory = $this->dic->ui()->factory()->input()->field();
93 $checkbox_transformation = $this->
refinery->custom()->transformation(
static function ($v) {
94 if (is_array($v) || is_bool($v)) {
97 return ($v ===
'checked');
101 $client_enabled =
$factory->optionalGroup(
104 'client_polyfill_url' =>
$factory->url(
105 $this->lng->txt(
'mathjax_polyfill_url'),
107 $this->
lng->txt(
'mathjax_polyfill_url_desc_line1'),
108 $this->
lng->txt(
'mathjax_polyfill_url_desc_line2')
111 ->withValue(
$config->getClintPolyfillUrl()),
113 'client_script_url' =>
$factory->url(
114 $this->lng->txt(
'mathjax_script_url'),
117 sprintf($this->
lng->txt(
'mathjax_script_url_desc_line1'),
$config->getMathJax2DefaultUrl()),
118 sprintf($this->
lng->txt(
'mathjax_script_url_desc_line2'),
$config->getMathJax3DefaultUrl()),
120 )->withRequired(
true)
121 ->withValue(
$config->getClientScriptUrl()),
123 'client_limiter' =>
$factory->select(
124 $this->lng->txt(
'mathjax_limiter'),
125 $config->getClientLimiterOptions(),
126 $this->
lng->txt(
'mathjax_limiter_info')
127 )->withRequired(
true)
128 ->withValue(
$config->getClientLimiter()),
131 $this->lng->txt(
'mathjax_test_expression'),
132 $this->
lng->txt(
'mathjax_test_expression_info_client')
134 $config->withClientEnabled(
true)
135 ->withServerEnabled(
false),
139 ->insertLatexImages(
'<p>[tex]' . $testcode .
'[/tex]</p>')
140 )->withDisabled(
true)->withValue($testcode)
143 $this->
lng->txt(
'mathjax_enable_client'),
144 $this->
lng->txt(
'mathjax_enable_client_info') .
' ' .
145 $this->
renderLink(
'mathjax_home_link',
'https://www.mathjax.org')
149 $server_enabled =
$factory->optionalGroup(
152 $this->lng->txt(
'mathjax_server_address'),
153 $this->
lng->txt(
'mathjax_server_address_info')
154 )->withRequired(
true)
155 ->withValue(
$config->getServerAddress()),
157 'server_timeout' =>
$factory->numeric(
158 $this->lng->txt(
'mathjax_server_timeout'),
159 $this->
lng->txt(
'mathjax_server_timeout_info')
163 'server_for_browser' =>
$factory->checkbox(
164 $this->lng->txt(
'mathjax_server_for_browser'),
165 $this->
lng->txt(
'mathjax_server_for_browser_info')
168 'server_for_export' =>
$factory->checkbox(
169 $this->lng->txt(
'mathjax_server_for_export'),
170 $this->
lng->txt(
'mathjax_server_for_export_info')
173 'server_for_pdf' =>
$factory->checkbox(
174 $this->lng->txt(
'mathjax_server_for_pdf'),
175 $this->
lng->txt(
'mathjax_server_for_pdf_info')
179 $this->lng->txt(
'mathjax_server_cache_size'),
180 $this->
lng->txt(
'mathjax_server_cache_size_info') .
' ' .
181 $this->
renderLink(
'mathjax_server_clear_cache', $this->
ctrl->getLinkTarget($this,
'clearCache'),
false)
185 $this->
lng->txt(
'mathjax_test_expression'),
186 $this->
lng->txt(
'mathjax_test_expression_info_server')
188 $config->withClientEnabled(
false)
189 ->withServerEnabled(
true)
190 ->withServerForBrowser(
true),
194 ->insertLatexImages(
'<p>[tex]' . $testcode .
'[/tex]</p>')
195 )->withDisabled(
true)->withValue($testcode)
197 $this->
lng->txt(
'mathjax_enable_server'),
198 $this->
lng->txt(
'mathjax_enable_server_info') .
' ' .
199 $this->
renderLink(
'mathjax_server_installation',
'./Services/MathJax/docs/install-server.md')
205 $form = $this->dic->ui()->factory()->input()->container()->form()->standard($this->
ctrl->getFormAction($this), [
206 'mathjax' =>
$factory->section([], $this->
lng->txt(
'mathjax_settings')),
207 'client_enabled' =>
$config->isClientEnabled() ? $client_enabled : $client_enabled->withValue(null),
208 'server_enabled' =>
$config->isServerEnabled() ? $server_enabled : $server_enabled->withValue(null)
212 if ($this->request->getMethod() ===
"POST") {
213 $form = $form->withRequest($this->request);
214 $data = $form->getData();
219 if (is_array(
$data[
'client_enabled'])) {
220 $client_data =
$data[
'client_enabled'];
222 ->withClientPolyfillUrl((
string) $client_data[
'client_polyfill_url'])
223 ->withClientScriptUrl((
string) $client_data[
'client_script_url'])
224 ->withClientLimiter((
int) $client_data[
'client_limiter']);
229 if (is_array(
$data[
'server_enabled'])) {
230 $server_data =
$data[
'server_enabled'];
232 ->withServerAddress((
string) $server_data[
'server_address'])
233 ->withServerTimeout((
int) $server_data[
'server_timeout'])
234 ->withServerForBrowser((
bool) $server_data[
'server_for_browser'])
235 ->withServerForExport((
bool) $server_data[
'server_for_export'])
236 ->withServerForPdf((
bool) $server_data[
'server_for_pdf']);
242 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"settings_saved"),
true);
243 $this->
ctrl->redirect($this);
247 $this->tpl->setContent($this->dic->ui()->renderer()->render($form));
renderLink(string $langvar, string $url, bool $new_tab=true)
Render an html link.
Factory for objects used by ilMathJax.
static getIndependent(ilMathJaxConfig $config, ilMathJaxFactory $factory)
Get an independent instance with a specific config for use in unit tests or on the mathjax settings p...
static getInstance()
Singleton: get instance for use in ILIAS requests with a config loaded from the settings.