本文整理汇总了PHP中get_loc_field_name函数的典型用法代码示例。如果您正苦于以下问题:PHP get_loc_field_name函数的具体用法?PHP get_loc_field_name怎么用?PHP get_loc_field_name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_loc_field_name函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: get_vocab
print " <div>\n";
print " <input type=\"hidden\" name=\"Action\" value=\"Add\">\n";
print " <input type=\"hidden\" name=\"Id\" value=\"-1\">\n";
print " <input type=\"submit\" value=\"" . get_vocab("add_new_user") . "\">\n";
print " </div>\n";
print "</form>\n";
}
if ($initial_user_creation != 1) {
$list = sql_query("SELECT * FROM {$tbl_users} ORDER BY level DESC, name");
print "<table id=\"edit_users_list\" class=\"admin_table\">\n";
print "<thead>\n";
print "<tr>";
// Column headers (we don't use 'id' and 'password')
foreach ($fields as $fieldname) {
if ($fieldname != 'id' && $fieldname != 'password') {
print "<th>" . get_loc_field_name($fieldname) . "</th>";
}
}
// Last column which is an action button
print "<th>" . get_vocab("action") . "</th>";
print "</tr>\n";
print "</thead>\n";
print "<tbody>\n";
$i = 0;
while ($line = sql_row_keyed($list, $i++)) {
print "<tr>\n";
// Column contents
foreach ($line as $key => $col_value) {
// sql_row_keyed returns an array indexed by both index number annd key name,
// so skip past the index numbers
if (is_int($key)) {
开发者ID:verdurin,项目名称:mrbs-mcr,代码行数:31,代码来源:edit_users.php
示例2: array
$params = array('label' => get_vocab("room_admin_email") . ":", 'label_title' => get_vocab("email_list_note"), 'name' => 'room_admin_email', 'value' => $row['room_admin_email'], 'attributes' => array('rows="4"', 'cols="40"'), 'disabled' => $disabled, 'create_hidden' => FALSE);
generate_textarea($params);
echo "</div>\n";
// Custom HTML
if ($is_admin) {
// Only show the raw HTML to admins. Non-admins will see the rendered 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"'), 'disabled' => $disabled, 'create_hidden' => FALSE);
generate_textarea($params);
echo "</div>\n";
}
// then look at any user defined fields
foreach ($fields as $field) {
if (!in_array($field['name'], $standard_fields['room'])) {
echo "<div>\n";
$params = array('label' => get_loc_field_name($tbl_room, $field['name']) . ":", 'name' => VAR_PREFIX . $field['name'], 'value' => $row[$field['name']], 'disabled' => $disabled, 'create_hidden' => FALSE);
// 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) {
$params['attributes'] = array('rows="4"', 'cols="40"');
generate_textarea($params);
} else {
generate_input($params);
}
echo "</div>\n";
}
}
echo "</fieldset>\n";
// Submit and Back buttons (Submit only if they're an admin)
开发者ID:linuxmuster,项目名称:linuxmuster-mrbs-manager,代码行数:31,代码来源:edit_area_room.php
示例3: report_header
function report_header()
{
global $output_format, $ajax;
global $custom_fields, $tbl_entry;
global $approval_somewhere, $confirmation_somewhere;
global $field_order_list;
// Don't do anything if this is an Ajax request: we only want to send the data
if ($ajax) {
return;
}
// Build an array of values to go into the header row
$values = array();
foreach ($field_order_list as $field) {
// We give some columns an stype data value so that the JavaScript knows how to sort them
switch ($field) {
case 'name':
$values[] = get_vocab("namebooker");
break;
case 'area_name':
$values[] = get_vocab("area");
break;
case 'room_name':
$values[] = get_vocab("room");
break;
case 'start_time':
$values[] = stype_wrap(get_vocab("start_date"), 'title-numeric');
break;
case 'end_time':
$values[] = stype_wrap(get_vocab("end_date"), 'title-numeric');
$values[] = stype_wrap(get_vocab("duration"), 'title-numeric');
break;
case 'description':
$values[] = get_vocab("fulldescription_short");
break;
case 'type':
$values[] = get_vocab("type");
break;
case 'create_by':
$values[] = get_vocab("createdby");
break;
case 'confirmation_enabled':
if ($confirmation_somewhere) {
$values[] = get_vocab("confirmation_status");
}
break;
case 'approval_enabled':
if ($approval_somewhere) {
$values[] = get_vocab("approval_status");
}
break;
case 'last_updated':
$values[] = stype_wrap(get_vocab("lastupdate"), 'title-numeric');
break;
default:
// the custom fields
if (array_key_exists($field, $custom_fields)) {
$values[] = get_loc_field_name($tbl_entry, $field);
}
break;
}
// switch
}
// foreach
// Find out what the non-breaking space is in this character set
$charset = get_charset();
$nbsp = mrbs_entity_decode(' ', ENT_NOQUOTES, $charset);
for ($i = 0; $i < count($values); $i++) {
if ($output_format != OUTPUT_HTML) {
// Remove any HTML entities from the values
$values[$i] = mrbs_entity_decode($values[$i], ENT_NOQUOTES, $charset);
// Trim non-breaking spaces from the string
$values[$i] = trim($values[$i], $nbsp);
// And do an ordinary trim
$values[$i] = trim($values[$i]);
// We don't escape HTML output here because the vocab strings are trusted.
// And some of them contain HTML entities such as on purpose
$values[$i] = escape($values[$i]);
}
}
$head_rows = array();
$head_rows[] = $values;
output_head_rows($head_rows, $output_format);
}
开发者ID:bdwong-mirrors,项目名称:mrbs,代码行数:83,代码来源:report.php
示例4: invalid_booking
// Don't bother with them if this is an Ajax request.
if (!$ajax) {
if ($name == '') {
invalid_booking(get_vocab('must_set_description'));
}
if (empty($rooms)) {
invalid_booking(get_vocab('no_rooms_selected'));
}
if ($rep_type == REP_WEEKLY && $rep_num_weeks < 1) {
invalid_booking(get_vocab('you_have_not_entered') . " " . get_vocab("useful_n-weekly_value"));
}
if (count($is_mandatory_field)) {
foreach ($is_mandatory_field as $field => $value) {
$field = preg_replace('/^entry\\./', '', $field);
if ($value && array_key_exists($field, $custom_fields) && $custom_fields[$field] === '') {
invalid_booking(get_vocab('missing_mandatory_field') . ' "' . get_loc_field_name($tbl_entry, $field) . '"');
}
}
}
}
if (isset($month_relative_ord) && isset($month_relative_day)) {
$month_relative = $month_relative_ord . $month_relative_day;
}
// Handle private booking
// Enforce config file settings if needed
if ($private_mandatory) {
$isprivate = $private_default;
} else {
$isprivate = $private ? TRUE : FALSE;
}
// The id must be either an integer or NULL, so that subsequent code that tests whether
开发者ID:dev-lav,项目名称:htdocs,代码行数:31,代码来源:edit_entry_handler.php
示例5: array
// ignore these columns, either because we don't want to display them,
// or because we have already displayed them in the header column
$ignore = array('id', 'area_id', 'room_name', 'sort_key', 'custom_html');
foreach ($fields as $field) {
if (!in_array($field['name'], $ignore)) {
switch ($field['name']) {
// the standard MRBS fields
case 'description':
case 'capacity':
case 'room_admin_email':
$text = get_vocab($field['name']);
break;
// any user defined fields
// any user defined fields
default:
$text = get_loc_field_name($tbl_room, $field['name']);
break;
}
echo "<th><div>" . htmlspecialchars($text) . "</div></th>\n";
}
}
echo "</tr>\n";
echo "</thead>\n";
echo "<tbody>\n";
$row_class = "odd_row";
foreach ($rooms as $r) {
$row_class = $row_class == "even_row" ? "odd_row" : "even_row";
echo "<tr class=\"{$row_class}\">\n";
foreach ($fields as $field) {
if (!in_array($field['name'], $ignore)) {
switch ($field['name']) {
开发者ID:jessfishenden,项目名称:mrbs,代码行数:31,代码来源:admin.php
示例6: print_footer
// Print footer and exit
print_footer(TRUE);
}
if (count($is_mandatory_field)) {
foreach ($is_mandatory_field as $field => $value) {
$field = preg_replace('/^entry\\./', '', $field);
if ($value && $custom_fields[$field] == '') {
print_header($day, $month, $year, $area, isset($room) ? $room : "");
?>
<h1><?php
echo get_vocab('invalid_booking');
?>
</h1>
<p>
<?php
echo get_vocab('missing_mandatory_field') . " \"" . get_loc_field_name($tbl_entry, $field) . "\"";
?>
</p>
<?php
// Print footer and exit
print_footer(TRUE);
}
}
}
if ($enable_periods) {
$resolution = 60;
}
// When All Day is checked, $start_seconds and $end_seconds are disabled and so won't
// get passed through by the form. We therefore need to set them.
if (isset($all_day) && $all_day == "yes") {
if ($enable_periods) {
开发者ID:JeremyJacquemont,项目名称:SchoolProjects,代码行数:31,代码来源:edit_entry_handler.php
示例7: create_field_entry_custom_field
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";
}
开发者ID:jberanek,项目名称:mrbs_clone,代码行数:33,代码来源:edit_entry.php
示例8: array
// Display the data in a table
$ignore_columns = array('id', 'password', 'name');
// We don't display these columns or they get special treatment
if (!$ajax) {
echo "<div id=\"user_list\" class=\"datatable_container\">\n";
echo "<table class=\"admin_table display\" id=\"users_table\">\n";
// The table header
echo "<thead>\n";
echo "<tr>";
// First column which is the name
echo "<th>" . get_vocab("users.name") . "</th>\n";
// Other column headers
foreach ($fields as $field) {
$fieldname = $field['name'];
if (!in_array($fieldname, $ignore_columns)) {
$heading = get_loc_field_name($tbl_users, $fieldname);
// We give some columns an stype data value so that the JavaScript knows how to sort them
switch ($fieldname) {
case 'level':
$heading = '<span class="normal" data-stype="title-numeric">' . $heading . '</span>';
break;
default:
break;
}
echo "<th>{$heading}</th>";
}
}
echo "</tr>\n";
echo "</thead>\n";
// The table body
echo "<tbody>\n";
开发者ID:dev-lav,项目名称:htdocs,代码行数:31,代码来源:edit_users.php
示例9: array
// Display the data in a table
$ignore_columns = array('id', 'password', 'name');
// We don't display these columns or they get special treatment
if (!$ajax) {
echo "<div id=\"user_list\" class=\"datatable_container\">\n";
echo "<table class=\"admin_table display\" id=\"users_table\">\n";
// The table header
echo "<thead>\n";
echo "<tr>";
// First column which is the name
echo "<th>" . get_vocab("users.name") . "</th>\n";
// Other column headers
foreach ($fields as $field) {
$fieldname = $field['name'];
if (!in_array($fieldname, $ignore_columns)) {
echo "<th>" . get_loc_field_name($tbl_users, $fieldname) . "</th>";
}
}
echo "</tr>\n";
echo "</thead>\n";
// The table body
echo "<tbody>\n";
}
// If we're Ajax capable and this is not an Ajax request then don't ouput
// the table body, because that's going to be sent later in response to
// an Ajax request
if (!$ajax_capable || $ajax) {
for ($i = 0; $row = sql_row_keyed($res, $i); $i++) {
// You can only see this row if (a) we allow everybody to see all rows or
// (b) you are an admin or (c) you are this user
if (!$auth['only_admin_can_see_other_users'] || $level >= $min_user_viewing_level || strcasecmp($row['name'], $user) == 0) {
开发者ID:koroder,项目名称:Web-portal-for-academic-institution,代码行数:31,代码来源:edit_users.php
示例10: array
// ignore these columns, either because we don't want to display them,
// or because we have already displayed them in the header column
$ignore = array('id', 'area_id', 'room_name', 'disabled', 'sort_key', 'custom_html', 'code');
foreach ($fields as $field) {
if (!in_array($field['name'], $ignore)) {
switch ($field['name']) {
// the standard MRBS fields
case 'description':
case 'Face to Face':
case 'Available':
$text = get_vocab($field['name']);
break;
// any user defined fields
// any user defined fields
default:
$text = get_loc_field_name($codes, $field['name']);
$text = get_vocab($text);
break;
}
// We don't use htmlspecialchars() here because the column names are
// trusted and some of them may deliberately contain HTML entities (eg )
echo "<th>{$text}</th>\n";
}
}
/*if ($is_admin)
{
echo "<th> </th>\n";
}*/
echo "</tr>\n";
echo "</thead>\n";
// The body
开发者ID:cvelayo,项目名称:worklog,代码行数:31,代码来源:admin.php
示例11: freeze_panes_table_html
function freeze_panes_table_html($info, $columns, $class, $action = FALSE)
{
global $tbl_users, $PHP_SELF;
global $user, $level, $min_user_editing_level, $max_content_length;
global $fields;
$html = '';
$html .= "<div class=\"{$class}\">\n";
$html .= "<table class=\"admin_table\">\n";
$html .= "<thead>\n";
$html .= "<tr>";
if ($action) {
// First column which is an action button
$html .= "<th><div>" . get_vocab("action") . "</div></th>";
}
// Column headers
foreach ($fields as $field) {
$fieldname = $field['name'];
if (in_array($fieldname, $columns)) {
$html .= "<th><div>" . get_loc_field_name($tbl_users, $fieldname) . "</div></th>";
}
}
$html .= "</tr>\n";
$html .= "</thead>\n";
$html .= "<tbody>\n";
$row_class = "odd_row";
foreach ($info as $line) {
$row_class = $row_class == "even_row" ? "odd_row" : "even_row";
$html .= "<tr class=\"{$row_class}\">\n";
if ($action) {
// First column (the action button)
$html .= "<td class=\"action\"><div>\n";
// You can only edit a user if you have sufficient admin rights, or else if that user is yourself
if ($level >= $min_user_editing_level || strcasecmp($line['name'], $user) == 0) {
$html .= "<form method=\"post\" action=\"" . htmlspecialchars(basename($PHP_SELF)) . "\">\n";
$html .= "<div>\n";
$html .= "<input type=\"hidden\" name=\"Action\" value=\"Edit\">\n";
$html .= "<input type=\"hidden\" name=\"Id\" value=\"" . $line['id'] . "\">\n";
$html .= "<input type=\"image\" class=\"button\" src=\"images/edit.png\"\n title=\"" . get_vocab("edit") . "\" alt=\"" . get_vocab("edit") . "\">\n";
$html .= "</div>\n";
$html .= "</form>\n";
} else {
$html .= " \n";
}
$html .= "</div></td>\n";
}
// Column contents
foreach ($fields as $field) {
$key = $field['name'];
if (in_array($key, $columns)) {
$col_value = $line[$key];
switch ($key) {
// special treatment for some fields
case 'level':
// the level field contains a code and we want to display a string
$html .= "<td><div>" . get_vocab("level_{$col_value}") . "</div></td>\n";
break;
case 'email':
// we don't want to truncate the email address
$html .= "<td><div>" . htmlspecialchars($col_value) . "</div></td>\n";
break;
default:
if ($field['nature'] == 'boolean' || $field['nature'] == 'integer' && isset($field['length']) && $field['length'] <= 2) {
// booleans: represent by a checkmark
$html .= "<td class=\"int\"><div>";
$html .= !empty($col_value) ? "<img src=\"images/check.png\" alt=\"check mark\" width=\"16\" height=\"16\">" : " ";
$html .= "</div></td>\n";
} elseif ($field['nature'] == 'integer' && isset($field['length']) && $field['length'] > 2) {
// integer values
$html .= "<td class=\"int\"><div>" . $col_value . "</div></td>\n";
} else {
// strings
$text = htmlspecialchars($col_value);
$html .= "<td title=\"{$text}\"><div>";
$html .= substr($text, 0, $max_content_length);
$html .= strlen($text) > $max_content_length ? " ..." : "";
$html .= "</div></td>\n";
}
break;
}
// end switch
}
}
// end foreach
$html .= "</tr>\n";
}
// end while
$html .= "</tbody>\n";
$html .= "</table>\n";
$html .= "</div>\n";
return $html;
}
开发者ID:jessfishenden,项目名称:mrbs,代码行数:91,代码来源:edit_users.php
示例12: reporton
//.........这里部分代码省略.........
// Description:
if ($output_as_csv) {
$line = csv_row_add_value($line, $row['description']);
} else {
echo "<tr>\n";
echo "<td>" . get_vocab("description") . ":</td>\n";
echo "<td>" . escape($row['description']) . "</td>\n";
echo "</tr>\n";
}
// Entry Type:
$et = empty($typel[$row['type']]) ? "?" . $row['type'] . "?" : $typel[$row['type']];
if ($output_as_csv) {
$line = csv_row_add_value($line, $et);
} else {
echo "<tr>\n";
echo "<td>" . get_vocab("type") . ":</td>\n";
echo "<td>" . escape($et) . "</td>\n";
echo "</tr>\n";
}
// Created by:
if ($output_as_csv) {
$line = csv_row_add_value($line, $row['create_by']);
} else {
echo "<tr>\n";
echo "<td>" . get_vocab("createdby") . ":</td>\n";
echo "<td>" . escape($row['create_by']) . "</td>\n";
echo "</tr>\n";
}
// Confirmation status
if ($confirmation_somewhere) {
// Translate the status field bit into meaningful text
if ($row['confirmation_enabled']) {
$confirmation_status = $row['status'] & STATUS_TENTATIVE ? get_vocab("tentative") : get_vocab("confirmed");
} else {
$confirmation_status = '';
}
// Now output the text
if ($output_as_csv) {
$line = csv_row_add_value($line, $confirmation_status);
} else {
echo "<tr>\n";
echo "<td>" . get_vocab("confirmation_status") . ":</td>\n";
echo "<td>" . escape($confirmation_status) . "</td>\n";
echo "</tr>\n";
}
}
// Approval status
if ($approval_somewhere) {
// Translate the status field bit into meaningful text
if ($row['approval_enabled']) {
$approval_status = $row['status'] & STATUS_AWAITING_APPROVAL ? get_vocab("awaiting_approval") : get_vocab("approved");
} else {
$approval_status = '';
}
// Now output the text
if ($output_as_csv) {
$line = csv_row_add_value($line, $approval_status);
} else {
echo "<tr>\n";
echo "<td>" . get_vocab("approval_status") . ":</td>\n";
echo "<td>" . escape($approval_status) . "</td>\n";
echo "</tr>\n";
}
}
// Now do any custom fields
foreach ($custom_fields as $key => $value) {
// Output a yes/no if it's a boolean or integer <= 2 bytes (which we will
// assume are intended to be booleans)
if ($field_natures[$key] == 'boolean' || $field_natures[$key] == 'integer' && isset($field_lengths[$key]) && $field_lengths[$key] <= 2) {
$output = empty($row[$key]) ? get_vocab("no") : get_vocab("yes");
} else {
$output = isset($row[$key]) ? $row[$key] : '';
}
if ($output_as_csv) {
$line = csv_row_add_value($line, $output);
} else {
echo "<tr>\n";
echo "<td>" . get_loc_field_name($tbl_entry, $key) . ":</td>\n";
echo "<td>" . escape($output) . "</td>\n";
echo "</tr>\n";
}
}
// Last updated:
if ($output_as_csv) {
$line = csv_row_add_value($line, time_date_string($row['last_updated']));
} else {
echo "<tr>\n";
echo "<td>" . get_vocab("lastupdate") . ":</td>\n";
echo "<td>" . time_date_string($row['last_updated']) . "</td>\n";
echo "</tr>\n";
}
if ($output_as_csv) {
// terminate and output the line
$line .= $csv_row_sep;
echo $line;
} else {
echo "</table>\n";
echo "</div>\n\n";
}
}
开发者ID:JeremyJacquemont,项目名称:SchoolProjects,代码行数:101,代码来源:report.php
示例13: get_vocab
// No need to pass through a hidden variable if disabled because the handler will sort it out
echo "<div id=\"div_privacy_status\">\n";
echo "<label>" . get_vocab("privacy_status") . ":</label>\n";
echo "<div class=\"group\">\n";
echo "<label><input class=\"radio\" name=\"private\" type=\"radio\" value=\"0\"" . ($private ? "" : " checked=\"checked\"") . ($private_mandatory ? " disabled=\"disabled\"" : "") . ">" . get_vocab("public") . "</label>\n";
echo "<label><input class=\"radio\" name=\"private\" type=\"radio\" value=\"1\"" . ($private ? " checked=\"checked\"" : "") . ($private_mandatory ? " disabled=\"disabled\"" : "") . ">" . get_vocab("private") . "</label>\n";
echo "</div>\n";
echo "</div>\n";
}
// CUSTOM FIELDS
foreach ($fields as $field) {
$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";
开发者ID:JeremyJacquemont,项目名称:SchoolProjects,代码行数:31,代码来源:edit_entry.php
示例14: create_field_entry_custom_field
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";
}
开发者ID:koroder,项目名称:Web-portal-for-academic-institution,代码行数:40,代码来源:edit_entry.php
注:本文中的get_loc_field_name函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论