1<?php
2/**
3 * Action Component for the FontColor plugin
4 */
5
6if(!defined('DOKU_INC')) die();
7
8/**
9 * Action Component for the FontColor plugin
10 */
11class action_plugin_fontcolor extends DokuWiki_Action_Plugin {
12    /**
13     * register the event handlers
14     */
15    public function register(Doku_Event_Handler $controller) {
16        $controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'toolbarEventHandler', array());
17    }
18
19    /**
20     * Adds FontColor toolbar button
21     *
22     * @param Doku_Event $event
23     * @param mixed $param
24     */
25    public function toolbarEventHandler(Doku_Event $event, $param) {
26        $colors = array(
27            'Yellow'        => '#ffff00',
28            'Red'           => '#ff0000',
29            'Orange'        => '#ffa500',
30            'Salmon'        => '#fa8072',
31            'Pink'          => '#ffc0cb',
32            'Plum'          => '#dda0dd',
33            'Purple'        => '#800080',
34            'Fuchsia'       => '#ff00ff',
35            'Silver'        => '#c0c0c0',
36            'Aqua'          => '#00ffff',
37            'Teal'          => '#008080',
38            'Cornflower'    => '#6495ed',
39            'Sky Blue'      => '#87ceeb',
40            'Aquamarine'    => '#7fffd4',
41            'Pale Green'    => '#98fb98',
42            'Lime'          => '#00ff00',
43            'Green'         => '#008000',
44            'Olive'         => '#808000',
45            'Indian Red'    => '#cd5c5c',
46            'Khaki'         => '#f0e68c',
47            'Powder Blue'   => '#b0e0e6',
48            'Sandy Brown'   => '#f4a460',
49            'Steel Blue'    => '#4682b4',
50            'Thistle'       => '#d8bfd8',
51            'Yellow Green'  => '#9acd32',
52            'Dark Violet'   => '#9400d3',
53            'Maroon'        => '#800000'
54        );
55
56        $button = array(
57            'type' => 'picker',
58            'title' => 'Font color',
59            'icon' => '../../plugins/fontcolor/images/toolbar_icon.png',
60            'list' => array()
61        );
62
63        foreach($colors as $colorName => $colorValue) {
64            $button['list'] [] = array(
65                'type' => 'format',
66                'title' => $colorName,
67                'icon' => '../../plugins/fontcolor/images/color-icon.php?color='
68                    . substr($colorValue, 1),
69                'open' => '<fc ' . $colorValue . '>',
70                'close' => '</fc>'
71            );
72        }
73
74        $event->data[] = $button;
75    }
76}
77