1<?php 2/** 3 * Bootstrap Wrapper Action Plugin 4 * 5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6 * @author Giuseppe Di Terlizzi <giuseppe.diterlizzi@gmail.com> 7 * @copyright (C) 2015-2020, Giuseppe Di Terlizzi 8 */ 9 10 11/** 12 * Bootstrap Wrapper Action Plugin 13 * 14 * Add external CSS file to DokuWiki 15 */ 16class action_plugin_bootswrapper extends DokuWiki_Action_Plugin 17{ 18 19 /** 20 * Syntax with section edit 21 * 22 * @var array 23 */ 24 private $section_edit_buttons = array( 25 'plugin_bootswrapper_pane', 26 'plugin_bootswrapper_panel', 27 ); 28 29 /** 30 * Register events 31 * 32 * @param Doku_Event_Handler $controller 33 */ 34 public function register(Doku_Event_Handler $controller) 35 { 36 $controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, '_insert_button'); 37 $controller->register_hook('HTML_SECEDIT_BUTTON', 'BEFORE', $this, '_secedit_button'); 38 $controller->register_hook('HTML_EDIT_FORMSELECTION', 'BEFORE', $this, '_editform'); 39 } 40 41 /** 42 * Edit Form 43 * 44 * @param Doku_Event &$event 45 */ 46 public function _editform(Doku_Event $event) 47 { 48 if (!in_array($event->data['target'], $this->section_edit_buttons)) { 49 return; 50 } 51 52 $event->data['target'] = 'section'; 53 return; 54 } 55 56 /** 57 * Set Section Edit button 58 * 59 * @param Doku_Event &$event 60 */ 61 public function _secedit_button(Doku_Event $event) 62 { 63 global $lang; 64 65 if (!in_array($event->data['target'], $this->section_edit_buttons)) { 66 return; 67 } 68 69 $event->data['name'] = $lang['btn_secedit'] . ' - ' . ucfirst(str_replace('plugin_bootswrapper_', '', $event->data['target'])); 70 } 71 72 /** 73 * Set toolbar button in edit mode 74 * 75 * @param Doku_Event &$event 76 */ 77 public function _insert_button(Doku_Event $event, $param) 78 { 79 $event->data[] = array( 80 'type' => 'mediapopup', 81 'title' => 'Bootstrap Wrapper', 82 'icon' => '../../plugins/bootswrapper/images/bootstrap.png', 83 'url' => 'lib/plugins/bootswrapper/exe/popup.php?ns=', 84 'name' => 'bootstrap-wrapper', 85 'options' => 'width=800,height=600,left=20,top=20,toolbar=no,menubar=no,scrollbars=yes,resizable=yes', 86 'block' => false, 87 ); 88 } 89} 90