*/ use dokuwiki\Extension\ActionPlugin; use dokuwiki\Extension\EventHandler; use dokuwiki\Extension\Event; use dokuwiki\Form\Form; use dokuwiki\plugin\struct\meta\AccessTable; use dokuwiki\plugin\struct\meta\Assignments; use dokuwiki\plugin\struct\meta\Value; /** * Class action_plugin_struct_entry * * Handles adding struct forms to the default editor */ class action_plugin_struct_edit extends ActionPlugin { /** * @var string The form name we use to transfer schema data */ protected static $VAR = 'struct_schema_data'; /** * Registers a callback function for a given event * * @param EventHandler $controller DokuWiki's event controller object * @return void */ public function register(EventHandler $controller) { // add the struct editor to the edit form; $controller->register_hook('HTML_EDITFORM_OUTPUT', 'BEFORE', $this, 'handleEditform'); $controller->register_hook('FORM_EDIT_OUTPUT', 'BEFORE', $this, 'addFromData'); } /** * Adds the html for the struct editors to the edit from * * Handles the FORM_EDIT_OUTPUT event * * @return bool */ public function addFromData(Event $event, $_param) { $html = $this->getEditorHtml(); /** @var Form $form */ $form = $event->data; $pos = $form->findPositionByAttribute('id', 'wiki__editbar'); // insert the form before the main buttons $form->addHTML($html, $pos); return true; } /** * Enhance the editing form with structural data editing * * TODO: Remove this after HTML_EDITFORM_OUTPUT is no longer released in DokuWiki stable * * @param Event $event event object by reference * @param mixed $param [the parameters passed as fifth argument to register_hook() when this * handler was registered] * @return bool */ public function handleEditform(Event $event, $param) { $html = $this->getEditorHtml(); /** @var Doku_Form $form */ $form = $event->data; $pos = $form->findElementById('wiki__editbar'); // insert the form before the main buttons $form->insertElement($pos, $html); return true; } /** * @return string */ private function getEditorHtml() { global $ID; $assignments = Assignments::getInstance(); $tables = $assignments->getPageAssignments($ID); $html = ''; foreach ($tables as $table) { $html .= $this->createForm($table); } return "