1<?php 2 3/** 4 * DokuWiki Plugin dwtimeline (Action Component) 5 * 6 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html 7 * @author saggi <saggi@gmx.de> 8 */ 9 10class action_plugin_dwtimeline extends DokuWiki_Action_Plugin 11{ 12 /** 13 * Register the eventhandlers 14 */ 15 public function register(Doku_Event_Handler $controller) 16 { 17 $controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'insertButton', array()); 18 } 19 20 /** 21 * Inserts the toolbar button 22 */ 23 public function insertButton(Doku_Event $event, $param) 24 { 25 $event->data[] = array( 26 'type' => 'picker', 27 'title' => $this->getLang('tl-picker'), 28 'icon' => '../../plugins/dwtimeline/icons/timeline_picker.png', 29 'list' => array( 30 array( 31 'type' => 'format', 32 'title' => $this->getLang('tl-button'), 33 'icon' => '../../plugins/dwtimeline/icons/timeline_marker.png', 34 'open' => $this->buildSkeleton('complete'), 35 'sample' => $this->getLang('ms-content'), 36 'close' => '\n</milestone>\n</dwtimeline title="' . $this->getLang('tl-end') . '">', 37 ), 38 array( 39 'type' => 'format', 40 'title' => $this->getLang('ms-button'), 41 'icon' => '../../plugins/dwtimeline/icons/page_white_code.png', 42 'open' => $this->buildSkeleton('milestone'), 43 'sample' => $this->getLang('ms-content'), 44 'close' => '\n</milestone>', 45 ), 46 ) 47 ); 48 } 49 50 private function buildSkeleton($skeletontype, $data = null) 51 { 52 switch ($skeletontype) { 53 case 'complete': 54 $skeleton = '<dwtimeline align="' . $this->getConf('align') . '" title="'; 55 $skeleton .= $this->getLang('tl-title') . '" description="' . $this->getLang('tl-desc') . '">\n'; 56 $skeleton .= $this->buildSkeleton('milestone'); 57 $skeleton .= $this->getLang('ms-content') . '\n'; 58 $skeleton .= '</milestone>\n'; 59 $skeleton .= $this->buildSkeleton('milestone', '02'); 60 break; 61 case 'milestone': 62 if (!$data) { 63 $data = $this->getLang('ms-data'); 64 } 65 $skeleton = '<milestone title="' . $this->getLang('ms-title') . '" description="'; 66 $skeleton .= $this->getLang('ms-desc') . '" '; 67 $skeleton .= 'data="' . $data . '" backcolor="' . $this->getLang('ms-backcolor') . '">\n'; 68 break; 69 default: 70 $skeleton = '<dwtimeline title="' . $this->getLang('tl-title') . '" description="'; 71 $skeleton .= $this->getLang('tl-desc') . '">\n'; 72 $skeleton .= $this->buildSkeleton('milestone'); 73 break; 74 } 75 return $skeleton; 76 } 77} 78