1<?php 2/** 3 * Plugin svgpureInsert: Inserts a non png or other modified svg file, just its pure version 4 * 5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6 * @author Andreas Gohr <gohr@cosmocode.de> 7 */ 8 9if(!defined('DOKU_INC')) exit; 10if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN', DOKU_INC . 'lib/plugins/'); 11 12class action_plugin_svgpureinsert extends DokuWiki_Action_Plugin { 13 14 public function register(Doku_Event_Handler $controller) { 15 $controller->register_hook('FETCH_MEDIA_STATUS', 'BEFORE', $this, 'handle_send'); 16 } 17 18 public function handle_send(Doku_Event &$event) { 19 if($event->data['ext'] != 'svg') return; 20 if($event->data['status'] >= 400) return; // ACLs and precondition checks 21 22 /** @var helper_plugin_svgpureinsert $hlp */ 23 $hlp = plugin_load('helper', 'svgpureinsert'); 24 list($file) = $hlp->getAdjustedSVG($event->data['media'], $event->data['cache']); 25 26 if($file) { 27 $event->data['file'] = $file; 28 $event->data['status'] = 200; 29 $event->data['statusmessage'] = ''; 30 } 31 } 32}