ILIAS  release_8 Revision v8.24
ilMathJaxConfigCheckedObjective Class Reference
+ Inheritance diagram for ilMathJaxConfigCheckedObjective:
+ Collaboration diagram for ilMathJaxConfigCheckedObjective:

Public Member Functions

 __construct (?\ilMathJaxSetupConfig $setup_config=null)
 
 getHash ()
 
 getLabel ()
 
 isNotable ()
 
 getPreconditions (Setup\Environment $environment)
 
 isApplicable (Setup\Environment $environment)
 

Protected Member Functions

 checkClientScriptUrl (ilMathJaxConfig $config, Setup\AdminInteraction $interaction)
 Check if an outdated script URL is used and try to correct it. More...
 

Protected Attributes

ilMathJaxSetupConfig $setup_config = null
 

Detailed Description

Definition at line 23 of file class.ilMathJaxConfigCheckedObjective.php.

Constructor & Destructor Documentation

◆ __construct()

ilMathJaxConfigCheckedObjective::__construct ( ?\ilMathJaxSetupConfig  $setup_config = null)

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

28 {
29 $this->setup_config = $setup_config;
30 }

References $setup_config.

Member Function Documentation

◆ checkClientScriptUrl()

ilMathJaxConfigCheckedObjective::checkClientScriptUrl ( ilMathJaxConfig  $config,
Setup\AdminInteraction  $interaction 
)
protected

Check if an outdated script URL is used and try to correct it.

  • Correct automatically if MathJax in the browser is not enabled (change an old default setting)
  • Ask if MathJax in the browser is enabled
  • Warn if an outdated URL is used in the config.json

Return a config object which has to be saved, if changes are made

Definition at line 81 of file class.ilMathJaxConfigCheckedObjective.php.

82 {
83 $change = false;
84 $recommended = 'https://cdn.jsdelivr.net/npm/mathjax@2.7.9/MathJax.js?config=TeX-AMS-MML_HTMLorMML,Safe';
85 $outdated = [
86 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML',
87 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML,Safe',
88 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.9/MathJax.js?config=TeX-AMS-MML_HTMLorMML',
89 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.9/MathJax.js?config=TeX-AMS-MML_HTMLorMML,Safe',
90 'https://cdn.jsdelivr.net/npm/mathjax@2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML',
91 'https://cdn.jsdelivr.net/npm/mathjax@2.7.9/MathJax.js?config=TeX-AMS-MML_HTMLorMML'
92 ];
93
94 if (in_array($config->getClientScriptUrl(), $outdated)) {
95 if ($config->isClientEnabled()) {
96 $change = $interaction->confirmOrDeny("Replace outdated or unsave MathJax URL with $recommended ?");
97 } else {
98 $interaction->inform("Replaced inactive outdated MathJax URL with $recommended");
99 $change = true;
100 }
101 }
102 if ($change
103 && $this->setup_config !== null
104 && in_array($this->setup_config->getConfig()->getClientScriptUrl(), $outdated)
105 ) {
106 $interaction->inform("Please change the URL in the setup.json to avoid this message in the next update.");
107 }
108
109 if ($change) {
110 return $config->withClientScriptUrl($recommended);
111 }
112 return null;
113 }
Global Mathjax configuration.
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:85

References $config.

◆ getHash()

ilMathJaxConfigCheckedObjective::getHash ( )

Definition at line 32 of file class.ilMathJaxConfigCheckedObjective.php.

32 : string
33 {
34 return hash("sha256", self::class);
35 }

◆ getLabel()

ilMathJaxConfigCheckedObjective::getLabel ( )

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

37 : string
38 {
39 return "Check configuration of Services/MathJax";
40 }

◆ getPreconditions()

ilMathJaxConfigCheckedObjective::getPreconditions ( Setup\Environment  $environment)

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

47 : array
48 {
49 return [
50 new \ilSettingsFactoryExistsObjective()
51 ];
52 }

◆ isApplicable()

ilMathJaxConfigCheckedObjective::isApplicable ( Setup\Environment  $environment)

Definition at line 68 of file class.ilMathJaxConfigCheckedObjective.php.

68 : bool
69 {
70 return true;
71 }

◆ isNotable()

ilMathJaxConfigCheckedObjective::isNotable ( )

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

42 : bool
43 {
44 return false;
45 }

Field Documentation

◆ $setup_config

ilMathJaxSetupConfig ilMathJaxConfigCheckedObjective::$setup_config = null
protected

Definition at line 25 of file class.ilMathJaxConfigCheckedObjective.php.

Referenced by __construct().


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