1<?php 2 3/** 4 * Action component of diagrams plugin 5 * 6 * This handles general operations independent of the configured mode 7 * 8 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html 9 * @author Innovakom + CosmoCode <dokuwiki@cosmocode.de> 10 */ 11class action_plugin_diagrams_action extends DokuWiki_Action_Plugin 12{ 13 14 /**@inheritDoc */ 15 public function register(Doku_Event_Handler $controller) 16 { 17 $controller->register_hook('DOKUWIKI_STARTED', 'AFTER', $this, 'addJsinfo'); 18 $controller->register_hook('MEDIAMANAGER_STARTED', 'AFTER', $this, 'addJsinfo'); 19 $controller->register_hook('DOKUWIKI_STARTED', 'AFTER', $this, 'checkConf'); 20 $controller->register_hook('PLUGIN_MOVE_HANDLERS_REGISTER', 'BEFORE', $this, 'registerMoveHandler'); 21 } 22 23 /** 24 * Registers our handler with the move plugin 25 * 26 * @param Doku_Event $event 27 * @return void 28 */ 29 public function registerMoveHandler(Doku_Event $event) 30 { 31 $event->data['handlers']['diagrams_mediafile'] = [new \syntax_plugin_diagrams_mediafile(), 'handleMove']; 32 } 33 34 /** 35 * Add data to JSINFO 36 * 37 * full service URL 38 * digram mode 39 * security token used for uploading 40 * 41 * @param Doku_Event $event DOKUWIKI_STARTED|MEDIAMANAGER_STARTED 42 */ 43 public function addJsinfo(Doku_Event $event) 44 { 45 global $JSINFO; 46 $JSINFO['sectok'] = getSecurityToken(); 47 $JSINFO['plugins']['diagrams'] = [ 48 'service_url' => $this->getConf('service_url'), 49 'mode' => $this->getConf('mode'), 50 ]; 51 } 52 53 /** 54 * Check if DokuWiki is properly configured to handle SVG diagrams 55 * 56 * @param Doku_Event $event DOKUWIKI_STARTED 57 */ 58 public function checkConf(Doku_Event $event) 59 { 60 $mime = getMimeTypes(); 61 if (!array_key_exists('svg', $mime) || $mime['svg'] !== 'image/svg+xml') { 62 msg($this->getLang('missingConfig'), -1); 63 } 64 } 65 66 67 68} 69