3 This plugin provides utility and access code for NearLinks, SisterPages
4 and other InterWiki plugins. It depends upon the MetaWikiDatabase file
5 being available (not distributed with ewiki, but cron can download it).
6 You need to have it inside of the EWIKI_VAR directory with a filename
7 of "metadb" (maybe .gz compressed).
11 define("EWIKI_METADB_FN", "metadb");
14 #-- utility code class (static)
18 #-- read-in metadb file
21 $ewiki_metadb = array();
23 if (file_exists($fn = EWIKI_VAR."/".EWIKI_METADB_FN)
24 or (file_exists($fn .= ".gz"))) {
26 $f = gzopen($fn, "r");
27 $line = gzread($f, 1<<24);
30 foreach (explode("\n", $line) as $line) {
31 $real = strtok($line, " ");
33 $where = strtok(" \n\r");
35 $ewiki_metadb[$ci] = array($real, $where);
38 return(count($ewiki_metadb));
42 $ewiki_metadb = array();
45 #-- search for listed page names in InterWiki namespace
46 function FIND($list) {
47 global $ewiki_metadb, $ewiki_config;
50 foreach ($list as $id) {
51 $ci = strtolower($id);
52 if ($uu = $ewiki_metadb[$ci]) {
55 foreach (explode("|", trim($uu[1], "|")) as $iw) {
56 if ($ewiki_config["interwiki"][$iw]) {
57 $r[$id][] = "$iw:$real";