fixed HTML errors,

added option types
This commit is contained in:
Roland Gruber 2004-03-14 15:34:53 +00:00
parent 8b4d423193
commit 7fa9d49d1e
1 changed files with 20 additions and 11 deletions

View File

@ -40,6 +40,9 @@ if (!$_SESSION['ldap'] || !$_SESSION['ldap']->server()) {
exit; exit;
} }
// empty list of attribute types
$_SESSION['profile_types'] = array();
// print header // print header
echo $_SESSION['header']; echo $_SESSION['header'];
echo "<title></title>\n<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/layout.css\">\n"; echo "<title></title>\n<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/layout.css\">\n";
@ -110,7 +113,6 @@ echo ("</form></body></html>\n");
// $module_name: The name of the module the options belong to // $module_name: The name of the module the options belong to
// $old_profile: A hash array with the values from the loaded profile // $old_profile: A hash array with the values from the loaded profile
function print_option($values, $modulename, $old_profile) { function print_option($values, $modulename, $old_profile) {
echo "<td>";
switch ($values['kind']) { switch ($values['kind']) {
// text value // text value
case 'text': case 'text':
@ -118,39 +120,46 @@ function print_option($values, $modulename, $old_profile) {
break; break;
// help link // help link
case 'help': case 'help':
echo "<a href=../help.php?module=$modulename&item=" . $values['value'] . ">" . _('Help') . "</a>\n"; echo "<a href=../help.php?module=$modulename&amp;module=" . $values['value'] . ">" . _('Help') . "</a>\n";
break; break;
// input field // input field
case 'input': case 'input':
if (($values['type'] == 'text') || ($values['type'] == 'checkbox')) { if (($values['type'] == 'text') || ($values['type'] == 'checkbox')) {
if ($values['type'] == 'text') { if ($values['type'] == 'text') {
$output = "<input type=\"" . $values['type'] . " name=\"" . $values['name']; $output = "<input type=\"" . $values['type'] . "\" name=\"" . $values['name'] . "\"";
if ($values['size']) $output .= " size=\"" . $values['size'] . "\""; if ($values['size']) $output .= " size=\"" . $values['size'] . "\"";
if ($values['maxlength']) $output .= " maxlength=\"" . $values['maxlength'] . "\""; if ($values['maxlength']) $output .= " maxlength=\"" . $values['maxlength'] . "\"";
if (isset($old_profile[$values['name']])) $output .= " value=\"" . $old_profile[$values['name']][0] . "\""; if (isset($old_profile[$values['name']])) $output .= " value=\"" . $old_profile[$values['name']][0] . "\"";
elseif ($values['value']) $output .= " value=\"" . $values['value'] . "\""; elseif ($values['value']) $output .= " value=\"" . $values['value'] . "\"";
if ($values['disabled']) $output .= " disabled"; if ($values['disabled']) $output .= " disabled";
$output .= "></td>\n"; $output .= ">\n";
echo $output; echo $output;
$_SESSION['profile_types'][$values['name']] = "text";
} }
elseif ($values['type'] == 'checkbox') { elseif ($values['type'] == 'checkbox') {
$output = "<input type=\"" . $values['type'] . " name=\"" . $values['name']; $output = "<input type=\"" . $values['type'] . "\" name=\"" . $values['name'] . "\"";
if ($values['size']) $output .= " size=\"" . $values['size'] . "\""; if ($values['size']) $output .= " size=\"" . $values['size'] . "\"";
if ($values['maxlength']) $output .= " maxlength=\"" . $values['maxlength'] . "\""; if ($values['maxlength']) $output .= " maxlength=\"" . $values['maxlength'] . "\"";
if ($values['value']) $output .= " value=\"" . $values['value'] . "\""; if ($values['value']) $output .= " value=\"" . $values['value'] . "\"";
if ($values['disabled']) $output .= " disabled"; if ($values['disabled']) $output .= " disabled";
if (isset($old_profile[$values['name']]) && ($old_profile[$values['name']][0] == true)) $output .= " checked"; if (isset($old_profile[$values['name']]) && ($old_profile[$values['name']][0] == true)) $output .= " checked";
elseif ($values['checked']) $output .= " checked"; elseif ($values['checked']) $output .= " checked";
$output .= "></td>\n"; $output .= ">\n";
echo $output; echo $output;
$_SESSION['profile_types'][$values['name']] = "checkbox";
} }
} }
break; break;
// select box // select box
case 'select': case 'select':
echo "<select name=\"" . $values['name'] . "\" size=\"" . $values['size'] . "\""; if ($values['multiple']) {
if ($values['multiple']) $output .= " multiple"; echo "<select name=\"" . $values['name'] . "[]\" size=\"" . $values['size'] . "\" multiple>\n";
echo "\">\n"; $_SESSION['profile_types'][$values['name']] = "multiselect";
}
else {
echo "<select name=\"" . $values['name'] . "\" size=\"" . $values['size'] . "\">\n";
$_SESSION['profile_types'][$values['name']] = "select";
}
// option values // option values
for ($i = 0; $i < sizeof($values['options']); $i++) { for ($i = 0; $i < sizeof($values['options']); $i++) {
// use values from old profile if given // use values from old profile if given
@ -174,11 +183,11 @@ function print_option($values, $modulename, $old_profile) {
} }
echo "</select>\n"; echo "</select>\n";
break; break;
// print error message for invalid types
default: default:
echo "<td>" . _("Unrecognized type") . ": " . $values['kind'] . "</td>\n"; echo _("Unrecognized type") . ": " . $values['kind'] . "\n";
break; break;
} }
echo "</td>";
} }
?> ?>