$vn_end_result = $vn_current_page * $vn_items_per_page;
    if ($vn_end_result > $vn_num_results) {
        $vn_end_result = $vn_num_results;
    }
    print "<div id='searchResultHeading'>" . _t("Items in this collection: %1", $vn_num_results) . "</div>";
    print "<div id='searchCount'>" . _t("Showing %1 - %2 of %3:", $vn_start_result, $vn_end_result, $vn_num_results) . "</div>";
    ?>
				<div id="itemResults">
<?php 
    $vn_item_num_label = $vn_start_result;
    while ($vn_itemc < $vn_items_per_page && $qr_hits->nextHit()) {
        $vs_idno = $qr_hits->get('ca_occurrences.idno');
        $vn_occurrence_id = $qr_hits->get('ca_occurrences.occurrence_id');
        $vs_description = $qr_hits->get('ca_occurrences.pbcoreDescription.description_text');
        if (strlen($vs_description) > 185) {
            $vs_description = trim(unicode_substr($vs_description, 0, 185)) . "...";
        }
        $va_labels = $qr_hits->getDisplayLabels($this->request);
        print "<div class='result'>" . $vn_item_num_label . ") ";
        print caNavLink($this->request, join($va_labels, ", "), '', 'Detail', 'Occurrence', 'Show', array('occurrence_id' => $vn_occurrence_id));
        print "<div class='resultDescription'>" . $vs_description;
        print "<img src='" . $this->request->getThemeUrlPath() . "/graphics/nhf/cross.gif' width='8' height='8' border='0' style='margin: 0px 3px 0px 15px;'>";
        print caNavLink($this->request, _t("more"), '', 'Detail', 'Occurrence', 'Show', array('occurrence_id' => $vn_occurrence_id));
        print "</div><!-- end description -->";
        print "</div>\n";
        $vn_itemc++;
        $vn_item_num_label++;
    }
    if ($vn_total_pages > 1) {
        $va_other_paging_parameters = array('collection_id' => $vn_collection_id, 'show_type_id' => intval($this->getVar('current_type_id')));
        ?>
Beispiel #2
0
					<div id='setItemContainer<?php 
        print $vn_item_id;
        ?>
' class='imagecontainer'>
						<div class='remove'><a href='#' class='setDeleteButton' id='setItemDelete<?php 
        print $vn_item_id;
        ?>
'>X</a></div>
						<div class='setItemThumbnail'>
<?php 
        if ($va_item['representation_tag_thumbnail']) {
            print caNavLink($this->request, $va_item['representation_tag_thumbnail'], '', 'Detail', 'Object', 'Show', array('object_id' => $va_item['row_id']));
        }
        if ($va_item['name']) {
            if (unicode_strlen($va_item['name']) > 70) {
                $va_title[] = '<em>' . unicode_substr($va_item['name'], 0, 67) . '...</em>';
            } else {
                $va_title[] = '<em>' . $va_item['name'] . '</em>';
            }
        }
        if ($va_item['idno']) {
            $va_title[] = $va_item['idno'];
        }
        $vs_title = join('<br/>', $va_title);
        ?>
						</div>
						<div id='caption<?php 
        print $vn_item_id;
        ?>
' class='setItemCaption'><?php 
        print caNavLink($this->request, $vs_title, '', 'Detail', 'Object', 'Show', array('object_id' => $va_item['row_id']));
Beispiel #3
0
 /**
  * HTML Form element generation
  * Optional name parameter allows you to generate a form element for a field but give it a
  * name different from the field name
  * 
  * @param string $ps_field field name
  * @param string $ps_format field format
  * @param array $pa_options additional options
  * TODO: document them.
  */
 public function htmlFormElement($ps_field, $ps_format = null, $pa_options = null)
 {
     $o_db = $this->getDb();
     // init options
     if (!is_array($pa_options)) {
         $pa_options = array();
     }
     foreach (array('display_form_field_tips', 'classname', 'maxOptionLength', 'textAreaTagName', 'display_use_count', 'display_omit_items__with_zero_count', 'display_use_count_filters', 'display_use_count_filters', 'selection', 'name', 'value', 'dont_show_null_value', 'size', 'multiple', 'show_text_field_for_vars', 'nullOption', 'empty_message', 'displayMessageForFieldValues', 'DISPLAY_FIELD', 'WHERE', 'select_item_text', 'hide_select_if_only_one_option', 'field_errors', 'display_form_field_tips', 'form_name', 'no_tooltips', 'tooltip_namespace', 'extraLabelText', 'width', 'height', 'label', 'list_code', 'hide_select_if_no_options', 'id', 'lookup_url', 'progress_indicator', 'error_icon', 'maxPixelWidth', 'displayMediaVersion', 'FIELD_TYPE', 'DISPLAY_TYPE', 'choiceList', 'readonly', 'description', 'hidden') as $vs_key) {
         if (!isset($pa_options[$vs_key])) {
             $pa_options[$vs_key] = null;
         }
     }
     $va_attr = $this->getFieldInfo($ps_field);
     foreach (array('DISPLAY_WIDTH', 'DISPLAY_USE_COUNT', 'DISPLAY_SHOW_COUNT', 'DISPLAY_OMIT_ITEMS_WITH_ZERO_COUNT', 'DISPLAY_TYPE', 'IS_NULL', 'DEFAULT_ON_NULL', 'DEFAULT', 'LIST_MULTIPLE_DELIMITER', 'FIELD_TYPE', 'LIST_CODE', 'DISPLAY_FIELD', 'WHERE', 'DISPLAY_WHERE', 'DISPLAY_ORDERBY', 'LIST', 'BOUNDS_CHOICE_LIST', 'BOUNDS_LENGTH', 'DISPLAY_DESCRIPTION', 'LABEL', 'DESCRIPTION', 'SUB_LABEL', 'SUB_DESCRIPTION', 'MAX_PIXEL_WIDTH') as $vs_key) {
         if (!isset($va_attr[$vs_key])) {
             $va_attr[$vs_key] = null;
         }
     }
     if (isset($pa_options['FIELD_TYPE'])) {
         $va_attr['FIELD_TYPE'] = $pa_options['FIELD_TYPE'];
     }
     if (isset($pa_options['DISPLAY_TYPE'])) {
         $va_attr['DISPLAY_TYPE'] = $pa_options['DISPLAY_TYPE'];
     }
     $vn_display_width = isset($pa_options['width']) && $pa_options['width'] > 0 ? $pa_options['width'] : $va_attr["DISPLAY_WIDTH"];
     $vn_display_height = isset($pa_options['height']) && $pa_options['height'] > 0 ? $pa_options['height'] : $va_attr["DISPLAY_HEIGHT"];
     $va_parsed_width = caParseFormElementDimension($vn_display_width);
     $va_parsed_height = caParseFormElementDimension($vn_display_height);
     $va_dim_styles = array();
     if ($va_parsed_width['type'] == 'pixels') {
         $va_dim_styles[] = "width: " . $va_parsed_width['dimension'] . "px;";
     }
     if ($va_parsed_height['type'] == 'pixels') {
         $va_dim_styles[] = "height: " . $va_parsed_height['dimension'] . "px;";
     }
     //if ($vn_max_pixel_width) {
     //	$va_dim_styles[] = "max-width: {$vn_max_pixel_width}px;";
     //}
     $vs_dim_style = trim(join(" ", $va_dim_styles));
     $vs_field_label = isset($pa_options['label']) && strlen($pa_options['label']) > 0 ? $pa_options['label'] : $va_attr["LABEL"];
     $vs_errors = '';
     // TODO: PULL THIS FROM A CONFIG FILE
     $pa_options["display_form_field_tips"] = true;
     if (isset($pa_options['classname'])) {
         $vs_css_class_attr = ' class="' . $pa_options['classname'] . '" ';
     } else {
         $vs_css_class_attr = '';
     }
     if (!isset($pa_options['id'])) {
         $pa_options['id'] = $pa_options['name'];
     }
     if (!isset($pa_options['id'])) {
         $pa_options['id'] = $ps_field;
     }
     if (!isset($pa_options['maxPixelWidth']) || (int) $pa_options['maxPixelWidth'] <= 0) {
         $vn_max_pixel_width = $va_attr['MAX_PIXEL_WIDTH'];
     } else {
         $vn_max_pixel_width = (int) $pa_options['maxPixelWidth'];
     }
     if ($vn_max_pixel_width <= 0) {
         $vn_max_pixel_width = null;
     }
     if (!isset($pa_options["maxOptionLength"]) && isset($vn_display_width)) {
         $pa_options["maxOptionLength"] = isset($vn_display_width) ? $vn_display_width : null;
     }
     $vs_text_area_tag_name = 'textarea';
     if (isset($pa_options["textAreaTagName"]) && $pa_options['textAreaTagName']) {
         $vs_text_area_tag_name = isset($pa_options['textAreaTagName']) ? $pa_options['textAreaTagName'] : null;
     }
     if (!isset($va_attr["DISPLAY_USE_COUNT"]) || !($vs_display_use_count = $va_attr["DISPLAY_USE_COUNT"])) {
         $vs_display_use_count = isset($pa_options["display_use_count"]) ? $pa_options["display_use_count"] : null;
     }
     if (!isset($va_attr["DISPLAY_SHOW_COUNT"]) || !($vb_display_show_count = (bool) $va_attr["DISPLAY_SHOW_COUNT"])) {
         $vb_display_show_count = isset($pa_options["display_show_count"]) ? (bool) $pa_options["display_show_count"] : null;
     }
     if (!isset($va_attr["DISPLAY_OMIT_ITEMS_WITH_ZERO_COUNT"]) || !($vb_display_omit_items__with_zero_count = (bool) $va_attr["DISPLAY_OMIT_ITEMS_WITH_ZERO_COUNT"])) {
         $vb_display_omit_items__with_zero_count = isset($pa_options["display_omit_items__with_zero_count"]) ? (bool) $pa_options["display_omit_items__with_zero_count"] : null;
     }
     if (!isset($va_attr["DISPLAY_OMIT_ITEMS_WITH_ZERO_COUNT"]) || !($va_display_use_count_filters = $va_attr["DISPLAY_USE_COUNT_FILTERS"])) {
         $va_display_use_count_filters = isset($pa_options["display_use_count_filters"]) ? $pa_options["display_use_count_filters"] : null;
     }
     if (!isset($va_display_use_count_filters) || !is_array($va_display_use_count_filters)) {
         $va_display_use_count_filters = null;
     }
     if (isset($pa_options["selection"]) && is_array($pa_options["selection"])) {
         $va_selection = isset($pa_options["selection"]) ? $pa_options["selection"] : null;
     } else {
         $va_selection = array();
     }
     if (isset($pa_options["choiceList"]) && is_array($pa_options["choiceList"])) {
         $va_attr["BOUNDS_CHOICE_LIST"] = $pa_options["choiceList"];
     }
     $vs_element = $vs_subelement = "";
     if ($va_attr) {
         # --- Skip omitted fields completely
         if ($va_attr["DISPLAY_TYPE"] == DT_OMIT) {
             return "";
         }
         if (!isset($pa_options["name"]) || !$pa_options["name"]) {
             $pa_options["name"] = htmlspecialchars($ps_field, ENT_QUOTES, 'UTF-8');
         }
         $va_js = array();
         $va_handlers = array("onclick", "onchange", "onkeypress", "onkeydown", "onkeyup");
         foreach ($va_handlers as $vs_handler) {
             if (isset($pa_options[$vs_handler]) && $pa_options[$vs_handler]) {
                 $va_js[] = "{$vs_handler}='" . $pa_options[$vs_handler] . "'";
             }
         }
         $vs_js = join(" ", $va_js);
         if (!isset($pa_options["value"])) {
             // allow field value to be overriden with value from options array
             $vm_field_value = $this->get($ps_field, $pa_options);
         } else {
             $vm_field_value = $pa_options["value"];
         }
         $vm_raw_field_value = $vm_field_value;
         $vb_is_null = isset($va_attr["IS_NULL"]) ? $va_attr["IS_NULL"] : false;
         if (isset($pa_options['dont_show_null_value']) && $pa_options['dont_show_null_value']) {
             $vb_is_null = false;
         }
         if (!is_array($vm_field_value) && strlen($vm_field_value) == 0 && (!isset($vb_is_null) || !$vb_is_null || (isset($va_attr["DEFAULT_ON_NULL"]) ? $va_attr["DEFAULT_ON_NULL"] : 0))) {
             $vm_field_value = isset($va_attr["DEFAULT"]) ? $va_attr["DEFAULT"] : "";
         }
         # --- Return hidden fields
         if ($va_attr["DISPLAY_TYPE"] == DT_HIDDEN || caGetOption('hidden', $pa_options, false)) {
             return '<input type="hidden" name="' . $pa_options["name"] . '" value="' . $this->escapeHTML($vm_field_value) . '"/>';
         }
         if (isset($pa_options["size"]) && $pa_options["size"] > 0) {
             $ps_size = " size='" . $pa_options["size"] . "'";
         } else {
             if (($va_attr["DISPLAY_TYPE"] == DT_LIST_MULTIPLE || $va_attr["DISPLAY_TYPE"] == DT_LIST) && $vn_display_height > 1) {
                 $ps_size = " size='" . $vn_display_height . "'";
             } else {
                 $ps_size = '';
             }
         }
         $vs_multiple_name_extension = '';
         if ($vs_is_multiple = isset($pa_options["multiple"]) && $pa_options["multiple"] || $va_attr["DISPLAY_TYPE"] == DT_LIST_MULTIPLE ? "multiple='1'" : "") {
             $vs_multiple_name_extension = '[]';
             if (!($vs_list_multiple_delimiter = $va_attr['LIST_MULTIPLE_DELIMITER'])) {
                 $vs_list_multiple_delimiter = ';';
             }
             $va_selection = array_merge($va_selection, explode($vs_list_multiple_delimiter, $vm_field_value));
         }
         # --- Return form element
         switch ($va_attr["FIELD_TYPE"]) {
             # ----------------------------
             case FT_NUMBER:
             case FT_TEXT:
             case FT_VARS:
                 if ($va_attr["FIELD_TYPE"] == FT_VARS) {
                     if (!$pa_options['show_text_field_for_vars']) {
                         break;
                     }
                     if (!is_string($vm_field_value) && !is_numeric($vm_field_value)) {
                         $vm_value = '';
                     }
                 }
                 if ($va_attr['DISPLAY_TYPE'] == DT_COUNTRY_LIST) {
                     $vs_element = caHTMLSelect($ps_field, caGetCountryList(), array('id' => $ps_field), array('value' => $vm_field_value));
                     if ($va_attr['STATEPROV_FIELD']) {
                         $vs_element .= "<script type='text/javascript'>\n";
                         $vs_element .= "var caStatesByCountryList = " . json_encode(caGetStateList()) . ";\n";
                         $vs_element .= "\n\t\t\t\t\t\t\t\tjQuery('#{$ps_field}').click({countryID: '{$ps_field}', stateProvID: '" . $va_attr['STATEPROV_FIELD'] . "', value: '" . addslashes($this->get($va_attr['STATEPROV_FIELD'])) . "', statesByCountryList: caStatesByCountryList}, caUI.utils.updateStateProvinceForCountry);\n\t\t\t\t\t\t\t\tjQuery(document).ready(function() {\n\t\t\t\t\t\t\t\t\tcaUI.utils.updateStateProvinceForCountry({data: {countryID: '{$ps_field}', stateProvID: '" . $va_attr['STATEPROV_FIELD'] . "', value: '" . addslashes($this->get($va_attr['STATEPROV_FIELD'])) . "', statesByCountryList: caStatesByCountryList}});\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t";
                         $vs_element .= "</script>\n";
                     }
                     break;
                 }
                 if ($va_attr['DISPLAY_TYPE'] == DT_STATEPROV_LIST) {
                     $vs_element = caHTMLSelect($ps_field . '_select', array(), array('id' => $ps_field . '_select'), array('value' => $vm_field_value));
                     $vs_element .= caHTMLTextInput($ps_field . '_name', array('id' => $ps_field . '_text', 'value' => $vm_field_value));
                     break;
                 }
                 if ($vn_display_width > 0 && in_array($va_attr["DISPLAY_TYPE"], array(DT_SELECT, DT_LIST, DT_LIST_MULTIPLE))) {
                     #
                     # Generate auto generated <select> (from foreign key, from ca_lists or from field-defined choice list)
                     #
                     # TODO: CLEAN UP THIS CODE, RUNNING VARIOUS STAGES THROUGH HELPER FUNCTIONS; ALSO FORMALIZE AND DOCUMENT VARIOUS OPTIONS
                     // -----
                     // from ca_lists
                     // -----
                     if (!($vs_list_code = $pa_options['list_code'])) {
                         if (isset($va_attr['LIST_CODE']) && $va_attr['LIST_CODE']) {
                             $vs_list_code = $va_attr['LIST_CODE'];
                         }
                     }
                     if ($vs_list_code) {
                         $va_many_to_one_relations = $this->_DATAMODEL->getManyToOneRelations($this->tableName());
                         if ($va_many_to_one_relations[$ps_field]) {
                             $vs_key = 'item_id';
                         } else {
                             $vs_key = 'item_value';
                         }
                         $vs_null_option = null;
                         if (!$pa_options["nullOption"] && $vb_is_null) {
                             $vs_null_option = _t("- NONE -");
                         } else {
                             if ($pa_options["nullOption"]) {
                                 $vs_null_option = $pa_options["nullOption"];
                             }
                         }
                         $t_list = new ca_lists();
                         $va_list_attrs = array('id' => $pa_options['id']);
                         //if ($vn_max_pixel_width) { $va_list_attrs['style'] = $vs_width_style; }
                         if (method_exists($this, 'getTypeFieldName') && $ps_field == $this->getTypeFieldName()) {
                             $va_limit_list = caGetTypeListForUser($this->tableName(), array('access' => __CA_BUNDLE_ACCESS_EDIT__));
                         }
                         // NOTE: "raw" field value (value passed into method, before the model default value is applied) is used so as to allow the list default to be used if needed
                         $vs_element = $t_list->getListAsHTMLFormElement($vs_list_code, $pa_options["name"] . $vs_multiple_name_extension, $va_list_attrs, array('value' => $vm_raw_field_value, 'key' => $vs_key, 'nullOption' => $vs_null_option, 'readonly' => $pa_options['readonly'], 'restrictTypeListForTable' => $this->tableName(), 'limitToItemsWithID' => $va_limit_list ? $va_limit_list : null));
                         if (isset($pa_options['hide_select_if_no_options']) && $pa_options['hide_select_if_no_options'] && !$vs_element) {
                             $vs_element = "";
                             $ps_format = '^ERRORS^ELEMENT';
                         }
                     } else {
                         // -----
                         // from related table
                         // -----
                         $va_many_to_one_relations = $this->_DATAMODEL->getManyToOneRelations($this->tableName());
                         if (isset($va_many_to_one_relations[$ps_field]) && $va_many_to_one_relations[$ps_field]) {
                             #
                             # Use foreign  key to populate <select>
                             #
                             $o_one_table = $this->_DATAMODEL->getTableInstance($va_many_to_one_relations[$ps_field]["one_table"]);
                             $vs_one_table_primary_key = $o_one_table->primaryKey();
                             if ($o_one_table->isHierarchical()) {
                                 #
                                 # Hierarchical <select>
                                 #
                                 $va_hier = $o_one_table->getHierarchyAsList(0, $vs_display_use_count, $va_display_use_count_filters, $vb_display_omit_items__with_zero_count);
                                 if (!is_array($va_hier)) {
                                     return '';
                                 }
                                 $va_display_fields = $va_attr["DISPLAY_FIELD"];
                                 if (!in_array($vs_one_table_primary_key, $va_display_fields)) {
                                     $va_display_fields[] = $o_one_table->tableName() . "." . $vs_one_table_primary_key;
                                 }
                                 if (!is_array($va_display_fields) || sizeof($va_display_fields) < 1) {
                                     $va_display_fields = array("*");
                                 }
                                 $vs_hier_parent_id_fld = $o_one_table->getProperty("HIER_PARENT_ID_FLD");
                                 $va_options = array();
                                 if ($pa_options["nullOption"]) {
                                     $va_options[""] = array($pa_options["nullOption"]);
                                 }
                                 $va_suboptions = array();
                                 $va_suboption_values = array();
                                 $vn_selected = 0;
                                 $vm_cur_top_level_val = null;
                                 $vm_selected_top_level_val = null;
                                 foreach ($va_hier as $va_option) {
                                     if (!$va_option["NODE"][$vs_hier_parent_id_fld]) {
                                         continue;
                                     }
                                     $vn_val = $va_option["NODE"][$o_one_table->primaryKey()];
                                     $vs_selected = $vn_val == $vm_field_value ? 'selected="1"' : "";
                                     $vn_indent = $va_option["LEVEL"] - 1;
                                     $va_display_data = array();
                                     foreach ($va_display_fields as $vs_fld) {
                                         $va_bits = explode(".", $vs_fld);
                                         if ($va_bits[1] != $vs_one_table_primary_key) {
                                             $va_display_data[] = $va_option["NODE"][$va_bits[1]];
                                         }
                                     }
                                     $vs_option_label = join(" ", $va_display_data);
                                     $va_options[$vn_val] = array($vs_option_label, $vn_indent, $va_option["HITS"], $va_option['NODE']);
                                 }
                                 if (sizeof($va_options) == 0) {
                                     $vs_element = isset($pa_options['empty_message']) ? $pa_options['empty_message'] : 'No options available';
                                 } else {
                                     $vs_element = "<select name='" . $pa_options["name"] . $vs_multiple_name_extension . "' " . $vs_js . " " . $vs_is_multiple . " " . $ps_size . " id='" . $pa_options["id"] . $vs_multiple_name_extension . "' {$vs_css_class_attr}  style='{$vs_dim_style}'" . ($pa_options['readonly'] ? ' disabled="disabled" ' : '') . ">\n";
                                     if (!$pa_options["nullOption"] && $vb_is_null) {
                                         $vs_element .= "<option value=''>" . _t('- NONE -') . "</option>\n";
                                     } else {
                                         if ($pa_options["nullOption"]) {
                                             $vs_element .= "<option value=''>" . $pa_options["nullOption"] . "</option>\n";
                                         }
                                     }
                                     foreach ($va_options as $vn_val => $va_option_info) {
                                         $vs_selected = $vn_val == $vm_field_value || in_array($vn_val, $va_selection) ? "selected='selected'" : "";
                                         $vs_element .= "<option value='" . $vn_val . "' {$vs_selected}>";
                                         $vn_indent = $va_option_info[1] * 2;
                                         $vs_indent = "";
                                         if ($vn_indent > 0) {
                                             $vs_indent = str_repeat("&nbsp;", ($vn_indent - 1) * 2) . " ";
                                             $vn_indent++;
                                         }
                                         $vs_option_text = $va_option_info[0];
                                         $vs_use_count = "";
                                         if ($vs_display_use_count && $vb_display_show_count && $vn_val != "") {
                                             $vs_use_count = " (" . intval($va_option_info[2]) . ")";
                                         }
                                         $vs_display_message = '';
                                         if (is_array($pa_options['displayMessageForFieldValues'])) {
                                             foreach ($pa_options['displayMessageForFieldValues'] as $vs_df => $va_df_vals) {
                                                 if (isset($va_option_info[3][$vs_df]) && is_array($va_df_vals)) {
                                                     $vs_tmp = $va_option_info[3][$vs_df];
                                                     if (isset($va_df_vals[$vs_tmp])) {
                                                         $vs_display_message = ' ' . $va_df_vals[$vs_tmp];
                                                     }
                                                 }
                                             }
                                         }
                                         if ($pa_options["maxOptionLength"] && strlen($vs_option_text) + strlen($vs_use_count) + $vn_indent > $pa_options["maxOptionLength"]) {
                                             if (($vn_strlen = $pa_options["maxOptionLength"] - strlen($vs_indent) - strlen($vs_use_count) - 3) < $pa_options["maxOptionLength"]) {
                                                 $vn_strlen = $pa_options["maxOptionLength"];
                                             }
                                             $vs_option_text = unicode_substr($vs_option_text, 0, $vn_strlen) . "...";
                                         }
                                         $vs_element .= $vs_indent . $vs_option_text . $vs_use_count . $vs_display_message . "</option>\n";
                                     }
                                     $vs_element .= "</select>\n";
                                 }
                             } else {
                                 #
                                 # "Flat" <select>
                                 #
                                 if (!is_array($va_display_fields = $pa_options["DISPLAY_FIELD"])) {
                                     $va_display_fields = $va_attr["DISPLAY_FIELD"];
                                 }
                                 if (!is_array($va_display_fields)) {
                                     return "Configuration error: DISPLAY_FIELD directive for field '{$ps_field}' must be an array of field names in the format tablename.fieldname";
                                 }
                                 if (!in_array($vs_one_table_primary_key, $va_display_fields)) {
                                     $va_display_fields[] = $o_one_table->tableName() . "." . $vs_one_table_primary_key;
                                 }
                                 if (!is_array($va_display_fields) || sizeof($va_display_fields) < 1) {
                                     $va_display_fields = array("*");
                                 }
                                 $vs_sql = "\n\t\t\t\t\t\t\t\t\t\t\tSELECT *\n\t\t\t\t\t\t\t\t\t\t\tFROM " . $va_many_to_one_relations[$ps_field]["one_table"] . "\n\t\t\t\t\t\t\t\t\t\t\t";
                                 if (isset($pa_options["WHERE"]) && (is_array($pa_options["WHERE"]) && ($vs_where = join(" AND ", $pa_options["WHERE"]))) || is_array($va_attr["DISPLAY_WHERE"]) && ($vs_where = join(" AND ", $va_attr["DISPLAY_WHERE"]))) {
                                     $vs_sql .= " WHERE {$vs_where} ";
                                 }
                                 if (isset($va_attr["DISPLAY_ORDERBY"]) && $va_attr["DISPLAY_ORDERBY"] && ($vs_orderby = join(",", $va_attr["DISPLAY_ORDERBY"]))) {
                                     $vs_sql .= " ORDER BY {$vs_orderby} ";
                                 }
                                 $qr_res = $o_db->query($vs_sql);
                                 if ($o_db->numErrors()) {
                                     $vs_element = "Error creating menu: " . join(';', $o_db->getErrors());
                                     break;
                                 }
                                 $va_opts = array();
                                 if (isset($pa_options["nullOption"]) && $pa_options["nullOption"]) {
                                     $va_opts[$pa_options["nullOption"]] = array($pa_options["nullOption"], null);
                                 } else {
                                     if ($vb_is_null) {
                                         $va_opts[_t("- NONE -")] = array(_t("- NONE -"), null);
                                     }
                                 }
                                 if ($pa_options["select_item_text"]) {
                                     $va_opts[$pa_options["select_item_text"]] = array($pa_options["select_item_text"], null);
                                 }
                                 $va_fields = array();
                                 foreach ($va_display_fields as $vs_field) {
                                     $va_tmp = explode(".", $vs_field);
                                     $va_fields[] = $va_tmp[1];
                                 }
                                 while ($qr_res->nextRow()) {
                                     $vs_display = "";
                                     foreach ($va_fields as $vs_field) {
                                         if ($vs_field != $vs_one_table_primary_key) {
                                             $vs_display .= $qr_res->get($vs_field) . " ";
                                         }
                                     }
                                     $va_opts[] = array($vs_display, $qr_res->get($vs_one_table_primary_key), $qr_res->getRow());
                                 }
                                 if (sizeof($va_opts) == 0) {
                                     $vs_element = isset($pa_options['empty_message']) ? $pa_options['empty_message'] : 'No options available';
                                 } else {
                                     if (isset($pa_options['hide_select_if_only_one_option']) && $pa_options['hide_select_if_only_one_option'] && sizeof($va_opts) == 1) {
                                         $vs_element = "<input type='hidden' name='" . $pa_options["name"] . "' " . $vs_js . " " . $ps_size . " id='" . $pa_options["id"] . "' value='" . ($vm_field_value ? $vm_field_value : $va_opts[0][1]) . "' {$vs_css_class_attr}/>";
                                         $ps_format = '^ERRORS^ELEMENT';
                                     } else {
                                         $vs_element = "<select name='" . $pa_options["name"] . $vs_multiple_name_extension . "' " . $vs_js . " " . $vs_is_multiple . " " . $ps_size . " id='" . $pa_options["id"] . $vs_multiple_name_extension . "' {$vs_css_class_attr} style='{$vs_dim_style}'" . ($pa_options['readonly'] ? ' disabled="disabled" ' : '') . ">\n";
                                         foreach ($va_opts as $va_opt) {
                                             $vs_option_text = $va_opt[0];
                                             $vs_value = $va_opt[1];
                                             $vs_selected = $vs_value == $vm_field_value || in_array($vs_value, $va_selection) ? "selected='selected'" : "";
                                             $vs_use_count = "";
                                             if ($vs_display_use_count && $vb_display_show_count && $vs_value != "") {
                                                 //$vs_use_count = "(".intval($va_option_info[2]).")";
                                             }
                                             if ($pa_options["maxOptionLength"] && strlen($vs_option_text) + strlen($vs_use_count) > $pa_options["maxOptionLength"]) {
                                                 $vs_option_text = unicode_substr($vs_option_text, 0, $pa_options["maxOptionLength"] - 3 - strlen($vs_use_count)) . "...";
                                             }
                                             $vs_display_message = '';
                                             if (is_array($pa_options['displayMessageForFieldValues'])) {
                                                 foreach ($pa_options['displayMessageForFieldValues'] as $vs_df => $va_df_vals) {
                                                     if (isset($va_opt[2][$vs_df]) && is_array($va_df_vals)) {
                                                         $vs_tmp = $va_opt[2][$vs_df];
                                                         if (isset($va_df_vals[$vs_tmp])) {
                                                             $vs_display_message = ' ' . $va_df_vals[$vs_tmp];
                                                         }
                                                     }
                                                 }
                                             }
                                             $vs_element .= "<option value='{$vs_value}' {$vs_selected}>";
                                             $vs_element .= $vs_option_text . $vs_use_count . $vs_display_message;
                                             $vs_element .= "</option>\n";
                                         }
                                         $vs_element .= "</select>\n";
                                     }
                                 }
                             }
                         } else {
                             #
                             # choice list
                             #
                             $vs_element = '';
                             // if 'LIST' is set try to stock over choice list with the contents of the list
                             if (isset($va_attr['LIST']) && $va_attr['LIST']) {
                                 // NOTE: "raw" field value (value passed into method, before the model default value is applied) is used so as to allow the list default to be used if needed
                                 $vs_element = ca_lists::getListAsHTMLFormElement($va_attr['LIST'], $pa_options["name"] . $vs_multiple_name_extension, array('class' => $pa_options['classname'], 'id' => $pa_options['id']), array('key' => 'item_value', 'value' => $vm_raw_field_value, 'nullOption' => $pa_options['nullOption'], 'readonly' => $pa_options['readonly']));
                             }
                             if (!$vs_element && (isset($va_attr["BOUNDS_CHOICE_LIST"]) && is_array($va_attr["BOUNDS_CHOICE_LIST"]))) {
                                 if (sizeof($va_attr["BOUNDS_CHOICE_LIST"]) == 0) {
                                     $vs_element = isset($pa_options['empty_message']) ? $pa_options['empty_message'] : 'No options available';
                                 } else {
                                     $vs_element = "<select name='" . $pa_options["name"] . $vs_multiple_name_extension . "' " . $vs_js . " " . $vs_is_multiple . " " . $ps_size . " id='" . $pa_options['id'] . $vs_multiple_name_extension . "' {$vs_css_class_attr} style='{$vs_dim_style}'" . ($pa_options['readonly'] ? ' disabled="disabled" ' : '') . ">\n";
                                     if ($pa_options["select_item_text"]) {
                                         $vs_element .= "<option value=''>" . $this->escapeHTML($pa_options["select_item_text"]) . "</option>\n";
                                     }
                                     if (!$pa_options["nullOption"] && $vb_is_null) {
                                         $vs_element .= "<option value=''>" . _t('- NONE -') . "</option>\n";
                                     } else {
                                         if ($pa_options["nullOption"]) {
                                             $vs_element .= "<option value=''>" . $pa_options["nullOption"] . "</option>\n";
                                         }
                                     }
                                     foreach ($va_attr["BOUNDS_CHOICE_LIST"] as $vs_option => $vs_value) {
                                         $vs_selected = strval($vs_value) === strval($vm_field_value) || in_array($vs_value, $va_selection) ? "selected='selected'" : "";
                                         if ($pa_options["maxOptionLength"] && strlen($vs_option) > $pa_options["maxOptionLength"]) {
                                             $vs_option = unicode_substr($vs_option, 0, $pa_options["maxOptionLength"] - 3) . "...";
                                         }
                                         $vs_element .= "<option value='{$vs_value}' {$vs_selected}>" . $this->escapeHTML($vs_option) . "</option>\n";
                                     }
                                     $vs_element .= "</select>\n";
                                 }
                             }
                         }
                     }
                 } else {
                     if ($va_attr["DISPLAY_TYPE"] === DT_COLORPICKER) {
                         // COLORPICKER
                         $vs_element = '<input name="' . $pa_options["name"] . '" type="hidden" size="' . ($pa_options['size'] ? $pa_options['size'] : $vn_display_width) . '" value="' . $this->escapeHTML($vm_field_value) . '" ' . $vs_js . ' id=\'' . $pa_options["id"] . "' style='{$vs_dim_style}'/>\n";
                         $vs_element .= '<div id="' . $pa_options["id"] . '_colorchip" class="colorpicker_chip" style="background-color: #' . $vm_field_value . '"><!-- empty --></div>';
                         $vs_element .= "<script type='text/javascript'>jQuery(document).ready(function() { jQuery('#" . $pa_options["name"] . "_colorchip').ColorPicker({\n\t\t\t\t\t\t\t\tonShow: function (colpkr) {\n\t\t\t\t\t\t\t\t\tjQuery(colpkr).fadeIn(500);\n\t\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tonHide: function (colpkr) {\n\t\t\t\t\t\t\t\t\tjQuery(colpkr).fadeOut(500);\n\t\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tonChange: function (hsb, hex, rgb) {\n\t\t\t\t\t\t\t\t\tjQuery('#" . $pa_options["name"] . "').val(hex);\n\t\t\t\t\t\t\t\t\tjQuery('#" . $pa_options["name"] . "_colorchip').css('backgroundColor', '#' + hex);\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tcolor: jQuery('#" . $pa_options["name"] . "').val()\n\t\t\t\t\t\t\t})}); </script>\n";
                         if (method_exists('AssetLoadManager', 'register')) {
                             AssetLoadManager::register('jquery', 'colorpicker');
                         }
                     } else {
                         # normal controls: all non-DT_SELECT display types are returned as DT_FIELD's. We could generate
                         # radio-button controls for foreign key and choice lists, but we don't bother because it's never
                         # really necessary.
                         if ($vn_display_height > 1) {
                             $vs_element = '<' . $vs_text_area_tag_name . ' name="' . $pa_options["name"] . '" rows="' . $vn_display_height . '" cols="' . $vn_display_width . '"' . ($pa_options['readonly'] ? ' readonly="readonly" disabled="disabled"' : '') . ' wrap="soft" ' . $vs_js . ' id=\'' . $pa_options["id"] . "' style='{$vs_dim_style}' " . $vs_css_class_attr . ">" . $this->escapeHTML($vm_field_value) . '</' . $vs_text_area_tag_name . '>' . "\n";
                         } else {
                             $vs_element = '<input name="' . $pa_options["name"] . '" type="text" size="' . ($pa_options['size'] ? $pa_options['size'] : $vn_display_width) . '"' . ($pa_options['readonly'] ? ' readonly="readonly" ' : '') . ' value="' . $this->escapeHTML($vm_field_value) . '" ' . $vs_js . ' id=\'' . $pa_options["id"] . "' {$vs_css_class_attr} style='{$vs_dim_style}'/>\n";
                         }
                         if (isset($va_attr['UNIQUE_WITHIN']) && is_array($va_attr['UNIQUE_WITHIN'])) {
                             $va_within_fields = array();
                             foreach ($va_attr['UNIQUE_WITHIN'] as $vs_within_field) {
                                 $va_within_fields[$vs_within_field] = $this->get($vs_within_field);
                             }
                             $vs_element .= "<span id='" . $pa_options["id"] . '_uniqueness_status' . "'></span>";
                             $vs_element .= "<script type='text/javascript'>\n\tcaUI.initUniquenessChecker({\n\t\terrorIcon: '" . $pa_options['error_icon'] . "',\n\t\tprocessIndicator: '" . $pa_options['progress_indicator'] . "',\n\t\tstatusID: '" . $pa_options["id"] . "_uniqueness_status',\n\t\tlookupUrl: '" . $pa_options['lookup_url'] . "',\n\t\tformElementID: '" . $pa_options["id"] . "',\n\t\trow_id: " . intval($this->getPrimaryKey()) . ",\n\t\ttable_num: " . $this->tableNum() . ",\n\t\tfield: '" . $ps_field . "',\n\t\twithinFields: " . json_encode($va_within_fields) . ",\n\t\t\n\t\talreadyInUseMessage: '" . addslashes(_t('Value must be unique. Please try another.')) . "'\n\t});\n</script>";
                         } else {
                             if (isset($va_attr['LOOKUP']) && $va_attr['LOOKUP']) {
                                 if (class_exists("AppController") && ($app = AppController::getInstance()) && ($req = $app->getRequest())) {
                                     AssetLoadManager::register('jquery', 'autocomplete');
                                     $vs_element .= "<script type='text/javascript'>\n\tjQuery('#" . $pa_options["id"] . "').autocomplete({ source: '" . caNavUrl($req, 'lookup', 'Intrinsic', 'Get', array('bundle' => $this->tableName() . ".{$ps_field}", "max" => 500)) . "', minLength: 3, delay: 800});\n</script>";
                                 }
                             }
                         }
                         if (isset($pa_options['usewysiwygeditor']) && $pa_options['usewysiwygeditor']) {
                             AssetLoadManager::register("ckeditor");
                             $vs_width = $vn_display_width;
                             $vs_height = $vn_display_height;
                             if (!preg_match("!^[\\d\\.]+px\$!i", $vs_width)) {
                                 $vs_width = (int) $vs_width * 6 . "px";
                             }
                             if (!preg_match("!^[\\d\\.]+px\$!i", $vs_height)) {
                                 $vs_height = (int) $vs_height * 16 . "px";
                             }
                             if (!is_array($va_toolbar_config = $this->getAppConfig()->getAssoc('wysiwyg_editor_toolbar'))) {
                                 $va_toolbar_config = array();
                             }
                             $vs_element .= "<script type='text/javascript'>jQuery(document).ready(function() {\n\t\t\t\t\t\t\t\tvar ckEditor = CKEDITOR.replace( '" . $pa_options['id'] . "',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ttoolbar : " . json_encode(array_values($va_toolbar_config)) . ",\n\t\t\t\t\t\t\t\t\twidth: '{$vs_width}',\n\t\t\t\t\t\t\t\t\theight: '{$vs_height}',\n\t\t\t\t\t\t\t\t\ttoolbarLocation: 'top',\n\t\t\t\t\t\t\t\t\tenterMode: CKEDITOR.ENTER_BR\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tckEditor.on('instanceReady', function(){ \n\t\t\t\t\t\t\t\t\t ckEditor.document.on( 'keydown', function(e) {if (caUI && caUI.utils) { caUI.utils.showUnsavedChangesWarning(true); } });\n\t\t\t\t\t\t\t\t});\n \t});\t\t\t\t\t\t\t\t\t\n</script>";
                         }
                     }
                 }
                 break;
                 # ----------------------------
             # ----------------------------
             case FT_TIMESTAMP:
                 if ($this->get($ps_field)) {
                     # is timestamp set?
                     $vs_element = $this->escapeHTML($vm_field_value);
                     # return printed date
                 } else {
                     $vs_element = "[Not set]";
                     # return text instead of 1969 date
                 }
                 break;
                 # ----------------------------
             # ----------------------------
             case FT_DATETIME:
             case FT_HISTORIC_DATETIME:
             case FT_DATE:
             case FT_HISTORIC_DATE:
                 if (!$vm_field_value) {
                     $vm_field_value = $pa_options['value'];
                 }
                 switch ($va_attr["DISPLAY_TYPE"]) {
                     case DT_TEXT:
                         $vs_element = $vm_field_value ? $vm_field_value : "[Not set]";
                         break;
                     default:
                         $vn_max_length = $va_attr["BOUNDS_LENGTH"][1];
                         $vs_max_length = '';
                         if ($vn_max_length > 0) {
                             $vs_max_length = 'maxlength="' . $vn_max_length . '"';
                         }
                         if ($vn_display_height > 1) {
                             $vs_element = '<' . $vs_text_area_tag_name . ' name="' . $pa_options["name"] . '" rows="' . $vn_display_height . '" cols="' . $vn_display_width . '" wrap="soft" ' . $vs_js . ' ' . $vs_css_class_attr . " style='{$vs_dim_style}'" . ($pa_options['readonly'] ? ' readonly="readonly" ' : '') . ">" . $this->escapeHTML($vm_field_value) . '</' . $vs_text_area_tag_name . '>';
                         } else {
                             $vs_element = '<input type="text" name="' . $pa_options["name"] . '" value="' . $this->escapeHTML($vm_field_value) . "\" size='{$vn_display_width}' {$vs_max_length} {$vs_js} {$vs_css_class_attr} style='{$vs_dim_style}'" . ($pa_options['readonly'] ? ' readonly="readonly" ' : '') . "/>";
                         }
                         break;
                 }
                 break;
                 # ----------------------------
             # ----------------------------
             case FT_TIME:
                 if (!$this->get($ps_field)) {
                     $vm_field_value = "";
                 }
                 switch ($va_attr["DISPLAY_TYPE"]) {
                     case DT_TEXT:
                         $vs_element = $vm_field_value ? $vm_field_value : "[Not set]";
                         break;
                     default:
                         $vn_max_length = $va_attr["BOUNDS_LENGTH"][1];
                         $vs_max_length = '';
                         if ($vn_max_length > 0) {
                             $vs_max_length = 'maxlength="' . $vn_max_length . '"';
                         }
                         if ($vn_display_height > 1) {
                             $vs_element = '<' . $vs_text_area_tag_name . ' name="' . $pa_options["name"] . '" id="' . $pa_options["id"] . '" rows="' . $vn_display_height . '" cols="' . $vn_display_width . '" wrap="soft" ' . $vs_js . ' ' . $vs_css_class_attr . " style='{$vs_dim_style}'" . ($pa_options['readonly'] ? ' readonly="readonly" ' : '') . ">" . $this->escapeHTML($vm_field_value) . '</' . $vs_text_area_tag_name . '>';
                         } else {
                             $vs_element = '<input type="text" name="' . $pa_options["name"] . '" id="' . $pa_options["id"] . '" value="' . $this->escapeHTML($vm_field_value) . "\" size='{$vn_display_width}' {$vs_max_length} {$vs_js} {$vs_css_class_attr}' style='{$vs_dim_style}'" . ($pa_options['readonly'] ? ' readonly="readonly" ' : '') . "/>";
                         }
                         break;
                 }
                 break;
                 # ----------------------------
             # ----------------------------
             case FT_DATERANGE:
             case FT_HISTORIC_DATERANGE:
                 switch ($va_attr["DISPLAY_TYPE"]) {
                     case DT_TEXT:
                         $vs_element = $vm_field_value ? $vm_field_value : "[Not set]";
                         break;
                     default:
                         $vn_max_length = $va_attr["BOUNDS_LENGTH"][1];
                         $vs_max_length = '';
                         if ($vn_max_length > 0) {
                             $vs_max_length = 'maxlength="' . $vn_max_length . '"';
                         }
                         if ($vn_display_height > 1) {
                             $vs_element = '<' . $vs_text_area_tag_name . ' name="' . $pa_options["name"] . '" id="' . $pa_options["id"] . '" rows="' . $vn_display_height . '" cols="' . $vn_display_width . '" wrap="soft" ' . $vs_js . ' ' . $vs_css_class_attr . " style='{$vs_dim_style}'" . ($pa_options['readonly'] ? ' readonly="readonly" ' : '') . ">" . $this->escapeHTML($vm_field_value) . '</' . $vs_text_area_tag_name . '>';
                         } else {
                             $vs_element = '<input type="text" name="' . $pa_options["name"] . '" id="' . $pa_options["id"] . '" value="' . $this->escapeHTML($vm_field_value) . "\" size='{$vn_display_width}' {$vn_max_length} {$vs_js} {$vs_css_class_attr} style='{$vs_dim_style}'" . ($pa_options['readonly'] ? ' readonly="readonly" ' : '') . "/>";
                         }
                         break;
                 }
                 break;
                 # ----------------------------
             # ----------------------------
             case FT_TIMERANGE:
                 switch ($va_attr["DISPLAY_TYPE"]) {
                     case DT_TEXT:
                         $vs_element = $vm_field_value ? $vm_field_value : "[Not set]";
                         break;
                     default:
                         $vn_max_length = $va_attr["BOUNDS_LENGTH"][1];
                         $vs_max_length = '';
                         if ($vn_max_length > 0) {
                             $vs_max_length = 'maxlength="' . $vn_max_length . '"';
                         }
                         if ($vn_display_height > 1) {
                             $vs_element = '<' . $vs_text_area_tag_name . ' name="' . $pa_options["name"] . '" id="' . $pa_options["id"] . '" rows="' . $vn_display_height . '" cols="' . $vn_display_width . '" wrap="soft" ' . $vs_js . ' ' . $vs_css_class_attr . " style='{$vs_dim_style}'" . ($pa_options['readonly'] ? ' readonly="readonly" ' : '') . ">" . $this->escapeHTML($vm_field_value) . '</' . $vs_text_area_tag_name . '>';
                         } else {
                             $vs_element = '<input type="text" name="' . $pa_options["name"] . '" id="' . $pa_options["id"] . '" value="' . $this->escapeHTML($vm_field_value) . "\" size='{$vn_display_width}' {$vs_max_length} {$vs_js} {$vs_css_class_attr}  style='{$vs_dim_style}'" . ($pa_options['readonly'] ? ' readonly="readonly" ' : '') . "/>";
                         }
                         break;
                 }
                 break;
                 # ----------------------------
             # ----------------------------
             case FT_TIMECODE:
                 $o_tp = new TimecodeParser();
                 $o_tp->setParsedValueInSeconds($vm_field_value);
                 $vs_timecode = $o_tp->getText("COLON_DELIMITED", array("BLANK_ON_ZERO" => true));
                 $vn_max_length = $va_attr["BOUNDS_LENGTH"][1];
                 $vs_max_length = '';
                 if ($vn_max_length > 0) {
                     $vs_max_length = 'maxlength="' . $vn_max_length . '"';
                 }
                 if ($vn_display_height > 1) {
                     $vs_element = '<' . $vs_text_area_tag_name . ' name="' . $pa_options["name"] . '" id="' . $pa_options["id"] . '" rows="' . $vn_display_height . '" cols="' . $vn_display_width . '" wrap="soft" ' . $vs_js . ' ' . $vs_css_class_attr . " style='{$vs_dim_style}'" . ($pa_options['readonly'] ? ' readonly="readonly" ' : '') . ">" . $this->escapeHTML($vs_timecode) . '</' . $vs_text_area_tag_name . '>';
                 } else {
                     $vs_element = '<input type="text" NAME="' . $pa_options["name"] . '" id="' . $pa_options["id"] . '" value="' . $this->escapeHTML($vs_timecode) . "\" size='{$vn_display_width}' {$vs_max_length} {$vs_js} {$vs_css_class_attr} style='{$vs_dim_style}'" . ($pa_options['readonly'] ? ' readonly="readonly" ' : '') . "/>";
                 }
                 break;
                 # ----------------------------
             # ----------------------------
             case FT_MEDIA:
             case FT_FILE:
                 $vs_element = '<input type="file" name="' . $pa_options["name"] . '" id="' . $pa_options["id"] . '" ' . $vs_js . '/>';
                 // show current media icon
                 if ($vs_version = array_key_exists('displayMediaVersion', $pa_options) ? $pa_options['displayMediaVersion'] : 'icon') {
                     $va_valid_versions = $this->getMediaVersions($ps_field);
                     if (!in_array($vs_version, $va_valid_versions)) {
                         $vs_version = $va_valid_versions[0];
                     }
                     if ($vs_tag = $this->getMediaTag($ps_field, $vs_version)) {
                         $vs_element .= $vs_tag;
                     }
                 }
                 break;
                 # ----------------------------
             # ----------------------------
             case FT_PASSWORD:
                 $vn_max_length = $va_attr["BOUNDS_LENGTH"][1];
                 $vs_max_length = '';
                 if ($vn_max_length > 0) {
                     $vs_max_length = 'maxlength="' . $vn_max_length . '"';
                 }
                 $vs_element = '<input type="password" name="' . $pa_options["name"] . '" id="' . $pa_options["id"] . '" value="' . $this->escapeHTML($vm_field_value) . '" size="' . $vn_display_width . '" ' . $vs_max_length . ' ' . $vs_js . ' autocomplete="off" ' . $vs_css_class_attr . " style='{$vs_dim_style}'" . ($pa_options['readonly'] ? ' readonly="readonly" ' : '') . "/>";
                 break;
                 # ----------------------------
             # ----------------------------
             case FT_BIT:
                 switch ($va_attr["DISPLAY_TYPE"]) {
                     case DT_FIELD:
                         $vs_element = '<input type="text" name="' . $pa_options["name"] . "\" value='{$vm_field_value}' maxlength='1' size='2' {$vs_js} style='{$vs_dim_style}'" . ($pa_options['readonly'] ? ' readonly="readonly" ' : '') . "/>";
                         break;
                     case DT_SELECT:
                         $vs_element = "<select name='" . $pa_options["name"] . "' " . $vs_js . " id='" . $pa_options["id"] . "' {$vs_css_class_attr} style='{$vs_dim_style}'" . ($pa_options['readonly'] ? ' disabled="disabled" ' : '') . ">\n";
                         foreach (array("Yes" => 1, "No" => 0) as $vs_option => $vs_value) {
                             $vs_selected = $vs_value == $vm_field_value ? "selected='selected'" : "";
                             $vs_element .= "<option value='{$vs_value}' {$vs_selected}" . ($pa_options['readonly'] ? ' disabled="disabled" ' : '') . ">" . _t($vs_option) . "</option>\n";
                         }
                         $vs_element .= "</select>\n";
                         break;
                     case DT_CHECKBOXES:
                         $vs_element = '<input type="checkbox" name="' . $pa_options["name"] . '" value="1" ' . ($vm_field_value ? 'checked="1"' : '') . ' ' . $vs_js . ($pa_options['readonly'] ? ' disabled="disabled" ' : '') . ' id="' . $pa_options["id"] . '"/>';
                         break;
                     case DT_RADIO_BUTTONS:
                         $vs_element = 'Radio buttons not supported for bit-type fields';
                         break;
                 }
                 break;
                 # ----------------------------
         }
         # Apply format
         $vs_formatting = "";
         if (isset($pa_options['field_errors']) && is_array($pa_options['field_errors']) && sizeof($pa_options['field_errors'])) {
             $va_field_errors = array();
             foreach ($pa_options['field_errors'] as $o_e) {
                 $va_field_errors[] = $o_e->getErrorDescription();
             }
             $vs_errors = join('; ', $va_field_errors);
         } else {
             $vs_errors = '';
         }
         if (is_null($ps_format)) {
             if (isset($pa_options['field_errors']) && is_array($pa_options['field_errors']) && sizeof($pa_options['field_errors'])) {
                 $ps_format = $this->_CONFIG->get('form_element_error_display_format');
             } else {
                 $ps_format = $this->_CONFIG->get('form_element_display_format');
             }
         }
         if ($ps_format != '') {
             $ps_formatted_element = $ps_format;
             $ps_formatted_element = str_replace("^ELEMENT", $vs_element, $ps_formatted_element);
             if ($vs_subelement) {
                 $ps_formatted_element = str_replace("^SUB_ELEMENT", $vs_subelement, $ps_formatted_element);
             }
             $vb_fl_display_form_field_tips = false;
             if ($pa_options["display_form_field_tips"] || !isset($pa_options["display_form_field_tips"]) && $va_attr["DISPLAY_DESCRIPTION"] || !isset($pa_options["display_form_field_tips"]) && !isset($va_attr["DISPLAY_DESCRIPTION"]) && $vb_fl_display_form_field_tips) {
                 if (preg_match("/\\^DESCRIPTION/", $ps_formatted_element)) {
                     $ps_formatted_element = str_replace("^LABEL", $vs_field_label, $ps_formatted_element);
                     $ps_formatted_element = str_replace("^DESCRIPTION", isset($pa_options["description"]) && $pa_options["description"] ? $pa_options["description"] : $va_attr["DESCRIPTION"], $ps_formatted_element);
                 } else {
                     // no explicit placement of description text, so...
                     $vs_field_id = '_' . $this->tableName() . '_' . $this->getPrimaryKey() . '_' . $pa_options["name"] . '_' . $pa_options['form_name'];
                     $ps_formatted_element = str_replace("^LABEL", '<span id="' . $vs_field_id . '">' . $vs_field_label . '</span>', $ps_formatted_element);
                     if (!isset($pa_options['no_tooltips']) || !$pa_options['no_tooltips']) {
                         TooltipManager::add('#' . $vs_field_id, "<h3>{$vs_field_label}</h3>" . (isset($pa_options["description"]) && $pa_options["description"] ? $pa_options["description"] : $va_attr["DESCRIPTION"]), $pa_options['tooltip_namespace']);
                     }
                 }
                 if (!isset($va_attr["SUB_LABEL"])) {
                     $va_attr["SUB_LABEL"] = '';
                 }
                 if (!isset($va_attr["SUB_DESCRIPTION"])) {
                     $va_attr["SUB_DESCRIPTION"] = '';
                 }
                 if (preg_match("/\\^SUB_DESCRIPTION/", $ps_formatted_element)) {
                     $ps_formatted_element = str_replace("^SUB_LABEL", $va_attr["SUB_LABEL"], $ps_formatted_element);
                     $ps_formatted_element = str_replace("^SUB_DESCRIPTION", $va_attr["SUB_DESCRIPTION"], $ps_formatted_element);
                 } else {
                     // no explicit placement of description text, so...
                     // ... make label text itself rollover for description text because no icon was specified
                     $ps_formatted_element = str_replace("^SUB_LABEL", $va_attr["SUB_LABEL"], $ps_formatted_element);
                 }
             } else {
                 $ps_formatted_element = str_replace("^LABEL", $vs_field_label, $ps_formatted_element);
                 $ps_formatted_element = str_replace("^DESCRIPTION", "", $ps_formatted_element);
                 if ($vs_subelement) {
                     $ps_formatted_element = str_replace("^SUB_LABEL", $va_attr["SUB_LABEL"], $ps_formatted_element);
                     $ps_formatted_element = str_replace("^SUB_DESCRIPTION", "", $ps_formatted_element);
                 }
             }
             $ps_formatted_element = str_replace("^ERRORS", $vs_errors, $ps_formatted_element);
             $ps_formatted_element = str_replace("^EXTRA", isset($pa_options['extraLabelText']) ? $pa_options['extraLabelText'] : '', $ps_formatted_element);
             $vs_element = $ps_formatted_element;
         } else {
             $vs_element .= "<br/>" . $vs_subelement;
         }
         return $vs_element;
     } else {
         $this->postError(716, _t("'%1' does not exist in this object", $ps_field), "BaseModel->formElement()");
         return "";
     }
     return "";
 }
// 				}
// 			}
// 			print "</select>\n";
// 			print "</div>";
$va_search_history = $this->getVar('search_history');
$vs_cur_search = $vo_result_context->getSearchExpression();
if (is_array($va_search_history) && sizeof($va_search_history) > 0) {
    print "<div class='col'>";
    print _t("Search history:") . " ";
    print caFormTag($this->request, 'Index', 'caSearchHistoryForm');
    print "<select name='search' onchange='this.form.submit();'>\n";
    foreach (array_reverse($va_search_history) as $vs_search => $va_search_info) {
        $SELECTED = $vs_cur_search == $va_search_info['display'] ? 'SELECTED="1"' : '';
        $vs_display = strip_tags($va_search_info['display']);
        if (unicode_strlen($vs_display) > 15) {
            $vs_display = unicode_substr($vs_display, 0, 12) . '...';
        }
        print "<option value='" . htmlspecialchars($vs_search, ENT_QUOTES, 'UTF-8') . "' {$SELECTED}>" . $vs_display . " (" . $va_search_info['hits'] . ")</option>\n";
    }
    print "</select>\n";
    print "</form>\n";
    print "</div>";
}
print "</form>\n";
?>
			<a href='#' id='hideOptions' onclick='$("#searchOptionsBox").slideUp(250); $("#showOptions").slideDown(1); return false;'><?php 
print _t("Hide");
?>
 &rsaquo; </a>
			<div style='clear:both;height:1px;'>&nbsp;</div>
		</div><!-- end bg -->