* or * at the VERY FIRST LINE in the content! Otherwise it will be ignored. * Author: Reini Urban * * BUGS/COMMENTS: * * Actually, it seems that this plugin can be invoked from anywhere on a page. * (Not just the first line.) * * This plugin could probably result in a lot of confusion, especially when * redirecting to external sites. (Perhaps it can even be used for dastardly * purposes?) Maybe it should be disabled by default. * * It would be nice, when redirecting to another wiki page, to (as * UseModWiki does) add a note to the top of the target page saying * something like "(Redirected from SomeRedirectingPage)". */ class WikiPlugin_RedirectTo extends WikiPlugin { function getName() { return _("RedirectTo"); } function getDescription() { return _("Redirects to another url or page."); } function getDefaultArguments() { return array( 'href' => '', // 'type' => 'Temp' // or 'Permanent' // s far ignored 'page' => false, 'args' => false, // pass more args to the page. TestMe! ); } function run($dbi, $argstr, $request) { $args = ($this->getArgs($argstr, $request)); $href = $args['href']; $page = $args['page']; if (!$href and !$page) return $this->error(sprintf(_("%s or %s parameter missing"), 'href', 'page')); if ($href) { /* * I don't think this hack is needed. * Just use quotes on the href argument value, like: * * */ // // FIXME: unmunged url hack // $url = preg_replace('/href=(.*)\Z/','$1',$argstr); $url = $href; // // FIXME: may want some checking on href to avoid malicious // uses of the plugin? } else { $url = $request->getURLtoSelf(array_merge(array('pagename' => $page), SplitQueryArgs($args['args']))); } if ($page == $request->getArg('pagename')) { return $this->error(sprintf(_("Recursive redirect to self: '%s'"), $url)); } return $request->redirect($url); } }; // For emacs users // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil // End: ?>