1<?php 2/** 3 * DokuWiki Plugin Typography; Action component 4 * 5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6 * @author Satoshi Sahara <sahara.satoshi@gmail.com> 7 */ 8class action_plugin_typography extends DokuWiki_Action_Plugin 9{ 10 /** 11 * register the event handlers 12 */ 13 public function register(Doku_Event_Handler $controller) 14 { 15 if (plugin_isdisabled('fontcolor')) { 16 $controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'fontColorToolbar', array()); 17 } 18 if (plugin_isdisabled('fontsize2')) { 19 $controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'fontSizeToolbar', array()); 20 } 21 if (plugin_isdisabled('fontfamily')) { 22 $controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'fontFamilyToolbar', array()); 23 } 24 } 25 26 27 /** 28 * Adds FontColor toolbar button 29 * @see https://www.dokuwiki.org/plugin:fontcolor 30 */ 31 public function fontColorToolbar(Doku_Event $event, $param) 32 { 33 $title_note = ''; 34 $colors = array( 35 'White' => '#ffffff', 36 'Yellow' => '#ffff00', 37 'Red' => '#ff0000', 38 'Orange' => '#ffa500', 39 'Salmon' => '#fa8072', 40 'Pink' => '#ffc0cb', 41 'Plum' => '#dda0dd', 42 'Purple' => '#800080', 43 'Fuchsia' => '#ff00ff', 44 'Silver' => '#c0c0c0', 45 'Aqua' => '#00ffff', 46 'Teal' => '#008080', 47 'Cornflower' => '#6495ed', 48 'Sky Blue' => '#87ceeb', 49 'Aquamarine' => '#7fffd4', 50 'Pale Green' => '#98fb98', 51 'Lime' => '#00ff00', 52 'Green' => '#008000', 53 'Olive' => '#808000', 54 'Indian Red' => '#cd5c5c', 55 'Khaki' => '#f0e68c', 56 'Powder Blue' => '#b0e0e6', 57 'Sandy Brown' => '#f4a460', 58 'Steel Blue' => '#4682b4', 59 'Thistle' => '#d8bfd8', 60 'Yellow Green' => '#9acd32', 61 'Dark Violet' => '#9400d3', 62 'Maroon' => '#800000' 63 ); 64 65 $button = array( 66 'type' => 'picker', 67 'title' => $this->getLang('fc_picker') . $title_note, 68 'icon' => DOKU_REL.'lib/plugins/typography/images/fontcolor/picker.png', 69 'list' => array() 70 ); 71 foreach ($colors as $colorName => $colorValue) { 72 $button['list'][] = array( 73 'type' => 'format', 74 'title' => $colorName, 75 'icon' => DOKU_REL 76 .'lib/plugins/typography/images/fontcolor/color-icon.php?color=' 77 .substr($colorValue, 1), 78 'open' => '<fc ' . $colorValue . '>', 79 'close' => '</fc>' 80 ); 81 } 82 $event->data[] = $button; 83 } 84 85 /** 86 * Adds FontFamily toolbar button 87 * @see https://www.dokuwiki.org/plugin:fontcfamily 88 */ 89 public function fontFamilyToolbar(Doku_Event $event, $param) 90 { 91 $options = array( 92 'serif' => 'serif', 93 'sans-serif' => 'sans-serif', 94 //'cursive' => 'cursive', 95 //'fantasy' => 'fantasy', 96 ); 97 $button = array( 98 'type' => 'picker', 99 'title' => $this->getLang('ff_picker'), 100 'icon' => DOKU_REL.'lib/plugins/typography/images/fontfamily/picker.png', 101 'list' => array() 102 ); 103 foreach ($options as $familyName => $familyValue) { 104 $button['list'][] = array( 105 'type' => 'format', 106 'title' => $this->getLang('ff_'.$familyName), 107 'sample' => $this->getLang('ff_'.$familyName.'_sample'), 108 'icon' => DOKU_REL.'lib/plugins/typography/images/fontfamily/'.$familyName.'.png', 109 'open' => '<ff '.$familyValue.'>', 110 'close' => '</ff>', 111 ); 112 } 113 $event->data[] = $button; 114 } 115 116 /** 117 * Adds FontSize toolbar button 118 * @see https://www.dokuwiki.org/plugin:fontsize2 119 */ 120 public function fontSizeToolbar(Doku_Event $event, $param) 121 { 122 $options = array( 123 'xxs' => 'xx-small', 124 'xs' => 'x-small', 125 's' => 'small', 126 'm' => 'medium', 127 'l' => 'large', 128 'xl' => 'x-large', 129 'xxl' => 'xx-large', 130 'smaller' => 'smaller', 131 'larger' => 'larger' 132 ); 133 $button = array( 134 'type' => 'picker', 135 'title' => $this->getLang('fs_picker'), 136 'icon' => DOKU_REL.'lib/plugins/typography/images/fontsize/picker.png', 137 'list' => array() 138 ); 139 foreach ($options as $sizeName => $sizeValue) { 140 $button['list'][] = array( 141 'type' => 'format', 142 'title' => $this->getLang('fs_'.$sizeName), 143 'sample' => $this->getLang('fs_'.$sizeName.'_sample'), 144 'icon' => DOKU_REL.'lib/plugins/typography/images/fontsize/'.$sizeName.'.png', 145 'open' => '<fs '.$sizeValue.'>', 146 'close' => '</fs>', 147 ); 148 } 149 $event->data[] = $button; 150 } 151 152} 153