echo "<div id=\"status\">\n"; $options = array('0' => get_vocab("enabled"), '1' => get_vocab("disabled")); $params = array('label' => get_vocab("status") . ":", 'label_title' => get_vocab("disabled_area_note"), 'name' => 'area_disabled', 'value' => $row['disabled'] ? '1' : '0', 'options' => $options, 'force_assoc' => TRUE); generate_radio_group($params); echo "</div>\n"; // Timezone create_field_entry_timezone(); // Area admin email echo "<div>\n"; $params = array('label' => get_vocab("area_admin_email") . ":", 'label_title' => get_vocab("email_list_note"), 'name' => 'area_admin_email', 'value' => $row['area_admin_email'], 'attributes' => array('rows="4"', 'cols="40"')); generate_textarea($params); echo "</div>\n"; // The custom HTML echo "<div>\n"; $params = array('label' => get_vocab("custom_html") . ":", 'label_title' => get_vocab("custom_html_note"), 'name' => 'custom_html', 'value' => $row['custom_html'], 'attributes' => array('rows="4"', 'cols="40"')); generate_textarea($params); echo "</div>\n"; // Mode - Times or Periods echo "<div id=\"mode\">\n"; $options = array('1' => get_vocab("mode_periods"), '0' => get_vocab("mode_times")); $params = array('label' => get_vocab("mode") . ":", 'name' => 'area_enable_periods', 'value' => $enable_periods ? '1' : '0', 'options' => $options, 'force_assoc' => TRUE); generate_radio_group($params); echo "</div>\n"; echo "</fieldset>\n"; // If we're using JavaScript, don't display the time settings section // if we're using periods (the JavaScript will display it if we change) echo "<fieldset id=\"time_settings\"" . ($enable_periods ? ' class="js_none"' : '') . ">\n"; echo "<legend>" . get_vocab("time_settings"); echo "<span class=\"js_none\"> (" . get_vocab("times_only") . ")</span>"; echo "</legend>\n"; echo "<div class=\"div_time\">\n";
function create_field_entry_custom_field($field, $key, $disabled = FALSE) { global $custom_fields, $tbl_entry; global $is_mandatory_field, $text_input_max, $maxlength; echo "<div>\n"; $params = array('label' => get_loc_field_name($tbl_entry, $key) . ":", 'name' => VAR_PREFIX . $key, 'value' => isset($custom_fields[$key]) ? $custom_fields[$key] : NULL, 'disabled' => $disabled, 'attributes' => array(), 'maxlength' => isset($maxlength["entry.{$key}"]) ? $maxlength["entry.{$key}"] : NULL, 'mandatory' => isset($is_mandatory_field["entry.{$key}"]) && $is_mandatory_field["entry.{$key}"]); // Output a checkbox if it's a boolean or integer <= 2 bytes (which we will // assume are intended to be booleans) if ($field['nature'] == 'boolean' || $field['nature'] == 'integer' && isset($field['length']) && $field['length'] <= 2) { generate_checkbox($params); } elseif ($field['nature'] == 'character' && isset($field['length']) && $field['length'] > $text_input_max) { // HTML5 does not allow a pattern attribute for the textarea element $params['attributes'][] = 'rows="8"'; $params['attributes'][] = 'cols="40"'; generate_textarea($params); } else { $is_integer_field = $field['nature'] == 'integer' && $field['length'] > 2; if ($is_integer_field) { $params['type'] = 'number'; $params['step'] = '1'; } else { $params['type'] = 'text'; if ($params['mandatory']) { // 'required' is not sufficient for strings, because we also want to make sure // that the string contains at least one non-whitespace character $params['pattern'] = REGEX_TEXT_POS; } } $params['field'] = "entry.{$key}"; generate_input($params); } echo "</div>\n"; }
$key = $field['name']; if (!in_array($key, $standard_fields['entry'])) { $var_name = VAR_PREFIX . $key; $value = $custom_fields[$key]; $label_text = get_loc_field_name($tbl_entry, $key) . ":"; echo "<div>\n"; // Output a checkbox if it's a boolean or integer <= 2 bytes (which we will // assume are intended to be booleans) if ($field['nature'] == 'boolean' || $field['nature'] == 'integer' && isset($field['length']) && $field['length'] <= 2) { echo "<label for=\"{$var_name}\">{$label_text}</label>\n"; echo "<input type=\"checkbox\" class=\"checkbox\" " . "id=\"{$var_name}\" name=\"{$var_name}\" value=\"1\" " . (!empty($value) ? " checked=\"checked\"" : "") . ">\n"; } elseif (count($select_options["entry.{$key}"]) > 0) { $mandatory = array_key_exists("entry.{$key}", $is_mandatory_field) && $is_mandatory_field["entry.{$key}"] ? true : false; generate_select($label_text, $var_name, $value, $select_options["entry.{$key}"], $mandatory); } elseif ($field['nature'] == 'character' && isset($field['length']) && $field['length'] > $text_input_max) { generate_textarea($label_text, $var_name, $value); } else { generate_input($label_text, $var_name, $value); } echo "</div>\n"; } } // REPEAT BOOKING INPUTS if ($edit_type == "series" && $repeats_allowed) { // If repeats are allowed and the edit_type is a series (which means // that either you're editing an existing series or else you're making // a new booking) then print the repeat inputs echo "<fieldset id=\"rep_info\">\n"; echo "<legend></legend>\n"; ?> <div id="rep_type">
echo "<input type=\"hidden\" name=\"{$var_name}\" value=\"" . $data[$key] . "\">\n"; } break; case 'email': generate_input($label_text, $var_name, $data[$key], FALSE, isset($maxlength["users.{$key}"]) ? $maxlength["users.{$key}"] : NULL, 'type=email multiple'); break; default: // Output a checkbox if it's a boolean or integer <= 2 bytes (which we will // assume are intended to be booleans) if ($field['nature'] == 'boolean' || $field['nature'] == 'integer' && isset($field['length']) && $field['length'] <= 2) { echo "<label for=\"{$var_name}\">{$label_text}</label>\n"; echo "<input type=\"checkbox\" class=\"checkbox\" " . "id=\"{$var_name}\" name=\"{$var_name}\" value=\"1\"" . (!empty($data[$key]) ? " checked=\"checked\"" : "") . ">\n"; } elseif (!empty($select_options["users.{$key}"])) { generate_select($label_text, $var_name, $data[$key], $select_options["users.{$key}"]); } elseif ($field['nature'] == 'character' && isset($field['length']) && $field['length'] > $text_input_max) { generate_textarea($label_text, $var_name, $data[$key]); } else { generate_input($label_text, $var_name, $data[$key], FALSE, isset($maxlength["users.{$key}"]) ? $maxlength["users.{$key}"] : NULL); } break; } // end switch echo "</div>\n"; } // end switch // Then output any error messages associated with the field // except for the password field which is a special case switch ($key) { case 'email': if (!empty($invalid_email)) { echo "<p class=\"error\">" . get_vocab('invalid_email') . "</p>\n";
function create_field_entry_custom_field($field, $key, $disabled = FALSE) { global $custom_fields, $tbl_entry, $select_options; global $is_mandatory_field, $text_input_max; $var_name = VAR_PREFIX . $key; $value = $custom_fields[$key]; $label_text = get_loc_field_name($tbl_entry, $key) . ":"; $mandatory = array_key_exists("entry.{$key}", $is_mandatory_field) && $is_mandatory_field["entry.{$key}"] ? true : false; echo "<div>\n"; // Output a checkbox if it's a boolean or integer <= 2 bytes (which we will // assume are intended to be booleans) if ($field['nature'] == 'boolean' || $field['nature'] == 'integer' && isset($field['length']) && $field['length'] <= 2) { echo "<label for=\"{$var_name}\">{$label_text}</label>\n"; echo "<input type=\"checkbox\" class=\"checkbox\" " . "id=\"{$var_name}\" name=\"{$var_name}\" value=\"1\" " . (!empty($value) ? " checked=\"checked\"" : "") . ($disabled ? " disabled=\"disabled\"" : "") . ($mandatory ? " required" : "") . ">\n"; } elseif (!empty($select_options["entry.{$key}"])) { generate_select($label_text, $var_name, $value, $select_options["entry.{$key}"], $mandatory, $disabled); } elseif ($field['nature'] == 'character' && isset($field['length']) && $field['length'] > $text_input_max) { // HTML5 does not allow a pattern attribute for the textarea element $attributes = isset($is_mandatory_field["entry.{$key}"]) && $is_mandatory_field["entry.{$key}"] ? "required" : ""; generate_textarea($label_text, $var_name, $value, $disabled, $attributes); } else { $is_integer_field = $field['nature'] == 'integer' && $field['length'] > 2; if ($is_integer_field) { $attributes = 'type="number" step="1"'; } else { $attributes = 'type="text"'; } if (isset($is_mandatory_field["entry.{$key}"]) && $is_mandatory_field["entry.{$key}"]) { $attributes .= ' required'; // 'required' is not sufficient for strings, because we also want to make sure // that the string contains at least one non-whitespace character $attributes .= $is_integer_field ? '' : ' pattern="' . REGEX_TEXT_POS . '"'; } generate_input($label_text, $var_name, $value, $disabled, NULL, $attributes); } if ($disabled) { echo "<input type=\"hidden\" name=\"{$var_name}\" value=\"{$value}\">\n"; } echo "</div>\n"; }