1007225e5Sgerardnico<?php 2007225e5Sgerardnico/** 3007225e5Sgerardnico * Action Component 4007225e5Sgerardnico * Add a button in the edit toolbar 5007225e5Sgerardnico * 6007225e5Sgerardnico * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 7007225e5Sgerardnico * @author Nicolas GERARD 8007225e5Sgerardnico */ 9007225e5Sgerardnico 10007225e5Sgerardnicouse ComboStrap\PluginUtility; 11007225e5Sgerardnico 12007225e5Sgerardnicoif (!defined('DOKU_INC')) die(); 13007225e5Sgerardnicorequire_once(__DIR__ . '/../class/PluginUtility.php'); 14007225e5Sgerardnico 15007225e5Sgerardnico 16*5f891b7eSNickeauclass action_plugin_combo_toolbar extends DokuWiki_Action_Plugin 17*5f891b7eSNickeau{ 18007225e5Sgerardnico 19007225e5Sgerardnico /** 20007225e5Sgerardnico * register the event handlers 21007225e5Sgerardnico * 22007225e5Sgerardnico * @author Nicolas GERARD 23007225e5Sgerardnico */ 24*5f891b7eSNickeau function register(Doku_Event_Handler $controller) 25*5f891b7eSNickeau { 26007225e5Sgerardnico $controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'handle_toolbar', array()); 27007225e5Sgerardnico } 28007225e5Sgerardnico 29*5f891b7eSNickeau function handle_toolbar(&$event, $param) 30*5f891b7eSNickeau { 31007225e5Sgerardnico 322128d419Sgerardnico 33*5f891b7eSNickeau $imageBase = '../../plugins/' . PluginUtility::PLUGIN_BASE_NAME . '/images/'; 342128d419Sgerardnico $unit = array( 35007225e5Sgerardnico 'type' => 'format', 362128d419Sgerardnico 'title' => 'Insert an unit test', 37*5f891b7eSNickeau 'icon' => $imageBase . 'unit-doc-block.png', 38007225e5Sgerardnico 'open' => '<unit name="default">\n<file lang path>\n</file>\n\t<code lang>', 39*5f891b7eSNickeau 'close' => '\n\t</code>\n\t<console>\n\t</console></unit>\n', 402128d419Sgerardnico // 'key' => $unitShortcutKey 41007225e5Sgerardnico ); 42007225e5Sgerardnico 432128d419Sgerardnico /** 442128d419Sgerardnico * This is called from the js.php with a get HTTP 452128d419Sgerardnico * There is no knowledge of which page is modified 462128d419Sgerardnico */ 472128d419Sgerardnico 482128d419Sgerardnico $frontmatter = <<<EOF 492128d419Sgerardnico---json 502128d419Sgerardnico{ 512128d419Sgerardnico "canonical":"unique:name", 522128d419Sgerardnico "title":"A title for the search page result engine", 532128d419Sgerardnico "description":"A description for the search page result engine" 542128d419Sgerardnico} 552128d419Sgerardnico--- 562128d419SgerardnicoEOF; 572128d419Sgerardnico // https://www.dokuwiki.org/devel:event:toolbar_define 582128d419Sgerardnico $frontmatter = array( 592128d419Sgerardnico 'type' => 'insert', 602128d419Sgerardnico 'title' => 'Insert a frontmatter', 61*5f891b7eSNickeau 'icon' => $imageBase . 'table-of-contents.svg', 622128d419Sgerardnico 'insert' => $frontmatter, 632128d419Sgerardnico 'block' => true 642128d419Sgerardnico ); 652128d419Sgerardnico 662128d419Sgerardnico 672128d419Sgerardnico $blockquote = array( 682128d419Sgerardnico 'type' => 'format', 692128d419Sgerardnico 'title' => 'blockquote', 702128d419Sgerardnico 'icon' => '../../plugins/' . PluginUtility::PLUGIN_BASE_NAME . '/images/blockquote-icon.png', 712128d419Sgerardnico 'open' => '<blockquote>', 722128d419Sgerardnico 'close' => '</blockquote>', 732128d419Sgerardnico 742128d419Sgerardnico ); 752128d419Sgerardnico 762128d419Sgerardnico $event->data[] = array( 772128d419Sgerardnico 'type' => 'picker', 782128d419Sgerardnico 'title' => "Choose comboStrap component", 792128d419Sgerardnico 'icon' => '../../plugins/' . PluginUtility::PLUGIN_BASE_NAME . '/images/logo.svg', 802128d419Sgerardnico 'list' => array($frontmatter, $blockquote, $unit) 812128d419Sgerardnico ); 822128d419Sgerardnico 83*5f891b7eSNickeau $event->data[] = array( 84*5f891b7eSNickeau 'type' => 'format', 85*5f891b7eSNickeau 'title' => 'webcode', 86*5f891b7eSNickeau 'icon' => '../../plugins/' . PluginUtility::PLUGIN_BASE_NAME . '/images/webcode.png', 87*5f891b7eSNickeau 'open' => '<webcode name="Default" frameborder="0">\n', 88*5f891b7eSNickeau 'close' => '\n</webcode>\n' 89*5f891b7eSNickeau //'key' => $webCodeShortcutKey 90*5f891b7eSNickeau ); 91*5f891b7eSNickeau 922128d419Sgerardnico return true; 932128d419Sgerardnico 94007225e5Sgerardnico 95007225e5Sgerardnico } 96007225e5Sgerardnico 97007225e5Sgerardnico} 98007225e5Sgerardnico 99