1<?php 2/** 3 * Action Component 4 * Add a button in the edit toolbar 5 * 6 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 7 * @author Nicolas GERARD 8 */ 9 10use ComboStrap\PluginUtility; 11use ComboStrap\Resources; 12 13if (!defined('DOKU_INC')) die(); 14require_once(__DIR__ . '/../class/PluginUtility.php'); 15 16 17class action_plugin_combo_toolbar extends DokuWiki_Action_Plugin 18{ 19 20 /** 21 * register the event handlers 22 * 23 * @author Nicolas GERARD 24 */ 25 function register(Doku_Event_Handler $controller) 26 { 27 $controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'handle_toolbar', array()); 28 } 29 30 function handle_toolbar(&$event, $param) 31 { 32 33 34 $imageBase = '../../plugins/' . Resources::getRelativeImagesDirectory(); 35 36 $unit = array( 37 'type' => 'format', 38 'title' => 'Insert an unit test', 39 'icon' => $imageBase . '/unit-doc-block.png', 40 'open' => '<unit name="default">\n<file lang path>\n</file>\n\t<code lang>', 41 'close' => '\n\t</code>\n\t<console>\n\t</console></unit>\n', 42 // 'key' => $unitShortcutKey 43 ); 44 45 /** 46 * This is called from the js.php with a get HTTP 47 * There is no knowledge of which page is modified 48 */ 49 50 $frontmatterInsert = <<<EOF 51---json 52{ 53 "canonical":"unique:name", 54 "title":"A title for the search page result engine", 55 "description":"A description for the search page result engine" 56} 57--- 58EOF; 59 // https://www.dokuwiki.org/devel:event:toolbar_define 60 $frontmatter = array( 61 'type' => 'insert', 62 'title' => 'Insert a frontmatter', 63 'icon' => $imageBase . '/table-of-contents.svg', 64 'insert' => $frontmatterInsert, 65 'block' => true 66 ); 67 68 69 $blockquote = array( 70 'type' => 'format', 71 'title' => 'blockquote', 72 'icon' => $imageBase . '/blockquote-icon.png', 73 'open' => '<blockquote>', 74 'close' => '</blockquote>', 75 76 ); 77 78 $webcode = array( 79 'type' => 'format', 80 'title' => 'webcode', 81 'icon' => $imageBase . '/code-square.svg', 82 'open' => '<webcode name="Default" frameborder="0">\n', 83 'close' => '\n</webcode>\n' 84 //'key' => $webCodeShortcutKey 85 ); 86 87 $twitter = array( 88 'type' => 'format', 89 'title' => 'twitter', 90 'icon' => $imageBase . '/twitter.svg', 91 'open' => '<blockquote>\n<cite>[[', 92 'close' => ']]</cite>\n</webcode>\n' 93 //'key' => $webCodeShortcutKey 94 ); 95 96 $event->data[] = array( 97 'type' => 'picker', 98 'title' => "Choose comboStrap component", 99 'icon' => $imageBase . '/logo.svg', 100 'list' => array($frontmatter, $blockquote, $webcode, $twitter, $unit) 101 ); 102 103 104 105 106 return true; 107 108 109 } 110 111} 112 113