* License: 3-clause BSD license
*/
use Friendica\App;
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
function mathjax_install() {
Addon::registerHook('load_config', 'addon/mathjax/mathjax.php', 'mathjax_load_config');
Addon::registerHook('page_header', 'addon/mathjax/mathjax.php', 'mathjax_page_header');
Addon::registerHook('addon_settings', 'addon/mathjax/mathjax.php', 'mathjax_settings');
Addon::registerHook('addon_settings_post', 'addon/mathjax/mathjax.php', 'mathjax_settings_post');
Addon::registerHook('template_vars', 'addon/mathjax/mathjax.php', 'mathjax_template_vars');
logger('installed js_math addon');
}
function mathjax_uninstall() {
Addon::unregisterHook('load_config', 'addon/mathjax/mathjax.php', 'mathjax_load_config');
Addon::unregisterHook('page_header', 'addon/mathjax/mathjax.php', 'mathjax_page_header');
Addon::unregisterHook('addon_settings', 'addon/mathjax/mathjax.php', 'mathjax_settings');
Addon::unregisterHook('addon_settings_post', 'addon/mathjax/mathjax.php', 'mathjax_settings_post');
Addon::unregisterHook('template_vars', 'addon/mathjax/mathjax.php', 'mathjax_template_vars');
}
function mathjax_load_config(\Friendica\App $a)
{
$a->loadConfigFile(__DIR__. '/config/mathjax.ini.php');
}
function mathjax_template_vars($a, &$arr)
{
if (!array_key_exists('addon_hooks',$arr['vars']))
{
$arr['vars']['addon_hooks'] = array();
}
$arr['vars']['addon_hooks'][] = "mathjax";
}
function mathjax_settings_post ($a, $post) {
if (! local_user())
return;
if (!x($_POST,'mathjax-submit'))
return;
PConfig::set(local_user(),'mathjax','use',intval($_POST['mathjax_use']));
}
function mathjax_settings (&$a, &$s) {
if (! local_user())
return;
$use = PConfig::get(local_user(),'mathjax','use');
$usetext = (($use) ? ' checked="checked" ' : '');
$s .= '';
$s .= 'MathJax '.L10n::t('Settings').'
';
$s .= '';
$s .= '