4 This plugin adds a page redirection feature. ewiki instantly switches
5 to another page, when one of the following markup snippets is found:
10 [jump:WardsWiki:WelcomeVisitors]
11 [jump:Google:ErfurtWiki:MarioSalzer]
12 [jump:http://www.heise.de/]
14 One can also use [redirect:] or [location:]. Page switching only occours
15 with the "view" action. Sending a HTTP redirect is the default, but in
16 place redirects are also possible.
17 There exists a loop protection, which limits redirects to 5 (for browsers
18 that cannot detect this themselfes).
22 define("EWIKI_JUMP_HTTP", 1); #-- issue a HTTP redirect, or jump in place
23 define("EWIKI_UP_REDIRECT_COUNT", "redir");
26 $ewiki_t["en"]["REDIRECTION_LOOP"] = "<h2>Redirection loop detected<h2>\nOperation stopped, because we're traped in an infinite redirection loop with page \$id.";
29 $ewiki_plugins["handler"][] = "ewiki_handler_jump";
30 $ewiki_config["interwiki"]["jump"] = "";
31 $ewiki_config["interwiki"]["goto"] = "";
34 function ewiki_handler_jump(&$id, &$data, &$action) {
38 static $redirect_count = 5;
39 $jump_markup = array("jump", "goto", "redirect", "location");
41 #-- we only care about "view" action
42 if ($action != "view") {
47 if (isset($_REQUEST[EWIKI_UP_REDIRECT_COUNT])) {
48 $redirect_count = $_REQUEST[EWIKI_UP_REDIRECT_COUNT];
50 if ($redirect_count-- <= 0) {
51 return(ewiki_t("REDIRECTION_LOOP", array("id"=>$id)));
54 #-- search for [jump:...]
55 if ($links = explode("\n", trim($data["refs"])))
56 foreach ($links as $link) {
58 if (strlen($link) && strpos($link, ":")
59 && in_array(strtolower(strtok($link, ":")), $jump_markup)
60 && ($dest = trim(strtok("\n"))) )
64 if (strpos($dest, "://")) {
69 $url = ewiki_interwiki($dest, $uu, $uu2);
73 if (EWIKI_JUMP_HTTP && EWIKI_HTTP_HEADERS && !headers_sent()) {
77 $url = ewiki_script("", $dest,
78 array(EWIKI_UP_REDIRECT_COUNT=>$redirect_count),
79 0, 0, ewiki_script_url()
81 $url .= defined("SID") ? EWIKI_ADDPARAMDELIM.SID : "";
83 header("Location: $url");
87 #-- show page as usual, what will reveal dest URL
90 # the rendering kernel will just show up the [jump:]!
91 # (without the jump: of course)
93 #-- it's simply about another WikiPage
96 #-- we'll just restart ewiki
99 return(ewiki_page("view/".$id));