and
parts (if any)
if (($l = strpos(strtolower($r), "", $l+1) + 1;
$w = $w - $l;
$r = substr($r, $l, $w);
}
#-- return body (means successful handled)
return($r);
}
#-- return page
## $ewiki_plugins["handler"][] = "ewiki_handler_spages";
function ewiki_handler_spages($id, $data, $action) {
global $ewiki_spages;
#-- compare requested page $id with spages` $id values
$i0 = strtolower($id);
foreach ($ewiki_spages as $i1 => $fn) {
if (strtolower($i1)==$i0) {
return(ewiki_spage($id));
}
}
}
#-- init
function ewiki_init_spages($dirs, $idprep="") {
global $ewiki_spages, $ewiki_plugins;
if (!is_array($dirs)) {
$dirs = array($dirs);
}
#-- go through list of directories
foreach ($dirs as $dir) {
if (empty($dir)) {
continue;
}
#-- read in one directory
$dh = opendir($dir);
while (false !== ($fn = readdir($dh))) {
#-- skip over . and ..
if ($fn[0] == ".") { continue; }
#-- be recursive
if ($fn && is_dir("$dir/$fn")) {
if ($fn != trim($fn, ".")) {
$fnadd = trim($fn, ".") . ".";
}
else {
$fnadd = "$fn/";
}
ewiki_init_spages(array("$dir/$fn"), "$idprep$fnadd");
continue;
}
#-- strip filename extensions
$id = str_replace(
array(".html", ".htm", ".php", ".txt", ".wiki", ".src"),
"",
basename($fn)
);
#-- register spage file and as page plugin (one for every spage)
$ewiki_spages[strtolower("$idprep$id")] = "$dir/$fn";
$ewiki_plugins["page"]["$idprep$id"] = "ewiki_spage";
}
closedir($dh);
}
}
?>