14ff971beSsaggi-dw<?php 2545c554bSsaggi-dw 34ff971beSsaggi-dw/** 44ff971beSsaggi-dw * DokuWiki Plugin dwtimeline (Action Component) 54ff971beSsaggi-dw * 64ff971beSsaggi-dw * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html 74ff971beSsaggi-dw * @author saggi <saggi@gmx.de> 84ff971beSsaggi-dw */ 94ff971beSsaggi-dw 10*9db2d6feSsaggi-dwuse dokuwiki\Extension\ActionPlugin; 11*9db2d6feSsaggi-dwuse dokuwiki\Extension\Event; 12*9db2d6feSsaggi-dwuse dokuwiki\Extension\EventHandler; 13*9db2d6feSsaggi-dw 14*9db2d6feSsaggi-dwclass action_plugin_dwtimeline extends ActionPlugin 15545c554bSsaggi-dw{ 164ff971beSsaggi-dw /** 174ff971beSsaggi-dw * Register the eventhandlers 184ff971beSsaggi-dw */ 19*9db2d6feSsaggi-dw public function register(EventHandler $controller) 20545c554bSsaggi-dw { 21*9db2d6feSsaggi-dw $controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'insertButton', []); 224ff971beSsaggi-dw } 234ff971beSsaggi-dw 244ff971beSsaggi-dw /** 254ff971beSsaggi-dw * Inserts the toolbar button 264ff971beSsaggi-dw */ 27*9db2d6feSsaggi-dw public function insertButton(Event $event, $param) 28545c554bSsaggi-dw { 29*9db2d6feSsaggi-dw $event->data[] = [ 302ddb0813SSteffen Sagert 'type' => 'picker', 312ddb0813SSteffen Sagert 'title' => $this->getLang('tl-picker'), 322ddb0813SSteffen Sagert 'icon' => '../../plugins/dwtimeline/icons/timeline_picker.png', 33*9db2d6feSsaggi-dw 'list' => [ 34*9db2d6feSsaggi-dw [ 354ff971beSsaggi-dw 'type' => 'format', 364ff971beSsaggi-dw 'title' => $this->getLang('tl-button'), 374ff971beSsaggi-dw 'icon' => '../../plugins/dwtimeline/icons/timeline_marker.png', 382ddb0813SSteffen Sagert 'open' => $this->buildSkeleton('complete'), 394ff971beSsaggi-dw 'sample' => $this->getLang('ms-content'), 404ff971beSsaggi-dw 'close' => '\n</milestone>\n</dwtimeline title="' . $this->getLang('tl-end') . '">', 41*9db2d6feSsaggi-dw ], 42*9db2d6feSsaggi-dw [ 432ddb0813SSteffen Sagert 'type' => 'format', 442ddb0813SSteffen Sagert 'title' => $this->getLang('ms-button'), 452ddb0813SSteffen Sagert 'icon' => '../../plugins/dwtimeline/icons/page_white_code.png', 462ddb0813SSteffen Sagert 'open' => $this->buildSkeleton('milestone'), 472ddb0813SSteffen Sagert 'sample' => $this->getLang('ms-content'), 482ddb0813SSteffen Sagert 'close' => '\n</milestone>', 49*9db2d6feSsaggi-dw ], 50*9db2d6feSsaggi-dw ] 51*9db2d6feSsaggi-dw ]; 524ff971beSsaggi-dw } 534ff971beSsaggi-dw 54545c554bSsaggi-dw private function buildSkeleton($skeletontype, $data = null) 55545c554bSsaggi-dw { 562ddb0813SSteffen Sagert switch ($skeletontype) { 572ddb0813SSteffen Sagert case 'complete': 58545c554bSsaggi-dw $skeleton = '<dwtimeline align="' . $this->getConf('align') . '" title="'; 59545c554bSsaggi-dw $skeleton .= $this->getLang('tl-title') . '" description="' . $this->getLang('tl-desc') . '">\n'; 60c78eb039Ssaggi-dw $skeleton .= $this->buildSkeleton('milestone'); 61545c554bSsaggi-dw $skeleton .= $this->getLang('ms-content') . '\n'; 622ddb0813SSteffen Sagert $skeleton .= '</milestone>\n'; 63c78eb039Ssaggi-dw $skeleton .= $this->buildSkeleton('milestone', '02'); 642ddb0813SSteffen Sagert break; 652ddb0813SSteffen Sagert case 'milestone': 66545c554bSsaggi-dw if (!$data) { 67545c554bSsaggi-dw $data = $this->getLang('ms-data'); 68545c554bSsaggi-dw } 69545c554bSsaggi-dw $skeleton = '<milestone title="' . $this->getLang('ms-title') . '" description="'; 70545c554bSsaggi-dw $skeleton .= $this->getLang('ms-desc') . '" '; 71c78eb039Ssaggi-dw $skeleton .= 'data="' . $data . '" backcolor="' . $this->getLang('ms-backcolor') . '">\n'; 722ddb0813SSteffen Sagert break; 732ddb0813SSteffen Sagert default: 74545c554bSsaggi-dw $skeleton = '<dwtimeline title="' . $this->getLang('tl-title') . '" description="'; 75545c554bSsaggi-dw $skeleton .= $this->getLang('tl-desc') . '">\n'; 76c78eb039Ssaggi-dw $skeleton .= $this->buildSkeleton('milestone'); 772ddb0813SSteffen Sagert break; 782ddb0813SSteffen Sagert } 794ff971beSsaggi-dw return $skeleton; 804ff971beSsaggi-dw } 814ff971beSsaggi-dw} 82