4 This plugin encapsulates the database layer to fragment your database
5 into several pieces. All pages from then will be created in separate
6 namespaces. The global '$subwiki' variable makes the internal pagename
7 prefix and must be set by yoursite.php (the layout wrapper).
9 The initial pages are created as usual, but then exist multiple times
10 in the database ("WikiOne:EditThisPage" and "WikiTwo:EditThisPage").
11 You should preferrably use the colon as separator, as it perfectly
12 matches the InterWiki syntax; define the interwiki monikers and
13 wrappers at different URLs correctly to get a closed system.
16 define("SUBWIKI_SEPARATOR", ":");
19 $ewiki_plugins["init"][] = "ewiki_database_subwiki_init";
20 # initialization timing is difficult here, this breaks binary upload support
23 function ewiki_database_subwiki_init()
25 global $ewiki_plugins, $subwiki, $ewiki_db;
27 #-- only engage wrapper if subwiki filtering requested
29 $ewiki_db = & new ewiki_database_subwiki($ewiki_db);
35 class ewiki_database_subwiki {
38 var $dot = SUBWIKI_SEPARATOR;
40 function ewiki_database_subwiki(&$backend) {
41 $this->db = & $backend;
45 function GET($id, $version=false) {
47 $id = $subwiki . $this->dot . $id;
48 $r = $this->db->GET($id, $version);
50 $r["id"] = substr($r["id"], strlen($subwiki) + 1);
57 $id = $GLOBALS["subwiki"] . $this->dot . $id;
58 return $this->db->HIT($id);
62 function DELETE($id, $version=false) {
63 $id = $GLOBALS["subwiki"] . $this->dot . $id;
64 return $this->db->DELETE($id, $version);
68 function WRITE($hash, $overburn=0) {
69 $hash["id"] = $GLOBALS["subwiki"] . $this->dot . $hash["id"];
70 return $this->db->WRITE($hash, $overburn);
79 function FIND($list) {
82 $n = strlen($subwiki);
83 foreach ($list as $i=>$s) {
84 $list[$i] = $subwiki . $dot . $s;
86 $e = $this->db->FIND($list);
88 foreach ($e as $s=>$x) {
89 $r[substr($s, $n+1)] = $x;
93 return $this->db->FIND($list);
97 function SEARCH($field, $content, $ci=1, $regex=0, $mask=0, $filter=0) {
99 $r = $dbf($func, $args, $f1, $f2);
100 foreach ($r->entries as $i=>$d) {
101 if (is_array($d) && (0==strncmp($d["id"], $subwiki, $n))) {
102 $r->entries[$i]["id"] = substr($d["id"], $n+1);
104 elseif (is_string($d) && (0==strncmp($d, $subwiki, $n))) {
105 $r->entries[$i] = substr($d, $n+1);
113 function GETALL($fields, $mask=0, $filter=0) {