Skip to content
Snippets Groups Projects
Commit 7d36f41f authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

enable shell plugins

parent 4011ff8d
No related branches found
No related tags found
1 merge request!43Shell plugins: Process viewer and load
...@@ -130,6 +130,16 @@ return [ ...@@ -130,6 +130,16 @@ return [
], ],
*/ */
], ],
// new WIP plugin class: a plugin must have key "enabled"
'shellcmd'=>[
'load'=>[
'enabled'=>1,
],
'processes'=>[
'enabled'=>1,
],
],
], ],
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
......
...@@ -68,6 +68,12 @@ class ciplugins { ...@@ -68,6 +68,12 @@ class ciplugins {
*/ */
protected $_aConfig = []; protected $_aConfig = [];
/**
* global plugins config
* see config/config_custom.php - key plugins
* @var array
*/
protected $_aGlobals = [];
// --------------------------------------------------------------- // ---------------------------------------------------------------
// CONSTRUCTOR // CONSTRUCTOR
...@@ -75,15 +81,29 @@ class ciplugins { ...@@ -75,15 +81,29 @@ class ciplugins {
/** /**
* initialize plugins * initialize plugins
*
* @param array $aGlobals global settings for plugins
* @return boolean * @return boolean
*/ */
public function __construct() { public function __construct($aGlobals=[]) {
$this->_sPlugindir=dirname(__DIR__).'/plugins'; $this->_sPlugindir=dirname(__DIR__).'/plugins';
$this->setGlobalCustoms($aGlobals);
return true; 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 // FOR LISTING :: GETTER
// --------------------------------------------------------------- // ---------------------------------------------------------------
...@@ -102,6 +122,8 @@ class ciplugins { ...@@ -102,6 +122,8 @@ class ciplugins {
/** /**
* get an array of available plugins read from filesystem * get an array of available plugins read from filesystem
*
* @param string $sType set a new type of plugin; default: use current type
* @return array * @return array
*/ */
public function getPlugins($sType=false){ public function getPlugins($sType=false){
...@@ -117,9 +139,40 @@ class ciplugins { ...@@ -117,9 +139,40 @@ class ciplugins {
return $aReturn; 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
// //
// --------------------------------------------------------------- // ---------------------------------------------------------------
......
...@@ -79,14 +79,18 @@ $sHeader.="</style>\n"; ...@@ -79,14 +79,18 @@ $sHeader.="</style>\n";
$sShellOuptut=''; $sShellOuptut='';
$sTopRight=''; $sTopRight='';
$CI_plugins=new plugin_renderer(); $CI_plugins=new plugin_renderer(isset($aConfig['plugins']) ? $aConfig['plugins'] : []);
$CI_plugins->setType('shellcmd'); $CI_plugins->setType('shellcmd');
$aPluginsShellcmd=$CI_plugins->getPlugins();
$sHeader = "\n<!-- shellcmd plugins :: js files -->\n"; $aEnabledShellPlugins=$CI_plugins->getEnabledPlugins('shellcmd');
$sHeader.='<script src="/deployment/js/ubd.class.js"></script>'."\n" $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" .'<script src="/deployment/js/addi.js"></script>'."\n"
: ''
; ;
foreach ($CI_plugins->getPlugins('shellcmd') as $sPlugin){ foreach ($aEnabledShellPlugins as $sPlugin){
if ($CI_plugins->testPlugin($sPlugin)){ if ($CI_plugins->testPlugin($sPlugin)){
$aPluginConfig=$CI_plugins->getPluginConfig(); $aPluginConfig=$CI_plugins->getPluginConfig();
$sHeader.=$CI_plugins->getHtmlLoadScript('render.js'); $sHeader.=$CI_plugins->getHtmlLoadScript('render.js');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment