diff --git a/config/config_defaults.php b/config/config_defaults.php index 0cb6c90ef8f35e80fdb14959f0cbdedd9ec3d27a..b1ced00f73dd9d889b0b18283d9a9bbcdaf8a272 100644 --- a/config/config_defaults.php +++ b/config/config_defaults.php @@ -130,6 +130,16 @@ return [ ], */ ], + + // new WIP plugin class: a plugin must have key "enabled" + 'shellcmd'=>[ + 'load'=>[ + 'enabled'=>1, + ], + 'processes'=>[ + 'enabled'=>1, + ], + ], ], // ---------------------------------------------------------------------- diff --git a/public_html/deployment/classes/plugins.class.php b/public_html/deployment/classes/plugins.class.php index 1a52f30cd7cebcc93bd711ba8f4f070020b86ccd..be93422595710cf3a052c50c4729469ac856f68c 100644 --- a/public_html/deployment/classes/plugins.class.php +++ b/public_html/deployment/classes/plugins.class.php @@ -68,6 +68,12 @@ class ciplugins { */ protected $_aConfig = []; + /** + * global plugins config + * see config/config_custom.php - key plugins + * @var array + */ + protected $_aGlobals = []; // --------------------------------------------------------------- // CONSTRUCTOR @@ -75,15 +81,29 @@ class ciplugins { /** * initialize plugins + * + * @param array $aGlobals global settings for plugins * @return boolean */ - public function __construct() { + public function __construct($aGlobals=[]) { $this->_sPlugindir=dirname(__DIR__).'/plugins'; + $this->setGlobalCustoms($aGlobals); return true; } + /** + * global configs + * see config/config_custom.php - key plugins + * + * @param array $aGlobals global settings for plugins + * @return boolean + */ + public function setGlobalCustoms($aGlobals){ + $this->_aGlobals=$aGlobals; + return true; + } // --------------------------------------------------------------- // FOR LISTING :: GETTER // --------------------------------------------------------------- @@ -102,6 +122,8 @@ class ciplugins { /** * get an array of available plugins read from filesystem + * + * @param string $sType set a new type of plugin; default: use current type * @return array */ public function getPlugins($sType=false){ @@ -117,9 +139,40 @@ class ciplugins { return $aReturn; } + /** + * get an array of enabled plugins + * config/config_custom.php - key "plugins" -> [type] -> [plugin] -> enabled + * and it must be physically available + * + * @param string $sType set a new type of plugin; default: use current type + * @return array + */ + public function getEnabledPlugins($sType=false){ + $aReturn = []; + if($sType){ + if (!$this->setType($sType)){ + return $aReturn; + } + } + if (isset($this->_aGlobals[$this->_sType]) + && is_array($this->_aGlobals[$this->_sType]) + ){ + foreach($this->_aGlobals[$this->_sType] as $sPluginName=>$aData){ + if ( + isset($aData['enabled']) + && $aData['enabled'] + && is_dir($this->_sPlugindir.'/'.$this->_sType.'/'.$sPluginName) + ){ + $aReturn[]=$sPluginName; + } + } + } + return $aReturn; + } + // --------------------------------------------------------------- // - // BELOW ARE METHODS FOR A SET SPECIFIC PLUGIN AND TYPE + // BELOW ARE METHODS FOR A SPECIFICLY SET PLUGIN AND TYPE // // --------------------------------------------------------------- diff --git a/public_html/deployment/index.php b/public_html/deployment/index.php index c6d7c2f19188ab8dfe5da9abc0b9c2b61937782d..e58eabe6e983d333a4379ddfb6e0346a86376472 100644 --- a/public_html/deployment/index.php +++ b/public_html/deployment/index.php @@ -79,14 +79,18 @@ $sHeader.="</style>\n"; $sShellOuptut=''; $sTopRight=''; -$CI_plugins=new plugin_renderer(); +$CI_plugins=new plugin_renderer(isset($aConfig['plugins']) ? $aConfig['plugins'] : []); $CI_plugins->setType('shellcmd'); -$aPluginsShellcmd=$CI_plugins->getPlugins(); -$sHeader = "\n<!-- shellcmd plugins :: js files -->\n"; -$sHeader.='<script src="/deployment/js/ubd.class.js"></script>'."\n" - .'<script src="/deployment/js/addi.js"></script>'."\n" + +$aEnabledShellPlugins=$CI_plugins->getEnabledPlugins('shellcmd'); +$sHeader.= count($aEnabledShellPlugins) + ? '' + ."\n<!-- shellcmd plugins :: js files -->\n" + .'<script src="/deployment/js/ubd.class.js"></script>'."\n" + .'<script src="/deployment/js/addi.js"></script>'."\n" + : '' ; -foreach ($CI_plugins->getPlugins('shellcmd') as $sPlugin){ +foreach ($aEnabledShellPlugins as $sPlugin){ if ($CI_plugins->testPlugin($sPlugin)){ $aPluginConfig=$CI_plugins->getPluginConfig(); $sHeader.=$CI_plugins->getHtmlLoadScript('render.js');