changed git call from https to git readonly
[atutor.git] / mods / wiki / plugins / db / ext_multi.php
1 <?php
2
3 /*
4    Using this extension you get access to the data from multiple backends
5    (the requests will be dispatched and query results merged from
6    individual database implementations). It is HIGHLY EXPERIMENTAL and
7    it's typically safer to simply merge all page data into one database
8    backend/implementation instead.
9    
10    You should set this up by hand as follows, because order is important:
11    <!php
12      include("plugins/db/any.php");
13      include("plugins/db/dzf2.php");
14      include("plugins/db/ext_multi.php");
15      #-- create
16      $ewiki_db = & new ewiki_database_multi(false);
17      #-- register databases
18      $ewiki_db->all[] = & new ewiki_database_anydb();
19      $ewiki_db->all[] = & new ewiki_database_dzf2();
20    !>
21    
22    If you only load the plugins, the order may not be preserved, so that
23    new page entries go to the wrong backend (typically the first was the
24    active/main database).
25 #this should be configureable!
26    
27    If you also want subwiki support, then you should load that plugin
28    after _this_ one.
29 #both features could be merged
30
31 */
32
33 define("EWIKI_MULTIDB_GUESS", 0);  // which database to use for WRITE calls, if disabled this will always fallback to the first backend
34
35
36 #-- registration
37 $ewiki_plugins["database"][0] = "ewiki_database_multi";
38
39
40 #-- backend wrapper
41 class ewiki_database_multi {
42
43    var $all = array();
44
45    function ewiki_database_multi($auto=true) {
46       if ($auto) {
47          foreach (get_declared_classes() as $classname) {
48             if ((strpos($name, "ewiki_database_") === 0) && !strpos($name, "_multi")) {
49                $this->all = & new $classname;
50       }  }  }
51    }
52
53
54    function GET($id, $version=false) {
55       for ($i=0; $i<count($this->all); $i++) {
56          $r = $this->all[$i]->GET($id, $version);
57          if ($r) {
58             $r["db"] = $i;
59             return $r;
60          }
61       }
62    }
63
64
65    function WRITE($hash, $overwrite=0) {
66       $i = $hash["db"];
67       if (!$i) {
68          $i = 0;
69       }
70       return $this->all[$i]->WRITE($hash, $overwrite);
71    }
72
73
74    function HIT($id) {
75    }
76
77
78    function FIND($list) {
79    }
80
81
82    function GETALL($fields, $mask=0, $filter=0) {
83    }
84
85
86    function SEARCH($field, $content, $ci="i", $regex=0, $mask=0, $filter=0) {
87    }
88
89
90    function DELETE($id, $version) {
91    }
92
93
94    function INIT() {
95       for ($i=0; $i<count($this->all); $i++) {
96          $this->all[$i]->INIT();
97       }
98    }
99    
100    
101    function WHICH($id) {
102       
103    }
104
105
106 } // end of class
107
108
109 ?>