public function ajaxRenderform($pluginId) { $pluginFormBuilder = new PluginFormBuilder(); $query_q = 'SELECT * FROM cms_fieldsets WHERE com_struc_id = "' . $_POST['psid'] . '"'; $query_r = mysql_query($query_q); $row = mysql_fetch_array($query_r); $renderForm = $pluginFormBuilder->formBody($_POST['psid'], $row['id'], $_POST['id']); echo $renderForm; }
public function renderPluginForm($pluginId, $plugStrucId, $id) { $pstruc_q = 'SELECT * FROM cms_plugin_structure WHERE id = "' . $plugStrucId . '"'; $pstruc_r = mysql_query($pstruc_q); $pstruc = mysql_fetch_array($pstruc_r); $fieldset_q = 'SELECT * FROM cms_fieldsets WHERE com_struc_id = "' . $plugStrucId . '"'; $fieldset_r = mysql_query($fieldset_q); $pluginForm = ''; //Loop through each fieldset. Each form is each fieldset basically while ($fieldset = mysql_fetch_array($fieldset_r)) { $pluginForm .= "<div class=\"widget first\">\n"; $pluginForm .= "<div class=\"head\"><h5 class=\"iInfo\">" . $fieldset['name'] . "</h5><div class=\"loader\"></div></div>\n"; $pluginForm .= "<form method=\"post\" id=\"valid\" class=\"mainForm\" action=\"" . _EQROOT_ . "plugins/" . (!empty($id) ? 'save' : 'addNew') . "\" enctype=\"multipart/form-data\">\n"; $pluginForm .= "<input type=\"hidden\" name=\"pluginid\" value=\"" . $pluginId . "\" />"; if (!empty($_GET['pageid'])) { $pluginForm .= "<input type=\"hidden\" name=\"pageid\" value=\"" . $_GET['pageid'] . "\" />\n"; } $pluginForm .= "<input type=\"hidden\" name=\"plugstrucid\" value=\"" . $plugStrucId . "\" />\n"; $pluginForm .= "<input type=\"hidden\" name=\"recordset\" value=\"" . $pstruc['db_name'] . "\" />\n"; $pluginForm .= "<input type=\"hidden\" name=\"recordid\" value=\"" . (!empty($_GET['recordid']) ? $_GET['recordid'] : '0') . "\" />\n"; $pluginForm .= "<input type=\"hidden\" name=\"fieldsetid\" value=\"" . $fieldset['id'] . "\" />\n"; if (!empty($id)) { $pluginForm .= "<input type=\"hidden\" name=\"id\" value=\"" . $id . "\" />\n"; } $pluginForm .= "<div id=\"formBody\">\n"; if (!empty($id)) { $pluginForm .= PluginFormBuilder::formBody($pstruc['id'], $fieldset['id'], $id); } else { $pluginForm .= PluginFormBuilder::formBody($pstruc['id'], $fieldset['id'], ''); } $pluginForm .= "</div>\n"; $pluginForm .= "<div class=\"fix\"></div>\n"; $pluginForm .= "<div class=\"rowElem formaction noborder\">\n"; if (!empty($id)) { $pluginForm .= "<input type=\"button\" value=\"Delete\" class=\"redBtn floatright\" onclick=\"redirect('" . _EQROOT_ . "plugins/deleterecord/" . $id . "?pid=" . $pluginId . "&psid=" . $plugStrucId . "','Delete this record? Are you sure?')\">\n"; } $pluginForm .= "<input type=\"button\" value=\"" . (!empty($id) ? 'Back' : 'Cancel') . "\" class=\"blueBtn floatright\" onclick=\"redirect('" . _EQROOT_ . (empty($_GET['pageid']) ? 'plugins/view/' . $pluginId : 'pages/edit/' . $_GET['pageid']) . "')\">\n"; $pluginForm .= "<input type=\"submit\" value=\"" . (!empty($id) ? 'Save' : 'Add') . "\" id=\"addEdit\" class=\"greyishBtn floatright\">\n"; $pluginForm .= "<div class=\"fix\"></div>\n"; $pluginForm .= "</div>\n"; $pluginForm .= "</div>\n"; $childArray = PluginListBuilder::buildPluginStrucArray($pluginId, $plugStrucId); $x = 0; if (!empty($id)) { foreach ($childArray as $c) { $pluginForm .= "<div class=\"widget first\"><ul class=\"tabs\">\n<li class=\"activeTab\"><a>" . $c['name'] . "</a></li>\n</ul>\n"; $className = ''; if (isset($_SESSION['child' . $pstruc['db_name']])) { if ($_SESSION['child' . $pstruc['db_name']] == $c['db_name']) { $className = 'display:block;'; } else { $className = 'display:none;'; } } else { if ($x == 0) { $className = 'display:block;'; } else { $className = 'display:none;'; } } $pluginForm .= "<div style=\"" . $className . "\" id=\"" . $c['db_name'] . "-tab\" class=\"tab_content\">\n"; $pluginForm .= "<a href=\"" . _EQROOT_ . "plugins/add/" . $pluginId . "?psid=" . $c['id'] . "&recordid=" . $id . "\" class=\"addComponentStructure modal\"><i class=\"fa fa-plus fa-1x\"></i> New " . $c['recordname'] . "</a>\n"; $pluginForm .= "<div class=\"floatright searchPluginDiv\"><label class=\"floatleft\">Search: </label><form method=\"GET\" action=\"" . $_SERVER['REQUEST_URI'] . "\" class=\"floatleft\"><input type=\"text\" name=\"search" . $c['db_name'] . "\" value=\"" . (isset($_GET['searchChild' . $pstruc['db_name']]) ? $_GET['searchChild' . $pstruc['db_name']] : "") . "\" class=\"searchPlugin\" onkeydown=\"if (event.keyCode == 13) { this.form.submit(); return false; }\"></form></div>\n"; $pluginForm .= "<div class=\"widget first\">" . PluginListBuilder::generateTableHead($pluginId, $c['id']); $pluginForm .= PluginListBuilder::generateTableBody($pluginId, $c['id'], $id) . "</div>\n"; $pluginForm .= "<div class=\"fix\"></div></div>\n"; $x++; } } $pluginForm .= "</div><div class=\"fix\"></div></div>"; } return $pluginForm; }