d5acb54e23f6d8e106855af5f9be9003f4daaefe
[atutor.git] / mods / wiki / plugins / mpi / mpi_fallback.php
1 <?php
2
3 /*
4    <?plugin FallBack to="MetaWiki" ?>
5
6    will make all locally not-existing WikiWords on the current page link
7    to the according pages on the given Wiki (see intermap) - much like
8    the RedirectLinks plugin
9 */
10
11
12 $ewiki_plugins["mpi"]["fallback"] = "ewiki_mpi_fallback";
13
14
15 function ewiki_mpi_fallback($action, $args, &$s, &$iii) {
16    global $ewiki_config, $ewiki_plugins;
17    if (($to = $args["to"]) || ($to = $args[0])) {
18       $ewiki_config["links_fallback_iw"] = ewiki_array($ewiki_config["interwiki"], $to);
19       $ewiki_plugins["format_prepare_linking"][] = "ewiki_fallback_iw";
20    }
21 }
22
23 function ewiki_fallback_iw(&$src) {
24    global $ewiki_config, $ewiki_links;
25    foreach ($ewiki_links as $i=>$v) {
26       if (!strpos($v, "://") && !$v) {
27          $ewiki_links[$i] = $ewiki_config["links_fallback_iw"] . urlencode($i);
28       }
29    }
30 }
31
32 ?>