1<?php
2/**
3 * @package    indexnumber
4 * @author     Gabriel Birke <gb@birke-software.de>
5 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
6 */
7
8if(!defined('DOKU_INC')) die();
9if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
10require_once(DOKU_PLUGIN.'action.php');
11
12class action_plugin_indexnumber extends DokuWiki_Action_Plugin {
13
14  /*
15   * Register the handlers with the dokuwiki's event controller
16   */
17  function register(Doku_Event_Handler $controller) {
18    $controller->register_hook('TOOLBAR_DEFINE', 'AFTER',  $this, 'add_button');
19  }
20
21  /**
22   * Parse the configured index names and add the button to the toolbar.
23   */
24  function add_button(&$event, $param) {
25    $indexnames = $this->getConf('indexnames');
26    $index_list = array_map("trim", explode("\n", $indexnames));
27    $index_list = array_filter($index_list);
28    if (!empty($index_list))
29    {
30      $event->data[] = array(
31                  'type'   => 'indexnumberpicker',
32                  'title'  => $this->getLang('toolbar_title'),
33                  'icon'   => '../../plugins/indexnumber/indexnumber_icon.png',
34                  'list'   => $index_list,
35                  'idxrefs' => false
36                  );
37    }
38  }
39
40}
41