Mercurial > hg > fapweb
diff admajax.php @ 624:aad32d21091f
Some work on settings groups.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 01 Nov 2014 06:18:17 +0200 |
parents | 8840026c931d |
children | abda11cd3259 |
line wrap: on
line diff
--- a/admajax.php Sat Nov 01 05:46:38 2014 +0200 +++ b/admajax.php Sat Nov 01 06:18:17 2014 +0200 @@ -1191,49 +1191,61 @@ echo stGetCompoData($res["id"], $res, "co"); break; + case "settingslist": + $index = 0; + foreach (stExecSQL("SELECT * FROM settings_groups") as $group) + { + if ($index++ > 0) echo ","; + echo "\"".$group["id"]."\":\"".chentities($group["name"])."\""; + } + break; case "settings": - $prefix = "st"; - - echo - "<h1>Site settings</h1>\n". - "<form method=\"post\" action=\"\" onsubmit=\"return jsUpdateSettings()\">\n". - "<table>\n"; - foreach (stExecSQL("SELECT * FROM settings WHERE vtype<>".VT_TEXT." ORDER BY vtype ASC") as $item) + $group = stFetchSQL(stPrepareSQL("SELECT * FROM settings_groups WHERE id=%D", "id")); + if ($group !== FALSE) { + $prefix = "st"; echo - " <tr>\n". - " <td>"; - $id = $item["key"]; - switch ($item["vtype"]) + "<h1>".chentities($group["description"])."</h1>\n". + "<form method=\"post\" action=\"\" onsubmit=\"return jsUpdateSettings(".$group["id"].")\">\n". + "<table>\n"; + + foreach (stExecSQL("SELECT * FROM settings WHERE vtype<>".VT_TEXT." AND vgroup=".$group["id"]." ORDER BY vtype ASC") as $item) { - case VT_INT: - echo stGetFormTextInput(10, 10, "", $id, $prefix, $item["vint"]); - break; - case VT_STR: - echo stGetFormTextInput(40, 128, "", $id, $prefix, $item["vstr"]); - break; - case VT_BOOL: - echo stGetFormCheckBoxInput("", $id, $prefix, $item["vint"], ""); - break; + echo + " <tr>\n". + " <td>"; + $id = $item["key"]; + switch ($item["vtype"]) + { + case VT_INT: + echo stGetFormTextInput(10, 10, "", $id, $prefix, $item["vint"]); + break; + case VT_STR: + echo stGetFormTextInput(40, 128, "", $id, $prefix, $item["vstr"]); + break; + case VT_BOOL: + echo stGetFormCheckBoxInput("", $id, $prefix, $item["vint"], ""); + break; + } + echo + "</td>\n". + " <td><label for=\"".$prefix.$id."\">".chentities($item["sdesc"])."</label></td>\n". + " </tr>\n"; } - echo - "</td>\n". - " <td><label for=\"".$prefix.$id."\">".chentities($item["sdesc"])."</label></td>\n". - " </tr>\n"; - } - echo "</table>\n".stGetSaveButton(); + echo "</table>\n".stGetSaveButton(); - foreach (stExecSQL("SELECT * FROM settings WHERE vtype=".VT_TEXT." ORDER BY key DESC") as $item) - { - echo - "<h2>".chentities($item["sdesc"])."</h2>\n". - stGetFormTextArea(10, 60, "", $item["key"], $prefix, $item["vtext"]). - "\n<br />\n". - stGetSaveButton(); + foreach (stExecSQL("SELECT * FROM settings WHERE vtype=".VT_TEXT." AND vgroup=".$group["id"]." ORDER BY key DESC") as $item) + { + echo + "<h2>".chentities($item["sdesc"])."</h2>\n". + stGetFormTextArea(10, 60, "", $item["key"], $prefix, $item["vtext"]). + "\n<br />\n". + stGetSaveButton(); + } + echo "</form>\n"; } - echo "</form>\n"; break; case "compolist":