register_hook( 'PLUGIN_USERSETTINGS_REGISTER', 'BEFORE', $this, 'handleSettingsRegister' ); // Inject annotation stats + user preference into JSINFO. $controller->register_hook( 'TPL_METAHEADER_OUTPUT', 'BEFORE', $this, 'handleMetaHeader' ); // Handle the AJAX call. $controller->register_hook( 'AJAX_CALL_UNKNOWN', 'BEFORE', $this, 'handleAjax' ); } // ------------------------------------------------------------------ // 1. usersettings toggle registration // ------------------------------------------------------------------ /** * Append the annotations_enabled toggle definition to the event data. * * The event data is an array that the usersettings helper fires with * createAndTrigger(); every handler appends its definition(s). * * @param Doku_Event $event PLUGIN_USERSETTINGS_REGISTER * @param mixed $param */ public function handleSettingsRegister(Doku_Event $event, $param) { $event->data[] = [ 'key' => 'annotations_enabled', 'label' => $this->getLang('toggle_label'), 'desc' => $this->getLang('toggle_desc'), 'type' => 'checkbox', 'default' => true, 'plugin' => 'annotations', ]; } // ------------------------------------------------------------------ // 2. Inject into JSINFO // ------------------------------------------------------------------ /** * Add annotation stats and the user preference to JSINFO so script.js * does not need an extra round-trip on page load. * * IMPORTANT: tpl_metaheaders() calls jsinfo() and then immediately * JSON-encodes $JSINFO into an inline