ILIAS  release_8 Revision v8.24
class.ilMathJaxSetupConfig.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use ILIAS\Setup;
22
24{
25 // raw setup data
26 protected array $data = [];
27
28 // translated config
30
34 public function __construct(array $data)
35 {
36 $this->data = $data;
37
38 $this->config = new \ilMathJaxConfig(
39 (bool) ($this->data['client_enabled'] ?? false),
40 (string) ($this->data['client_polyfill_url'] ?? ''),
41 (string) ($this->data['client_script_url'] ?? ''),
42 (int) ($this->data['client_limiter'] ?? 0),
43 (bool) ($this->data['server_enabled'] ?? false),
44 (string) ($this->data['server_address'] ?? ''),
45 (int) ($this->data['server_timeout'] ?? 0),
46 (bool) ($this->data['server_for_browser'] ?? false),
47 (bool) ($this->data['server_for_export'] ?? false),
48 (bool) ($this->data['server_for_pdf'] ?? false)
49 );
50 }
51
56 public function getConfig(): ilMathJaxConfig
57 {
58 return $this->config;
59 }
60
65 {
66 return [
67 'client_enabled' => $config->isClientEnabled(),
68 'client_polyfill_url' => $config->getClintPolyfillUrl(),
69 'client_script_url' => $config->getClientScriptUrl(),
70 'client_limiter' => $config->getClientLimiter(),
71 'server_enabled' => $config->isServerEnabled(),
72 'server_address' => $config->getServerAddress(),
73 'server_timeout' => $config->getServerTimeout(),
74 'server_for_browser' => $config->isServerForBrowser(),
75 'server_for_export' => $config->isServerForExport(),
76 'server_for_pdf' => $config->isServerForPdf()
77 ];
78 }
79
85 public function isApplicableTo(ilMathJaxConfig $config): bool
86 {
87 return isset($this->data['client_enabled']) && $this->config->isClientEnabled() !== $config->isClientEnabled()
88 || isset($this->data['client_polyfill_url']) && $this->config->getClintPolyfillUrl() !== $config->getClintPolyfillUrl()
89 || isset($this->data['client_script_url']) && $this->config->getClientScriptUrl() !== $config->getClientScriptUrl()
90 || isset($this->data['client_limiter']) && $this->config->getClientLimiter() !== $config->getClientLimiter()
91 || isset($this->data['server_enabled']) && $this->config->isServerEnabled() !== $config->isServerEnabled()
92 || isset($this->data['server_address']) && $this->config->getServerAddress() !== $config->getServerAddress()
93 || isset($this->data['server_timeout']) && $this->config->getServerAddress() !== $config->getServerAddress()
94 || isset($this->data['server_for_browser']) && $this->config->isServerForBrowser() !== $config->isServerForBrowser()
95 || isset($this->data['server_for_export']) && $this->config->isServerForExport() !== $config->isServerForExport()
96 || isset($this->data['server_for_pdf']) && $this->config->isServerForPdf() !== $config->isServerForPdf();
97 }
98
104 {
105 if (isset($this->data['client_enabled'])) {
106 $config = $config->withClientEnabled($this->config->isClientEnabled());
107 }
108 if (isset($this->data['client_polyfill_url'])) {
109 $config = $config->withClientPolyfillUrl($this->config->getClintPolyfillUrl());
110 }
111 if (isset($this->data['client_script_url'])) {
112 $config = $config->withClientScriptUrl($this->config->getClientScriptUrl());
113 }
114 if (isset($this->data['client_limiter'])) {
115 $config = $config->withClientLimiter($this->config->getClientLimiter());
116 }
117 if (isset($this->data['server_enabled'])) {
118 $config = $config->withServerEnabled($this->config->isServerEnabled());
119 }
120 if (isset($this->data['server_address'])) {
121 $config = $config->withServerAddress($this->config->getServerAddress());
122 }
123 if (isset($this->data['server_timeout'])) {
124 $config = $config->withServerTimeout($this->config->getServerTimeout());
125 }
126 if (isset($this->data['server_for_browser'])) {
127 $config = $config->withServerForBrowser($this->config->isServerForBrowser());
128 }
129 if (isset($this->data['server_for_export'])) {
130 $config = $config->withServerForExport($this->config->isServerForExport());
131 }
132 if (isset($this->data['server_for_pdf'])) {
133 $config = $config->withServerForPdf($this->config->isServerForPdf());
134 }
135
136 return $config;
137 }
138}
Global Mathjax configuration.
withServerEnabled(bool $server_enabled)
Enable a server side rendering engine configured and enabled.
withClientScriptUrl(string $client_async_url)
Set the url of Mathjax script to be embedded on the page (for MathJax 3)
getClientLimiter()
Type of enclosing limiters for wich the embedded client-side Mathjax is configured.
withClientLimiter(int $client_limiter)
Set the type of enclosing limiters for wich the embedded client-side Mathjax is configured.
getServerTimeout()
timeout (s) to wait for the result of the rendering server
isServerForBrowser()
Should the server-side rendingeing be used for browser output.
withClientPolyfillUrl(string $client_js_url)
Set the url of a polyfill script neededby MathJax 3.
withServerAddress(string $server_address)
Set the url of the Mathjax server.
isServerForPdf()
Should the server-side rendingeing be used for PDF generation.
getServerAddress()
Url of Mathjax server.
withClientEnabled(bool $client_enabled)
Enable latex code bing rendered in the browser.
withServerTimeout(int $server_timeout)
Set the timeout (s) to wait for the result of the rendering server.
isServerEnabled()
Is a server side rendering engine configured and enabled.
withServerForPdf(bool $server_for_pdf)
Enable the server-side rendingeing for PDF generation.
isServerForExport()
Should the server-side rendingeing be used for HTML exports.
getClientScriptUrl()
Url of Mathjax script to be embedded with script tag on the page.
getClintPolyfillUrl()
Url of a javascript polyfill (needed by MathJax 3)
withServerForBrowser(bool $server_for_browser)
Enable the server-side rendingeing for browser output.
isClientEnabled()
Should latex code be rendered in the browser.
withServerForExport(bool $server_for_export)
Enable the server-side rendingeing for HTML exports.
isApplicableTo(ilMathJaxConfig $config)
Check if the setup config can be applied to an existing stored config Only the values that are actual...
getDataFromConfig(ilMathJaxConfig $config)
Get a data array from a config.
getConfig()
Get the MathJaxConfig object which is created from the data in config.json.
applyTo(ilMathJaxConfig $config)
Apply the setup config to an existing stored config Only the values that are actually defined in the ...
__construct(array $data)
Create the config fron a data array.
A configuration for the setup.
Definition: Config.php:27
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...