function BuildPage($page, $id) { global $selectedTab, $loguser; //TODO: This should be done in JS. //So that a user who doesn't have Javascript will see all the tabs. $display = $id != $selectedTab ? " style=\"display: none;\"" : ""; $cellClass = 0; $output = "<table class=\"outline margin width50 eptable\" id=\"" . $id . "\"" . $display . ">\n"; foreach ($page as $pageID => $section) { $secClass = $section["class"]; $output .= "<tr class=\"header0 {$secClass}\"><th colspan=\"2\">" . $section['name'] . "</th></tr>\n"; foreach ($section['items'] as $field => $item) { $output .= "<tr class=\"cell{$cellClass} {$secClass}\" >\n"; $output .= "<td>\n"; if (isset($item["fail"])) { $output .= "[ERROR] "; } if ($item['type'] != "checkbox") { $output .= "<label for=\"" . $field . "\">" . $item['caption'] . "</label>\n"; } if (isset($item['hint'])) { $output .= "<img src=\"" . resourceLink("img/icons/icon5.png") . "\" title=\"" . $item['hint'] . "\" alt=\"[?]\" />\n"; } $output .= "</td>\n"; $output .= "<td>\n"; if (isset($item['before'])) { $output .= " " . $item['before']; } // Yes, some cases are missing the break; at the end. // This is intentional, but I don't think it's a good idea... switch ($item['type']) { case "label": $output .= htmlspecialchars($item['value']) . "\n"; break; case "birthday": $item['type'] = "text"; //$item['value'] = gmdate("F j, Y", $item['value']); $item['value'] = timestamptostring($item['value']); case "password": if ($item['type'] == "password") { $item['extra'] = "/ " . __("Repeat:") . " <input type=\"password\" name=\"repeat" . $field . "\" size=\"" . $item['size'] . "\" maxlength=\"" . $item['length'] . "\" />"; } case "passwordonce": if (!isset($item['size'])) { $item['size'] = 13; } if (!isset($item['length'])) { $item['length'] = 32; } if ($item["type"] == "passwordonce") { $item["type"] = "password"; } case "color": case "text": $output .= "<input id=\"" . $field . "\" name=\"" . $field . "\" type=\"" . $item['type'] . "\" value=\"" . htmlspecialchars($item['value']) . "\""; if (isset($item['size'])) { $output .= " size=\"" . $item['size'] . "\""; } if (isset($item['length'])) { $output .= " maxlength=\"" . $item['length'] . "\""; } if (isset($item['width'])) { $output .= " style=\"width: " . $item['width'] . ";\""; } if (isset($item['more'])) { $output .= " " . $item['more']; } $output .= " />\n"; break; case "textarea": if (!isset($item['rows'])) { $item['rows'] = 8; } $output .= "<textarea id=\"" . $field . "\" name=\"" . $field . "\" rows=\"" . $item['rows'] . "\" style=\"width: 98%;\">" . htmlspecialchars($item['value']) . "</textarea>"; break; case "checkbox": $output .= "<label><input id=\"" . $field . "\" name=\"" . $field . "\" type=\"checkbox\""; if (isset($item['negative']) && !$item['value'] || !isset($item['negative']) && $item['value']) { $output .= " checked=\"checked\""; } $output .= " /> " . $item['caption'] . "</label>\n"; break; case "select": $disabled = isset($item['disabled']) ? $item['disabled'] : false; $disabled = $disabled ? "disabled=\"disabled\" " : ""; $checks = array(); $checks[$item['value']] = " selected=\"selected\""; $options = ""; foreach ($item['options'] as $key => $val) { $options .= format("<option value=\"{0}\"{1}>{2}</option>", $key, $checks[$key], $val); } $output .= format("<select id=\"{0}\" name=\"{0}\" size=\"1\" {2}>\n{1}\n</select>\n", $field, $options, $disabled); break; case "radiogroup": $checks = array(); $checks[$item['value']] = " checked=\"checked\""; foreach ($item['options'] as $key => $val) { $output .= format("<label><input type=\"radio\" name=\"{1}\" value=\"{0}\"{2} />{3}</label>", $key, $field, $checks[$key], $val); } break; case "displaypic": case "minipic": $output .= "<input type=\"file\" id=\"" . $field . "\" name=\"" . $field . "\" style=\"width: 98%;\" />\n"; $output .= "<label><input type=\"checkbox\" name=\"remove" . $field . "\" /> " . __("Remove") . "</label>\n"; break; case "number": //$output .= "<input type=\"number\" id=\"".$field."\" name=\"".$field."\" value=\"".$item['value']."\" />"; $output .= "<input type=\"text\" id=\"" . $field . "\" name=\"" . $field . "\" value=\"" . $item['value'] . "\" size=\"6\" maxlength=\"4\" />"; break; case "datetime": $output .= "<input type=\"text\" id=\"" . $field . "\" name=\"" . $field . "\" value=\"" . $item['value'] . "\" />\n"; $output .= __("or preset:") . "\n"; $options = "<option value=\"-1\">" . __("[select]") . "</option>"; foreach ($item['presets'] as $key => $val) { $options .= format("<option value=\"{0}\">{1}</option>", $key, $val); } $output .= format("<select id=\"{0}\" name=\"{0}\" size=\"1\" >\n{1}\n</select>\n", $item['presetname'], $options); break; case "timezone": $output .= "<input type=\"text\" name=\"" . $field . "H\" size=\"2\" maxlength=\"3\" value=\"" . (int) ($item['value'] / 3600) . "\" />\n"; $output .= ":\n"; $output .= "<input type=\"text\" name=\"" . $field . "M\" size=\"2\" maxlength=\"3\" value=\"" . floor(abs($item['value'] / 60) % 60) . "\" />"; break; } if (isset($item['extra'])) { $output .= " " . $item['extra']; } $output .= "</td>\n"; $output .= "</tr>\n"; $cellClass = ($cellClass + 1) % 2; } } $output .= "</table>"; Write($output); }
function BuildPage($page, $id) { global $first, $loguser; $display = $id != $first ? " style=\"display: none;\"" : ""; $cellClass = 0; $output = "<table class=\"outline margin width50 eptable\" id=\"" . $id . "\"" . $display . ">\n"; foreach ($page as $pageID => $section) { $output .= "<tr class=\"header0\"><th colspan=\"2\">" . $section['name'] . "</th></tr>\n"; foreach ($section['items'] as $field => $item) { $output .= "<tr class=\"cell" . $cellClass . "\">\n"; $output .= "<td>\n"; if ($item['type'] != "checkbox") { $output .= "<label for=\"" . $field . "\">" . $item['caption'] . "</label>\n"; } if ($item['hint']) { $output .= "<img src=\"img/icons/icon5.png\" title=\"" . $item['hint'] . "\" alt=\"[?]\" />\n"; } $output .= "</td>\n"; $output .= "<td>\n"; if ($item['before']) { $output .= " " . $item['before']; } switch ($item['type']) { case "label": $output .= htmlspecialchars($item['value']) . "\n"; break; case "birthday": $item['type'] = "text"; //$item['value'] = gmdate("F j, Y", $item['value']); $item['value'] = timestamptostring($item['value']); case "password": if (!isset($item['size'])) { $item['size'] = 13; } if (!isset($item['length'])) { $item['length'] = 32; } if ($item['type'] == "password") { $item['extra'] = "/ " . __("Repeat:") . " <input type=\"password\" name=\"repeat" . $field . "\" size=\"" . $item['size'] . "\" maxlength=\"" . $item['length'] . "\" />"; } case "text": $output .= "<input id=\"" . $field . "\" name=\"" . $field . "\" type=\"" . $item['type'] . "\" value=\"" . htmlval($item['value']) . "\""; if (isset($item['size'])) { $output .= " size=\"" . $item['size'] . "\""; } if (isset($item['length'])) { $output .= " maxlength=\"" . $item['length'] . "\""; } if (isset($item['width'])) { $output .= " style=\"width: " . $item['width'] . ";\""; } if (isset($item['more'])) { $output .= " " . $item['more']; } $output .= " />\n"; break; case "textarea": if (!isset($item['rows'])) { $item['rows'] = 8; } $output .= "<textarea id=\"" . $field . "\" name=\"" . $field . "\" rows=\"" . $item['rows'] . "\" style=\"width: 98%;\">" . htmlval($item['value']) . "</textarea>"; break; case "checkbox": $output .= "<label><input id=\"" . $field . "\" name=\"" . $field . "\" type=\"checkbox\""; if ($item['negative'] && !$item['value'] || !$item['negative'] && $item['value']) { $output .= " checked=\"checked\""; } $output .= " /> " . $item['caption'] . "</label>\n"; break; case "select": $disabled = isset($item['disabled']) ? $item['disabled'] : false; $disabled = $disabled ? "disabled=\"disabled\" " : ""; $checks = array(); $checks[$item['value']] = " selected=\"selected\""; $options = ""; foreach ($item['options'] as $key => $val) { $options .= format("<option value=\"{0}\"{1}>{2}</option>", $key, $checks[$key], $val); } $output .= format("<select id=\"{0}\" name=\"{0}\" size=\"1\" {2}>\n{1}\n</select>\n", $field, $options, $disabled); break; case "radiogroup": $checks = array(); $checks[$item['value']] = " checked=\"checked\""; foreach ($item['options'] as $key => $val) { $output .= format("<label><input type=\"radio\" name=\"{1}\" value=\"{0}\"{2} />{3}</label>", $key, $field, $checks[$key], $val); } break; case "displaypic": case "minipic": $output .= "<input type=\"file\" id=\"" . $field . "\" name=\"" . $field . "\" style=\"width: 98%;\" />\n"; $output .= "<label><input type=\"checkbox\" name=\"remove" . $field . "\" /> " . __("Remove") . "</label>\n"; break; case "number": //$output .= "<input type=\"number\" id=\"".$field."\" name=\"".$field."\" value=\"".$item['value']."\" />"; $output .= "<input type=\"text\" id=\"" . $field . "\" name=\"" . $field . "\" value=\"" . $item['value'] . "\" size=\"6\" maxlength=\"4\" />"; break; case "datetime": $output .= "<input type=\"text\" id=\"" . $field . "\" name=\"" . $field . "\" value=\"" . $item['value'] . "\" />\n"; $output .= __("or preset:") . "\n"; $options = "<option value=\"-1\">" . __("[select]") . "</option>"; foreach ($item['presets'] as $key => $val) { $options .= format("<option value=\"{0}\">{1}</option>", $key, $val); } $output .= format("<select id=\"{0}\" name=\"{0}\" size=\"1\" >\n{1}\n</select>\n", $item['presetname'], $options); break; case "timezone": $output .= "<input type=\"text\" name=\"" . $field . "H\" size=\"2\" maxlength=\"3\" value=\"" . (int) ($item['value'] / 3600) . "\" />\n"; $output .= ":\n"; $output .= "<input type=\"text\" name=\"" . $field . "M\" size=\"2\" maxlength=\"3\" value=\"" . floor(abs($item['value'] / 60) % 60) . "\" />"; break; } if ($item['extra']) { $output .= " " . $item['extra']; } $output .= "</td>\n"; $output .= "</tr>\n"; $cellClass = ($cellClass + 1) % 2; } } $output .= "</table>"; Write($output); }