1<?php 2/** 3 * Redirect plugin 4 * 5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6 * @author Andreas Gohr <andi@splitbrain.org> 7 */ 8 9// must be run within Dokuwiki 10if(!defined('DOKU_INC')) die(); 11 12/** 13 * Class action_plugin_redirect 14 * 15 * Execute redirects 16 */ 17class action_plugin_redirect extends DokuWiki_Action_Plugin { 18 19 /** 20 * register the eventhandlers 21 * 22 * @param Doku_Event_Handler $controller 23 */ 24 public function register(Doku_Event_Handler $controller) { 25 $controller->register_hook( 26 'DOKUWIKI_STARTED', 27 'AFTER', 28 $this, 29 'handle_start', 30 array() 31 ); 32 } 33 34 /** 35 * handle event 36 * 37 * @param Doku_Event $event 38 * @param array $param 39 */ 40 public function handle_start(Doku_Event $event, $param) { 41 global $ID; 42 global $ACT; 43 global $INPUT; 44 45 if($ACT != 'show') return; 46 if($INPUT->get->str('redirect') == 'no') return; 47 48 /** @var helper_plugin_redirect $hlp */ 49 $hlp = plugin_load('helper', 'redirect'); 50 $url = $hlp->getRedirectURL($ID); 51 if($url) send_redirect($url); 52 } 53 54} 55 56