- // get the list of available plugins
- $available = array();
- if (!$barrel) {
-
- $plugfiles = System::find($this->plugdir.' -type f -name *.php');
- foreach ($plugfiles as $file) {
- $name = basename($file);
- $name = substr($name, 0, -4);
- array_push($available, $name);
- }
-
- } else {
-
- $sql = "select plugin from diogenes_plugin where page=0 AND barrel=''";
- $res = $this->dbh->query($sql);
- while (list($plugin) = mysql_fetch_row($res))
+ $defcache = array();
+ // fill initial values
+ foreach ($allplugins as $plugin)
+ {
+ $plug_h = $this->load($plugin);
+ $defcache[$plugin] = $plug_h->toArray();
+ }
+
+ // get DB values
+ $dbcache = array();
+
+ $sql_limit = $barrel ? " where barrel='{$barrel}' or barrel=''" : "";
+ $sql = "select barrel, page, plugin, status, pos, params from diogenes_plugin" . $sql_limit;
+ $res = $this->dbh->query($sql);
+ while($row = mysql_fetch_row($res))
+ {
+ $c_barrel = array_shift($row);
+ $c_page = array_shift($row);
+ $plugin = array_shift($row);
+ $plugentry = array(
+ 'status' => $row[0],
+ 'pos' => $row[1],
+ 'params' => ($row[2] ? var_decode_bin($row[2]) : array())
+ );
+ $plug_h = $this->load($plugin, $plugentry);
+ //echo "Got params from DB for '$plugin', barrel '$c_barrel', page '$c_page' : ".$row[2]."<br/>";
+ $dbcache[$c_barrel][$c_page][$plugin] = $plug_h->toArray();
+ }
+ mysql_free_result($res);
+
+ // build the input tree
+ $globals_node = new Diogenes_Tree_Node($dbcache[''][0], 'globals defaults');
+ $sql_limit = $barrel ? " where alias='{$barrel}'" : " where alias!=''";
+ $res = $this->dbh->query("select alias from diogenes_site" . $sql_limit);
+ while(list($c_barrel) = mysql_fetch_row($res))
+ {
+ $barrel_node = new Diogenes_Tree_Node($dbcache[$c_barrel][0], "barrel '$c_barrel' defaults");
+ $res2 = $this->dbh->query("select PID from {$c_barrel}_page");
+ while(list($page) = mysql_fetch_row($res2))