public static function return_column_plugins($c, $setting) { $col = array(); foreach ($c->getPluginsBySetting($setting) as $name => $settings) { try { $col[] = PluginManager::getPlugin($name)->setSettings($settings); } catch (Exception $e) { Kohana::log('debug', $e->getMessage()); } } return $col; }
function edit($id, $name, $descr, $state, $strict, $type, $alarm_id, $others) { if (!isset($state)) { $state = 0; } if (!isset($strict)) { $strict = 0; } $pm = new PluginManager(PluginManager::PLUGIN_TYPE_CONTROL); $plugin = $pm->getPlugin($type); $plugin->storeForm($others); $code = $plugin->storeConfig(); $sth = $this->pdo->prepare("UPDATE controllers SET name = ?, descr = ?, enabled = ?, strict = ?, control_type = ?, control_code = ?, alarm_id = ? WHERE id = ?"); $res = $sth->execute(array($name, $descr, $state, $strict, $type, $code, $alarm_id, $id)); if ($res == 0) { $errorInfo = $sth->errorInfo(); throw new Exception("Impossible de modifier ce contrôleur: " . print_r($errorInfo, true)); } $_SESSION["message"] = array("type" => "success", "title" => "Modification terminée", "descr" => "Le contrôleur a bien été modifié"); header('Location: ' . '/monitoring/?v=dashboard&cat=controllers'); }
private function __checkPluginControl($request) { $pm = new PluginManager(PluginManager::PLUGIN_TYPE_CONTROL); $controlName = $request["controlname"]; $plugin = $pm->getPlugin($controlName); try { $res = $plugin->testControl(); if ($res == false) { throw new Exception("Control has returned a FALSE value"); } } catch (Exception $ex) { echo "0"; } echo "1"; exit(0); }
/** * get a plugin (via ajax) * * @return void * @author Andy Bennett */ function ajax() { if ($this->uri->segment(3) == 'get_plugin_row') { $name = $this->input->post('name'); $pm = new PluginManager(); $plugin = $pm->getPlugin($name); $v = new View('plugin-row'); $v->set('aplugin', $plugin); $v->aname = $name; $v->render(TRUE); } }
/** * get the plugins based on a setting * * @param string $setting * @return void * @author Andy Bennett */ public function get_plugins($setting) { if (!is_numeric($this->container_id)) { throw new Kohana_User_Exception("Containers Error", "The container has not been initialised"); } $col = array(); $res = $this->model->get_plugins_by_setting($this->container_id, $setting); foreach ($res as $plugin) { $name = $plugin->plugin_name; $settings = (array) $plugin; try { $col[] = PluginManager::getPlugin($name)->setSettings($settings); } catch (Exception $e) { Kohana::log('debug', $e->getMessage()); } } return $col; }
function assignCategoryControllers($tpl) { $action = isset($_REQUEST["a"]) ? $_REQUEST["a"] : "list"; if ($action == "list") { $sth = $this->pdo->prepare("SELECT id, name, alarm_count, enabled FROM controllers"); $sth->execute(); $res = $sth->fetchAll(); $tpl->assign('controllers_data', $res); $tpl->assign('view', 'view_dashboard_controllers'); } else { if ($action == "add") { $item = array("id" => -1, "name" => "", "descr" => "", "enabled" => 1, "strict" => 0, "control_type" => "", "control_code" => "", "alarm_id" => 1); // Request for alarms $sth = $this->pdo->prepare("SELECT id, name FROM alarms"); $sth->execute(); $alarms = $sth->fetchAll(); // Request for controls $pm = new PluginManager(PluginManager::PLUGIN_TYPE_CONTROL); $plugins = $pm->getPlugins(); // Request current control $key = array_keys($plugins); $key = $key[0]; $plugin = $plugins[$key]; $ffh = new FieldFormHelper(); $ffh->putFields($plugin->loadForm()); $subformHtml = $ffh->getHTML(); $tpl->assign('action', $action); $tpl->assign('item', $item); $tpl->assign('alarms_data', $alarms); $tpl->assign('controls_data', $plugins); $tpl->assign('subform_html', $subformHtml); $tpl->assign('view', 'view_dashboard_controllers_form'); } else { if ($action == "edit") { $sth = $this->pdo->prepare("SELECT id, name, descr, enabled, strict, control_type, control_code, alarm_id FROM controllers WHERE id = ?"); $sth->execute(array($_REQUEST["id"])); $res = $sth->fetch(PDO::FETCH_ASSOC); $item = $res; // Request for alarms $sth = $this->pdo->prepare("SELECT id, name FROM alarms"); $sth->execute(); $alarms = $sth->fetchAll(); // Request for controls $pm = new PluginManager(PluginManager::PLUGIN_TYPE_CONTROL); $plugins = $pm->getPlugins(); // Request current control $plugin = $pm->getPlugin($item["control_type"]); $plugin->loadConfig($item["control_code"]); $ffh = new FieldFormHelper(); $ffh->putFields($plugin->loadForm()); $subformHtml = $ffh->getHTML(); $tpl->assign('action', $action); $tpl->assign('item', $item); $tpl->assign('alarms_data', $alarms); $tpl->assign('controls_data', $plugins); $tpl->assign('subform_html', $subformHtml); $tpl->assign('view', 'view_dashboard_controllers_form'); } } } }
/** * get page plugins * * @param string $pid * @return array * @author Andy Bennett */ public static function get_page_plugins($pid, $plugin_name = NULL) { $plug_table = Kohana::config('appconf.page_plugins_table'); if (is_null($plug_table)) { $plug_table = 'page_plugins'; } $db = new SteamDatabase(); $db->select('*')->from($plug_table)->where(array('pid' => $pid)); if (isset($plugin_name)) { $db->orwhere(array('plugin_name' => $plugin_name)); } $db->orderby('order'); $c = $db->get_result(); $col = array(); foreach ($c as $p) { $name = $p->plugin_name; $settings = array(); // $settings['column'] = $p->column; $settings['order'] = $p->order; $settings['template'] = $p->template; try { $col[] = PluginManager::getPlugin($name)->setSettings($settings); } catch (Exception $e) { Kohana::log('debug', $e->getMessage()); } } return $col; }
/** * Sends data to ViewManager * * @access private * @param array Result */ private function display($result) { $request = $this->pluginManager->getPlugin('router')->getRequest(); $view = $request['view']; $vm = new ViewManager($view, $result, $this->user); }