public function __construct(&$po_request, &$po_response, $pa_view_paths = null)
 {
     parent::__construct($po_request, $po_response, $pa_view_paths);
     if ($this->ops_tablename) {
         if ($va_items_per_page_config = $po_request->config->get('items_per_page_options_for_' . $this->ops_tablename . '_browse')) {
             $this->opa_items_per_page = $va_items_per_page_config;
         }
         if (($vn_items_per_page_default = (int) $po_request->config->get('items_per_page_default_for_' . $this->ops_tablename . '_browse')) > 0) {
             $this->opn_items_per_page_default = $vn_items_per_page_default;
         } else {
             $this->opn_items_per_page_default = $this->opa_items_per_page[0];
         }
         // get configured result views, if specified
         if ($va_result_views_for = $po_request->config->getAssoc('result_views_for_' . $this->ops_tablename)) {
             $this->opa_views = $va_result_views_for;
         }
         $this->ops_view_default = null;
         if ($vs_view_default = $po_request->config->get('view_default_for_' . $this->ops_tablename . '_browse')) {
             $this->ops_view_default = $vs_view_default;
         }
         $va_sortable_elements = ca_metadata_elements::getSortableElements($this->ops_tablename, $this->opn_type_restriction_id);
         $this->opa_sorts = array();
         foreach ($va_sortable_elements as $vn_element_id => $va_sortable_element) {
             $this->opa_sorts[$this->ops_tablename . '.' . $va_sortable_element['element_code']] = $va_sortable_element['display_label'];
         }
     }
 }
 public function __construct(&$po_request, &$po_response, $pa_view_paths = null)
 {
     parent::__construct($po_request, $po_response, $pa_view_paths);
     $va_sortable_elements = ca_metadata_elements::getSortableElements($this->ops_tablename, $this->opn_type_restriction_id);
     $this->opa_sorts = array();
     foreach ($va_sortable_elements as $vn_element_id => $va_sortable_element) {
         $this->opa_sorts[$this->ops_tablename . '.' . $va_sortable_element['element_code']] = $va_sortable_element['display_label'];
     }
 }
示例#3
0
 /**
  * Get part of result set for display in editable "spreadsheet"
  *
  */
 public function getPartialResult($pa_options = null)
 {
     $t = new Timer();
     //self::Index($pa_options);
     $vn_display_id = $this->opo_result_context->getCurrentBundleDisplay();
     $t_model = $this->opo_datamodel->getInstanceByTableName($this->ops_tablename, true);
     $va_display_list = array();
     $t_display = $this->opo_datamodel->getInstanceByTableName('ca_bundle_displays', true);
     $t_display->load($vn_display_id);
     if ($vn_display_id && $t_display->haveAccessToDisplay($this->request->getUserID(), __CA_BUNDLE_DISPLAY_READ_ACCESS__)) {
         $va_placements = $t_display->getPlacements(array('settingsOnly' => true));
         foreach ($va_placements as $vn_placement_id => $va_display_item) {
             $va_display_list[$vn_placement_id] = array('placement_id' => $vn_placement_id, 'bundle_name' => $va_display_item['bundle_name']);
         }
     }
     //
     // Default display list (if none are specifically defined)
     //
     if (!sizeof($va_display_list)) {
         if ($vs_idno_fld = $t_model->getProperty('ID_NUMBERING_ID_FIELD')) {
             $va_display_list[$this->ops_tablename . '.' . $vs_idno_fld] = array('placement_id' => $this->ops_tablename . '.' . $vs_idno_fld, 'bundle_name' => $this->ops_tablename . '.' . $vs_idno_fld);
         }
         if (method_exists($t_model, 'getLabelTableInstance')) {
             $t_label = $t_model->getLabelTableInstance();
             $va_display_list[$this->ops_tablename . '.preferred_labels'] = array('placement_id' => $this->ops_tablename . '.preferred_labels', 'bundle_name' => $this->ops_tablename . '.preferred_labels');
         }
     }
     $po_search = isset($pa_options['search']) ? $pa_options['search'] : null;
     $pn_start = $this->request->getParameter('start', pInteger);
     if (!($vn_items_per_page = $this->request->getParameter('n', pInteger))) {
         if (!($vn_items_per_page = $this->opo_result_context->getItemsPerPage())) {
             $vn_items_per_page = $this->opn_items_per_page_default;
             $this->opo_result_context->setItemsPerPage($vn_items_per_page);
         }
     }
     $vs_search = $this->opo_result_context->getSearchExpression();
     if (!($vs_sort = $this->opo_result_context->getCurrentSort())) {
         $va_tmp = array_keys($this->opa_sorts);
         $vs_sort = array_shift($va_tmp);
     }
     $vs_sort_direction = $this->opo_result_context->getCurrentSortDirection();
     $vn_display_id = $this->opo_result_context->getCurrentBundleDisplay();
     if (!$this->opn_type_restriction_id) {
         $this->opn_type_restriction_id = '';
     }
     $this->view->setVar('type_id', $this->opn_type_restriction_id);
     // Get attribute sorts
     $va_sortable_elements = ca_metadata_elements::getSortableElements($this->ops_tablename, $this->opn_type_restriction_id);
     if (!is_array($this->opa_sorts)) {
         $this->opa_sorts = array();
     }
     foreach ($va_sortable_elements as $vn_element_id => $va_sortable_element) {
         $this->opa_sorts[$this->ops_tablename . '.' . $va_sortable_element['element_code']] = $va_sortable_element['display_label'];
     }
     if ($pa_options['appendToSearch']) {
         $vs_append_to_search .= " AND (" . $pa_options['appendToSearch'] . ")";
     }
     //
     // Execute the search
     //
     if ($vs_search && $vs_search != "") {
         /* any request? */
         $va_search_opts = array('sort' => $vs_sort, 'sort_direction' => $vs_sort_direction, 'appendToSearch' => $vs_append_to_search, 'checkAccess' => $va_access_values, 'no_cache' => $vb_is_new_search, 'dontCheckFacetAvailability' => true, 'filterNonPrimaryRepresentations' => true);
         if ($vb_is_new_search || isset($pa_options['saved_search']) || is_subclass_of($po_search, "BrowseEngine") && !$po_search->numCriteria()) {
             $vs_browse_classname = get_class($po_search);
             $po_search = new $vs_browse_classname();
             if (is_subclass_of($po_search, "BrowseEngine")) {
                 $po_search->addCriteria('_search', $vs_search);
                 if (method_exists($this, "hookBeforeNewSearch")) {
                     $this->hookBeforeNewSearch($po_search);
                 }
             }
             $this->opo_result_context->setParameter('show_type_id', null);
         }
         if ($this->opn_type_restriction_id) {
             $po_search->setTypeRestrictions(array($this->opn_type_restriction_id));
         }
         $vb_criteria_have_changed = false;
         if (is_subclass_of($po_search, "BrowseEngine")) {
             $vo_result = $po_search->getResults($va_search_opts);
         } else {
             $vo_result = $po_search->search($vs_search, $va_search_opts);
         }
         $this->opo_result_context->validateCache();
         // Only prefetch what we need
         $vo_result->setOption('prefetch', $vn_items_per_page);
         $this->view->setVar('result', $vo_result);
     }
     $va_results = array();
     $vo_result->seek($pn_start);
     //$vo_result->registerElementsToPrefetch(array(15,4,1));
     //print "[7] ". $t->getTime(4)."\n";
     $vn_c = 0;
     $vs_pk = $vo_result->primaryKey();
     while ($vo_result->nextHit()) {
         $va_result = array("item_id" => $vo_result->get($vs_pk));
         foreach ($va_display_list as $vn_placement_id => $va_placement) {
             $va_result[str_replace(".", "-", $va_placement['bundle_name'])] = $t_display->getDisplayValue($vo_result, $vn_placement_id, array('request' => $this->request));
         }
         $va_results[] = $va_result;
         $vn_c++;
         if ($vn_c >= $vn_items_per_page) {
             break;
         }
     }
     //print "[8] ". $t->getTime(4)."\n";
     $this->view->setVar('results', $va_results);
     $this->render('Results/ajax_partial_results_json.php');
     //print "[x] ". $t->getTime(4)."\n";
 }
 /**
  * Options:
  *		appendToSearch = optional text to be AND'ed wuth current search expression
  *		output_format = determines format out search result output. "PDF" and "HTML" are currently supported; "HTML" is the default
  *		view = view with path relative to controller to use overriding default ("search/<table_name>_search_basic_html.php")
  *		vars = associative array with key value pairs to assign to the view
  *
  * Callbacks:
  * 		hookBeforeNewSearch() is called just before executing a new search. The first parameter is the BrowseEngine object containing the search.
  */
 public function Index($pa_options = null)
 {
     $po_search = isset($pa_options['search']) ? $pa_options['search'] : null;
     if (isset($pa_options['saved_search']) && $pa_options['saved_search']) {
         $this->opo_result_context->setSearchExpression($pa_options['saved_search']['search']);
         $this->opo_result_context->isNewSearch(true);
     }
     parent::Index($pa_options);
     AssetLoadManager::register('hierBrowser');
     AssetLoadManager::register('browsable');
     // need this to support browse panel when filtering/refining search results
     $t_model = $this->opo_datamodel->getInstanceByTableName($this->ops_tablename, true);
     $va_access_values = caGetUserAccessValues($this->request);
     // Get elements of result context
     $vn_page_num = $this->opo_result_context->getCurrentResultsPageNumber();
     $vs_search = $this->opo_result_context->getSearchExpression();
     $vb_is_new_search = $this->opo_result_context->isNewSearch();
     if ((bool) $this->request->getParameter('reset', pString) && $this->request->getParameter('reset', pString) != 'save') {
         $vs_search = '';
         $vb_is_new_search = true;
     }
     if (!($vn_items_per_page = $this->opo_result_context->getItemsPerPage())) {
         $vn_items_per_page = $this->opn_items_per_page_default;
         $this->opo_result_context->setItemsPerPage($vn_items_per_page);
     }
     if (!($vs_view = $this->opo_result_context->getCurrentView())) {
         $va_tmp = array_keys($this->opa_views);
         $vs_view = $this->ops_view_default ? $this->ops_view_default : array_shift($va_tmp);
         $this->opo_result_context->setCurrentView($vs_view);
     }
     if (!isset($this->opa_views[$vs_view])) {
         $va_tmp = array_keys($this->opa_views);
         $vs_view = array_shift($va_tmp);
     }
     if (!($vs_sort = $this->opo_result_context->getCurrentSort())) {
         $va_tmp = array_keys($this->opa_sorts);
         $vs_sort = array_shift($va_tmp);
     }
     $vs_sort_direction = $this->opo_result_context->getCurrentSortDirection();
     $vb_sort_has_changed = $this->opo_result_context->sortHasChanged();
     if (!$this->opn_type_restriction_id) {
         $this->opn_type_restriction_id = '';
     }
     $this->view->setVar('type_id', $this->opn_type_restriction_id);
     MetaTagManager::setWindowTitle(_t('%1 search', $this->searchName('plural')));
     // Get attribute sorts
     $va_sortable_elements = ca_metadata_elements::getSortableElements($this->ops_tablename, $this->opn_type_restriction_id);
     if (!is_array($this->opa_sorts)) {
         $this->opa_sorts = array();
     }
     foreach ($va_sortable_elements as $va_sortable_element) {
         $this->opa_sorts[$this->ops_tablename . '.' . $va_sortable_element['element_code']] = $va_sortable_element['display_label'];
     }
     if ($pa_options['appendToSearch']) {
         $vs_append_to_search .= " AND (" . $pa_options['appendToSearch'] . ")";
     }
     //
     // Execute the search
     //
     if ($vs_search && $vs_search != "") {
         /* any request? */
         $va_search_opts = array('sort' => $vs_sort, 'sort_direction' => $vs_sort_direction, 'appendToSearch' => $vs_append_to_search, 'checkAccess' => $va_access_values, 'no_cache' => $vb_is_new_search, 'dontCheckFacetAvailability' => true, 'filterNonPrimaryRepresentations' => true);
         if ($vb_is_new_search || isset($pa_options['saved_search']) || is_subclass_of($po_search, "BrowseEngine") && !$po_search->numCriteria()) {
             $vs_browse_classname = get_class($po_search);
             $po_search = new $vs_browse_classname();
             if (is_subclass_of($po_search, "BrowseEngine")) {
                 $po_search->addCriteria('_search', $vs_search);
                 if (method_exists($this, "hookBeforeNewSearch")) {
                     $this->hookBeforeNewSearch($po_search);
                 }
             }
             $this->opo_result_context->setParameter('show_type_id', null);
         }
         if ($this->opn_type_restriction_id) {
             $po_search->setTypeRestrictions(array($this->opn_type_restriction_id), array('includeSubtypes' => false));
         }
         $vb_criteria_have_changed = false;
         if (is_subclass_of($po_search, "BrowseEngine")) {
             //
             // Restrict facets to specific group for main browse landing page (if set in app.conf config)
             //
             if ($vs_facet_group = $this->request->config->get($this->ops_tablename . '_search_refine_facet_group')) {
                 $po_search->setFacetGroup($vs_facet_group);
             }
             $vb_criteria_have_changed = $po_search->criteriaHaveChanged();
             $po_search->execute($va_search_opts);
             $this->opo_result_context->setParameter('browse_id', $po_search->getBrowseID());
             if ($vs_group_name = $this->request->config->get('browse_facet_group_for_' . $this->ops_tablename)) {
                 $po_search->setFacetGroup($vs_group_name);
             }
             $vo_result = $po_search->getResults($va_search_opts);
         } else {
             $vo_result = $po_search->search($vs_search, $va_search_opts);
         }
         $vo_result = isset($pa_options['result']) ? $pa_options['result'] : $vo_result;
         $this->opo_result_context->validateCache();
         // Only prefetch what we need
         $vo_result->setOption('prefetch', $vn_items_per_page);
         //
         // Handle details of partitioning search results by type, if required
         //
         if ((bool) $this->request->config->get('search_results_partition_by_type')) {
             $va_type_counts = $vo_result->getResultCountForFieldValues(array('ca_objects.type_id'));
             $va_type_counts_obj_type = $va_type_counts['ca_objects.type_id'];
             ksort($va_type_counts_obj_type);
             $this->view->setVar('counts_by_type', $va_type_counts_obj_type);
             $vn_show_type_id = $this->opo_result_context->getParameter('show_type_id');
             if (!isset($va_type_counts_obj_type[$vn_show_type_id])) {
                 $va_tmp = array_keys($va_type_counts_obj_type);
                 $vn_show_type_id = array_shift($va_tmp);
             }
             $this->view->setVar('show_type_id', $vn_show_type_id);
             $vo_result->filterResult('ca_objects.type_id', $vn_show_type_id);
         }
         if ($vb_is_new_search || $vb_criteria_have_changed || $vb_sort_has_changed) {
             $this->opo_result_context->setResultList($vo_result->getPrimaryKeyValues());
             $this->opo_result_context->setParameter('availableVisualizationChecked', 0);
             if ($this->opo_result_context->searchExpressionHasChanged()) {
                 $vn_page_num = 1;
             }
         }
         $this->view->setVar('num_hits', $vo_result->numHits());
         $this->view->setVar('num_pages', $vn_num_pages = ceil($vo_result->numHits() / $vn_items_per_page));
         if ($vn_page_num > $vn_num_pages) {
             $vn_page_num = 1;
         }
         $vo_result->seek(($vn_page_num - 1) * $vn_items_per_page);
         $this->view->setVar('page', $vn_page_num);
         $this->view->setVar('search', $vs_search);
         $this->view->setVar('result', $vo_result);
     }
     //
     // Set up view for display of results
     //
     $t_model = $this->opo_datamodel->getInstanceByTableName($this->ops_tablename, true);
     $this->view->setVar('views', $this->opa_views);
     // pass view list to view for rendering
     $this->view->setVar('current_view', $vs_view);
     $this->view->setVar('sorts', $this->opa_sorts);
     // pass sort list to view for rendering
     $this->view->setVar('current_sort', $vs_sort);
     $this->view->setVar('current_sort_direction', $vs_sort_direction);
     $this->view->setVar('current_items_per_page', $vn_items_per_page);
     $this->view->setVar('items_per_page', $this->opa_items_per_page);
     $this->view->setVar('t_subject', $t_model);
     $this->view->setVar('mode_name', _t('search'));
     $this->view->setVar('mode', 'search');
     $this->view->setVar('mode_type_singular', $this->searchName('singular'));
     $this->view->setVar('mode_type_plural', $this->searchName('plural'));
     $this->view->setVar('search_history', $this->opo_result_context->getSearchHistory());
     $this->view->setVar('result_context', $this->opo_result_context);
     $this->view->setVar('uses_hierarchy_browser', $this->usesHierarchyBrowser());
     $this->view->setVar('access_values', $va_access_values);
     $this->view->setVar('browse', $po_search);
     $t_display = $this->view->getVar('t_display');
     if (!is_array($va_display_list = $this->view->getVar('display_list'))) {
         $va_display_list = array();
     }
     if ($vs_view == 'editable') {
         $va_initial_data = array();
         $va_row_headers = array();
         $vn_item_count = 0;
         if ($vo_result) {
             $vs_pk = $vo_result->primaryKey();
             while ($vn_item_count < 100 && $vo_result->nextHit()) {
                 $va_result = array('item_id' => $vn_id = $vo_result->get($vs_pk));
                 foreach ($va_display_list as $vn_placement_id => $va_bundle_info) {
                     $va_result[str_replace(".", "-", $va_bundle_info['bundle_name'])] = $t_display->getDisplayValue($vo_result, $vn_placement_id, array('request' => $this->request));
                 }
                 $va_initial_data[] = $va_result;
                 $vn_item_count++;
                 $va_row_headers[] = $vn_item_count . " " . caEditorLink($this->request, caNavIcon($this->request, __CA_NAV_BUTTON_EDIT__), 'caResultsEditorEditLink', $this->ops_tablename, $vn_id);
             }
         }
         $this->view->setVar('initialData', $va_initial_data);
         $this->view->setVar('rowHeaders', $va_row_headers);
     }
     //
     // Bottom line
     //
     $va_bottom_line = array();
     $vb_bottom_line_is_set = false;
     foreach ($va_display_list as $vn_placement_id => $va_placement) {
         if (isset($va_placement['settings']['bottom_line']) && $va_placement['settings']['bottom_line']) {
             $va_bottom_line[$vn_placement_id] = caProcessBottomLineTemplate($this->request, $va_placement, $vo_result, array('pageStart' => ($vn_page_num - 1) * $vn_items_per_page, 'pageEnd' => ($vn_page_num - 1) * $vn_items_per_page + $vn_items_per_page));
             $vb_bottom_line_is_set = true;
         } else {
             $va_bottom_line[$vn_placement_id] = '';
         }
     }
     $this->view->setVar('bottom_line', $vb_bottom_line_is_set ? $va_bottom_line : null);
     switch ($pa_options['output_format']) {
         # ------------------------------------
         case 'LABELS':
             $this->_genLabels($vo_result, $this->request->getParameter("label_form", pString), $vs_search, $vs_search);
             break;
             # ------------------------------------
         # ------------------------------------
         case 'EXPORT':
             $this->_genExport($vo_result, $this->request->getParameter("export_format", pString), $vs_search, $vs_search);
             break;
             # ------------------------------------
         # ------------------------------------
         case 'HTML':
         default:
             // generate type menu and type value list
             if (method_exists($t_model, "getTypeList")) {
                 $this->view->setVar('type_list', $t_model->getTypeList());
             }
             if ($this->opb_uses_hierarchy_browser) {
                 AssetLoadManager::register('hierBrowser');
                 // only for interfaces that use the hierarchy browser
                 $t_list = new ca_lists();
                 if ($vs_type_list_code = $t_model->getTypeListCode()) {
                     $this->view->setVar('num_types', $t_list->numItemsInList($vs_type_list_code));
                     $this->view->setVar('type_menu', $t_list->getListAsHTMLFormElement($vs_type_list_code, 'type_id', array('id' => 'hierTypeList')));
                 }
                 // set last browse id for hierarchy browser
                 $this->view->setVar('browse_last_id', intval($this->request->session->getVar($this->ops_tablename . '_browse_last_id')));
             }
             $this->opo_result_context->setAsLastFind();
             $this->opo_result_context->saveContext();
             if (isset($pa_options['vars']) && is_array($pa_options['vars'])) {
                 foreach ($pa_options['vars'] as $vs_key => $vs_val) {
                     $this->view->setVar($vs_key, $vs_val);
                 }
             }
             if (isset($pa_options['view']) && $pa_options['view']) {
                 $this->render($pa_options['view']);
             } else {
                 $this->render('Search/' . $this->ops_tablename . '_search_basic_html.php');
             }
             break;
             # ------------------------------------
     }
 }
示例#5
0
 /**
  * Returns HTML form element for editing of setting
  *
  * Options:
  *
  * 	'name' => sets the name of the HTML form element explicitly, otherwise 'setting_<name_of_setting>' is used
  * 	'id' => sets the id of the HTML form element explicitly, otherwise 'setting_<name_of_setting>' is used
  *  'value' => sets the value of the HTML form element explicitly, otherwise the current value for the setting in the loaded row is used
  *  'label_id' => sets the id of the label for the setting form element (used to link tools tips to the label); if not set then the default is to set it to  'setting_<name_of_setting>_label'
  */
 public function settingHTMLFormElement($ps_setting, $pa_options = null)
 {
     if (!$this->isValidSetting($ps_setting)) {
         return false;
     }
     $va_available_settings = $this->getAvailableSettings();
     $va_properties = $va_available_settings[$ps_setting];
     if (isset($pa_options['name'])) {
         $vs_input_name = $pa_options['name'];
     } else {
         $vs_input_name = "setting_{$ps_setting}";
     }
     if (isset($pa_options['id'])) {
         $vs_input_id = $pa_options['id'];
     } else {
         $vs_input_id = "setting_{$ps_setting}";
     }
     if (isset($pa_options['value'])) {
         $vs_value = $pa_options['value'];
     } else {
         $vs_value = $this->getSetting(trim($ps_setting));
     }
     if (isset($pa_options['label_id'])) {
         $vs_label_id = $pa_options['label_id'];
     } else {
         $vs_label_id = "setting_{$ps_setting}_label";
     }
     $vs_return = "\n" . '<div class="formLabel" id="' . $vs_input_id . '_container">' . "\n";
     $vs_return .= '<span id="' . $vs_label_id . '"  class="' . $vs_label_id . '">' . $va_properties['label'] . '</span>';
     if ($vs_help_text = $pa_options['helpText']) {
         $vs_return .= "<a href='#' onclick='jQuery(\"#" . str_replace(".", "_", $vs_label_id) . "_help_text\").slideToggle(250); return false;' class='settingsKeyButton'>" . _t('Key') . "</a>";
     }
     $vs_return .= '<br />' . "\n";
     if ($vs_help_text) {
         $vs_return .= "\n<div id='" . str_replace(".", "_", $vs_label_id) . "_help_text' class='settingsKey'>{$vs_help_text}</div>\n";
     }
     switch ($va_properties['displayType']) {
         # --------------------------------------------
         case DT_FIELD:
             $vb_takes_locale = false;
             if (isset($va_properties['takesLocale']) && $va_properties['takesLocale']) {
                 $vb_takes_locale = true;
                 $va_locales = ca_locales::getLocaleList(array('sort_field' => '', 'sort_order' => 'asc', 'index_by_code' => true, 'available_for_cataloguing_only' => true));
             } else {
                 $va_locales = array('_generic' => array());
             }
             foreach ($va_locales as $vs_locale => $va_locale_info) {
                 if ($vb_takes_locale && sizeof($va_locales) > 1) {
                     $vs_locale_label = " (" . $va_locale_info['name'] . ")";
                     $vs_input_name_suffix = '_' . $vs_locale;
                 } else {
                     if ($vb_takes_locale) {
                         $vs_input_name_suffix = '_' . $vs_locale;
                     } else {
                         $vs_input_name_suffix = $vs_locale_label = '';
                     }
                 }
                 if ($vs_locale != '_generic' && is_array($vs_value)) {
                     // _generic means this setting doesn't take a locale
                     if (!($vs_text_value = $vs_value[$va_locale_info['locale_id']])) {
                         $vs_text_value = is_array($vs_value) && isset($vs_value[$va_locale_info['code']]) ? $vs_value[$va_locale_info['code']] : '';
                     }
                 } else {
                     $vs_text_value = $vs_value;
                 }
                 $vs_return .= caHTMLTextInput($vs_input_name . $vs_input_name_suffix, array('size' => $va_properties["width"], 'height' => $va_properties["height"], 'value' => $vs_text_value, 'id' => $vs_input_id)) . "{$vs_locale_label}<br/>\n";
             }
             break;
             # --------------------------------------------
         # --------------------------------------------
         case DT_CHECKBOXES:
             $va_attributes = array('value' => '1', 'id' => $vs_input_id);
             if ((int) $vs_value === 1) {
                 $va_attributes['checked'] = '1';
             }
             if (isset($va_properties['hideOnSelect'])) {
                 if (!is_array($va_properties['hideOnSelect'])) {
                     $va_properties['hideOnSelect'] = array($va_properties['hideOnSelect']);
                 }
                 $va_ids = array();
                 foreach ($va_properties['hideOnSelect'] as $vs_n) {
                     $va_ids[] = "#" . $pa_options['id_prefix'] . "_{$vs_n}_container";
                 }
                 $va_attributes['onchange'] = 'jQuery(this).prop("checked") ? jQuery("' . join(",", $va_ids) . '").slideUp(250).find("input, textarea").val("") : jQuery("' . join(",", $va_ids) . '").slideDown(250);';
             }
             $vs_return .= caHTMLCheckboxInput($vs_input_name, $va_attributes, array());
             break;
             # --------------------------------------------
         # --------------------------------------------
         case DT_COLORPICKER:
             $va_attributes = array('value' => $vs_value, 'id' => $vs_input_id);
             $vs_return .= caHTMLHiddenInput($vs_input_name, $va_attributes, array());
             $vs_return .= "<div id='{$vs_input_id}_colorchip' class='colorpicker_chip' style='background-color: #{$vs_value}'><!-- empty --></div>";
             $vs_return .= "<script type='text/javascript'>jQuery(document).ready(function() { jQuery('#{$vs_input_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('#{$vs_input_name}').val(hex);\n\t\t\t\t\t\t\t\t\tjQuery('#{$vs_input_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";
             JavascriptLoadManager::register('jquery', 'colorpicker');
             break;
             # --------------------------------------------
         # --------------------------------------------
         case DT_SELECT:
             include_once __CA_MODELS_DIR__ . '/ca_relationship_types.php';
             $vn_width = isset($va_properties['width']) && strlen($va_properties['width']) > 0 ? $va_properties['width'] : "100px";
             $vn_height = isset($va_properties['height']) && strlen($va_properties['height']) > 0 ? $va_properties['height'] : "50px";
             $vs_select_element = '';
             if (($vs_rel_table = $va_properties['useRelationshipTypeList']) || ($vb_locale_list = (bool) $va_properties['useLocaleList']) || ($vs_list_code = $va_properties['useList']) || ($vb_show_lists = (bool) $va_properties['showLists'] || (bool) $va_properties['showVocabularies'])) {
                 if ($vs_rel_table) {
                     $t_rel = new ca_relationship_types();
                     $va_rels = $t_rel->getRelationshipInfo($vs_rel_table);
                     $va_rel_opts = array();
                     if (isset($va_properties['allowNull']) && $va_properties['allowNull']) {
                         $va_rel_opts['-'] = null;
                     }
                     foreach ($va_rels as $vn_type_id => $va_rel_type_info) {
                         if (!$va_rel_type_info['parent_id']) {
                             continue;
                         }
                         $va_rel_opts[$va_rel_type_info['typename'] . '/' . $va_rel_type_info['typename_reverse']] = $va_rel_type_info['type_id'];
                     }
                 } else {
                     if ($vb_locale_list) {
                         include_once __CA_MODELS_DIR__ . '/ca_locales.php';
                         $va_rel_opts = array_flip(ca_locales::getLocaleList(array('return_display_values' => true)));
                     } else {
                         if ($vb_show_lists) {
                             include_once __CA_MODELS_DIR__ . '/ca_lists.php';
                             $t_list = new ca_lists();
                             $va_lists = caExtractValuesByUserLocale($t_list->getListOfLists());
                             $va_rel_opts = array();
                             foreach ($va_lists as $vn_list_id => $va_list_info) {
                                 if ($va_properties['showVocabularies'] && !$va_list_info['use_as_vocabulary']) {
                                     continue;
                                 }
                                 $va_rel_opts[$va_list_info['name'] . ' (' . $va_list_info['list_code'] . ')'] = $vn_list_id;
                             }
                         }
                     }
                 }
                 $va_attr = array();
                 if ($vn_height > 1) {
                     $va_attr['multiple'] = 1;
                     $vs_input_name .= '[]';
                 }
                 $va_opts = array('id' => $vs_input_id, 'width' => $vn_width, 'height' => $vn_height);
                 if ($vn_height > 1) {
                     if ($vs_value && !is_array($vs_value)) {
                         $vs_value = array($vs_value);
                     }
                     $va_opts['values'] = $vs_value;
                 } else {
                     if (is_array($vs_value)) {
                         $va_opts['value'] = array_pop($vs_value);
                     } else {
                         if ($vs_value) {
                             $va_opts['value'] = $vs_value;
                         } else {
                             $va_opts['value'] = null;
                         }
                     }
                 }
                 if ($vs_list_code) {
                     $t_list = new ca_lists();
                     if (!isset($va_opts['value'])) {
                         $va_opts['value'] = -1;
                     }
                     // make sure default list item is never selected
                     $vs_select_element = $t_list->getListAsHTMLFormElement($vs_list_code, $vs_input_name, $va_attr, $va_opts);
                 } else {
                     if (!isset($va_opts['value'])) {
                         $va_opts['value'] = -1;
                     }
                     // make sure default list item is never selected
                     $vs_select_element = caHTMLSelect($vs_input_name, $va_rel_opts, $va_attr, $va_opts);
                 }
             } else {
                 if (strlen($va_properties['showSortableBundlesFor']) > 0) {
                     require_once __CA_MODELS_DIR__ . '/ca_metadata_elements.php';
                     $o_dm = Datamodel::load();
                     if (!($t_rel = $o_dm->getInstanceByTableName($va_properties['showSortableBundlesFor'], true))) {
                         break;
                     }
                     $va_elements = ca_metadata_elements::getSortableElements($va_properties['showSortableBundlesFor']);
                     $va_select_opts = array(_t('User defined sort order') => '', _t('Order created') => 'relation_id', _t('Preferred label') => $va_properties['showSortableBundlesFor'] . ".preferred_labels." . $t_rel->getLabelDisplayField());
                     foreach ($va_elements as $vn_element_id => $va_element) {
                         if (!$va_element['display_label']) {
                             continue;
                         }
                         $va_select_opts[_t('Element: %1', $va_element['display_label'])] = $va_properties['showSortableBundlesFor'] . "." . $va_element['element_code'];
                     }
                     $va_opts = array('id' => $vs_input_id, 'width' => $vn_width, 'height' => $vn_height, 'value' => is_array($vs_value) ? $vs_value[0] : $vs_value, 'values' => is_array($vs_value) ? $vs_value : array($vs_value));
                     $vs_select_element = caHTMLSelect($vs_input_name, $va_select_opts, array(), $va_opts);
                 } elseif ((int) $va_properties['showSortableElementsFor'] > 0) {
                     require_once __CA_MODELS_DIR__ . '/ca_metadata_elements.php';
                     $t_element = new ca_metadata_elements($va_properties['showSortableElementsFor']);
                     if (!$t_element->getPrimaryKey()) {
                         return '';
                     }
                     $va_elements = $t_element->getElementsInSet();
                     $va_select_opts = array(_t('Order created') => '');
                     foreach ($va_elements as $vn_i => $va_element) {
                         if ((int) $va_element['element_id'] == (int) $va_properties['showSortableElementsFor']) {
                             continue;
                         }
                         if (!$va_element['display_label']) {
                             continue;
                         }
                         $va_select_opts[_t('Element: %1', $va_element['display_label'])] = $va_element['element_code'];
                     }
                     $va_opts = array('id' => $vs_input_id, 'width' => $vn_width, 'height' => $vn_height, 'value' => is_array($vs_value) ? $vs_value[0] : $vs_value, 'values' => is_array($vs_value) ? $vs_value : array($vs_value));
                     $vs_select_element = caHTMLSelect($vs_input_name, $va_select_opts, array(), $va_opts);
                 } elseif ((int) $va_properties['showMetadataElementsWithDataType'] > 0) {
                     require_once __CA_MODELS_DIR__ . '/ca_metadata_elements.php';
                     $va_rep_elements = ca_metadata_elements::getElementsAsList(true, $va_properties['table'], null, true, false, true, array($va_properties['showMetadataElementsWithDataType']));
                     if (is_array($va_rep_elements)) {
                         $va_select_opts = array();
                         foreach ($va_rep_elements as $vs_element_code => $va_element_info) {
                             $va_select_opts[$va_element_info['display_label']] = $vs_element_code;
                         }
                         $va_opts = array('id' => $vs_input_id, 'width' => $vn_width, 'height' => $vn_height, 'value' => is_array($vs_value) ? $vs_value[0] : $vs_value, 'values' => is_array($vs_value) ? $vs_value : array($vs_value));
                         $vs_select_element = caHTMLSelect($vs_input_name, $va_select_opts, array(), $va_opts);
                     }
                 } else {
                     // Regular drop-down with configured options
                     if ($vn_height > 1) {
                         $va_attr['multiple'] = 1;
                         $vs_input_name .= '[]';
                     }
                     $va_opts = array('id' => $vs_input_id, 'width' => $vn_width, 'height' => $vn_height, 'value' => is_array($vs_value) ? $vs_value[0] : $vs_value, 'values' => is_array($vs_value) ? $vs_value : array($vs_value));
                     if (!isset($va_opts['value'])) {
                         $va_opts['value'] = -1;
                     }
                     // make sure default list item is never selected
                     $vs_select_element = caHTMLSelect($vs_input_name, $va_properties['options'], array(), $va_opts);
                 }
             }
             if ($vs_select_element) {
                 $vs_return .= $vs_select_element;
             } else {
                 return '';
             }
             break;
             # --------------------------------------------
         # --------------------------------------------
         default:
             break;
             # --------------------------------------------
     }
     $vs_return .= '</div>' . "\n";
     TooltipManager::add('.' . $vs_label_id, "<h3>" . $va_properties["label"] . "</h3>" . $va_properties["description"]);
     return $vs_return;
 }