- // 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))
- {
- $page_node = new Diogenes_Tree_Node($dbcache[$c_barrel][$page], "barrel '$c_barrel' page $page");
- $barrel_node->setChild($page, $page_node);
- }
- mysql_free_result($res2);
- $globals_node->setChild($c_barrel, $barrel_node);
- }
- mysql_free_result($res);
-
- // compile the cache
- $top_out_node = new Diogenes_Tree_Node($defcache, 'plugin defaults');
- $this->compileNode($globals_node, $top_out_node, 'globals');
- $globals_out_node = $top_out_node->getChild('globals');
- //echo "<pre>" . $top_out_node->dump() . "</pre><hr/>";
-
- // produce dump(s)
- if ($barrel) {
- $dump_node = $globals_out_node->getChild($barrel);
- $dump_node->writeFile($this->cachefile($barrel));
+ // 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);
+ }
+