I think this should be made into a plugin. I'd suggest a simple function
that lists all the plugins in your shared/plugins folder and then a quick
check to see if it is enabled. You might also want to check for plugins in
your field/config folder, as I often put plugins there.

You could then create a page like site.plugincheck and put on it
[(plugincheck)] to output the results (and perhaps where, if anywhere, they
are enabled). It won't catch plugins enabled programmatically, but you
could easily get the site.config settings.

I really hate to put anything in the core code that doesn't absolutely have
to be there--in an effort to try and keep BoltWire running as fast as
possible. If you create the plugin I'll put it on the site.

Cheers,
Dan

On Mon, May 25, 2015 at 2:23 AM Tiffany Grenier <[email protected]>
wrote:

> Hello,
>
> I find it is easy to have forgotten plugin files that are not enabled. I
> call that sleeping plugins (because they lie there, not enabled, not
> because they are forgotten). And I think it would be good to have a list of
> the sleeping plugins in the config files.
> I order to do that, I changed the code of engine.php to recognize both
> "enable plugin" and "disable plugin". It becomes then really easy to enable
> a sleeping plugin and disable a running one, without fearing to forget it
> lies there.
>
> My new code is the following:
> ## LOAD CONFIG VALUES FROM SITE.CONFIG PAGE AND DETERMINE PLUGINS TO BE
> ENABLED
> $config = BOLTloadpage('site.config');
> preg_match_all('/^((enable|disable)([-\w]+)\:?|(([-\w]*)\: )?)(.*)?$/m',
> $config, $m);
> foreach ($m[6] as $i => $v) {
>  if ($m[5][$i] != '') $BOLTconfig[strtolower($m[5][$i])] = trim($v); //
> config values
>  if ($m[3][$i] != '' && $m[2][$i] == 'enable') $BOLTplugins[strtolower($m[
> 3][$i])] = trim($v); // enabled/activated plugins
>  else if($m[2][$i] == 'disable') $BOLTsleepingPlugins[strtolower($m[3][$i
> ])] = trim($v); // disabled/deactivated plugins
>  }
>
> Actually, with my proposal of default configuration, it is the following:
> ## LOAD CONFIG VALUES FROM SITE.CONFIG PAGE AND DETERMINE PLUGINS TO BE
> ENABLED
> $defaultConfig = BOLTloadpage('site.config',$systemPath);
> preg_match_all('/^((([-\w]*)\: )?)(.*)?$/m', $defaultConfig, $m0);
> foreach ($m0[4] as $i => $v) {
>  if ($m0[3][$i] != '') $BOLTdefaultConfig[strtolower($m0[3][$i])] = trim(
> $v); // config values
>  }
> $config = BOLTloadpage('site.config');
> preg_match_all('/^((enable|disable)([-\w]+)\:?|(([-\w]*)\: )?)(.*)?$/m',
> $config, $m);
> foreach ($m[6] as $i => $v) {
>  if ($m[5][$i] != '') $BOLTconfig[strtolower($m[5][$i])] = trim($v); //
> config values
>  if ($m[3][$i] != '' && $m[2][$i] == 'enable') $BOLTplugins[strtolower($m[
> 3][$i])] = trim($v); // enabled/activated plugins
>  else if($m[2][$i] == 'disable') $BOLTsleepingPlugins[strtolower($m[3][$i
> ])] = trim($v); // disabled/deactivated plugins
>  }
>
>
> I have also added a check that verifies the existence of the
> enabled/disabled plugin files, and mark disabled any plugin file that was
> absent from site.config. This complicates a bit more the enabling of plugin
> parts, in order to become the folowing piece of code:
> ## LOAD LOCAL CONFIG.PHP AND ENABLED PLUGINS
> if (file_exists("config/config.php")) { include_once("config/config.php");
> $BOLTvar['plugins'] .= ",config"; }
> if (file_exists("$pluginPath/farm.php")) { include_once(
> "$pluginPath/farm.php"); $BOLTvar['plugins'] .= ",farm"; }
> if (is_array($BOLTplugins)) {
>  if(BOLTconfig('checkPlugins')==='true') {
>  foreach(scandir($pluginPath) as $entry) {
>  $pos = strrpos($entry,'.php');
>  if($pos !== FALSE) {
>  $pluginFiles[strtolower(substr($entry,0,$pos))] = '';
>  }
>  }
>  if(!is_array($pluginFiles)) $uncheckedPlugins = $BOLTplugins;
>  else {
>  $uncheckedPlugins = array_diff_key($BOLTplugins, $pluginFiles); //save
> list of plugins for which no file has been found in the $pluginPath folder
>  $checkedPlugins = array_diff_key($BOLTplugins, $uncheckedPlugins);
>  foreach($checkedPlugins as $plugin => $check) {
>  include_once("$pluginPath/$plugin.php");
>  $BOLTvar['plugins'] .= ",$plugin";
>  }
>  if (is_array($BOLTsleepingPlugins)) {
>  $pluginFiles = array_diff_key($pluginFiles,$BOLTplugins,
> $BOLTsleepingPlugins); //keep list of files that don't correspond to any
> enabled or disabled plugin
>  }
>  else {
>  $pluginFiles = array_diff_key($pluginFiles,$BOLTplugins); //keep list of
> files that don't correspond to any enabled plugin
>  }
>  //append list of remaining plugins to config file and mark them as
> disabled for future times
>  $config = BOLTloadpage('site.config');
>  $config = trim($config);
>  foreach($pluginFiles as $file => $check) {
>  if($file != '') {
>  $config .= "\n".'disable'.ucfirst($file);
>  }
>  }
>  }
>  $config .= "\n";
>  BOLTsavecontent("site.config", $config);
>  }
>  else {
>  $uncheckedPlugins = $BOLTplugins;
>  }
>  if(count($uncheckedPlugins) > 0) {
>  foreach($uncheckedPlugins as $plugin => $check) {
>  if (! BOLTpageCheck($check)) {
>  continue;//$BOLTmissingPluginFiles[] = $plugin;
>  }
>  elseif (file_exists("config/$plugin.php")) {
>  include_once("config/$plugin.php");
>  $BOLTvar['plugins'] .= ",$plugin";
>  }
>  elseif (file_exists("$pluginPath/$plugin.php")) {
>  include_once("$pluginPath/$plugin.php");
>  $BOLTvar['plugins'] .= ",$plugin";
>  }
>  }
>  }
>  $BOLTvar['plugins'] = ltrim($BOLTvar['plugins'], ",");
>  }
>
>
> I would gladly have made a plugin of that, it is did not need to be part
> of engine.php...
> Any thought, question, suggestion?
>
> Cheers,
> Tiffany
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "BoltWire" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/boltwire.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"BoltWire" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/boltwire.
For more options, visit https://groups.google.com/d/optout.

Reply via email to