$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
$target = isset($_REQUEST['plug_target']) ? $_REQUEST['plug_target'] : '';
- // load all available plugins
- $cachefile = $globals->plugins->cacheFile($this->plug_barrel);
-
// if the tree cache does not exits try to init it
+ $cachefile = $globals->plugins->cacheFile($this->plug_barrel);
if(!file_exists($cachefile))
{
$globals->plugins->compileCache($this->plug_barrel, $page);
}
$cache = $globals->plugins->readCache($cachefile, $this->plug_barrel);
- $available = $globals->plugins->cachedAvailable($cache, $this->plug_barrel, $this->plug_page);
+ $available = $globals->plugins->cachedVisible($cache, $this->plug_barrel, $this->plug_page);
// handle updates
$rebuild_cache = 0;
// rebuild plugin cache
$globals->plugins->compileCache($this->plug_barrel, $page);
$cache = $globals->plugins->readCache($cachefile, $this->plug_barrel);
- $available = $globals->plugins->cachedAvailable($cache, $this->plug_barrel, $this->plug_page);
+ $available = $globals->plugins->cachedVisible($cache, $this->plug_barrel, $this->plug_page);
}
// get dump of plugins to fill out form
$page->assign('plug_barrel', $this->plug_barrel);
$page->assign('plug_page', $this->plug_page);
- $plugs = array();
+ $ro_plugs = array();
+ $rw_plugs_on = array();
+ $rw_plugs_off = array();
// start by adding the active plugins
foreach ($available as $plugname => $plugcache)
{
- if ($plugcache['status'] == PLUG_ACTIVE)
+ $plugentry = $plugcache;
+ $plugentry['icon'] = $globals->icons->get_action_icon('plugins');
+ $type = $plugentry['type'];
+
+ if ($plugentry['status'] & PLUG_LOCK)
{
- $plugentry = $plugcache;
- $plugentry['icon'] = $globals->icons->get_action_icon('plugins');
- $type = $plugentry['type'];
- if (!empty($plugs[$type])) {
- $plugentry['move_up'] = 1;
- $last = count($plugs[$type]) - 1;
- $plugs[$type][$last]['move_down'] = 1;
- } else {
- $plugs[$type] = array();
- }
- array_push($plugs[$type], $plugentry);
+ $o_plugs =& $ro_plugs;
+ $plugentry['readonly'] = 1;
+ } else {
+ if ($plugentry['status'] & PLUG_ACTIVE)
+ $o_plugs =& $rw_plugs_on;
+ else
+ $o_plugs =& $rw_plugs_off;
}
- }
- // next we add the inactive plugins
- if (!$this->readonly)
- {
- foreach ($available as $plugname => $plugcache)
- {
- if ( ($plugcache['status'] == PLUG_AVAILABLE) ||
- (($plugcache['status'] == PLUG_DISABLED) && !$this->plug_barrel) )
- {
- $plugentry = $plugcache;
- $plugentry['icon'] = $globals->icons->get_action_icon('plugins');
- $type = $plugentry['type'];
- if (empty($plugs[$type])) {
- $plugs[$type] = array();
- }
- array_push($plugs[$type], $plugentry);
- }
+ if (!empty($o_plugs[$type])) {
+ $plugentry['move_up'] = 1;
+ $last = count($o_plugs[$type]) - 1;
+ $o_plugs[$type][$last]['move_down'] = 1;
+ } else {
+ $o_plugs[$type] = array();
}
+ array_push($o_plugs[$type], $plugentry);
}
+ // next we add the inactive plugins
+ $plugs = array_merge_recursive($rw_plugs_on, $rw_plugs_off);
$page->assign('plugins', $plugs);
// values
$page->assign('show_params', $this->show_params);
$page->assign('readonly',$this->readonly);
- $statusvals = array(0 => 'disabled', '1' => 'available', 2 => 'enabled');
+ $statusvals = array(0 => 'off', 1 => 'on', 2 => 'off (lock)', 3 => 'on (lock)');
$page->assign('statusvals', $statusvals);
// translations
*
* @param $cache
* @param $barrel
- * @param $page
+ * @param $page
*/
function cachedActive($cache, $barrel, $page)
{
$p_node = $this->cacheGetPageNode($cache, $barrel, $page);
$plugins = array();
+ foreach ($p_node->data as $plugname => $plugentry)
+ {
+ //echo "cachedEditable : examining $plugname (status {$plugentry['status']})<br/>\n";
+ if ($plugentry['status'] & PLUG_ACTIVE)
+ {
+ //echo "cachedActive : adding $plugname<br/>\n";
+ $plugins[$plugname] = $plugentry;
+ }
+ }
return $plugins;
}
* @param $barrel
* @param $page
*/
- function cachedAvailable($cache, $barrel, $page)
+ function cachedVisible($cache, $barrel, $page)
{
$p_node = $this->cacheGetPageNode($cache, $barrel, $page);
- //echo "<pre>".var_encode_text($p_node)."</pre>";
+ return $p_node->data;
+/*
+ $available = array();
foreach ($p_node->data as $plugname => $plugentry)
{
- $plugfile = $this->plugdir."/".$plugname.".php";
- if (file_exists($plugfile) and (!$barrel || ($plugentry['status'] != PLUG_DISABLED)))
+ //echo "cachedEditable : examining $plugname (status {$plugentry['status']})<br/>\n";
+ if (!($plugentry['status'] & PLUG_LOCK) || !$barrel)
{
+ //echo "cachedEditable : adding $plugname<br/>\n";
$available[$plugname] = $plugentry;
- }
+ // }
}
return $available;
+*/
}
{
//echo "Processing plugin '$plugin' for <{$node->name}><br/>\n";
$outval = '';
- if ($parentval['status'] != PLUG_DISABLED)
+ if (($parentval['status'] & PLUG_ACTIVE) || !($parentval['status'] & PLUG_LOCK))
{
- //echo "* plugin available/enabled at parent level<br/>\n";
+ //echo "* plugin '$plugin' not locked off parent level<br/>\n";
$outval = $parentval;
if (is_array($node->data[$plugin]))
{
//echo "** plugin set at current level<br/>\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<br/>\n";
$outval['status'] = $node->data[$plugin]['status'];
} else {
- //echo "*** plugin forced on at parent level<br/>\n";
+ $outval['status'] = $parentval['status'];
}
} else {
//echo "** plugin unset at current level<br/>\n";
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);
}
}
}