25f8990111b5a14ff316b3f168585c72bbeeccf4
[atutor.git] / mods / wiki / plugins / interwiki / neighbor.php
1 <?php
2 /*
3    Adds additional links behind any page that also exists on foreign
4    Wikis. The links could also be icons, but this wasn't implemented
5    here.
6 */
7
8
9 $ewiki_plugins["link_final"][] = "ewiki_neighbor_links";
10
11 function ewiki_neighbor_links(&$str, &$type, &$href, &$title) {
12
13    global $ewiki_metadb;
14    if (!isset($ewiki_metadb)) {
15       ewiki_metadb::LOAD();
16    }
17    if (!$ewiki_metadb) {
18       return;
19    }
20    
21    #-- check for alternate universes
22    if ($alt = $ewiki_metadb[strtolower($href)]) {
23
24       $inj = array();
25       $real = $alt[0];
26       foreach ($alt[1] as $iw) {
27          $url = ewiki_interwiki("$iw:$real");
28          $inj[] = "<a href=\"$url\">$iw:</a>";
29       }
30       
31       $str .= " (" . implode(", ", $inj). ")";
32    }
33    
34 }
35
36
37 ?>