Edit the MathJax settings. 
   85                                     : void
   86    {
   87        $testcode = 'f(x)=\int_{-\infty}^x e^{-t^2}dt';
   88 
   90        $factory = $this->dic->ui()->factory()->input()->field();
 
   91 
   92        
   93        $checkbox_transformation = $this->
refinery->custom()->transformation(
static function ($v) {
 
   94            if (is_array($v) || is_bool($v)) {
   95                return $v;
   96            }
   97            return ($v === 'checked');
   98        });
   99 
  100        
  101        $client_enabled = 
$factory->optionalGroup(
 
  102            [
  103 
  104            'client_polyfill_url' => 
$factory->url(
 
  105                $this->lng->txt('mathjax_polyfill_url'),
  106                implode('<br />', [
  107                    $this->
lng->txt(
'mathjax_polyfill_url_desc_line1'),
 
  108                    $this->lng->txt('mathjax_polyfill_url_desc_line2')
  109                ])
  110            )
  111                                             ->withValue(
$config->getClintPolyfillUrl()),
 
  112 
  113            'client_script_url' => 
$factory->url(
 
  114                $this->lng->txt('mathjax_script_url'),
  115                implode('<br />', [
  116                    
  117                    sprintf($this->
lng->txt(
'mathjax_script_url_desc_line1'), 
$config->getMathJax2DefaultUrl()),
 
  118                    sprintf($this->
lng->txt(
'mathjax_script_url_desc_line2'), 
$config->getMathJax3DefaultUrl()),
 
  119                ])
  120            )->withRequired(true) 
  121                                           ->withValue(
$config->getClientScriptUrl()),
 
  122 
  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()),
 
  129 
  131                $this->lng->txt('mathjax_test_expression'),
  132                $this->lng->txt('mathjax_test_expression_info_client')
  134                    $config->withClientEnabled(
true)
 
  135                           ->withServerEnabled(false),
  137                )
  139                           ->insertLatexImages('<p>[tex]' . $testcode . '[/tex]</p>')
  140            )->withDisabled(
true)->
withValue($testcode)
 
  141 
  142        ],
  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')
  146        )->withAdditionalTransformation($checkbox_transformation);
  147 
  148        
  149        $server_enabled = 
$factory->optionalGroup(
 
  150            [
  152                $this->lng->txt('mathjax_server_address'),
  153                $this->lng->txt('mathjax_server_address_info')
  154            )->withRequired(true)
  155                                        ->withValue(
$config->getServerAddress()),
 
  156 
  157            'server_timeout' => 
$factory->numeric(
 
  158                $this->lng->txt('mathjax_server_timeout'),
  159                $this->lng->txt('mathjax_server_timeout_info')
  160            )
  161                                        ->withValue(
$config->getServerTimeout()),
 
  162 
  163            'server_for_browser' => 
$factory->checkbox(
 
  164                $this->lng->txt('mathjax_server_for_browser'),
  165                $this->lng->txt('mathjax_server_for_browser_info')
  166            )->withValue(
$config->isServerForBrowser()),
 
  167 
  168            'server_for_export' => 
$factory->checkbox(
 
  169                $this->lng->txt('mathjax_server_for_export'),
  170                $this->lng->txt('mathjax_server_for_export_info')
  171            )->withValue(
$config->isServerForExport()),
 
  172 
  173            'server_for_pdf' => 
$factory->checkbox(
 
  174                $this->lng->txt('mathjax_server_for_pdf'),
  175                $this->lng->txt('mathjax_server_for_pdf_info')
  176            )->withValue(
$config->isServerForPdf()),
 
  177 
  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)
  183 
  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),
  192                )
  194                           ->insertLatexImages('<p>[tex]' . $testcode . '[/tex]</p>')
  195            )->withDisabled(
true)->
withValue($testcode)
 
  196        ],
  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')
  200        )->withAdditionalTransformation($checkbox_transformation);
  201 
  202 
  203        
  204        
  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)
 
  209        ]);
  210 
  211        
  212        if ($this->request->getMethod() === "POST") {
  213            $form = $form->withRequest($this->request);
  214            $data = $form->getData();
 
  215        }
  216 
  217        
  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']);
  225            } else {
  227            }
  228 
  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']);
  237            } else {
  239            }
  241 
  242            $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"settings_saved"), 
true);
 
  243            $this->
ctrl->redirect($this);
 
  244        }
  245 
  246        
  247        $this->tpl->setContent($this->dic->ui()->renderer()->render($form));
  248    }
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...