X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2FPlugins.php;h=120e22c9376628f8ad23ed6be44cbd26952f1ed8;hb=ff680e8badbf51b8ebf5cad8e88f0e002f5c30d5;hp=c2f4423b2a0941ad5ffddfc088185317427f0572;hpb=56aefc1ef7ef2d90499b174648625baa6ccb30b1;p=diogenes.git diff --git a/include/Plugins.php b/include/Plugins.php index c2f4423..120e22c 100644 --- a/include/Plugins.php +++ b/include/Plugins.php @@ -61,6 +61,7 @@ class Diogenes_Plugins return $cachefile; } + /** Return the cache entry for specified plugin * * @param $cache @@ -75,27 +76,6 @@ class Diogenes_Plugins } - /** Return the cache entry for a plugin at a specified position - * - * @param $cache - * @param $barrel - * @param $page - * @param $pos - */ - function cacheGetAtPos($cache, $barrel, $page, $pos) - { - $p_node = $this->cacheGetPageNode($cache, $barrel, $page); - foreach ($p_node->data as $plugname => $plugentry) - { - if ($plugentry['pos'] == $pos) - { - $plugentry['plugin'] = $plugname; - return $plugentry; - } - } - } - - /** Return the cache entry for specified plugin * * @param $cache @@ -118,12 +98,21 @@ class Diogenes_Plugins * * @param $cache * @param $barrel - * @param $page + * @param $page */ - function cachedActive($cache, $barrel, $page) + function cacheGetActive($cache, $barrel, $page) { $p_node = $this->cacheGetPageNode($cache, $barrel, $page); $plugins = array(); + foreach ($p_node->data as $plugname => $plugentry) + { + //echo "cacheGetActive : examining $plugname (status {$plugentry['status']})
\n"; + if ($plugentry['status'] & PLUG_ACTIVE) + { + //echo "cacheGetActive : adding $plugname
\n"; + $plugins[$plugname] = $plugentry; + } + } return $plugins; } @@ -135,19 +124,10 @@ class Diogenes_Plugins * @param $barrel * @param $page */ - function cachedAvailable($cache, $barrel, $page) + function cacheGetVisible($cache, $barrel, $page) { $p_node = $this->cacheGetPageNode($cache, $barrel, $page); - //echo "
".var_encode_text($p_node)."
"; - foreach ($p_node->data as $plugname => $plugentry) - { - $plugfile = $this->plugdir."/".$plugname.".php"; - if (file_exists($plugfile) and (!$barrel || ($plugentry['status'] != PLUG_DISABLED))) - { - $available[$plugname] = $plugentry; - } - } - return $available; + return $p_node->data; } @@ -180,20 +160,19 @@ class Diogenes_Plugins { //echo "Processing plugin '$plugin' for <{$node->name}>
\n"; $outval = ''; - if ($parentval['status'] != PLUG_DISABLED) + if (($parentval['status'] & PLUG_ACTIVE) || !($parentval['status'] & PLUG_LOCK)) { - //echo "* plugin available/enabled at parent level
\n"; + //echo "* plugin '$plugin' not locked off parent level
\n"; $outval = $parentval; - if (is_array($node->data[$plugin])) + if ((is_array($node->data[$plugin])) && ($node->data[$plugin]['status'] & PLUG_SET)) { //echo "** plugin set at current level
\n"; - $outval['pos'] = $node->data[$plugin]['pos']; $outval['params'] = $node->data[$plugin]['params']; - if ($parentval['status'] == PLUG_AVAILABLE) { + if (!($parentval['status'] & PLUG_LOCK)) { //echo "*** plugin status set to DB-specified value
\n"; $outval['status'] = $node->data[$plugin]['status']; } else { - //echo "*** plugin forced on at parent level
\n"; + $outval['status'] = $parentval['status']; } } else { //echo "** plugin unset at current level
\n"; @@ -249,7 +228,7 @@ class Diogenes_Plugins $dbcache = array(); $sql_limit = $barrel ? " where barrel='{$barrel}' or barrel=''" : ""; - $sql = "select barrel, page, plugin, status, pos, params from diogenes_plugin" . $sql_limit; + $sql = "select barrel, page, plugin, status, params from diogenes_plugin" . $sql_limit; $res = $this->dbh->query($sql); while($row = mysql_fetch_row($res)) { @@ -258,8 +237,7 @@ class Diogenes_Plugins $plugin = array_shift($row); $plugentry = array( 'status' => $row[0], - 'pos' => $row[1], - 'params' => ($row[2] ? var_decode_bin($row[2]) : array()) + 'params' => ($row[1] ? var_decode_bin($row[1]) : array()) ); $plug_h = $this->load($plugin, $plugentry); //echo "Got params from DB for '$plugin', barrel '$c_barrel', page '$c_page' : ".$row[2]."
"; @@ -295,12 +273,14 @@ class Diogenes_Plugins if ($barrel) { $dump_node = $globals_out_node->getChild($barrel); $dump_node->writeFile($this->cachefile($barrel)); + $dump_node->writeFile($this->cachefile($barrel).".txt", NODE_DUMP_TEXT); } else { $globals_out_node->writeFile($this->cachefile($barrel), NODE_DUMP_NOCHILDREN); $globals_out_node->writeFile($this->cachefile($barrel).".txt", NODE_DUMP_NOCHILDREN | NODE_DUMP_TEXT); foreach ($globals_out_node->children as $c_barrel => $dump_node) { $dump_node->writeFile($this->cachefile($c_barrel)); + $dump_node->writeFile($this->cachefile($c_barrel).".txt", NODE_DUMP_TEXT); } } } @@ -328,9 +308,6 @@ class Diogenes_Plugins if (is_array($plugentry)) $plug_h->fromArray($plugentry); - $plug_log = $plug_h->toArray(); - //$pluglog['name'] = 'foo'; - array_push($this->log, $plug_log); return $plug_h; } @@ -360,9 +337,7 @@ class Diogenes_Plugins { $trclass = $odd ? ' class="odd"' : ''; $out .= "{$val['name']} v{$val['version']}\n"; - if (isset($val['pos'])) { - $out .= "position{$val['pos']}\n"; - } + $out .= "status{$val['status']}\n"; $out .= "type{$val['type']}\n"; $out .= "description{$val['description']}\n"; if (!empty($val['params'])) {