ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilMathJaxConfig Class Reference

Global Mathjax configuration. More...

+ Collaboration diagram for ilMathJaxConfig:

Public Member Functions

 __construct (bool $client_enabled, string $client_polyfill_url, string $client_script_url, int $client_limiter, bool $server_enabled, string $server_address, int $server_timeout, bool $server_for_browser, bool $server_for_export, bool $server_for_pdf)
 Constructor. More...
 
 getMathJax2DefaultUrl ()
 Get the default URL for including MathJax 2. More...
 
 getMathJax3DefaultUrl ()
 Get the default URL for including MathJax 3. More...
 
 isClientEnabled ()
 Should latex code be rendered in the browser. More...
 
 getClintPolyfillUrl ()
 Url of a javascript polyfill (needed by MathJax 3) More...
 
 getClientScriptUrl ()
 Url of Mathjax script to be embedded with script tag on the page. More...
 
 getClientLimiter ()
 Type of enclosing limiters for wich the embedded client-side Mathjax is configured. More...
 
 getClientLimiterOptions ()
 Get the avaliable options for the client limiters. More...
 
 getClientLimiterStart ()
 Start limiter of Latex code which the client-side Mathjax searches for. More...
 
 getClientLimiterEnd ()
 End limiter of Latex code which the client-side Mathjax searches for. More...
 
 isServerEnabled ()
 Is a server side rendering engine configured and enabled. More...
 
 getServerAddress ()
 Url of Mathjax server. More...
 
 getServerTimeout ()
 timeout (s) to wait for the result of the rendering server More...
 
 isServerForBrowser ()
 Should the server-side rendingeing be used for browser output. More...
 
 isServerForExport ()
 Should the server-side rendingeing be used for HTML exports. More...
 
 isServerForPdf ()
 Should the server-side rendingeing be used for PDF generation. More...
 
 withClientEnabled (bool $client_enabled)
 Enable latex code bing rendered in the browser. More...
 
 withClientPolyfillUrl (string $client_js_url)
 Set the url of a polyfill script neededby MathJax 3. More...
 
 withClientScriptUrl (string $client_async_url)
 Set the url of Mathjax script to be embedded on the page (for MathJax 3) More...
 
 withClientLimiter (int $client_limiter)
 Set the type of enclosing limiters for wich the embedded client-side Mathjax is configured. More...
 
 withServerEnabled (bool $server_enabled)
 Enable a server side rendering engine configured and enabled. More...
 
 withServerAddress (string $server_address)
 Set the url of the Mathjax server. More...
 
 withServerTimeout (int $server_timeout)
 Set the timeout (s) to wait for the result of the rendering server. More...
 
 withServerForBrowser (bool $server_for_browser)
 Enable the server-side rendingeing for browser output. More...
 
 withServerForExport (bool $server_for_export)
 Enable the server-side rendingeing for HTML exports. More...
 
 withServerForPdf (bool $server_for_pdf)
 Enable the server-side rendingeing for PDF generation. More...
 

Protected Attributes

bool $client_enabled
 
string $client_polyfill_url
 
string $client_script_url
 
int $client_limiter
 
bool $server_enabled
 
string $server_address
 
int $server_timeout
 
bool $server_for_browser
 
bool $server_for_export
 
bool $server_for_pdf
 

Private Attributes

const MATHJAX2_DEFAULT_URL = 'https://cdn.jsdelivr.net/npm/mathjax@2.7.9/MathJax.js?config=TeX-AMS-MML_HTMLorMML,Safe'
 
const MATHJAX3_RELATIVE_URL = 'Services/MathJax/js/cdn-mathjax3-es5-tex-mml-chtml-safe.js'
 
const LIMITER_MATHJAX = 0
 
const LIMITER_TEX = 1
 
const LIMITER_SPAN = 2
 

Detailed Description

Global Mathjax configuration.

Definition at line 24 of file class.ilMathJaxConfig.php.

Constructor & Destructor Documentation

◆ __construct()

ilMathJaxConfig::__construct ( bool  $client_enabled,
string  $client_polyfill_url,
string  $client_script_url,
int  $client_limiter,
bool  $server_enabled,
string  $server_address,
int  $server_timeout,
bool  $server_for_browser,
bool  $server_for_export,
bool  $server_for_pdf 
)

Constructor.

Definition at line 47 of file class.ilMathJaxConfig.php.

References $client_enabled, $client_limiter, $server_enabled, $server_for_browser, $server_for_export, $server_for_pdf, and $server_timeout.

58  {
59  $this->client_enabled = $client_enabled;
60  $this->client_polyfill_url = trim($client_polyfill_url);
61  $this->client_script_url = trim($client_script_url);
62  $this->client_limiter = (in_array(
64  [self::LIMITER_MATHJAX, self::LIMITER_TEX, self::LIMITER_SPAN]
65  ) ? $client_limiter : self::LIMITER_MATHJAX);
66  $this->server_enabled = $server_enabled;
67  $this->server_address = trim($server_address);
68  $this->server_timeout = (empty($server_timeout) ? 5 : $server_timeout);
69  $this->server_for_browser = $server_for_browser;
70  $this->server_for_export = $server_for_export;
71  $this->server_for_pdf = $server_for_pdf;
72  }

Member Function Documentation

◆ getClientLimiter()

ilMathJaxConfig::getClientLimiter ( )

Type of enclosing limiters for wich the embedded client-side Mathjax is configured.

Definition at line 118 of file class.ilMathJaxConfig.php.

References $client_limiter.

Referenced by ilMathJaxSetupConfig\getDataFromConfig(), ilMathJaxSetupConfig\isApplicableTo(), and ilMathJaxConfigSettingsRepository\updateConfig().

118  : int
119  {
120  return $this->client_limiter;
121  }
+ Here is the caller graph for this function:

◆ getClientLimiterEnd()

ilMathJaxConfig::getClientLimiterEnd ( )

End limiter of Latex code which the client-side Mathjax searches for.

Definition at line 155 of file class.ilMathJaxConfig.php.

155  : string
156  {
157  switch ($this->client_limiter) {
158  case self::LIMITER_TEX:
159  return '[/tex]';
160  case self::LIMITER_SPAN:
161  return '</span>';
162  case self::LIMITER_MATHJAX:
163  default:
164  return '\)';
165  }
166  }

◆ getClientLimiterOptions()

ilMathJaxConfig::getClientLimiterOptions ( )

Get the avaliable options for the client limiters.

Returns
array limiter => display text

Definition at line 127 of file class.ilMathJaxConfig.php.

127  : array
128  {
129  return [
130  self::LIMITER_MATHJAX => '\&#8203;(...\&#8203;)',
131  self::LIMITER_TEX => '[tex]...[/tex]',
132  self::LIMITER_SPAN => '&lt;span class="math"&gt;...&lt;/span&gt;'
133  ];
134  }

◆ getClientLimiterStart()

ilMathJaxConfig::getClientLimiterStart ( )

Start limiter of Latex code which the client-side Mathjax searches for.

Definition at line 139 of file class.ilMathJaxConfig.php.

139  : string
140  {
141  switch ($this->client_limiter) {
142  case self::LIMITER_TEX:
143  return '[tex]';
144  case self::LIMITER_SPAN:
145  return '<span class="math">';
146  case self::LIMITER_MATHJAX:
147  default:
148  return '\(';
149  }
150  }

◆ getClientScriptUrl()

ilMathJaxConfig::getClientScriptUrl ( )

Url of Mathjax script to be embedded with script tag on the page.

Definition at line 110 of file class.ilMathJaxConfig.php.

References $client_script_url.

Referenced by ilMathJaxConfigCheckedObjective\checkClientScriptUrl(), ilMathJaxSetupConfig\getDataFromConfig(), ilMathJaxSetupConfig\isApplicableTo(), and ilMathJaxConfigSettingsRepository\updateConfig().

110  : string
111  {
113  }
+ Here is the caller graph for this function:

◆ getClintPolyfillUrl()

ilMathJaxConfig::getClintPolyfillUrl ( )

Url of a javascript polyfill (needed by MathJax 3)

Definition at line 102 of file class.ilMathJaxConfig.php.

References $client_polyfill_url.

Referenced by ilMathJaxSetupConfig\getDataFromConfig(), ilMathJaxSetupConfig\isApplicableTo(), and ilMathJaxConfigSettingsRepository\updateConfig().

102  : string
103  {
105  }
+ Here is the caller graph for this function:

◆ getMathJax2DefaultUrl()

ilMathJaxConfig::getMathJax2DefaultUrl ( )

Get the default URL for including MathJax 2.

Definition at line 77 of file class.ilMathJaxConfig.php.

77  : string
78  {
79  return self::MATHJAX2_DEFAULT_URL;
80  }

◆ getMathJax3DefaultUrl()

ilMathJaxConfig::getMathJax3DefaultUrl ( )

Get the default URL for including MathJax 3.

Definition at line 85 of file class.ilMathJaxConfig.php.

85  : string
86  {
87  return ILIAS_HTTP_PATH . '/' . self::MATHJAX3_RELATIVE_URL;
88  }

◆ getServerAddress()

ilMathJaxConfig::getServerAddress ( )

Url of Mathjax server.

Definition at line 179 of file class.ilMathJaxConfig.php.

References $server_address.

Referenced by ilMathJaxSetupConfig\getDataFromConfig(), ilMathJaxSetupConfig\isApplicableTo(), and ilMathJaxConfigSettingsRepository\updateConfig().

179  : string
180  {
181  return $this->server_address;
182  }
+ Here is the caller graph for this function:

◆ getServerTimeout()

ilMathJaxConfig::getServerTimeout ( )

timeout (s) to wait for the result of the rendering server

Definition at line 187 of file class.ilMathJaxConfig.php.

References $server_timeout.

Referenced by ilMathJaxSetupConfig\getDataFromConfig(), and ilMathJaxConfigSettingsRepository\updateConfig().

187  : int
188  {
189  return $this->server_timeout;
190  }
+ Here is the caller graph for this function:

◆ isClientEnabled()

ilMathJaxConfig::isClientEnabled ( )

Should latex code be rendered in the browser.

Definition at line 94 of file class.ilMathJaxConfig.php.

References $client_enabled.

Referenced by ilMathJaxConfigCheckedObjective\checkClientScriptUrl(), ilMathJaxSetupConfig\getDataFromConfig(), ilMathJaxSetupConfig\isApplicableTo(), and ilMathJaxConfigSettingsRepository\updateConfig().

94  : bool
95  {
96  return $this->client_enabled;
97  }
+ Here is the caller graph for this function:

◆ isServerEnabled()

ilMathJaxConfig::isServerEnabled ( )

Is a server side rendering engine configured and enabled.

Definition at line 171 of file class.ilMathJaxConfig.php.

References $server_enabled.

Referenced by ilMathJaxSetupConfig\getDataFromConfig(), ilMathJaxSetupConfig\isApplicableTo(), and ilMathJaxConfigSettingsRepository\updateConfig().

171  : bool
172  {
173  return $this->server_enabled;
174  }
+ Here is the caller graph for this function:

◆ isServerForBrowser()

ilMathJaxConfig::isServerForBrowser ( )

Should the server-side rendingeing be used for browser output.

Definition at line 195 of file class.ilMathJaxConfig.php.

References $server_for_browser.

Referenced by ilMathJaxSetupConfig\getDataFromConfig(), ilMathJaxSetupConfig\isApplicableTo(), and ilMathJaxConfigSettingsRepository\updateConfig().

195  : bool
196  {
198  }
+ Here is the caller graph for this function:

◆ isServerForExport()

ilMathJaxConfig::isServerForExport ( )

Should the server-side rendingeing be used for HTML exports.

Definition at line 203 of file class.ilMathJaxConfig.php.

References $server_for_export.

Referenced by ilMathJaxSetupConfig\getDataFromConfig(), ilMathJaxSetupConfig\isApplicableTo(), and ilMathJaxConfigSettingsRepository\updateConfig().

203  : bool
204  {
206  }
+ Here is the caller graph for this function:

◆ isServerForPdf()

ilMathJaxConfig::isServerForPdf ( )

Should the server-side rendingeing be used for PDF generation.

Definition at line 211 of file class.ilMathJaxConfig.php.

References $server_for_pdf.

Referenced by ilMathJaxSetupConfig\getDataFromConfig(), ilMathJaxSetupConfig\isApplicableTo(), and ilMathJaxConfigSettingsRepository\updateConfig().

211  : bool
212  {
213  return $this->server_for_pdf;
214  }
+ Here is the caller graph for this function:

◆ withClientEnabled()

ilMathJaxConfig::withClientEnabled ( bool  $client_enabled)

Enable latex code bing rendered in the browser.

Definition at line 219 of file class.ilMathJaxConfig.php.

References $client_enabled.

Referenced by ilMathJaxSetupConfig\applyTo().

220  {
221  $clone = clone $this;
222  $clone->client_enabled = $client_enabled;
223  return $clone;
224  }
Global Mathjax configuration.
+ Here is the caller graph for this function:

◆ withClientLimiter()

ilMathJaxConfig::withClientLimiter ( int  $client_limiter)

Set the type of enclosing limiters for wich the embedded client-side Mathjax is configured.

Definition at line 249 of file class.ilMathJaxConfig.php.

References $client_limiter.

Referenced by ilMathJaxSetupConfig\applyTo().

250  {
251  $clone = clone $this;
252  $clone->client_limiter = $client_limiter;
253  return $clone;
254  }
Global Mathjax configuration.
+ Here is the caller graph for this function:

◆ withClientPolyfillUrl()

ilMathJaxConfig::withClientPolyfillUrl ( string  $client_js_url)

Set the url of a polyfill script neededby MathJax 3.

Definition at line 229 of file class.ilMathJaxConfig.php.

Referenced by ilMathJaxSetupConfig\applyTo().

230  {
231  $clone = clone $this;
232  $clone->client_polyfill_url = $client_js_url;
233  return $clone;
234  }
Global Mathjax configuration.
+ Here is the caller graph for this function:

◆ withClientScriptUrl()

ilMathJaxConfig::withClientScriptUrl ( string  $client_async_url)

Set the url of Mathjax script to be embedded on the page (for MathJax 3)

Definition at line 239 of file class.ilMathJaxConfig.php.

Referenced by ilMathJaxSetupConfig\applyTo(), and ilMathJaxConfigCheckedObjective\checkClientScriptUrl().

240  {
241  $clone = clone $this;
242  $clone->client_script_url = $client_async_url;
243  return $clone;
244  }
Global Mathjax configuration.
+ Here is the caller graph for this function:

◆ withServerAddress()

ilMathJaxConfig::withServerAddress ( string  $server_address)

Set the url of the Mathjax server.

Definition at line 269 of file class.ilMathJaxConfig.php.

References $server_address.

Referenced by ilMathJaxSetupConfig\applyTo().

270  {
271  $clone = clone $this;
272  $clone->server_address = $server_address;
273  return $clone;
274  }
Global Mathjax configuration.
+ Here is the caller graph for this function:

◆ withServerEnabled()

ilMathJaxConfig::withServerEnabled ( bool  $server_enabled)

Enable a server side rendering engine configured and enabled.

Definition at line 259 of file class.ilMathJaxConfig.php.

References $server_enabled.

Referenced by ilMathJaxSetupConfig\applyTo().

260  {
261  $clone = clone $this;
262  $clone->server_enabled = $server_enabled;
263  return $clone;
264  }
Global Mathjax configuration.
+ Here is the caller graph for this function:

◆ withServerForBrowser()

ilMathJaxConfig::withServerForBrowser ( bool  $server_for_browser)

Enable the server-side rendingeing for browser output.

Definition at line 289 of file class.ilMathJaxConfig.php.

References $server_for_browser.

Referenced by ilMathJaxSetupConfig\applyTo().

290  {
291  $clone = clone $this;
292  $clone->server_for_browser = $server_for_browser;
293  return $clone;
294  }
Global Mathjax configuration.
+ Here is the caller graph for this function:

◆ withServerForExport()

ilMathJaxConfig::withServerForExport ( bool  $server_for_export)

Enable the server-side rendingeing for HTML exports.

Definition at line 299 of file class.ilMathJaxConfig.php.

References $server_for_export.

Referenced by ilMathJaxSetupConfig\applyTo().

300  {
301  $clone = clone $this;
302  $clone->server_for_export = $server_for_export;
303  return $clone;
304  }
Global Mathjax configuration.
+ Here is the caller graph for this function:

◆ withServerForPdf()

ilMathJaxConfig::withServerForPdf ( bool  $server_for_pdf)

Enable the server-side rendingeing for PDF generation.

Definition at line 309 of file class.ilMathJaxConfig.php.

References $server_for_pdf.

Referenced by ilMathJaxSetupConfig\applyTo().

310  {
311  $clone = clone $this;
312  $clone->server_for_pdf = $server_for_pdf;
313  return $clone;
314  }
Global Mathjax configuration.
+ Here is the caller graph for this function:

◆ withServerTimeout()

ilMathJaxConfig::withServerTimeout ( int  $server_timeout)

Set the timeout (s) to wait for the result of the rendering server.

Definition at line 279 of file class.ilMathJaxConfig.php.

References $server_timeout.

Referenced by ilMathJaxSetupConfig\applyTo().

280  {
281  $clone = clone $this;
282  $clone->server_timeout = $server_timeout;
283  return $clone;
284  }
Global Mathjax configuration.
+ Here is the caller graph for this function:

Field Documentation

◆ $client_enabled

bool ilMathJaxConfig::$client_enabled
protected

Definition at line 33 of file class.ilMathJaxConfig.php.

Referenced by __construct(), isClientEnabled(), and withClientEnabled().

◆ $client_limiter

int ilMathJaxConfig::$client_limiter
protected

Definition at line 36 of file class.ilMathJaxConfig.php.

Referenced by __construct(), getClientLimiter(), and withClientLimiter().

◆ $client_polyfill_url

string ilMathJaxConfig::$client_polyfill_url
protected

Definition at line 34 of file class.ilMathJaxConfig.php.

Referenced by getClintPolyfillUrl().

◆ $client_script_url

string ilMathJaxConfig::$client_script_url
protected

Definition at line 35 of file class.ilMathJaxConfig.php.

Referenced by getClientScriptUrl().

◆ $server_address

string ilMathJaxConfig::$server_address
protected

Definition at line 38 of file class.ilMathJaxConfig.php.

Referenced by getServerAddress(), and withServerAddress().

◆ $server_enabled

bool ilMathJaxConfig::$server_enabled
protected

Definition at line 37 of file class.ilMathJaxConfig.php.

Referenced by __construct(), isServerEnabled(), and withServerEnabled().

◆ $server_for_browser

bool ilMathJaxConfig::$server_for_browser
protected

Definition at line 40 of file class.ilMathJaxConfig.php.

Referenced by __construct(), isServerForBrowser(), and withServerForBrowser().

◆ $server_for_export

bool ilMathJaxConfig::$server_for_export
protected

Definition at line 41 of file class.ilMathJaxConfig.php.

Referenced by __construct(), isServerForExport(), and withServerForExport().

◆ $server_for_pdf

bool ilMathJaxConfig::$server_for_pdf
protected

Definition at line 42 of file class.ilMathJaxConfig.php.

Referenced by __construct(), isServerForPdf(), and withServerForPdf().

◆ $server_timeout

int ilMathJaxConfig::$server_timeout
protected

Definition at line 39 of file class.ilMathJaxConfig.php.

Referenced by __construct(), getServerTimeout(), and withServerTimeout().

◆ LIMITER_MATHJAX

const ilMathJaxConfig::LIMITER_MATHJAX = 0
private

Definition at line 29 of file class.ilMathJaxConfig.php.

◆ LIMITER_SPAN

const ilMathJaxConfig::LIMITER_SPAN = 2
private

Definition at line 31 of file class.ilMathJaxConfig.php.

◆ LIMITER_TEX

const ilMathJaxConfig::LIMITER_TEX = 1
private

Definition at line 30 of file class.ilMathJaxConfig.php.

◆ MATHJAX2_DEFAULT_URL

const ilMathJaxConfig::MATHJAX2_DEFAULT_URL = 'https://cdn.jsdelivr.net/npm/mathjax@2.7.9/MathJax.js?config=TeX-AMS-MML_HTMLorMML,Safe'
private

Definition at line 26 of file class.ilMathJaxConfig.php.

◆ MATHJAX3_RELATIVE_URL

const ilMathJaxConfig::MATHJAX3_RELATIVE_URL = 'Services/MathJax/js/cdn-mathjax3-es5-tex-mml-chtml-safe.js'
private

Definition at line 27 of file class.ilMathJaxConfig.php.


The documentation for this class was generated from the following file: