1<?php
2/**
3 * DWspecialist Plugin: Inserts a button with DWspecialist-syntax into the toolbar
4 *
5 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
6 * @author     Dietrich Wittenberg <info.wittenberg@online.de>
7 */
8// must be run within Dokuwiki
9if(!defined('DOKU_INC')) die();
10if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
11require_once(DOKU_PLUGIN.'action.php');
12
13/**
14 * create the data-array of the toolbar-button definition for the allowed syntax
15 * @return array
16 */
17function _create_event_data() {
18	global $lang;
19
20	$actions=array(
21			"admin",
22			"back",
23			"backlink",
24			"breadcrumbs",
25			"edit",
26			"export_pdf",
27			"history",
28			"index",
29			"login",
30			"profile",
31			"recent",
32			"subscribe",
33			"subscription",
34			"top",
35			"topbar",
36	);
37
38	$action="specialist";
39	$list[] = array(
40			'type'	=>	'insert',
41			'title'	=>	$action,
42			'icon'	=>	'../../plugins/dwspecialist/images/'.$action.'.png',
43			'insert'=>	'<specialist>\n  * <special breadcrumbs>\n</specialist>\n',
44	);
45	foreach ($actions as $action) {
46	$act=tpl_get_action($action);
47		if ($act) {
48			$name = (key_exists('btn_'.$act['type'], $lang)) ? $lang['btn_'.$act['type']] : $action;
49		} else {
50			$name = $action;
51		}
52	$list[] = array(
53				'type'	=>	'insert',
54	  		'title'	=>	$name,
55	  		'icon'	=>	'../../plugins/dwspecialist/images/'.$action.'.png',
56	  		'insert'=>	'<special '.$action.'>',
57	  		);
58	}
59
60	return $list;
61}
62
63/**
64 * All DokuWiki plugins to extend the admin function
65 * need to inherit from this class
66*/
67class action_plugin_dwspecialist extends DokuWiki_Action_Plugin {
68
69  /**
70   * @return multitype:string
71   */
72/* not longer needed for DokuWiki 2009-12-25 “Lemming” and later
73	function getInfo(){
74    return array(
75      'author' => 'Dietrich Wittenberg',
76      'email'  => 'info.wittenberg@online.de',
77      'date'   => '2012-07-01',
78      'name'   => 'plugin DWspecialist',
79      'desc'   => 'adds editor-button to includes an unordered list used as a menu',
80      'url'    => 'http://dokuwiki.org/plugin:dwspecialist',
81    );
82  }
83*/
84
85  /*
86   * Register the eventhandlers
87   * @see DokuWiki_Action_Plugin::register()
88   */
89  function register(&$controller) {
90  	$controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'insert_button', array());
91  }
92
93  /**
94   * Insert the toolbar button
95   * @param unknown_type $event
96   * @param unknown_type $param
97   */
98  function insert_button(& $event, $param) {
99  	$event->data[] = array(
100  			'type'	=>	'picker',
101  			'title'	=>	'Spezialmenüeintrag auswählen',
102  			'icon'	=>	'../../plugins/dwspecialist/images/specialist.png',
103  			'list'	=>	_create_event_data()
104  			);
105  }
106}
107?>