1<?php 2/** 3 * DokuWiki Plugin MagicMatcher (Action Component for toolbar button) 4 * 5 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html 6 * @author Michael Große, Andreas Gohrs <dokuwiki@cosmocode.de> 7 */ 8 9// must be run within Dokuwiki 10if (!defined('DOKU_INC')) { 11 die(); 12} 13 14class action_plugin_tablelayout_layoutform extends DokuWiki_Action_Plugin 15{ 16 17 /** 18 * Registers a callback function for a given event 19 * 20 * @param Doku_Event_Handler $controller DokuWiki's event controller object 21 * @return void 22 */ 23 public function register(Doku_Event_Handler $controller) 24 { 25 $controller->register_hook('AJAX_CALL_UNKNOWN', 'BEFORE', $this, 'handleAjaxCall'); 26 } 27 28 /** 29 * List available templates 30 * 31 * @param Doku_Event $event event object by reference 32 * @param mixed $param [the parameters passed as fifth argument to register_hook() when this 33 * handler was registered] 34 * @return void 35 */ 36 public function handleAjaxCall(Doku_Event $event, $param) 37 { 38 if ($event->data !== 'plugin_tablelayout_form') { 39 return; 40 } 41 $event->preventDefault(); 42 $event->stopPropagation(); 43 44 header('Content-Type: text/html; charset=utf-8'); 45 46 $form = new \dokuwiki\Form\Form(); 47 $form->addFieldsetOpen($this->getLang('legend:tablelayout'))->addClass('borderless'); 48 $form->addTagOpen('div')->attr('style', 'display: none;'); 49 $form->addTagOpen('p'); 50 $form->addHTML($this->getLang('text:explain form')); 51 $form->addTagClose('p'); 52 $form->addTagOpen('div')->addClass('layoutform_wrapper'); 53 $form->addTagOpen('div'); 54 $form->addDropdown('rowsHeaderSource', 55 ['Auto', 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 56 $this->getLang('label:rowsHeader')); 57 $form->addTextInput('rowsVisible', $this->getLang('label:rowsVisible')) 58 ->attrs(array('type' => 'number', 'min' => '0')) 59 ->val(0); 60 $options = array( 61 'default' => $this->getLang('option:default'), 62 'left' => $this->getLang('option:float left'), 63 'right' => $this->getLang('option:float right'), 64 'center' => $this->getLang('option:center'), 65 ); 66 $form->addDropdown('float', $options, $this->getLang('label:alignment'))->val('default'); 67 $form->addTagClose('div'); 68 $form->addTagOpen('div'); 69 $form->addCheckbox('tableSort', $this->getLang('label:tableSort')); 70 $form->addCheckbox('tableSearch', $this->getLang('label:tableSearch')); 71 $form->addCheckbox('tablePrint', $this->getLang('label:tablePrint')); 72 $form->addTagClose('div'); 73 $form->addTagClose('div'); 74 $form->addButton('', $this->getLang('button:apply'))->attr('type', 'submit'); 75 $form->addTagClose('div'); 76 $form->addFieldsetClose(); 77 78 79 echo '<div id="tablelayoutoptions">' . $form->toHTML() . '</div>'; 80 } 81} 82 83// vim:ts=4:sw=4:et: 84