* or * at the VERY FIRST LINE in the content! Otherwise it will be ignored. * Author: Reini Urban * */ 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(_("href=%s parameter missing"), 'href')); // FIXME: unmunged url hack if ($href) $url = preg_replace('/href=(.*)\Z/','$1',$argstr); else { $url = $request->getURLtoSelf(array_merge(array('pagename' => $page), $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: ?>