示例#1
0
    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)) {
 $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)
示例#3
0
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('&nbsp;', 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 &nbsp; on purpose
            $values[$i] = escape($values[$i]);
        }
    }
    $head_rows = array();
    $head_rows[] = $values;
    output_head_rows($head_rows, $output_format);
}
示例#4
0
// 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
示例#5
0
 // 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']) {
    // 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) {
示例#7
0
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";
}
示例#8
0
 // 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";
 // 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) {
示例#10
0
文件: admin.php 项目: cvelayo/worklog
 // 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 &nbsp;)
         echo "<th>{$text}</th>\n";
     }
 }
 /*if ($is_admin)
   {
     echo "<th>&nbsp;</th>\n";
   }*/
 echo "</tr>\n";
 echo "</thead>\n";
 // The body
示例#11
0
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 .= "&nbsp;\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\">" : "&nbsp;";
                            $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;
}
示例#12
0
function reporton(&$row, &$last_area_room, &$last_date, $sortby, $display)
{
    global $typel;
    global $output_as_csv;
    global $csv_row_sep;
    global $custom_fields, $field_natures, $field_lengths, $tbl_entry;
    global $approval_somewhere, $confirmation_somewhere;
    global $strftime_format;
    // Initialise the line for CSV reports
    $line = "";
    // Display Area/Room, but only when it changes:
    $area_room = $row['area_name'] . " - " . $row['room_name'];
    $date = utf8_strftime($strftime_format['date'], $row['start_time']);
    // entries to be sorted on area/room
    echo $output_as_csv ? '' : "<div class=\"div_report\">\n";
    if ($sortby == "r") {
        if ($area_room != $last_area_room) {
            echo $output_as_csv ? '' : "<h2>" . get_vocab("room") . ": " . escape($area_room) . "</h2>\n";
        }
        if ($date != $last_date || $area_room != $last_area_room) {
            echo $output_as_csv ? '' : "<h3>" . get_vocab("date") . ": " . $date . "</h3>\n";
            $last_date = $date;
        }
        // remember current area/room that is being processed.
        // this is done here as the if statement above needs the old
        // values
        if ($area_room != $last_area_room) {
            $last_area_room = $area_room;
        }
    } else {
        if ($date != $last_date) {
            echo $output_as_csv ? '' : "<h2>" . get_vocab("date") . ": " . $date . "</h2>\n";
        }
        if ($area_room != $last_area_room || $date != $last_date) {
            echo $output_as_csv ? '' : "<h3>" . get_vocab("room") . ": " . escape($area_room) . "</h3>\n";
            $last_area_room = $area_room;
        }
        // remember current date that is being processed.
        // this is done here as the if statement above needs the old
        // values
        if ($date != $last_date) {
            $last_date = $date;
        }
    }
    if ($output_as_csv) {
        $line = csv_row_add_value($line, $area_room);
        // for the CSV report put the area-room name on every line
        $line = csv_row_add_value($line, $row['name']);
    } else {
        echo "<div class=\"report_entry_title\">\n";
        echo "<div class=\"report_entry_name\">\n";
        // Brief Description (title), linked to view_entry:
        echo "<a href=\"view_entry/id:" . $row['id'] . "\">" . htmlspecialchars($row['name']) . "</a>\n";
        echo "</div>\n";
    }
    echo $output_as_csv ? '' : "<div class=\"report_entry_when\">\n";
    // what do you want to display duration or end date/time
    if ($display == "d") {
        // Start date/time and duration:
        $when = empty($row['enable_periods']) ? describe_span($row['start_time'], $row['end_time']) : describe_period_span($row['start_time'], $row['end_time']);
    } else {
        // Start date/time and End date/time:
        $when = empty($row['enable_periods']) ? start_to_end($row['start_time'], $row['end_time']) : start_to_end_period($row['start_time'], $row['end_time']);
    }
    if ($output_as_csv) {
        $line = csv_row_add_value($line, $when);
    } else {
        echo "{$when}\n";
        echo "</div>\n";
        echo "</div>\n";
        echo "<table>\n";
        echo "<colgroup>\n";
        echo "<col class=\"col1\">\n";
        echo "<col class=\"col2\">\n";
        echo "</colgroup>\n";
    }
    // 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";
    }
}
    // 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";
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";
}