private function __obtainHTMLFormForPlugin($pluginName) { $pm = new PluginManager(PluginManager::PLUGIN_TYPE_CONTROL); $plugin = $pm->getPlugin($pluginName); $formArray = $plugin->loadForm(); if (!is_array($formArray)) { exit(0); } $ffh = new FieldFormHelper(); $ffh->putFields($formArray); $html = $ffh->getHTML(); echo $html; }
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'); } } } }