10a7415d3SAndreas Gohr<?php 20a7415d3SAndreas Gohr/** 3af1904f9SAndreas Gohr * Translation Plugin: Simple multilanguage plugin 40a7415d3SAndreas Gohr * 50a7415d3SAndreas Gohr * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 60a7415d3SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 70a7415d3SAndreas Gohr * @author Guy Brand <gb@isis.u-strasbg.fr> 80a7415d3SAndreas Gohr */ 90a7415d3SAndreas Gohr 100a7415d3SAndreas Gohr// must be run within Dokuwiki 110a7415d3SAndreas Gohrif(!defined('DOKU_INC')) die(); 120a7415d3SAndreas Gohr 130a7415d3SAndreas Gohrif(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN', DOKU_INC . 'lib/plugins/'); 140a7415d3SAndreas Gohrrequire_once(DOKU_PLUGIN . 'action.php'); 150a7415d3SAndreas Gohr 16*25fca7bdSGerry Weißbachclass action_plugin_autotranslation extends DokuWiki_Action_Plugin { 170a7415d3SAndreas Gohr 180a7415d3SAndreas Gohr /** 19c54240efSGuillaume Turri * For the helper plugin 20*25fca7bdSGerry Weißbach * @var helper_plugin_autotranslation 21af1904f9SAndreas Gohr */ 22c54240efSGuillaume Turri var $helper = null; 23af1904f9SAndreas Gohr 24ec6cbde6SDominik Eckelmann var $locale; 25ec6cbde6SDominik Eckelmann 26af1904f9SAndreas Gohr /** 27af1904f9SAndreas Gohr * Constructor. Load helper plugin 28af1904f9SAndreas Gohr */ 29488e4722SAndreas Gohr function __construct() { 30*25fca7bdSGerry Weißbach $this->helper =& plugin_load('helper', 'autotranslation'); 31af1904f9SAndreas Gohr } 32af1904f9SAndreas Gohr 33af1904f9SAndreas Gohr /** 34c54240efSGuillaume Turri * Register the events 350a7415d3SAndreas Gohr */ 3643ffc77dSGerry Weißbach function register(Doku_Event_Handler $controller) { 37ec6cbde6SDominik Eckelmann $scriptName = basename($_SERVER['PHP_SELF']); 38e5e7e41dSAndreas Gohr 39c54240efSGuillaume Turri // should the lang be applied to UI? 4034591120SDominik Eckelmann if($this->getConf('translateui')) { 41ec6cbde6SDominik Eckelmann switch($scriptName) { 42ec6cbde6SDominik Eckelmann case 'js.php': 43ec6cbde6SDominik Eckelmann $controller->register_hook('INIT_LANG_LOAD', 'BEFORE', $this, 'translation_js'); 44db7c51b4SAndreas Gohr $controller->register_hook('JS_CACHE_USE', 'BEFORE', $this, 'translation_jscache'); 45ec6cbde6SDominik Eckelmann break; 46ec6cbde6SDominik Eckelmann 47ec6cbde6SDominik Eckelmann case 'ajax.php': 48ec6cbde6SDominik Eckelmann $controller->register_hook('INIT_LANG_LOAD', 'BEFORE', $this, 'translate_media_manager'); 49ec6cbde6SDominik Eckelmann break; 50ec6cbde6SDominik Eckelmann 51ec6cbde6SDominik Eckelmann case 'mediamanager.php': 52ec6cbde6SDominik Eckelmann $controller->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE', $this, 'setJsCacheKey'); 53ec6cbde6SDominik Eckelmann break; 54ec6cbde6SDominik Eckelmann 55ec6cbde6SDominik Eckelmann default: 56ec6cbde6SDominik Eckelmann $controller->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE', $this, 'setJsCacheKey'); 57ec6cbde6SDominik Eckelmann } 580a7415d3SAndreas Gohr } 5934591120SDominik Eckelmann 6034591120SDominik Eckelmann if($scriptName !== 'js.php' && $scriptName !== 'ajax.php') { 6134591120SDominik Eckelmann $controller->register_hook('DOKUWIKI_STARTED', 'BEFORE', $this, 'translation_hook'); 6234591120SDominik Eckelmann $controller->register_hook('MEDIAMANAGER_STARTED', 'BEFORE', $this, 'translation_hook'); 6334591120SDominik Eckelmann } 6434591120SDominik Eckelmann 65af1904f9SAndreas Gohr $controller->register_hook('SEARCH_QUERY_PAGELOOKUP', 'AFTER', $this, 'translation_search'); 66cabcc95dSDominik Eckelmann $controller->register_hook('COMMON_PAGETPL_LOAD', 'AFTER', $this, 'page_template_replacement'); 67cabcc95dSDominik Eckelmann } 68cabcc95dSDominik Eckelmann 69bbe70520SAndreas Gohr /** 70bbe70520SAndreas Gohr * Hook Callback. Make current language available as page template placeholder and handle 71bbe70520SAndreas Gohr * original language copying 72bbe70520SAndreas Gohr * 73bbe70520SAndreas Gohr * @param $event 74bbe70520SAndreas Gohr * @param $args 75bbe70520SAndreas Gohr */ 76cabcc95dSDominik Eckelmann function page_template_replacement(&$event, $args) { 77cabcc95dSDominik Eckelmann global $ID; 78bbe70520SAndreas Gohr 79bbe70520SAndreas Gohr // load orginal content as template? 80c54240efSGuillaume Turri if($this->getConf('copytrans') && $this->helper->istranslatable($ID, false)) { 81bbe70520SAndreas Gohr // look for existing translations 82c54240efSGuillaume Turri $translations = $this->helper->getAvailableTranslations($ID); 83bbe70520SAndreas Gohr if($translations) { 84bbe70520SAndreas Gohr // find original language (might've been provided via parameter or use first translation) 85bbe70520SAndreas Gohr $orig = (string) $_REQUEST['fromlang']; 86bbe70520SAndreas Gohr if(!$orig) $orig = array_shift(array_keys($translations)); 87bbe70520SAndreas Gohr 88bbe70520SAndreas Gohr // load file 89bbe70520SAndreas Gohr $origfile = $translations[$orig]; 90bbe70520SAndreas Gohr $event->data['tpl'] = io_readFile(wikiFN($origfile)); 91bbe70520SAndreas Gohr 92bbe70520SAndreas Gohr // prefix with warning 93bbe70520SAndreas Gohr $warn = io_readFile($this->localFN('totranslate')); 94bbe70520SAndreas Gohr if($warn) $warn .= "\n\n"; 95bbe70520SAndreas Gohr $event->data['tpl'] = $warn . $event->data['tpl']; 96bbe70520SAndreas Gohr 97bbe70520SAndreas Gohr // show user a choice of translations if any 98bbe70520SAndreas Gohr if(count($translations) > 1) { 99bbe70520SAndreas Gohr $links = array(); 100bbe70520SAndreas Gohr foreach($translations as $t => $l) { 101c54240efSGuillaume Turri $links[] = '<a href="' . wl($ID, array('do' => 'edit', 'fromlang' => $t)) . '">' . $this->helper->getLocalName($t) . '</a>'; 102bbe70520SAndreas Gohr } 103bbe70520SAndreas Gohr 1045fd0d0d1SAndreas Gohr msg( 1055fd0d0d1SAndreas Gohr sprintf( 106bbe70520SAndreas Gohr $this->getLang('transloaded'), 107c54240efSGuillaume Turri $this->helper->getLocalName($orig), 108bbe70520SAndreas Gohr join(', ', $links) 109bbe70520SAndreas Gohr ) 110bbe70520SAndreas Gohr ); 111bbe70520SAndreas Gohr } 112bbe70520SAndreas Gohr 113bbe70520SAndreas Gohr } 114bbe70520SAndreas Gohr } 115bbe70520SAndreas Gohr 116bbe70520SAndreas Gohr // apply placeholders 117c54240efSGuillaume Turri $event->data['tpl'] = str_replace('@LANG@', $this->helper->realLC(''), $event->data['tpl']); 118c54240efSGuillaume Turri $event->data['tpl'] = str_replace('@TRANS@', $this->helper->getLangPart($ID), $event->data['tpl']); 1190a7415d3SAndreas Gohr } 1200a7415d3SAndreas Gohr 121bbe70520SAndreas Gohr /** 122bbe70520SAndreas Gohr * Hook Callback. Load correct translation when loading JavaScript 123bbe70520SAndreas Gohr * 124bbe70520SAndreas Gohr * @param $event 125bbe70520SAndreas Gohr * @param $args 126bbe70520SAndreas Gohr */ 127bbe70520SAndreas Gohr function translation_js(&$event, $args) { 128bbe70520SAndreas Gohr global $conf; 129bbe70520SAndreas Gohr if(!isset($_GET['lang'])) return; 1305e1f71acSGuillaume Turri if(!in_array($_GET['lang'], $this->helper->translations)) return; 131bbe70520SAndreas Gohr $lang = $_GET['lang']; 132bbe70520SAndreas Gohr $event->data = $lang; 133bbe70520SAndreas Gohr $conf['lang'] = $lang; 134bbe70520SAndreas Gohr } 135bbe70520SAndreas Gohr 136bbe70520SAndreas Gohr /** 137bbe70520SAndreas Gohr * Hook Callback. Pass language code to JavaScript dispatcher 138bbe70520SAndreas Gohr * 139bbe70520SAndreas Gohr * @param $event 140bbe70520SAndreas Gohr * @param $args 141bbe70520SAndreas Gohr * @return bool 142bbe70520SAndreas Gohr */ 143ec6cbde6SDominik Eckelmann function setJsCacheKey(&$event, $args) { 144ec6cbde6SDominik Eckelmann if(!isset($this->locale)) return false; 145ec6cbde6SDominik Eckelmann $count = count($event->data['script']); 146ec6cbde6SDominik Eckelmann for($i = 0; $i < $count; $i++) { 14743ffc77dSGerry Weißbach if(!empty($event->data['script'][$i]['src']) && strpos($event->data['script'][$i]['src'], '/lib/exe/js.php') !== false) { 148db7c51b4SAndreas Gohr $event->data['script'][$i]['src'] .= '&lang=' . hsc($this->locale); 149ec6cbde6SDominik Eckelmann } 150ec6cbde6SDominik Eckelmann } 151ec6cbde6SDominik Eckelmann 152ec6cbde6SDominik Eckelmann return false; 153ec6cbde6SDominik Eckelmann } 154ec6cbde6SDominik Eckelmann 155bbe70520SAndreas Gohr /** 156bbe70520SAndreas Gohr * Hook Callback. Make sure the JavaScript is translation dependent 157bbe70520SAndreas Gohr * 158bbe70520SAndreas Gohr * @param $event 159bbe70520SAndreas Gohr * @param $args 160bbe70520SAndreas Gohr */ 161db7c51b4SAndreas Gohr function translation_jscache(&$event, $args) { 162db7c51b4SAndreas Gohr if(!isset($_GET['lang'])) return; 1635e1f71acSGuillaume Turri if(!in_array($_GET['lang'], $this->helper->translations)) return; 164db7c51b4SAndreas Gohr 165db7c51b4SAndreas Gohr $lang = $_GET['lang']; 166db7c51b4SAndreas Gohr // reuse the constructor to reinitialize the cache key 167ba82fb96SAndreas Gohr if(method_exists($event->data, '__construct')) { 168ba82fb96SAndreas Gohr // New PHP 5 style constructor 16900e50232SAndreas Gohr $event->data->__construct( 170db7c51b4SAndreas Gohr $event->data->key . $lang, 171db7c51b4SAndreas Gohr $event->data->ext 172db7c51b4SAndreas Gohr ); 173ba82fb96SAndreas Gohr } else { 174ba82fb96SAndreas Gohr // Old PHP 4 style constructor - deprecated 175ba82fb96SAndreas Gohr $event->data->cache( 176ba82fb96SAndreas Gohr $event->data->key . $lang, 177ba82fb96SAndreas Gohr $event->data->ext 178ba82fb96SAndreas Gohr ); 179ba82fb96SAndreas Gohr } 180ec6cbde6SDominik Eckelmann } 181ec6cbde6SDominik Eckelmann 182bbe70520SAndreas Gohr /** 183bbe70520SAndreas Gohr * Hook Callback. Translate the AJAX loaded media manager 184bbe70520SAndreas Gohr * 185bbe70520SAndreas Gohr * @param $event 186bbe70520SAndreas Gohr * @param $args 187bbe70520SAndreas Gohr */ 188ec6cbde6SDominik Eckelmann function translate_media_manager(&$event, $args) { 189ec6cbde6SDominik Eckelmann global $conf; 190ec6cbde6SDominik Eckelmann if(isset($_REQUEST['ID'])) { 191ec6cbde6SDominik Eckelmann $id = getID(); 192c54240efSGuillaume Turri $lc = $this->helper->getLangPart($id); 193ec6cbde6SDominik Eckelmann } elseif(isset($_SESSION[DOKU_COOKIE]['translationlc'])) { 194ec6cbde6SDominik Eckelmann $lc = $_SESSION[DOKU_COOKIE]['translationlc']; 195ec6cbde6SDominik Eckelmann } else { 196db7c51b4SAndreas Gohr return; 197ec6cbde6SDominik Eckelmann } 198e5e7e41dSAndreas Gohr if(!$lc) return; 199e5e7e41dSAndreas Gohr 200ec6cbde6SDominik Eckelmann $conf['lang'] = $lc; 201ec6cbde6SDominik Eckelmann $event->data = $lc; 202ec6cbde6SDominik Eckelmann } 203ec6cbde6SDominik Eckelmann 2040a7415d3SAndreas Gohr /** 205bbe70520SAndreas Gohr * Hook Callback. Change the UI language in foreign language namespaces 2060a7415d3SAndreas Gohr */ 2070a7415d3SAndreas Gohr function translation_hook(&$event, $args) { 2080a7415d3SAndreas Gohr global $ID; 2090a7415d3SAndreas Gohr global $lang; 2100a7415d3SAndreas Gohr global $conf; 2117053cd66SAndreas Gohr global $ACT; 2127053cd66SAndreas Gohr // redirect away from start page? 2137053cd66SAndreas Gohr if($this->conf['redirectstart'] && $ID == $conf['start'] && $ACT == 'show') { 214c54240efSGuillaume Turri $lc = $this->helper->getBrowserLang(); 2157053cd66SAndreas Gohr if(!$lc) $lc = $conf['lang']; 216a4491becSGerry Weißbach $this->_redirect($lc.':'.$conf['start']); 2177053cd66SAndreas Gohr exit; 2187053cd66SAndreas Gohr } 2190a7415d3SAndreas Gohr 220a4491becSGerry Weißbach // Check if we can redirect 221a4491becSGerry Weißbach if($this->getConf('redirectlocalized')){ 222a4491becSGerry Weißbach $this->translation_redirect_localized(); 223a4491becSGerry Weißbach } 224a4491becSGerry Weißbach 2250a7415d3SAndreas Gohr // check if we are in a foreign language namespace 226c54240efSGuillaume Turri $lc = $this->helper->getLangPart($ID); 227a526927fSAndreas Gohr 228f2279247SAndreas Gohr // store language in session (for page related views only) 229f2279247SAndreas Gohr if(in_array($ACT, array('show', 'recent', 'diff', 'edit', 'preview', 'source', 'subscribe'))) { 230f2279247SAndreas Gohr $_SESSION[DOKU_COOKIE]['translationlc'] = $lc; 231f2279247SAndreas Gohr } 232a526927fSAndreas Gohr if(!$lc) $lc = $_SESSION[DOKU_COOKIE]['translationlc']; 233a526927fSAndreas Gohr if(!$lc) return; 23434591120SDominik Eckelmann $this->locale = $lc; 23534591120SDominik Eckelmann 23634591120SDominik Eckelmann if(!$this->getConf('translateui')) { 23734591120SDominik Eckelmann return true; 23834591120SDominik Eckelmann } 2390a7415d3SAndreas Gohr 2400a7415d3SAndreas Gohr if(file_exists(DOKU_INC . 'inc/lang/' . $lc . '/lang.php')) { 2410a7415d3SAndreas Gohr require(DOKU_INC . 'inc/lang/' . $lc . '/lang.php'); 2420a7415d3SAndreas Gohr } 2430a7415d3SAndreas Gohr $conf['lang_before_translation'] = $conf['lang']; //store for later access in syntax plugin 2440a7415d3SAndreas Gohr $conf['lang'] = $lc; 2450a7415d3SAndreas Gohr 2460a7415d3SAndreas Gohr return true; 2470a7415d3SAndreas Gohr } 248af1904f9SAndreas Gohr 249af1904f9SAndreas Gohr /** 250bbe70520SAndreas Gohr * Hook Callback. Resort page match results so that results are ordered by translation, having the 251af1904f9SAndreas Gohr * default language first 252af1904f9SAndreas Gohr */ 253af1904f9SAndreas Gohr function translation_search(&$event, $args) { 254d75e50bcSAndreas Gohr 255d75e50bcSAndreas Gohr if($event->data['has_titles']) { 256d75e50bcSAndreas Gohr // sort into translation slots 257d75e50bcSAndreas Gohr $res = array(); 258d75e50bcSAndreas Gohr foreach($event->result as $r => $t) { 259c54240efSGuillaume Turri $tr = $this->helper->getLangPart($r); 260d75e50bcSAndreas Gohr if(!is_array($res["x$tr"])) $res["x$tr"] = array(); 261d75e50bcSAndreas Gohr $res["x$tr"][] = array($r, $t); 262d75e50bcSAndreas Gohr } 263d75e50bcSAndreas Gohr // sort by translations 264d75e50bcSAndreas Gohr ksort($res); 265d75e50bcSAndreas Gohr // combine 266d75e50bcSAndreas Gohr $event->result = array(); 267d75e50bcSAndreas Gohr foreach($res as $r) { 268d75e50bcSAndreas Gohr foreach($r as $l) { 269d75e50bcSAndreas Gohr $event->result[$l[0]] = $l[1]; 270d75e50bcSAndreas Gohr } 271d75e50bcSAndreas Gohr } 272d75e50bcSAndreas Gohr } else { 273d75e50bcSAndreas Gohr # legacy support for old DokuWiki hooks 274d75e50bcSAndreas Gohr 275af1904f9SAndreas Gohr // sort into translation slots 276af1904f9SAndreas Gohr $res = array(); 277af1904f9SAndreas Gohr foreach($event->result as $r) { 278c54240efSGuillaume Turri $tr = $this->helper->getLangPart($r); 279af1904f9SAndreas Gohr if(!is_array($res["x$tr"])) $res["x$tr"] = array(); 280af1904f9SAndreas Gohr $res["x$tr"][] = $r; 281af1904f9SAndreas Gohr } 282af1904f9SAndreas Gohr // sort by translations 283af1904f9SAndreas Gohr ksort($res); 284af1904f9SAndreas Gohr // combine 285af1904f9SAndreas Gohr $event->result = array(); 286af1904f9SAndreas Gohr foreach($res as $r) { 287af1904f9SAndreas Gohr $event->result = array_merge($event->result, $r); 288af1904f9SAndreas Gohr } 289af1904f9SAndreas Gohr } 290d75e50bcSAndreas Gohr } 291af1904f9SAndreas Gohr 292a4491becSGerry Weißbach /** 293a4491becSGerry Weißbach * Redirects to the localized version of the page when showing and browser says so and translation was explicitly requested 294a4491becSGerry Weißbach **/ 295a4491becSGerry Weißbach function translation_redirect_localized() { 296a4491becSGerry Weißbach global $ID; 297a4491becSGerry Weißbach global $conf; 298a4491becSGerry Weißbach global $ACT; 299a4491becSGerry Weißbach 300a4491becSGerry Weißbach // redirect to localized page? 301a4491becSGerry Weißbach if( $ACT != 'show' ) { return; } 302a4491becSGerry Weißbach 303a4491becSGerry Weißbach $override = isset($_REQUEST['tns']); // override enabled - comes from the bottom bar. 30443ffc77dSGerry Weißbach $lang = !empty($conf['lang_before_translation']) ? $conf['lang_before_translation'] : $conf['lang']; // Check for original language 305a4491becSGerry Weißbach 306a4491becSGerry Weißbach // get current page language - if empty then default; 307a4491becSGerry Weißbach $currentSessionLanguage = $_SESSION[DOKU_COOKIE]['translationcur']; 3084e6ef383SGerry Weißbach $pageLang = $this->helper->getLangPart($ID); 309a4491becSGerry Weißbach 310a4491becSGerry Weißbach if ( empty($pageLang) ) { 311a4491becSGerry Weißbach $pageLang = $lang; 312a4491becSGerry Weißbach } 313a4491becSGerry Weißbach 314a4491becSGerry Weißbach // If both match, we're fine. 315a4491becSGerry Weißbach if ( $currentSessionLanguage == $pageLang ) { 316a4491becSGerry Weißbach return; 317a4491becSGerry Weißbach } 318a4491becSGerry Weißbach 319a4491becSGerry Weißbach // check current translation 320a4491becSGerry Weißbach if ( empty( $currentSessionLanguage ) && !$override ) { 321a4491becSGerry Weißbach 322a4491becSGerry Weißbach // If not set - we must just have entered - set the browser language 3234e6ef383SGerry Weißbach $currentSessionLanguage = $this->helper->getBrowserLang(); 324a4491becSGerry Weißbach 325a4491becSGerry Weißbach // if no browser Language set, take entered namespace language - empty for default. 326a4491becSGerry Weißbach if ( !$currentSessionLanguage ) { 327a4491becSGerry Weißbach $currentSessionLanguage = $pageLang; 328a4491becSGerry Weißbach } 329a4491becSGerry Weißbach 330a4491becSGerry Weißbach // Set new Language 331a4491becSGerry Weißbach $_SESSION[DOKU_COOKIE]['translationcur'] = $currentSessionLanguage; 332a4491becSGerry Weißbach 333a4491becSGerry Weißbach // Write Language back 334a4491becSGerry Weißbach $pageLang = $currentSessionLanguage; 335a4491becSGerry Weißbach } 336a4491becSGerry Weißbach 337a4491becSGerry Weißbach 338a4491becSGerry Weißbach if ( $override && $pageLang != $currentSessionLanguage ) { 339a4491becSGerry Weißbach // Set new Language 340a4491becSGerry Weißbach $currentSessionLanguage = $pageLang; 341a4491becSGerry Weißbach $_SESSION[DOKU_COOKIE]['translationcur'] = $currentSessionLanguage; 342a4491becSGerry Weißbach } else if ( !$override ) { 343a4491becSGerry Weißbach // Write Language back 344a4491becSGerry Weißbach $pageLang = $currentSessionLanguage; 345a4491becSGerry Weißbach } 346a4491becSGerry Weißbach 347a4491becSGerry Weißbach // If this is the default language, make empty 348a4491becSGerry Weißbach if ( $pageLang == $lang ) { 349a4491becSGerry Weißbach $pageLang = ''; 350a4491becSGerry Weißbach } 351a4491becSGerry Weißbach 352a4491becSGerry Weißbach // Generate new Page ID 3534e6ef383SGerry Weißbach list($newPage,$name) = $this->helper->buildTransID($pageLang,$this->helper->getIDPart($ID)); 354a4491becSGerry Weißbach $newPage = cleanID($newPage); 355a4491becSGerry Weißbach 356a4491becSGerry Weißbach // Check if Page exists 357a4491becSGerry Weißbach if ( $newPage != $ID && page_exists($newPage, '', false) ) { 358a4491becSGerry Weißbach // $newPage redirect 359a4491becSGerry Weißbach 360a4491becSGerry Weißbach if ( auth_quickaclcheck($newPage) < AUTH_READ ) { return; } 361a4491becSGerry Weißbach 362a4491becSGerry Weißbach session_write_close(); 363a4491becSGerry Weißbach $this->_redirect($newPage); 364a4491becSGerry Weißbach } 365a4491becSGerry Weißbach else 366a4491becSGerry Weißbach if ( $override ) { 367a4491becSGerry Weißbach // cleanup redirect 368a4491becSGerry Weißbach session_write_close(); 369a4491becSGerry Weißbach 370a4491becSGerry Weißbach if ( auth_quickaclcheck($newPage) < AUTH_READ ) { return; } 371a4491becSGerry Weißbach 372a4491becSGerry Weißbach $this->_redirect($ID); 373a4491becSGerry Weißbach } 374a4491becSGerry Weißbach 375a4491becSGerry Weißbach // no redirect; 376a4491becSGerry Weißbach } 377a4491becSGerry Weißbach 378a4491becSGerry Weißbach 379a4491becSGerry Weißbach function _redirect($url) 380a4491becSGerry Weißbach { 381a4491becSGerry Weißbach unset($_GET['id']); 382a4491becSGerry Weißbach $more = array(); 383a4491becSGerry Weißbach 384a4491becSGerry Weißbach if ( !empty($_GET) ) { 385a4491becSGerry Weißbach $params = ''; 386a4491becSGerry Weißbach foreach( $_GET as $key => $value ) { 387a4491becSGerry Weißbach // Possible multiple encodings. 388a4491becSGerry Weißbach $more[$key] = $value; 389a4491becSGerry Weißbach } 390a4491becSGerry Weißbach } 391a4491becSGerry Weißbach 392a4491becSGerry Weißbach if ( wl( $url, $more, true, '&') != DOKU_URL . substr($_SERVER['REQUEST_URI'], 1) ) { 393a4491becSGerry Weißbach header('Location: ' . wl( $url, $more, true, '&'), 302); 394a4491becSGerry Weißbach exit; 395a4491becSGerry Weißbach } 396a4491becSGerry Weißbach } 3970a7415d3SAndreas Gohr} 3980a7415d3SAndreas Gohr 399ec6cbde6SDominik Eckelmann//Setup VIM: ex: et ts=4 : 400