/**
  *
  */
 public function Index()
 {
     if (!$this->request->user->canDoAction('can_import_worldcat')) {
         return;
     }
     $this->view->setVar('importer_list', $va_importer_list = ca_data_importers::getImporters(null, array('formats' => array('WorldCat'))));
     $va_importer_options = array();
     foreach ($va_importer_list as $vn_importer_id => $va_importer_info) {
         $va_importer_options[$va_importer_info['label'] . ' (creates ' . ($va_importer_info['type_for_display'] ? $va_importer_info['type_for_display'] . ' ' : '') . $va_importer_info['importer_type'] . ')'] = $vn_importer_id;
     }
     $this->view->setVar('importer_list', $va_importer_options);
     $this->view->setVar('importer_list_select', caHTMLSelect('importer_id', $va_importer_options, array()));
     $this->view->setVar('log_level', $this->request->user->getVar('worldcat_log_level'));
     $this->render("import_settings_html.php");
 }
 /**
  *
  */
 public function __construct(&$po_request, &$po_response, $pa_view_paths = null)
 {
     parent::__construct($po_request, $po_response, $pa_view_paths);
     // merge displays with drop-in print templates
     $va_export_options = caGetAvailablePrintTemplates('results', array('table' => $this->ops_tablename));
     $this->view->setVar('export_formats', $va_export_options);
     //$this->view->setVar('current_export_format', $this->opo_result_context->getParameter('last_export_type'));
     $va_options = array();
     foreach ($va_export_options as $vn_i => $va_format_info) {
         $va_options[$va_format_info['name']] = $va_format_info['code'];
     }
     // Get current display list
     $t_display = new ca_bundle_displays();
     foreach (caExtractValuesByUserLocale($t_display->getBundleDisplays(array('table' => $this->ops_tablename, 'user_id' => $this->request->getUserID(), 'access' => __CA_BUNDLE_DISPLAY_READ_ACCESS__, 'checkAccess' => caGetUserAccessValues($this->request)))) as $va_display) {
         $va_options[$va_display['name']] = "_display_" . $va_display['display_id'];
     }
     ksort($va_options);
     $this->view->setVar('export_format_select', caHTMLSelect('export_format', $va_options, array('class' => 'searchToolsSelect'), array('value' => $this->view->getVar('current_export_format'), 'width' => '150px')));
 }
 /**
  * Return HTML form element for specified property 
  *
  */
 public function htmlFormElement($ps_property, $pa_attributes = null)
 {
     $vs_element = $vs_label = '';
     if (!($vs_format = $pa_attributes['format'])) {
         $vs_format = $this->opo_config->get('form_element_display_format');
     }
     if ($va_property_info = $this->getPropertyInfo($ps_property)) {
         switch ($va_property_info['fieldType']) {
             case 'FT_TEXT':
             case 'FT_NUMBER':
                 $vs_label = $va_property_info['label'];
                 if (!isset($pa_attributes['value'])) {
                     $pa_attributes['value'] = $this->getProperty($ps_property);
                 }
                 if (!isset($pa_attributes['size'])) {
                     $pa_attributes['size'] = $va_property_info['fieldWidth'];
                 }
                 switch ($va_property_info['displayType']) {
                     case 'DT_SELECT':
                         $vs_element = caHTMLMakeLabeledFormElement(caHTMLSelect($pa_attributes['name'] ? $pa_attributes['name'] : $ps_property, $va_property_info['options'], $pa_attributes, array('height' => 1)), $vs_label, $pa_attributes['name'] ? $pa_attributes['name'] : $ps_property, $va_property_info['description'], $vs_format, false);
                         break;
                     default:
                         $vs_element = caHTMLMakeLabeledFormElement(caHTMLTextInput($pa_attributes['name'] ? $pa_attributes['name'] : $ps_property, $pa_attributes), $vs_label, $pa_attributes['name'] ? $pa_attributes['name'] : $ps_property, $va_property_info['description'], $vs_format, false);
                         break;
                 }
                 break;
             case 'FT_VARS':
                 $vs_element = '';
                 // skip
                 break;
             default:
                 return 'Invalid field type for \'' . $ps_property . '\'';
                 break;
         }
     }
     return $vs_element;
 }
		<div class="bg">
<?php 
print caFormTag($this->request, 'Index', 'caSearchOptionsForm', null, 'post', 'multipart/form-data', '_top', array('disableUnsavedChangesWarning' => true));
//print "<div class='col'>";
print "<div class='unit'>";
print "<span>" . _t("Sort") . "</span>";
print "<select name='sort' style='width:120px;'>\n";
$vs_current_sort = $vo_result_context->getCurrentSort();
$vs_current_sort_direction = $vo_result_context->getCurrentSortDirection();
if (is_array($this->getVar("sorts")) && sizeof($this->getVar("sorts")) > 0) {
    foreach ($this->getVar("sorts") as $vs_sort => $vs_option) {
        print "<option value='" . $vs_sort . "'" . ($vs_current_sort == $vs_sort ? " SELECTED" : "") . ">" . $vs_option . "</option>";
    }
}
print "</select>\n";
print caHTMLSelect('direction', array('Ascending' => 'asc', 'Descending' => 'desc'), array(), array('value' => $vs_current_sort_direction));
$va_items_per_page = $this->getVar("items_per_page");
$vs_current_items_per_page = $vo_result_context->getItemsPerPage();
print "&nbsp; &nbsp;<span>" . _t("Results per page") . "</span>";
print "<select name='n'>\n";
if (is_array($va_items_per_page) && sizeof($va_items_per_page) > 0) {
    foreach ($va_items_per_page as $vn_items_per_p) {
        print "<option value='" . $vn_items_per_p . "' " . ($vn_items_per_p == $vs_current_items_per_page ? "SELECTED='1'" : "") . ">" . $vn_items_per_p . "</option>\n";
    }
}
print "</select>\n";
$va_views = $this->getVar("views");
$vs_current_view = $vo_result_context->getCurrentView();
if (is_array($va_views) && sizeof($va_views) > 0) {
    print "&nbsp; &nbsp;<span>" . _t("Layout") . "</span>";
    print "<select name='view'>";
Exemple #5
0
    }
}
# Locale selection
global $g_ui_locale;
$vs_base_url = $this->request->getRequestUrl();
$vs_base_url = substr($vs_base_url, 0, 1) == '/' ? $vs_base_url : '/' . $vs_base_url;
$vs_base_url = str_replace("/lang/[A-Za-z_]+", "", $vs_base_url);
if (is_array($va_ui_locales = $this->request->config->getList('ui_locales')) && sizeof($va_ui_locales) > 1) {
    print caFormTag($this->request, $this->request->getAction(), 'caLocaleSelectorForm', null, 'get', 'multipart/form-data', '_top', array('disableUnsavedChangesWarning' => true));
    $va_locale_options = array();
    foreach ($va_ui_locales as $vs_locale) {
        $va_parts = explode('_', $vs_locale);
        $vs_lang_name = Zend_Locale::getTranslation(strtolower($va_parts[0]), 'language', strtolower($va_parts[0]));
        $va_locale_options[$vs_lang_name] = $vs_locale;
    }
    print caHTMLSelect('lang', $va_locale_options, array('id' => 'caLocaleSelectorSelect', 'onchange' => 'window.location = \'' . caNavUrl($this->request, $this->request->getModulePath(), $this->request->getController(), $this->request->getAction(), array('lang' => '')) . '\' + jQuery(\'#caLocaleSelectorSelect\').val();'), array('value' => $g_ui_locale, 'dontConvertAttributeQuotesToEntities' => true));
    print "</form>\n";
}
?>
		
		</div><!-- end topbar -->
		<div id="pageArea">
			<div id="header">
<?php 
print caNavLink($this->request, "<img src='" . $this->request->getThemeUrlPath() . "/graphics/" . $this->request->config->get('header_img') . "' border='0'>", "", "", "", "");
?>
				
			
<?php 
// get last search ('basic_search' is the find type used by the SearchController)
$o_result_context = new ResultContext($this->request, 'ca_objects', 'basic_search');
<?php 
        $va_add_types = array(_t('under (child)') => 'under');
        if (!$vb_strict_type_hierarchy) {
            $va_add_types[_t('above (parent)')] = 'above';
        }
        if ($pn_parent_id > 0 && !$vb_strict_type_hierarchy) {
            $va_add_types[_t('next to (sibling)')] = 'next_to';
        }
        if ($vs_type_selector) {
            // for items that take types
            print "<div id='{$vs_id_prefix}HierarchyBrowseAdd'>" . _t("Add a new %1 %2 <em>%3</em>", $vs_type_selector, caHTMLSelect('add_type', $va_add_types, array('id' => "{$vs_id_prefix}addType")), $vs_subject_label);
            // Note the jQuery(\"#{$vs_id_prefix}childTypeList\").val() which grabs the value of the type
            print " <a href='#' onclick='_navigateToNewForm(jQuery(\"#{$vs_id_prefix}typeList\").val(), jQuery(\"#{$vs_id_prefix}addType\").val(), (jQuery(\"#{$vs_id_prefix}addType\").val() == \"next_to\") ? " . intval($pn_parent_id) . " : " . intval($pn_id) . ")'>" . caNavIcon($this->request, __CA_NAV_BUTTON_ADD__) . "</a></div>";
        } else {
            // for items without types
            print "<div id='{$vs_id_prefix}HierarchyBrowseAdd'>" . _t("Add a new %1 %2 <em>%3</em>", $t_subject->getProperty('NAME_SINGULAR'), caHTMLSelect('add_type', $va_add_types, array('id' => "{$vs_id_prefix}addType")), $vs_subject_label);
            print " <a href='#' onclick='_navigateToNewForm(0, jQuery(\"#{$vs_id_prefix}addType\").val(), (jQuery(\"#{$vs_id_prefix}addType\").val() == \"next_to\") ? " . intval($pn_parent_id) . " : " . intval($pn_id) . ")'>" . caNavIcon($this->request, __CA_NAV_BUTTON_ADD__) . "</a></div>";
        }
        ?>
					</div>
				</div>
				<div class="clear"><!-- empty --></div>
				<div id="<?php 
        print $vs_id_prefix;
        ?>
AddHierarchyBrowser" class="hierarchyBrowserSmall">
					<!-- Content for hierarchy browser is dynamically inserted here by ca.hierbrowser -->
				</div><!-- end hierbrowser -->
		</div>
<?php 
    }
Exemple #7
0
 /**
  * Generates HTML form element widget for preference based upon settings in preference definition file.
  * By calling this method for a series of preference names, one can quickly create an HTML-based configuration form.
  *
  * @access public
  * @param string $ps_pref Name of user preference
  * @param string $ps_format Format string containing simple tags to be replaced with preference information. Tags supported are:
  *		^LABEL = name of preference
  *		^ELEMENT = HTML code to generate form widget
  * 		If you omit $ps_format, the element code alone (content of ^ELEMENT) is returned.
  * @param array $pa_options Array of options. Support options are:
  *		field_errors = array of error messages to display on preference element
  *		useTable = if true and displayType for element in DT_CHECKBOXES checkboxes will be formatted in a table with numTableColumns columns
  *		numTableColumns = Number of columns to use when formatting checkboxes as a table. Default, if omitted, is 3
  *		genericUIList = forces FT_*_EDITOR_UI to return single UI list for table rather than by type
  *		classname = class to assign to form element
  * @return string HTML code to generate form widget
  */
 public function preferenceHtmlFormElement($ps_pref, $ps_format = null, $pa_options = null)
 {
     if ($this->isValidPreference($ps_pref)) {
         if (!is_array($pa_options)) {
             $pa_options = array();
         }
         $o_db = $this->getDb();
         $va_pref_info = $this->getPreferenceInfo($ps_pref);
         if (is_null($vs_current_value = $this->getPreference($ps_pref))) {
             $vs_current_value = $this->getPreferenceDefault($ps_pref);
         }
         $vs_output = "";
         $vs_class = "";
         $vs_classname = "";
         if (isset($pa_options['classname']) && $pa_options['classname']) {
             $vs_classname = $pa_options['classname'];
             $vs_class = " class='" . $pa_options['classname'] . "'";
         }
         foreach (array('displayType', 'displayWidth', 'displayHeight', 'length', 'formatType', 'choiceList', 'label', 'description') as $vs_k) {
             if (!isset($va_pref_info[$vs_k])) {
                 $va_pref_info[$vs_k] = null;
             }
         }
         switch ($va_pref_info["displayType"]) {
             # ---------------------------------
             case 'DT_FIELD':
                 if (($vn_display_width = $va_pref_info["displayWidth"]) < 1) {
                     $vn_display_width = 20;
                 }
                 if (($vn_display_height = $va_pref_info["displayHeight"]) < 1) {
                     $vn_display_height = 1;
                 }
                 if (isset($va_pref_info["length"]["maximum"])) {
                     $vn_max_input_length = $va_pref_info["length"]["maximum"];
                 } else {
                     $vn_max_input_length = $vn_display_width;
                 }
                 if ($vn_display_height > 1) {
                     $vs_output = "<textarea name='pref_{$ps_pref}' rows='" . $vn_display_height . "' cols='" . $vn_display_width . "'>" . htmlspecialchars($vs_current_value, ENT_QUOTES, 'UTF-8') . "</textarea>\n";
                 } else {
                     $vs_output = "<input type='text' name='pref_{$ps_pref}' size='{$vn_display_width}' maxlength='{$vn_max_input_length}'" . $vs_class . " value='" . htmlspecialchars($vs_current_value, ENT_QUOTES, 'UTF-8') . "'/>\n";
                 }
                 break;
                 # ---------------------------------
             # ---------------------------------
             case 'DT_SELECT':
                 switch ($va_pref_info['formatType']) {
                     case 'FT_UI_LOCALE':
                         $va_locales = array();
                         if ($r_dir = opendir(__CA_APP_DIR__ . '/locale/')) {
                             while (($vs_locale_dir = readdir($r_dir)) !== false) {
                                 if ($vs_locale_dir[0] == '.') {
                                     continue;
                                 }
                                 if (sizeof($va_tmp = explode('_', $vs_locale_dir)) == 2) {
                                     $va_locales[$vs_locale_dir] = $va_tmp;
                                 }
                             }
                         }
                         $va_opts = array();
                         $t_locale = new ca_locales();
                         foreach ($va_locales as $vs_code => $va_parts) {
                             try {
                                 $vs_lang_name = Zend_Locale::getTranslation(strtolower($va_parts[0]), 'language', strtolower($va_parts[0]));
                                 $vs_country_name = Zend_Locale::getTranslation($va_parts[1], 'Country', $vs_code);
                             } catch (Exception $e) {
                                 $vs_lang_name = strtolower($va_parts[0]);
                                 $vs_country_name = $vs_code;
                             }
                             $va_opts[($vs_lang_name ? $vs_lang_name : $vs_code) . ($vs_country_name ? ' (' . $vs_country_name . ')' : '')] = $vs_code;
                         }
                         break;
                     case 'FT_LOCALE':
                         $qr_locales = $o_db->query("\n\t\t\t\t\t\t\t\tSELECT *\n\t\t\t\t\t\t\t\tFROM ca_locales\n\t\t\t\t\t\t\t\tORDER BY \n\t\t\t\t\t\t\t\t\tname\n\t\t\t\t\t\t\t");
                         $va_opts = array();
                         while ($qr_locales->nextRow()) {
                             $va_opts[$qr_locales->get('name')] = $qr_locales->get('language') . '_' . $qr_locales->get('country');
                         }
                         break;
                     case 'FT_THEME':
                         if ($r_dir = opendir($this->_CONFIG->get('themes_directory'))) {
                             $va_opts = array();
                             while (($vs_theme_dir = readdir($r_dir)) !== false) {
                                 if ($vs_theme_dir[0] == '.') {
                                     continue;
                                 }
                                 $o_theme_info = Configuration::load($this->_CONFIG->get('themes_directory') . '/' . $vs_theme_dir . '/themeInfo.conf');
                                 $va_opts[$o_theme_info->get('name')] = $vs_theme_dir;
                             }
                         }
                         break;
                     case 'FT_OBJECT_EDITOR_UI':
                     case 'FT_OBJECT_LOT_EDITOR_UI':
                     case 'FT_ENTITY_EDITOR_UI':
                     case 'FT_PLACE_EDITOR_UI':
                     case 'FT_OCCURRENCE_EDITOR_UI':
                     case 'FT_COLLECTION_EDITOR_UI':
                     case 'FT_STORAGE_LOCATION_EDITOR_UI':
                     case 'FT_OBJECT_REPRESENTATION_EDITOR_UI':
                     case 'FT_REPRESENTATION_ANNOTATION_EDITOR_UI':
                     case 'FT_SET_EDITOR_UI':
                     case 'FT_SET_ITEM_EDITOR_UI':
                     case 'FT_LIST_EDITOR_UI':
                     case 'FT_LIST_ITEM_EDITOR_UI':
                     case 'FT_LOAN_EDITOR_UI':
                     case 'FT_MOVEMENT_EDITOR_UI':
                     case 'FT_TOUR_EDITOR_UI':
                     case 'FT_TOUR_STOP_EDITOR_UI':
                     case 'FT_SEARCH_FORM_EDITOR_UI':
                     case 'FT_BUNDLE_DISPLAY_EDITOR_UI':
                     case 'FT_RELATIONSHIP_TYPE_EDITOR_UI':
                     case 'FT_USER_INTERFACE_EDITOR_UI':
                     case 'FT_USER_INTERFACE_SCREEN_EDITOR_UI':
                     case 'FT_IMPORT_EXPORT_MAPPING_EDITOR_UI':
                     case 'FT_IMPORT_EXPORT_MAPPING_GROUP_EDITOR_UI':
                         $vn_table_num = $this->_editorPrefFormatTypeToTableNum($va_pref_info['formatType']);
                         $t_instance = $this->getAppDatamodel()->getInstanceByTableNum($vn_table_num, true);
                         $va_values = $this->getPreference($ps_pref);
                         if (!is_array($va_values)) {
                             $va_values = array();
                         }
                         if (method_exists($t_instance, 'getTypeFieldName') && $t_instance->getTypeFieldName() && (!isset($pa_options['genericUIList']) || !$pa_options['genericUIList'])) {
                             $vs_output = '';
                             $va_ui_list_by_type = $this->_getUIListByType($vn_table_num);
                             $va_types = array();
                             if ((bool) $t_instance->getFieldInfo($t_instance->getTypeFieldName(), 'IS_NULL')) {
                                 $va_types['_NONE_'] = array('LEVEL' => 0, 'name_singular' => _t('NONE'), 'name_plural' => _t('NONE'));
                             }
                             $va_types += $t_instance->getTypeList(array('returnHierarchyLevels' => true));
                             if (!is_array($va_types) || !sizeof($va_types)) {
                                 $va_types = array(1 => array());
                             }
                             // force ones with no types to get processed for __all__
                             foreach ($va_types as $vn_type_id => $va_type) {
                                 $va_opts = array();
                                 // print out type-specific
                                 if (is_array($va_ui_list_by_type[$vn_type_id])) {
                                     foreach (caExtractValuesByUserLocale($va_ui_list_by_type[$vn_type_id]) as $vn_ui_id => $vs_label) {
                                         $va_opts[$vn_ui_id] = $vs_label;
                                     }
                                 }
                                 // print out generic
                                 if (is_array($va_ui_list_by_type['__all__'])) {
                                     foreach (caExtractValuesByUserLocale($va_ui_list_by_type['__all__']) as $vn_ui_id => $vs_label) {
                                         $va_opts[$vn_ui_id] = $vs_label;
                                     }
                                 }
                                 if (!is_array($va_opts) || sizeof($va_opts) == 0) {
                                     continue;
                                 }
                                 $vs_output .= "<tr><td>" . str_repeat("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;", (int) $va_type['LEVEL']) . $va_type['name_singular'] . "</td><td><select name='pref_{$ps_pref}_{$vn_type_id}'>\n";
                                 foreach ($va_opts as $vs_val => $vs_opt) {
                                     $vs_selected = $vs_val == $va_values[$vn_type_id] ? "SELECTED" : "";
                                     $vs_output .= "<option value='" . htmlspecialchars($vs_val, ENT_QUOTES, 'UTF-8') . "' {$vs_selected}>{$vs_opt}</option>\n";
                                 }
                                 $vs_output .= "</select></td></tr>\n";
                             }
                         } else {
                             $va_opts = $this->_getUIList($vn_table_num);
                             if (!is_array($va_opts) || sizeof($va_opts) == 0) {
                                 $vs_output = '';
                                 break 2;
                             }
                             $vs_output = "<tr><td> </td><td><select name='pref_{$ps_pref}'>\n";
                             foreach ($va_opts as $vs_val => $vs_opt) {
                                 $vs_selected = $vs_val == $vs_current_value ? "SELECTED" : "";
                                 $vs_output .= "<option value='" . htmlspecialchars($vs_val, ENT_QUOTES, 'UTF-8') . "' {$vs_selected}>" . $vs_opt . "</option>\n";
                             }
                             $vs_output .= "</select></td></tr>\n";
                         }
                         break 2;
                     default:
                         $va_opts = $va_pref_info["choiceList"];
                         break;
                 }
                 if (!is_array($va_opts) || sizeof($va_opts) == 0) {
                     $vs_output = '';
                     break;
                 }
                 $vs_output = "<select name='pref_{$ps_pref}'" . $vs_class . ">\n";
                 foreach ($va_opts as $vs_opt => $vs_val) {
                     $vs_selected = $vs_val == $vs_current_value ? "selected='1'" : "";
                     $vs_output .= "<option value='" . htmlspecialchars($vs_val, ENT_QUOTES, 'UTF-8') . "' {$vs_selected}>" . $vs_opt . "</option>\n";
                 }
                 $vs_output .= "</select>\n";
                 break;
                 # ---------------------------------
             # ---------------------------------
             case 'DT_CHECKBOXES':
                 if ($va_pref_info["formatType"] == 'FT_BIT') {
                     $vs_selected = $vs_current_value ? "CHECKED" : "";
                     $vs_output .= "<input type='checkbox' name='pref_{$ps_pref}' value='1'" . $vs_class . " {$vs_selected}>\n";
                 } else {
                     if ($vb_use_table = isset($pa_options['useTable']) && (bool) $pa_options['useTable']) {
                         $vs_output .= "<table width='100%'>";
                     }
                     $vn_num_table_columns = isset($pa_options['numTableColumns']) && (int) $pa_options['numTableColumns'] > 0 ? (int) $pa_options['numTableColumns'] : 3;
                     $vn_c = 0;
                     foreach ($va_pref_info["choiceList"] as $vs_opt => $vs_val) {
                         if (is_array($vs_current_value)) {
                             $vs_selected = in_array($vs_val, $vs_current_value) ? "CHECKED" : "";
                         } else {
                             $vs_selected = '';
                         }
                         if ($vb_use_table && $vn_c == 0) {
                             $vs_output .= "<tr>";
                         }
                         if ($vb_use_table) {
                             $vs_output .= "<td width='" . floor(100 / $vn_num_table_columns) . "%'>";
                         }
                         $vs_output .= "<input type='checkbox' name='pref_" . $ps_pref . "[]' value='" . htmlspecialchars($vs_val, ENT_QUOTES, 'UTF-8') . "'" . $vs_class . " {$vs_selected}> " . $vs_opt . " \n";
                         if ($vb_use_table) {
                             $vs_output .= "</td>";
                         }
                         $vn_c++;
                         if ($vb_use_table && !($vn_c % $vn_num_table_columns)) {
                             $vs_output .= "</tr>\n";
                             $vn_c = 0;
                         }
                     }
                     if ($vb_use_table) {
                         $vs_output .= "</table>";
                     }
                 }
                 break;
                 # ---------------------------------
             # ---------------------------------
             case 'DT_STATEPROV_LIST':
                 $vs_output .= caHTMLSelect("pref_{$ps_pref}_select", array(), array('id' => "pref_{$ps_pref}_select", 'class' => $vs_classname), array('value' => $vs_current_value));
                 $vs_output .= caHTMLTextInput("pref_{$ps_pref}_name", array('id' => "pref_{$ps_pref}_text", 'value' => $vs_current_value, 'class' => $vs_classname));
                 break;
                 # ---------------------------------
             # ---------------------------------
             case 'DT_COUNTRY_LIST':
                 $vs_output .= caHTMLSelect("pref_{$ps_pref}", caGetCountryList(), array('id' => "pref_{$ps_pref}", 'class' => $vs_classname), array('value' => $vs_current_value));
                 if ($va_pref_info['stateProvPref']) {
                     $vs_output .= "<script type='text/javascript'>\n";
                     $vs_output .= "var caStatesByCountryList = " . json_encode(caGetStateList()) . ";\n";
                     $vs_output .= "\n\t\t\t\t\t\t\tjQuery('#pref_{$ps_pref}').click({countryID: 'pref_{$ps_pref}', stateProvID: 'pref_" . $va_pref_info['stateProvPref'] . "', value: '" . addslashes($this->getPreference($va_pref_info['stateProvPref'])) . "', statesByCountryList: caStatesByCountryList}, caUI.utils.updateStateProvinceForCountry);\n\t\t\t\t\t\t\tjQuery(document).ready(function() {\n\t\t\t\t\t\t\t\tcaUI.utils.updateStateProvinceForCountry({data: {countryID: 'pref_{$ps_pref}', stateProvID: 'pref_" . $va_pref_info['stateProvPref'] . "', value: '" . addslashes($this->getPreference($va_pref_info['stateProvPref'])) . "', statesByCountryList: caStatesByCountryList}});\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t";
                     $vs_output .= "</script>\n";
                 }
                 break;
                 # ---------------------------------
             # ---------------------------------
             case 'DT_CURRENCIES':
                 $vs_output .= caHTMLSelect("pref_{$ps_pref}", caAvailableCurrenciesForConversion(), array('id' => "pref_{$ps_pref}", 'class' => $vs_classname), array('value' => $vs_current_value));
                 break;
                 # ---------------------------------
             # ---------------------------------
             case 'DT_RADIO_BUTTONS':
                 foreach ($va_pref_info["choiceList"] as $vs_opt => $vs_val) {
                     $vs_selected = $vs_val == $vs_current_value ? "CHECKED" : "";
                     $vs_output .= "<input type='radio' name='pref_{$ps_pref}'" . $vs_class . " value='" . htmlspecialchars($vs_val, ENT_QUOTES, 'UTF-8') . "' {$vs_selected}> " . $vs_opt . " \n";
                 }
                 break;
                 # ---------------------------------
             # ---------------------------------
             case 'DT_PASSWORD':
                 if (($vn_display_width = $va_pref_info["displayWidth"]) < 1) {
                     $vn_display_width = 20;
                 }
                 if (isset($va_pref_info["length"]["maximum"])) {
                     $vn_max_input_length = $va_pref_info["length"]["maximum"];
                 } else {
                     $vn_max_input_length = $vn_display_width;
                 }
                 $vs_output = "<input type='password' name='pref_{$ps_pref}' size='{$vn_display_width}' maxlength='{$vn_max_input_length}'" . $vs_class . " value='" . htmlspecialchars($vs_current_value, ENT_QUOTES, 'UTF-8') . "'/>\n";
                 break;
                 # ---------------------------------
             # ---------------------------------
             default:
                 return "Configuration error: Invalid display type for {$ps_pref}";
                 # ---------------------------------
         }
         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');
                 $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 {
                 $ps_format = $this->_CONFIG->get('form_element_display_format');
                 $vs_errors = '';
             }
         }
         if ($ps_format && $vs_output) {
             $vs_format = $ps_format;
             $vs_format = str_replace("^ELEMENT", $vs_output, $vs_format);
         } else {
             $vs_format = $vs_output;
         }
         $vs_format = str_replace("^EXTRA", '', $vs_format);
         if (preg_match("/\\^DESCRIPTION/", $vs_format)) {
             $vs_format = str_replace("^LABEL", _t($va_pref_info["label"]), $vs_format);
             $vs_format = str_replace("^DESCRIPTION", _t($va_pref_info["description"]), $vs_format);
         } else {
             // no explicit placement of description text, so...
             $vs_field_id = "pref_{$ps_pref}_container";
             $vs_format = str_replace("^LABEL", '<span id="' . $vs_field_id . '">' . _t($va_pref_info["label"]) . '</span>', $vs_format);
             TooltipManager::add('#' . $vs_field_id, "<h3>" . $va_pref_info["label"] . "</h3>" . $va_pref_info["description"]);
         }
         return $vs_format;
     } else {
         return "";
     }
 }
 /**
  * Returns HTML search form input widget for bundle specified by standard "get" bundle code (eg. <table_name>.<bundle_name> format)
  * This method handles generation of search form widgets for (1) related tables (eg. ca_places),  preferred and non-preferred labels for both the 
  * primary and related tables, and all other types of elements for related tables. If this method can't handle the bundle it will pass the request to the 
  * superclass implementation of htmlFormElementForSearch()
  *
  * @param $po_request HTTPRequest
  * @param $ps_field string
  * @param $pa_options array
  * @return string HTML text of form element. Will return null (from superclass) if it is not possible to generate an HTML form widget for the bundle.
  * 
  */
 public function htmlFormElementForSearch($po_request, $ps_field, $pa_options = null)
 {
     $vb_as_array_element = (bool) caGetOption('asArrayElement', $pa_options, false);
     $va_tmp = explode('.', $ps_field);
     switch ($va_tmp[0]) {
         case '_fulltext':
             if (!isset($pa_options['width'])) {
                 $pa_options['width'] = 30;
             }
             if (!isset($pa_options['height'])) {
                 $pa_options['height'] = 30;
             }
             if (!isset($pa_options['values'])) {
                 $pa_options['values'] = array();
             }
             if (!isset($pa_options['values']['_fulltext'])) {
                 $pa_options['values'][$ps_field] = '';
             }
             return caHTMLTextInput("_fulltext" . ($vb_as_array_element ? "[]" : ""), array('value' => $pa_options['values']['_fulltext'], 'size' => $pa_options['width'], 'class' => $pa_options['class']), $pa_options);
             break;
         case '_fieldlist':
             if (!isset($pa_options['width'])) {
                 $pa_options['width'] = 30;
             }
             if (!isset($pa_options['height'])) {
                 $pa_options['height'] = 30;
             }
             if (!isset($pa_options['values'])) {
                 $pa_options['values'] = array();
             }
             $va_filter = $va_alt_names = $va_relationship_restricted_searches = null;
             if (is_array($va_fields = preg_split("![;,]+!", caGetOption('fields', $pa_options, null))) && sizeof($va_fields)) {
                 $va_filter = $va_alt_names = $va_relationship_restricted_searches = array();
                 foreach ($va_fields as $vs_field_raw) {
                     $va_tmp = explode(':', $vs_field_raw);
                     $va_tmp2 = explode('/', $va_tmp[0]);
                     // If there's a "/" separator then this is a relationship type-restricted search (Eg. ca_entities.preferred_labels.displayname/artist:"Isamu Noguchi")
                     if (sizeof($va_tmp2) > 1) {
                         $va_relationship_restricted_searches[$va_tmp2[0]][] = $va_tmp[0];
                     } else {
                         $va_filter[] = $va_tmp2[0];
                     }
                     if (isset($va_tmp[1]) && $va_tmp[1]) {
                         $va_alt_names[$va_tmp[0]] = $va_tmp[1];
                     }
                 }
             }
             $va_options = caGetBundlesAvailableForSearch($this->tableName(), array('forSelect' => true, 'filter' => $va_filter));
             // We need to add any relationship-restricted searh qualifiers here since they're not free-standing bundles but
             // rather variants on an unqualified relationship bundle
             foreach ($va_relationship_restricted_searches as $vs_without_rel_restriction => $va_with_rel_restrictions) {
                 foreach ($va_with_rel_restrictions as $vs_with_rel_restriction) {
                     $vs_label = isset($va_alt_names[$vs_with_rel_restriction]) ? $va_alt_names[$vs_with_rel_restriction] : $vs_with_rel_restriction;
                     $va_options[$vs_label] = $vs_with_rel_restriction;
                 }
             }
             if (is_array($va_alt_names)) {
                 foreach ($va_options as $vs_l => $vs_fld) {
                     if (isset($va_alt_names[$vs_fld])) {
                         unset($va_options[$vs_l]);
                         $va_options[$va_alt_names[$vs_fld]] = $vs_fld;
                     }
                 }
             }
             if (is_array($va_filter) && sizeof($va_filter)) {
                 // reorder options to keep field list order (sigh)
                 $va_options_tmp = array();
                 foreach ($va_filter as $vs_filter) {
                     if (($vs_k = array_search($vs_filter, $va_options)) !== false) {
                         $va_options_tmp[$vs_k] = $va_options[$vs_k];
                     }
                 }
                 $va_options = $va_options_tmp;
             }
             return caHTMLSelect("_fieldlist_field" . ($vb_as_array_element ? "[]" : ""), $va_options, array('size' => $pa_options['fieldListWidth'], 'class' => $pa_options['class']), array_merge($pa_options, array('value' => $pa_options['values']['_fieldlist_field'][0]))) . caHTMLTextInput("_fieldlist_value" . ($vb_as_array_element ? "[]" : ""), array('value' => $pa_options['values']['_fieldlist_value'], 'size' => $pa_options['width'], 'class' => $pa_options['class']), $pa_options);
             break;
     }
     if (!in_array($va_tmp[0], array('created', 'modified'))) {
         switch (sizeof($va_tmp)) {
             # -------------------------------------
             case 1:
                 // table_name
                 if ($va_tmp[0] != $this->tableName()) {
                     if (!is_array($pa_options)) {
                         $pa_options = array();
                     }
                     if (!isset($pa_options['width'])) {
                         $pa_options['width'] = 30;
                     }
                     if (!isset($pa_options['values'])) {
                         $pa_options['values'] = array();
                     }
                     if (!isset($pa_options['values'][$ps_field])) {
                         $pa_options['values'][$ps_field] = '';
                     }
                     return caHTMLTextInput($ps_field . ($vb_as_array_element ? "[]" : ""), array('value' => $pa_options['values'][$ps_field], 'size' => $pa_options['width'], 'class' => $pa_options['class'], 'id' => str_replace('.', '_', $ps_field)));
                 }
                 break;
                 # -------------------------------------
             # -------------------------------------
             case 2:
                 // table_name.field_name
             // table_name.field_name
             case 3:
                 // table_name.field_name.sub_element
                 if (!($t_instance = $this->_DATAMODEL->getInstanceByTableName($va_tmp[0], true))) {
                     return null;
                 }
                 switch ($va_tmp[1]) {
                     # --------------------
                     case 'preferred_labels':
                     case 'nonpreferred_labels':
                         return caHTMLTextInput($ps_field . ($vb_as_array_element ? "[]" : ""), array('value' => $pa_options['values'][$ps_field], 'size' => $pa_options['width'], 'class' => $pa_options['class'], 'id' => str_replace('.', '_', $ps_field)));
                         break;
                         # --------------------
                     # --------------------
                     default:
                         if ($va_tmp[0] != $this->tableName()) {
                             switch (sizeof($va_tmp)) {
                                 case 1:
                                     return caHTMLTextInput($ps_field . ($vb_as_array_element ? "[]" : ""), array('value' => $pa_options['values'][$ps_field], 'size' => $pa_options['width'], 'class' => $pa_options['class'], 'id' => str_replace('.', '_', $ps_field)));
                                 case 2:
                                 case 3:
                                     if (caGetOption('select', $pa_options, false)) {
                                         $va_access = caGetOption('checkAccess', $pa_options, null);
                                         if (!($t_instance = $this->_DATAMODEL->getInstanceByTableName($va_tmp[0], true))) {
                                             return null;
                                         }
                                         $vs_label_display_field = $t_instance->getLabelDisplayField();
                                         $qr_res = call_user_func_array($va_tmp[0] . '::find', array(array('deleted' => 0, 'parent_id' => null), array('sort' => caGetOption('sort', $pa_options, $t_instance->getLabelTableName() . '.' . $vs_label_display_field), 'returnAs' => 'searchResult')));
                                         $vs_pk = $t_instance->primaryKey();
                                         $va_opts = array('-' => '');
                                         while ($qr_res->nextHit()) {
                                             if (is_array($va_access) && !in_array($qr_res->get($va_tmp[0] . '.access'), $va_access)) {
                                                 continue;
                                             }
                                             $va_opts[$qr_res->get($va_tmp[0] . ".preferred_labels.{$vs_label_display_field}")] = $qr_res->get($ps_field);
                                         }
                                         return caHTMLSelect($ps_field . ($vb_as_array_element ? "[]" : ""), $va_opts, array('value' => $pa_options['values'][$ps_field], 'class' => $pa_options['class'], 'id' => str_replace('.', '_', $ps_field)));
                                     } else {
                                         return $t_instance->htmlFormElementForSearch($po_request, $ps_field, $pa_options);
                                     }
                                     break;
                             }
                         }
                         break;
                         # --------------------
                 }
                 break;
                 # -------------------------------------
         }
     }
     return parent::htmlFormElementForSearch($po_request, $ps_field, $pa_options);
 }
$va_forms = $this->getVar('form_codes');
$vs_form = $this->getVar('form');
// name of form to display
$va_form_info = caGetInfoForAdvancedSearchForm($vs_form, $t_subject->tableName());
//
// Set options for all form element here
//
$va_bundle_opts = array('values' => $o_result_context->getParameter('form_data'));
//
// List out form elements to display here
//
$va_form_fields = caGetAdvancedSearchFormElementNames($vs_form, $t_subject->tableName());
$va_form_field_with_subelements = caGetAdvancedSearchFormElementNames($vs_form, $t_subject->tableName(), array('includeSubElements' => true));
if (!$this->request->isAjax()) {
    if (sizeof($va_forms) > 1) {
        print "<div style='float: right;'><form action='#'>" . caHTMLSelect('form', $va_forms, array('onchange' => 'caLoadAdvancedSearchForm();', 'id' => 'caAdvancedSearchFormSelector'), array('value' => $vs_form)) . "</form></div>\n";
    }
    ?>
	<H1 class="results" style="margin-top:15px;"><?php 
    print _t("Advanced Search");
    ?>
</H1>
<?php 
}
if ($va_form_fields && is_array($va_form_fields) && sizeof($va_form_fields)) {
    ?>
		<div id="caAdvancedSearchForm">
			<?php 
    print caFormTag($this->request, 'Index', 'caAdvancedSearch', null, 'POST', 'multipart/form-data', '_top', array('disableUnsavedChangesWarning' => true));
    ?>
Exemple #10
0
 *
 * ----------------------------------------------------------------------
 */
$va_user_list = $this->getVar('user_list');
?>
<script language="JavaScript" type="text/javascript">
/* <![CDATA[ */
	$(document).ready(function(){
		$('#caUserList').caFormatListTable();
	});
/* ]]> */
</script>
<div class="sectionBox">
<?php 
print caFormTag($this->request, 'ListUsers', 'caUserListForm', null, 'post', 'multipart/form-data', '_top', array('disableUnsavedChangesWarning' => true));
print caFormControlBox('<div class="list-filter">' . _t('Filter') . ': <input type="text" name="filter" value="" onkeyup="$(\'#caUserList\').caFilterTable(this.value); return false;" size="20"/></div>', '' . _t('Show %1 users', caHTMLSelect('userclass', $this->request->user->getFieldInfo('userclass', 'BOUNDS_CHOICE_LIST'), array('onchange' => 'jQuery("#caUserListForm").submit();'), array('value' => $this->getVar('userclass')))), caNavHeaderButton($this->request, __CA_NAV_BUTTON_ADD__, _t("New user"), 'administrate/access', 'Users', 'Edit', array('user_id' => 0)));
if (sizeof($va_user_list)) {
    ?>
	
		<a href='#' id='showTools' onclick='jQuery("#searchToolsBox").slideDown(250); jQuery("#showTools").hide(); return false;'><?php 
    print _t("Tools");
    ?>
 <img src="<?php 
    print $this->request->getThemeUrlPath();
    ?>
/graphics/arrows/arrow_right_gray.gif" width="6" height="7" border="0"></a>
<?php 
    print $this->render('user_tools_html.php');
}
?>
	
 * This program is free software; you may redistribute it and/or modify it under
 * the terms of the provided license as published by Whirl-i-Gig
 *
 * CollectiveAccess is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTIES whatsoever, including any implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 * This source code is free and modifiable under the terms of
 * GNU General Public License. (http://www.gnu.org/copyleft/gpl.html). See
 * the "license.txt" file for details, or visit the CollectiveAccess web site at
 * http://www.CollectiveAccess.org
 *
 * ----------------------------------------------------------------------
 */
$va_editor_ui_list = $this->getVar('editor_ui_list');
$vs_type_menu = '<div class="sf-small-menu form-header-button rounded">' . '<div style="float:right; margin: 3px;">' . '<a href="#" onclick="_navigateToNewForm(jQuery(\'#tableList\').val());">' . caNavIcon($this->request, __CA_NAV_BUTTON_ADD_LARGE__) . '</a>' . '</div>' . '<form action="#">' . _t('New interface for ') . ' ' . caHTMLSelect('editor_type', $this->getVar('table_list'), array('id' => 'tableList')) . '</form>' . '</div>';
?>
<script language="JavaScript" type="text/javascript">
/* <![CDATA[ */
	$(document).ready(function(){
		$('#caUIList').caFormatListTable();
	});
	
	function _navigateToNewForm(editor_type) {
		document.location = '<?php 
print caNavUrl($this->request, 'administrate/setup/interface_editor', 'InterfaceEditor', 'Edit', array('ui_id' => 0));
?>
' + '/editor_type/' + editor_type;
	}
/* ]]> */
</script>
print caHTMLTextInput('sourceText', array('id' => 'caSourceText'), array('width' => '600px', 'height' => 3));
?>
					</p>
				</div>
			</div>
		</div>
		<div class='bundleLabel'>
			<span class="formLabelText"><?php 
print _t('Log level');
?>
</span> 
			<div class="bundleContainer">
				<div class="caLabelList">
					<p>
<?php 
print caHTMLSelect('logLevel', caGetLogLevels(), array('id' => 'caLogLevel'), array('value' => $va_last_settings['logLevel']));
?>
					</p>
				</div>
			</div>
		</div>
		<div class='bundleLabel'>
			<span class="formLabelText"><?php 
print _t('Testing options');
?>
</span> 
			<div class="bundleContainer">
				<div class="caLabelList" >
					<p class="formLabelPlain">
<?php 
$va_attr = array('id' => 'caDryRun', 'value' => 1);
 * This program is free software; you may redistribute it and/or modify it under
 * the terms of the provided license as published by Whirl-i-Gig
 *
 * CollectiveAccess is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTIES whatsoever, including any implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 * This source code is free and modifiable under the terms of
 * GNU General Public License. (http://www.gnu.org/copyleft/gpl.html). See
 * the "license.txt" file for details, or visit the CollectiveAccess web site at
 * http://www.CollectiveAccess.org
 *
 * ----------------------------------------------------------------------
 */
$va_mapping_list = $this->getVar('mapping_list');
$vs_type_menu = '<div class="sf-small-menu form-header-button rounded">' . '<div style="float:right; margin: 3px;">' . '<a href="#" onclick="_navigateToNewForm(jQuery(\'#tableList\').val(), jQuery(\'#targetList\').val(), jQuery(\'#directionList\').val());">' . caNavIcon($this->request, __CA_NAV_BUTTON_ADD__) . '</a>' . '</div>' . '<form action="#">' . _t('New %1 %2 mapping for %3', caHTMLSelect('format', $this->getVar('format_list'), array('id' => 'targetList')), caHTMLSelect('direction', $this->getVar('direction_list'), array('id' => 'directionList')), caHTMLSelect('table_num', $this->getVar('table_list'), array('id' => 'tableList'))) . '</form>' . '</div>';
?>
<script language="JavaScript" type="text/javascript">
/* <![CDATA[ */
	$(document).ready(function(){
		$('#caMappingList').caFormatListTable();
	});
	
	function _navigateToNewForm(table_num, target, direction) {
		document.location = '<?php 
print caNavUrl($this->request, 'administrate/setup/bundle_mapping_editor', 'BundleMappingEditor', 'Edit', array('mapping_id' => 0));
?>
' + '/table_num/' + table_num + '/target/' + target + '/direction/' + direction;
	}
/* ]]> */
</script>
</a></div>
		</form>
	</div>
	<br class="clear"/>
<?php 
}
?>
	<div class="col">
<?php 
print "<span class='header'>" . _t("Create set") . ":</span><br/>";
?>
		<form id="caCreateSetFromResults">
<?php 
print caHTMLTextInput('set_name', array('id' => 'caCreateSetFromResultsInput', 'class' => 'searchSetsTextInput', 'value' => $o_result_context->getSearchExpression()), array('width' => '150px'));
print " ";
print caHTMLSelect('set_create_mode', array(_t('from results') => 'from_results', _t('from checked') => 'from_checked'), array('id' => 'caCreateSetFromResultsMode', 'class' => 'searchSetsSelect'), array('value' => null, 'width' => '140px'));
if ($t_list->getAppConfig()->get('enable_set_type_controls')) {
    print $t_list->getListAsHTMLFormElement('set_types', 'set_type', array('id' => 'caCreateSetTypeID', 'class' => 'searchSetsSelect'), array('value' => null, 'width' => '140px'));
}
print caBusyIndicatorIcon($this->request, array('id' => 'caCreateSetFromResultsIndicator')) . "\n";
?>
			<a href='#' onclick="caCreateSetFromResults(); return false;" class="button"><?php 
print _t('Create');
?>
 &rsaquo;</a>
<?php 
if ($this->request->user->canDoAction('can_batch_edit_' . $t_subject->tableName())) {
    print '<div class="searchSetsBatchEdit">' . caHTMLCheckboxInput('batch_edit', array('id' => 'caCreateSetBatchEdit', 'value' => 1)) . " " . _t('Open set for batch editing') . "</div>\n";
}
?>
		</form>
    if (!$t_order->getPrimaryKey() || $t_order->paymentIsAllowed()) {
        // && in_array($t_order->get('payment_method'), $va_payment_types))) {
        ?>
			<div id='caPaymentFields'>
				<H1><?php 
        print _t("Payment Details");
        ?>
</H1>
				<div class="bgWhite">
<?php 
        print "<div>" . $t_order->htmlFormElement('payment_method', $vs_form_element_format, array('width' => $vn_width, 'field_errors' => $va_errors[$vs_f], 'choiceList' => $va_payment_types, 'id' => 'caPaymentMethod')) . "</div>\n";
        ?>
					<div id="caClientOrderCustomerCreditSubForm">
<?php 
        print "<div style='float:left;'><b>" . _t("Credit card") . "</b><br/>" . caHTMLSelect('credit_card_type', $va_credit_card_types) . "</div>\n";
        print "<div style='margin-left:15px; float:left;'><b>" . _t("Expiration date") . "</b><br/>" . caHTMLSelect('credit_card_exp_mon', $this->getVar('credit_card_exp_month_list')) . " " . caHTMLSelect('credit_card_exp_yr', $this->getVar('credit_card_exp_year_list')) . "</div>\n";
        print "<div style='clear:left; float:left;'><b>" . _t("Credit card number") . "</b><br/>" . caHTMLTextInput('credit_card_number', array('size' => 30)) . "</div>\n";
        print "<div style='margin-left:15px; float:left;'><b>" . _t("CCV") . "</b><br/>" . caHTMLTextInput('credit_card_ccv', array('size' => 4)) . "</div>\n";
        print "<div id='caClientOrderProcessingIndicator'><img src='" . $this->request->getThemeUrlPath() . "/graphics/icons/indicator.gif'/> " . _t('Please wait while order is processed (this may take up to 60 seconds to complete)') . "</div>\n";
        ?>
						<div style="clear:both; height:1px; margin:0px;"><!-- empty --></div>
					</div>
					<div id="caClientOrderCustomerPOSubForm">
						Email your Purchase order to rnr@hsp.org or FAX it to 215-732-6200
					</div>
					<div id="caClientOrderCustomerCheckSubForm">
						Send your check for <?php 
        print $vs_currency_symbol . $t_order->getTotal();
        ?>
 to Rights and Reproductions, Historical Society of Pennsylvania, 1300 Locust Street, Philadelphia, PA 19107
					</div>
 public function __construct(&$po_request, &$po_response, $pa_view_paths = null)
 {
     parent::__construct($po_request, $po_response, $pa_view_paths);
     //
     // Get browse target
     //
     if (!($vs_browse_target = $po_request->getParameter('target', pString))) {
         if (!($vs_browse_target = $po_request->session->getVar('pawtucket2_browse_target'))) {
             if (is_array($va_browse_targets = $this->request->config->getList('browse_targets'))) {
                 $vs_browse_target = array_shift($va_browse_targets);
             }
         }
     }
     // redirect user if not logged in
     if ($this->request->config->get('pawtucket_requires_login') && !$this->request->isLoggedIn() || $this->request->config->get('show_bristol_only') && !$this->request->isLoggedIn()) {
         $this->response->setRedirect(caNavUrl($this->request, "", "LoginReg", "form"));
     } elseif ($this->request->config->get('show_bristol_only') && $this->request->isLoggedIn()) {
         $this->response->setRedirect(caNavUrl($this->request, "bristol", "Show", "Index"));
     }
     //
     // Minimal view list (all targets have a "full" results view)
     //
     $this->opa_views = array('full' => _t('List'));
     $this->opa_views_options = array('full' => array("description" => _t("View results in a list"), "icon" => "icon_list.gif"));
     //
     // Set up for browse target
     //
     switch ($vs_browse_target) {
         case 'ca_entities':
             $this->ops_tablename = 'ca_entities';
             $this->opo_result_context = new ResultContext($po_request, $this->ops_tablename, $this->ops_find_type);
             $this->opo_browse = new EntityBrowse($this->opo_result_context->getSearchExpression(), 'pawtucket2');
             // get configured result views, if specified
             if ($va_result_views_for_ca_entities = $po_request->config->getAssoc('result_views_for_ca_entities')) {
                 $this->opa_views = $va_result_views_for_ca_entities;
             }
             // get configured result views options, if specified
             if ($va_result_views_options_for_ca_entities = $po_request->config->getAssoc('result_views_options_for_ca_entities')) {
                 $this->opa_views_options = $va_result_views_options_for_ca_entities;
             }
             // get configured result sort options, if specified
             if ($va_sort_options_for_ca_entities = $po_request->config->getAssoc('result_sort_options_for_ca_entities')) {
                 $this->opa_sorts = $va_sort_options_for_ca_entities;
             } else {
                 $this->opa_sorts = array('ca_entity_labels.displayname' => _t('Name'), 'ca_entities.type_id' => _t('Type'), 'ca_entities.idno_sort' => _t('Idno'));
             }
             break;
         case 'ca_places':
             $this->ops_tablename = 'ca_places';
             $this->opo_result_context = new ResultContext($po_request, $this->ops_tablename, $this->ops_find_type);
             $this->opo_browse = new PlaceBrowse($this->opo_result_context->getSearchExpression(), 'pawtucket2');
             // get configured result views, if specified
             if ($va_result_views_for_ca_places = $po_request->config->getAssoc('result_views_for_ca_places')) {
                 $this->opa_views = $va_result_views_for_ca_places;
             }
             // get configured result views options, if specified
             if ($va_result_views_options_for_ca_places = $po_request->config->getAssoc('result_views_options_for_ca_places')) {
                 $this->opa_views_options = $va_result_views_options_for_ca_places;
             }
             // get configured result sort options, if specified
             if ($va_sort_options_for_ca_places = $po_request->config->getAssoc('result_sort_options_for_ca_places')) {
                 $this->opa_sorts = $va_sort_options_for_ca_places;
             } else {
                 $this->opa_sorts = array('ca_place_labels.name' => _t('Name'), 'ca_places.type_id' => _t('Type'), 'ca_places.idno_sort' => _t('Idno'));
             }
             break;
         case 'ca_occurrences':
             $this->ops_tablename = 'ca_occurrences';
             $this->opo_result_context = new ResultContext($po_request, $this->ops_tablename, $this->ops_find_type);
             $this->opo_browse = new OccurrenceBrowse($this->opo_result_context->getSearchExpression(), 'pawtucket2');
             // get configured result views, if specified
             if ($va_result_views_for_ca_occurrences = $po_request->config->getAssoc('result_views_for_ca_occurrences')) {
                 $this->opa_views = $va_result_views_for_ca_occurrences;
             }
             // get configured result views options, if specified
             if ($va_result_views_options_for_ca_occurrences = $po_request->config->getAssoc('result_views_options_for_ca_occurrences')) {
                 $this->opa_views_options = $va_result_views_options_for_ca_occurrences;
             }
             // get configured result sort options, if specified
             if ($va_sort_options_for_ca_occurrences = $po_request->config->getAssoc('result_sort_options_for_ca_occurrences')) {
                 $this->opa_sorts = $va_sort_options_for_ca_occurrences;
             } else {
                 $this->opa_sorts = array('ca_occurrence_labels.name' => _t('Title'), 'ca_occurrences.idno_sort' => _t('Idno'));
             }
             break;
         case 'ca_collections':
             $this->ops_tablename = 'ca_collections';
             $this->opo_result_context = new ResultContext($po_request, $this->ops_tablename, $this->ops_find_type);
             $this->opo_browse = new CollectionBrowse($this->opo_result_context->getSearchExpression(), 'pawtucket2');
             // get configured result views, if specified
             if ($va_result_views_for_ca_collections = $po_request->config->getAssoc('result_views_for_ca_collections')) {
                 $this->opa_views = $va_result_views_for_ca_collections;
             }
             // get configured result views options, if specified
             if ($va_result_views_options_for_ca_collections = $po_request->config->getAssoc('result_views_options_for_ca_collections')) {
                 $this->opa_views_options = $va_result_views_options_for_ca_collections;
             }
             // get configured result sort options, if specified
             if ($va_sort_options_for_ca_collections = $po_request->config->getAssoc('result_sort_options_for_ca_collections')) {
                 $this->opa_sorts = $va_sort_options_for_ca_collections;
             } else {
                 $this->opa_sorts = array('ca_collection_labels.name' => _t('Name'), 'ca_collections.type_id' => _t('Type'), 'ca_collections.idno_sort' => _t('Idno'));
             }
             break;
         default:
             $this->ops_tablename = 'ca_objects';
             $this->opo_result_context = new ResultContext($po_request, $this->ops_tablename, $this->ops_find_type);
             $this->opo_browse = new ObjectBrowse($this->opo_result_context->getSearchExpression(), 'pawtucket2');
             // get configured result views, if specified
             if ($va_result_views_for_ca_objects = $po_request->config->getAssoc('result_views_for_ca_objects')) {
                 $this->opa_views = $va_result_views_for_ca_objects;
             } else {
                 $this->opa_views = array('full' => _t('List'), 'thumbnail' => _t('Thumbnails'));
             }
             // get configured result views options, if specified
             if ($va_result_views_options_for_ca_objects = $po_request->config->getAssoc('result_views_options_for_ca_objects')) {
                 $this->opa_views_options = $va_result_views_options_for_ca_objects;
             } else {
                 $this->opa_views_options = array('thumbnail' => array("description" => _t("View thumbnails with brief captions"), "icon" => "icon_thumbnail.gif"), 'full' => array("description" => _t("View images with full captions"), "icon" => "icon_full.gif"));
             }
             // get configured result sort options, if specified
             if ($va_sort_options_for_ca_objects = $po_request->config->getAssoc('result_sort_options_for_ca_objects')) {
                 $this->opa_sorts = $va_sort_options_for_ca_objects;
             } else {
                 $this->opa_sorts = array('ca_object_labels.name' => _t('Title'), 'ca_objects.type_id' => _t('Type'), 'ca_objects.idno_sort' => _t('Idno'));
             }
             if ($po_request->config->get("show_map_object_search_results")) {
                 JavascriptLoadManager::register('maps');
                 $this->opa_views['map'] = _t('Map');
                 if (!$this->opa_views_options['map']) {
                     $this->opa_views_options['map'] = array("description" => _t("View results plotted on a map"), "icon" => "icon_map.gif");
                 }
             }
             break;
     }
     // if target changes we need clear out all browse criteria as they are no longer valid
     if ($vs_browse_target != $po_request->session->getVar('pawtucket2_browse_target')) {
         $this->opo_browse->removeAllCriteria();
     }
     // Set up target vars and controls
     $po_request->session->setVar('pawtucket2_browse_target', $vs_browse_target);
     if (sizeof($va_browse_targets = $this->request->config->getList('browse_targets')) > 1) {
         $va_browse_options = array();
         foreach ($va_browse_targets as $vs_possible_browse_target) {
             if ($vs_browse_target_name = $this->opo_browse->getBrowseSubjectName($vs_possible_browse_target)) {
                 $va_browse_options[$vs_browse_target_name] = $vs_possible_browse_target;
             }
         }
         $this->view->setVar('browse_selector', "<form action='#'>" . caHTMLSelect('target', $va_browse_options, array('id' => 'caBrowseTargetSelectorSelect', 'onchange' => 'window.location = \'' . caNavUrl($this->request, $this->request->getModulePath(), $this->request->getController(), 'Index', array('target' => '')) . '\' + jQuery(\'#caBrowseTargetSelectorSelect\').val();'), array('value' => $vs_browse_target, 'dontConvertAttributeQuotesToEntities' => true)) . "</form>\n");
     }
     // get configured items per page options, if specified
     if ($va_items_per_page = $po_request->config->getList('items_per_page_options_for_' . $vs_browse_target . '_browse')) {
         $this->opa_items_per_page = $va_items_per_page;
     }
     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];
     }
     // set current result view options so can check we are including a configured result view
     $this->view->setVar('result_views', $this->opa_views);
     $this->view->setVar('result_views_options', $this->opa_views_options);
     //Roundabout added config options
     $ra_categories = array('artists' => $po_request->config->get('ra_browse_artists'), 'costumes' => $po_request->config->get('ra_browse_costumes'), 'orchestrations' => $po_request->config->get('ra_browse_orchestrations'), 'photographs' => $po_request->config->get('ra_browse_photographs'), 'playbills' => $po_request->config->get('ra_browse_playbills'), 'posters' => $po_request->config->get('ra_browse_posters'), 'productions' => $po_request->config->get('ra_browse_productions'), 'scripts' => $po_request->config->get('ra_browse_scripts'), 'sketch' => $po_request->config->get('ra_browse_sketch'), 'video' => $po_request->config->get('ra_browse_video'));
     $this->view->setVar('ra_categories', $ra_categories);
     if ($this->opn_type_restriction_id = $this->opo_result_context->getTypeRestriction($pb_type_restriction_has_changed)) {
         $_GET['type_id'] = $this->opn_type_restriction_id;
         // push type_id into globals so breadcrumb trail can pick it up
         $this->opb_type_restriction_has_changed = $pb_type_restriction_has_changed;
         // get change status
     }
 }
 /**
  * Return available displays as HTML <select> drop-down menu
  *
  * @param string $ps_select_name Name attribute for <select> form element 
  * @param array $pa_attributes Optional array of attributes to embed in HTML <select> tag. Keys are attribute names and values are attribute values.
  * @param array $pa_options Optional array of options. Supported options include:
  * 		Supports all options supported by caHTMLSelect() and ca_bundle_displays::getBundleDisplays() + the following:
  *			addDefaultDisplay - if true, the "default" display is included at the head of the list; this is simply a display called "default" that is assumed to be handled by your code; the default is not to add the default value (false)
  *			addDefaultDisplayIfEmpty - same as 'addDefaultDisplay' except that the default value is only added if the display list is empty
  * @return string HTML code defining <select> drop-down
  */
 public function getBundleDisplaysAsHTMLSelect($ps_select_name, $pa_attributes = null, $pa_options = null)
 {
     if (!is_array($pa_options)) {
         $pa_options = array();
     }
     $va_available_displays = caExtractValuesByUserLocale($this->getBundleDisplays($pa_options));
     $va_content = array();
     if (isset($pa_options['addDefaultDisplay']) && $pa_options['addDefaultDisplay'] || isset($pa_options['addDefaultDisplayIfEmpty']) && $pa_options['addDefaultDisplayIfEmpty'] && !sizeof($va_available_displays)) {
         $va_content[_t('Default')] = 0;
     }
     foreach ($va_available_displays as $vn_display_id => $va_info) {
         $va_content[$va_info['name']] = $vn_display_id;
     }
     if (sizeof($va_content) == 0) {
         return '';
     }
     return caHTMLSelect($ps_select_name, $va_content, $pa_attributes, $pa_options);
 }
 /** 
  * 
  */
 public function advanced()
 {
     $o_config = caGetSearchConfig();
     $ps_function = strtolower($this->request->getActionExtra());
     if (!($va_search_info = caGetInfoForAdvancedSearchType($ps_function))) {
         // invalid advanced search type – throw error
         die("Invalid advanced search type");
     }
     $vs_class = $va_search_info['table'];
     $va_types = caGetOption('restrictToTypes', $va_search_info, array(), array('castTo' => 'array'));
     $this->opo_result_context = new ResultContext($this->request, $va_search_info['table'], $this->ops_find_type . '_advanced');
     $this->opo_result_context->setAsLastFind();
     MetaTagManager::setWindowTitle($this->request->config->get("app_display_name") . ": " . _t("Search %1", $va_search_info["displayName"]));
     $this->view->setVar('searchInfo', $va_search_info);
     $this->view->setVar('options', caGetOption('options', $va_search_info, array(), array('castTo' => 'array')));
     $va_default_form_values = $this->opo_result_context->getParameter("pawtucketAdvancedSearchFormContent_{$ps_function}");
     $va_default_form_booleans = $this->opo_result_context->getParameter("pawtucketAdvancedSearchFormBooleans_{$ps_function}");
     $va_tags = $this->view->getTagList($va_search_info['view']);
     $t_subject = $this->request->datamodel->getInstanceByTableName($va_search_info['table'], true);
     $va_form_elements = array();
     $vs_script = null;
     foreach ($va_tags as $vs_tag) {
         $va_parse = caParseTagOptions($vs_tag);
         $vs_tag_proc = $va_parse['tag'];
         $va_opts = $va_parse['options'];
         if (($vs_default_value = caGetOption('default', $va_opts, null)) || ($vs_default_value = caGetOption($vs_tag_proc, $va_default_form_values, null))) {
             $va_default_form_values[$vs_tag_proc] = $vs_default_value;
             unset($va_opts['default']);
         }
         $vs_tag_val = null;
         switch (strtolower($vs_tag_proc)) {
             case 'submit':
                 $this->view->setVar($vs_tag, "<a href='#' class='caAdvancedSearchFormSubmit'>" . (isset($va_opts['label']) && $va_opts['label'] ? $va_opts['label'] : _t('Submit')) . "</a>");
                 break;
             case 'reset':
                 $this->view->setVar($vs_tag, "<a href='#' class='caAdvancedSearchFormReset'>" . (isset($va_opts['label']) && $va_opts['label'] ? $va_opts['label'] : _t('Reset')) . "</a>");
                 $vs_script = "<script type='text/javascript'>\n\tjQuery('.caAdvancedSearchFormSubmit').bind('click', function() {\n\t\tjQuery('#caAdvancedSearch').submit();\n\t\treturn false;\n\t});\n\tjQuery('.caAdvancedSearchFormReset').bind('click', function() {\n\t\tjQuery('#caAdvancedSearch').find('input[type!=\"hidden\"],textarea').val('');\n\t\tjQuery('#caAdvancedSearch').find('select.caAdvancedSearchBoolean').val('AND');\n\t\tjQuery('#caAdvancedSearch').find('select').prop('selectedIndex', 0);\n\t\treturn false;\n\t});\n\tjQuery(document).ready(function() {\n\t\tvar f, defaultValues = " . json_encode($va_default_form_values) . ", defaultBooleans = " . json_encode($va_default_form_booleans) . ";\n\t\tfor (f in defaultValues) {\n\t\t\tvar f_proc = f + '[]';\n\t\t\tjQuery('input[name=\"' + f_proc+ '\"], textarea[name=\"' + f_proc+ '\"], select[name=\"' + f_proc+ '\"]').each(function(k, v) {\n\t\t\t\tif (defaultValues[f][k]) { jQuery(v).val(defaultValues[f][k]); } \n\t\t\t});\n\t\t}\n\t\tfor (f in defaultBooleans) {\n\t\t\tvar f_proc = f + '[]';\n\t\t\tjQuery('select[name=\"' + f_proc+ '\"].caAdvancedSearchBoolean').each(function(k, v) {\n\t\t\t\tif (defaultBooleans[f][k]) { jQuery(v).val(defaultBooleans[f][k]); }\n\t\t\t});\n\t\t}\n\t});\n</script>\n";
                 break;
             default:
                 if (preg_match("!^(.*):label\$!", $vs_tag_proc, $va_matches)) {
                     $this->view->setVar($vs_tag, $vs_tag_val = $t_subject->getDisplayLabel($va_matches[1]));
                 } elseif (preg_match("!^(.*):boolean\$!", $vs_tag_proc, $va_matches)) {
                     $this->view->setVar($vs_tag, caHTMLSelect($vs_tag_proc . '[]', array(_t('AND') => 'AND', _t('OR') => 'OR', 'AND NOT' => 'AND NOT'), array('class' => 'caAdvancedSearchBoolean')));
                 } else {
                     $va_opts['asArrayElement'] = true;
                     if (isset($va_opts['restrictToTypes']) && $va_opts['restrictToTypes'] && !is_array($va_opts['restrictToTypes'])) {
                         $va_opts['restrictToTypes'] = explode(";", $va_opts['restrictToTypes']);
                     }
                     if ($vs_tag_val = $t_subject->htmlFormElementForSearch($this->request, $vs_tag_proc, $va_opts)) {
                         $this->view->setVar($vs_tag, $vs_tag_val);
                     }
                     $va_tmp = explode('.', $vs_tag_proc);
                     if (($t_element = ca_metadata_elements::getInstance($va_tmp[1])) && $t_element->get('datatype') == 0) {
                         if (is_array($va_elements = $t_element->getElementsInSet())) {
                             foreach ($va_elements as $va_element) {
                                 if ($va_element['datatype'] > 0) {
                                     $va_form_elements[] = $va_tmp[0] . '.' . $va_tmp[1] . '.' . $va_element['element_code'];
                                 }
                             }
                         }
                         break;
                     }
                 }
                 if ($vs_tag_val) {
                     $va_form_elements[] = $vs_tag_proc;
                 }
                 break;
         }
     }
     $this->view->setVar("form", caFormTag($this->request, "{$ps_function}", 'caAdvancedSearch', null, 'post', 'multipart/form-data', '_top', array('disableUnsavedChangesWarning' => true, 'submitOnReturn' => true)));
     $this->view->setVar("/form", $vs_script . caHTMLHiddenInput("_advancedFormName", array("value" => $ps_function)) . caHTMLHiddenInput("_formElements", array("value" => join(';', $va_form_elements))) . caHTMLHiddenInput("_advanced", array("value" => 1)) . "</form>");
     $this->render($va_search_info['view']);
 }
Exemple #19
0
				<?php 
    _p("Administrator's e-mail address");
    ?>
:<br/>
				<input type='text' name='email' value='<?php 
    print htmlspecialchars($ps_email, ENT_QUOTES, 'UTF-8');
    ?>
' size='40' maxlength='100'/>
			</div><!-- end formItem -->
			<div class='formItem'><?php 
    _p("Installation profile");
    ?>
:<br/>
				<div id="profileChooser">
<?php 
    print caHTMLSelect('profile', caGetAvailableXMLProfiles(), array('id' => 'profileSelect'), array('value' => $ps_profile));
    if (defined('__CA_ALLOW_DRAG_AND_DROP_PROFILE_UPLOAD_IN_INSTALLER__') && __CA_ALLOW_DRAG_AND_DROP_PROFILE_UPLOAD_IN_INSTALLER__) {
        ?>
				<div id="batchProcessingTableProgressGroup" style="display: none;">
					<div class="batchProcessingStatus"><span id="batchProcessingTableStatus" > </span></div>
					<div id="progressbar"></div>
				</div>
				<div id="profileUpload" style="border: 2px dashed #999999; text-align: center; padding: 20px; margin-top: 10px;">
					<span style="font-size: 20px; color: #aaaaaa; font-weight: bold;"><?php 
        print _t("Drag profiles here to add or update");
        ?>
</span>
				</div>
<?php 
    }
    ?>
 /**
  *
  */
 public function __call($ps_function, $pa_args)
 {
     AssetLoadManager::register("panel");
     AssetLoadManager::register("mediaViewer");
     AssetLoadManager::register("carousel");
     AssetLoadManager::register("readmore");
     AssetLoadManager::register("maps");
     $ps_function = strtolower($ps_function);
     $ps_id = urldecode($this->request->getActionExtra());
     if (!isset($this->opa_detail_types[$ps_function]) || !isset($this->opa_detail_types[$ps_function]['table']) || !($vs_table = $this->opa_detail_types[$ps_function]['table'])) {
         // invalid detail type – throw error
         die("Invalid detail type");
     }
     $t_table = $this->opo_datamodel->getInstanceByTableName($vs_table, true);
     if (($vb_use_identifiers_in_urls = caUseIdentifiersInUrls()) && substr($ps_id, 0, 3) == "id:") {
         $va_tmp = explode(":", $ps_id);
         $ps_id = (int) $va_tmp[1];
         $vb_use_identifiers_in_urls = false;
     }
     if (!$t_table->load($vb_use_identifiers_in_urls && $t_table->getProperty('ID_NUMBERING_ID_FIELD') ? $t_table->hasField('deleted') ? array($t_table->getProperty('ID_NUMBERING_ID_FIELD') => $ps_id, 'deleted' => 0) : array($t_table->getProperty('ID_NUMBERING_ID_FIELD') => $ps_id) : ($t_table->hasField('deleted') ? array($t_table->primaryKey() => (int) $ps_id, 'deleted' => 0) : array($t_table->primaryKey() => (int) $ps_id)))) {
         // invalid id - throw error
         die("Invalid id");
     }
     // Printables
     // 	merge displays with drop-in print templates
     //
     $va_export_options = caGetAvailablePrintTemplates('summary', array('table' => $t_table->tableName()));
     $this->view->setVar('export_formats', $va_export_options);
     $va_options = array();
     foreach ($va_export_options as $vn_i => $va_format_info) {
         $va_options[$va_format_info['name']] = $va_format_info['code'];
     }
     // Get current display list
     $t_display = new ca_bundle_displays();
     foreach (caExtractValuesByUserLocale($t_display->getBundleDisplays(array('table' => $this->ops_tablename, 'user_id' => $this->request->getUserID(), 'access' => __CA_BUNDLE_DISPLAY_READ_ACCESS__, 'checkAccess' => caGetUserAccessValues($this->request)))) as $va_display) {
         $va_options[$va_display['name']] = "_display_" . $va_display['display_id'];
     }
     ksort($va_options);
     $this->view->setVar('export_format_select', caHTMLSelect('export_format', $va_options, array('class' => 'searchToolsSelect'), array('value' => $this->view->getVar('current_export_format'), 'width' => '150px')));
     #
     # Enforce access control
     #
     if (sizeof($this->opa_access_values) && $t_table->hasField('access') && !in_array($t_table->get("access"), $this->opa_access_values)) {
         $this->notification->addNotification(_t("This item is not available for view"), "message");
         $this->response->setRedirect(caNavUrl($this->request, "", "", "", ""));
         return;
     }
     MetaTagManager::setWindowTitle($this->request->config->get("app_display_name") . ": " . $t_table->getTypeName() . ": " . $t_table->get('preferred_labels') . (($vs_idno = $t_table->get($t_table->getProperty('ID_NUMBERING_ID_FIELD'))) ? " [{$vs_idno}]" : ""));
     $vs_type = $t_table->getTypeCode();
     $this->view->setVar('detailType', $vs_table);
     $this->view->setVar('item', $t_table);
     $this->view->setVar('itemType', $vs_type);
     caAddPageCSSClasses(array($vs_table, $ps_function, $vs_type));
     // Do we need to pull in the multisearch result set?
     if (ResultContext::getLastFind($this->request, $vs_table, array('noSubtype' => true)) === 'multisearch') {
         $o_context = new ResultContext($this->request, $vs_table, 'multisearch', $ps_function);
         $o_context->setAsLastFind();
         $o_context->saveContext();
     } else {
         $o_context = ResultContext::getResultContextForLastFind($this->request, $vs_table);
     }
     $this->view->setVar('previousID', $vn_previous_id = $o_context->getPreviousID($t_table->getPrimaryKey()));
     $this->view->setVar('nextID', $vn_next_id = $o_context->getNextID($t_table->getPrimaryKey()));
     $this->view->setVar('previousURL', caDetailUrl($this->request, $vs_table, $vn_previous_id));
     $this->view->setVar('nextURL', caDetailUrl($this->request, $vs_table, $vn_next_id));
     $this->view->setVar('resultsURL', ResultContext::getResultsUrlForLastFind($this->request, $vs_table));
     $va_options = isset($this->opa_detail_types[$ps_function]['options']) && is_array($this->opa_detail_types[$ps_function]['options']) ? $this->opa_detail_types[$ps_function]['options'] : array();
     $this->view->setVar('previousLink', $vn_previous_id > 0 ? caDetailLink($this->request, caGetOption('previousLink', $va_options, _t('Previous')), '', $vs_table, $vn_previous_id) : '');
     $this->view->setVar('nextLink', $vn_next_id > 0 ? caDetailLink($this->request, caGetOption('nextLink', $va_options, _t('Next')), '', $vs_table, $vn_next_id) : '');
     $this->view->setVar('resultsLink', ResultContext::getResultsLinkForLastFind($this->request, $vs_table, caGetOption('resultsLink', $va_options, _t('Back'))));
     $this->view->setVar('commentsEnabled', (bool) $va_options['enableComments']);
     //
     //
     //
     if (method_exists($t_table, 'getPrimaryRepresentationInstance')) {
         if ($pn_representation_id = $this->request->getParameter('representation_id', pInteger)) {
             $t_representation = $this->opo_datamodel->getInstanceByTableName("ca_object_representations", true);
             $t_representation->load($pn_representation_id);
         } else {
             $t_representation = $t_table->getPrimaryRepresentationInstance(array("checkAccess" => $this->opa_access_values));
         }
         if ($t_representation) {
             $this->view->setVar("t_representation", $t_representation);
             $this->view->setVar("representation_id", $t_representation->get("representation_id"));
         } else {
             $t_representation = $this->opo_datamodel->getInstanceByTableName("ca_object_representations", true);
         }
         $this->view->setVar("representationViewer", caObjectDetailMedia($this->request, $t_table->getPrimaryKey(), $t_representation, $t_table, array("primaryOnly" => caGetOption('representationViewerPrimaryOnly', $va_options, false), "dontShowPlaceholder" => caGetOption('representationViewerDontShowPlaceholder', $va_options, false))));
     }
     //
     // map
     //
     if (!is_array($va_map_attributes = caGetOption('map_attributes', $va_options, array())) || !sizeof($va_map_attributes)) {
         if ($vs_map_attribute = caGetOption('map_attribute', $va_options, false)) {
             $va_map_attributes = array($vs_map_attribute);
         }
     }
     $this->view->setVar("map", "");
     if (is_array($va_map_attributes) && sizeof($va_map_attributes)) {
         $o_map = new GeographicMap(($vn_width = caGetOption('map_width', $va_options, false)) ? $vn_width : 285, ($vn_height = caGetOption('map_height', $va_options, false)) ? $vn_height : 200, 'map');
         $vn_mapped_count = 0;
         foreach ($va_map_attributes as $vs_map_attribute) {
             if ($t_table->get($vs_map_attribute)) {
                 $o_map->mapFrom($t_table, $vs_map_attribute);
                 $vn_mapped_count++;
             }
         }
         if ($vn_mapped_count > 0) {
             $this->view->setVar("map", $o_map->render('HTML'));
         }
     }
     //
     // comments, tags, rank
     //
     $this->view->setVar('averageRank', $t_table->getAverageRating(true));
     $this->view->setVar('numRank', $t_table->getNumRatings(true));
     #
     # User-generated comments, tags and ratings
     #
     $va_user_comments = $t_table->getComments(null, true);
     $va_comments = array();
     if (is_array($va_user_comments)) {
         foreach ($va_user_comments as $va_user_comment) {
             if ($va_user_comment["comment"] || $va_user_comment["media1"] || $va_user_comment["media2"] || $va_user_comment["media3"] || $va_user_comment["media4"]) {
                 # TODO: format date based on locale
                 $va_user_comment["date"] = date("n/j/Y", $va_user_comment["created_on"]);
                 # -- get name of commenter
                 if ($va_user_comment["user_id"]) {
                     $t_user = new ca_users($va_user_comment["user_id"]);
                     $va_user_comment["author"] = $t_user->getName();
                 } elseif ($va_user_comment["name"]) {
                     $va_user_comment["author"] = $va_user_comment["name"];
                 }
                 $va_comments[] = $va_user_comment;
             }
         }
     }
     $this->view->setVar('comments', $va_comments);
     $va_user_tags = $t_table->getTags(null, true);
     $va_tags = array();
     if (is_array($va_user_tags)) {
         foreach ($va_user_tags as $va_user_tag) {
             if (!in_array($va_user_tag["tag"], $va_tags)) {
                 $va_tags[] = $va_user_tag["tag"];
             }
         }
     }
     $this->view->setVar('tags_array', $va_tags);
     $this->view->setVar('tags', implode(", ", $va_tags));
     $this->view->setVar("itemComments", caDetailItemComments($this->request, $t_table->getPrimaryKey(), $t_table, $va_comments, $va_tags));
     //
     // share link
     //
     $this->view->setVar("shareLink", "<a href='#' onclick='caMediaPanel.showPanel(\"" . caNavUrl($this->request, '', 'Detail', 'ShareForm', array("tablename" => $t_table->tableName(), "item_id" => $t_table->getPrimaryKey())) . "\"); return false;'>Share</a>");
     // find view
     //		first look for type-specific view
     if (!$this->viewExists($vs_path = "Details/{$vs_table}_{$vs_type}_html.php")) {
         // If no type specific view use the default
         $vs_path = "Details/{$vs_table}_default_html.php";
     }
     switch ($ps_view = $this->request->getParameter('view', pString)) {
         case 'pdf':
             $this->_genExport($t_table, $this->request->getParameter("export_format", pString), 'Detail', 'Detail');
             break;
         default:
             //
             // Tag substitution
             //
             // Views can contain tags in the form {{{tagname}}}. Some tags, such as "itemType" and "detailType" are defined by
             // the detail controller. More usefully, you can pull data from the item being detailed by using a valid "get" expression
             // as a tag (Eg. {{{ca_objects.idno}}}. Even more usefully for some, you can also use a valid bundle display template
             // (see http://docs.collectiveaccess.org/wiki/Bundle_Display_Templates) as a tag. The template will be evaluated in the
             // context of the item being detailed.
             //
             $va_defined_vars = array_keys($this->view->getAllVars());
             // get list defined vars (we don't want to copy over them)
             $va_tag_list = $this->getTagListForView($vs_path);
             // get list of tags in view
             foreach ($va_tag_list as $vs_tag) {
                 if (in_array($vs_tag, $va_defined_vars)) {
                     continue;
                 }
                 if (strpos($vs_tag, "^") !== false || strpos($vs_tag, "<") !== false) {
                     $this->view->setVar($vs_tag, $t_table->getWithTemplate($vs_tag, array('checkAccess' => $this->opa_access_values)));
                 } elseif (strpos($vs_tag, ".") !== false) {
                     $this->view->setVar($vs_tag, $t_table->get($vs_tag, array('checkAccess' => $this->opa_access_values)));
                 } else {
                     $this->view->setVar($vs_tag, "?{$vs_tag}");
                 }
             }
             $this->render($vs_path);
             break;
     }
 }
    if (is_array($va_errors['payment_info']) && sizeof($va_errors['payment_info'])) {
        ?>
	<div class='formLabelError'><?php 
        print join("; ", $va_errors['payment_info']);
        ?>
</div>
<?php 
    }
    ?>
			<div id="caClientOrderCustomerCreditSubForm" style="display: none;">
				<table>
<?php 
    print "<tr><td>" . _t('Credit card') . "</td><td>" . caHTMLSelect('credit_card_type', $va_credit_card_types, array(), array('value' => $va_payment_info['credit_card_type'])) . "</td></tr>\n";
    print "<tr><td>" . _t('Credit card number') . "</td><td>" . caHTMLTextInput('credit_card_number', array('size' => 40, 'value' => $va_payment_info['credit_card_number'])) . "</td></tr>\n";
    print "<tr><td>" . _t('CCV') . "</td><td>" . caHTMLTextInput('credit_card_ccv', array('size' => 4, 'value' => $va_payment_info['credit_card_ccv'])) . "</td></tr>\n";
    print "<tr><td>" . _t('Expiration date') . "</td><td>" . caHTMLSelect('credit_card_exp_mon', $this->getVar('credit_card_exp_month_list'), array(), array('value' => $va_payment_info['credit_card_exp_mon'])) . " " . caHTMLSelect('credit_card_exp_yr', $this->getVar('credit_card_exp_year_list'), array(), array('value' => $va_payment_info['credit_card_exp_yr'])) . "</td></tr>\n";
    print "<tr><td> </td><td><div id='caClientOrderProcessingIndicator'><img src='" . $this->request->getThemeUrlPath() . "/graphics/icons/indicator.gif'/> " . _t('Please wait while order is processed (this may take up to 60 seconds to complete)') . "</div></td></tr>\n";
    ?>
				</table>
			</div>
			<div id="caClientOrderCustomerPOSubForm" style="display: none;">
				<table>
<?php 
    print "<tr><td>" . _t('Purchase order date') . "</td><td>" . caHTMLTextInput('purchase_order_date', array('width' => 40, 'class' => 'dateBg', 'value' => $va_payment_info['purchase_order_date'])) . "</td></tr>\n";
    print "<tr><td>" . _t('Purchase order #') . "</td><td>" . caHTMLTextInput('purchase_order_number', array('width' => 40, 'value' => $va_payment_info['purchase_order_number'])) . "</td></tr>\n";
    ?>
				</table>
			</div>
			<div id="caClientOrderCustomerCheckSubForm" style="display: none;">
				<table>
<?php 
Exemple #22
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;
 }
Exemple #23
0
		<div id="topBar">
<?php 
    # Locale selection
    global $g_ui_locale;
    $vs_base_url = $this->request->getRequestUrl();
    $vs_base_url = substr($vs_base_url, 0, 1) == '/' ? $vs_base_url : '/' . $vs_base_url;
    $vs_base_url = str_replace("/lang/[A-Za-z_]+", "", $vs_base_url);
    if (is_array($va_ui_locales = $this->request->config->getList('ui_locales')) && sizeof($va_ui_locales) > 1) {
        print caFormTag($this->request, $this->request->getAction(), 'caLocaleSelectorForm', null, 'get', 'multipart/form-data', '_top', array('disableUnsavedChangesWarning' => true));
        $va_locale_options = array();
        foreach ($va_ui_locales as $vs_locale) {
            $va_parts = explode('_', $vs_locale);
            $vs_lang_name = Zend_Locale::getTranslation(strtolower($va_parts[0]), 'language', strtolower($va_parts[0]));
            $va_locale_options[$vs_lang_name] = $vs_locale;
        }
        print caHTMLSelect('lang', $va_locale_options, array('id' => 'caLocaleSelectorSelect', 'onclick' => 'jQuery(document).attr("location", "' . caNavUrl($this->request, $this->request->getModulePath(), $this->request->getController(), $this->request->getAction(), array('lang' => '')) . '" + jQuery("#caLocaleSelectorSelect").val());'), array('value' => $g_ui_locale));
        print "</form>\n";
    }
    ?>
		</div><!-- end topbar -->
		<div id="pageArea">
		<div id="nav">
			<div id="header">
<?php 
    print caNavLink($this->request, "<img src='" . $this->request->getThemeUrlPath() . "/graphics/noguchi.png'  border='0' style='margin-bottom:10px'>", "", "", "", "");
    ?>
				
			</div><!-- end header -->
<?php 
    // get last search ('basic_search' is the find type used by the SearchController)
    $o_result_context = new ResultContext($this->request, 'ca_objects', 'basic_search');
/graphics/arrows/arrow_right_gray.gif" width="6" height="7" border="0"></a>

	<br style="clear: both;"/>
	
	<div id="searchToolsBox">
		<div class="bg">
<?php 
print caFormTag($this->request, 'Index', 'caViewOptions', null, 'post', 'multipart/form-data', '_top', array('disableUnsavedChangesWarning' => true));
?>
	<table width="100%">
		<tr valign="top">
			<td>
				<div class="formLabel">
<?php 
print _t('Read status') . "<br/>\n";
print caHTMLSelect('read_status', array('-' => '', _t('Unread only') => 'unread', _t('Read only') => 'read'), array(), array('value' => $va_filter_options['read_status']));
?>
				</div>
			</td><td>
<?php 
print $t_communication->htmlFormElement('created_on', null, array('FIELD_TYPE' => 'FT_DATETIME', 'DISPLAY_TYPE' => DT_FIELD, 'value' => $va_filter_options['created_on']));
?>
			</td><td>
				<div class="formLabel">
					<?php 
print _t('User account');
?>
<br/>
					<input type="text" size="50" name="client_user_id_autocomplete" value="<?php 
print htmlspecialchars($va_filter_options['_user_id_display'], ENT_QUOTES, 'utf-8');
?>
Exemple #25
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 "";
 }
Exemple #26
0
 /**
  * Returns list of configured visualizations as HTML form element
  *
  * @param string $ps_table Table for which to list available visualizations
  * @param string $ps_name Name of returned HTML <select>
  * @param array $pa_attributes Optional array of attributes to add to the returned HTML <select> element
  * @param array $pa_options Options are any options supported by the caHTMLSelect helper plus:
  *		restrictToTypes = optional list of types relevant to the specified table. Only unrestricted visualizations and visualizations restricted to the specified types will be included.
  *		resultContext =
  * @return string HTML for a <select> element with available visualizations; will return null if no visualizations are available. 
  */
 public static function getAvailableVisualizationsAsHTMLFormElement($ps_table, $ps_name, $pa_attributes = null, $pa_options = null)
 {
     $va_viz = Visualizer::getAvailableVisualizations($ps_table, $pa_options);
     $vo_result_context = isset($pa_options['resultContext']) && $pa_options['resultContext'] instanceof ResultContext ? $pa_options['resultContext'] : null;
     if ($vo_result_context && $vo_result_context->getParameter('availableVisualizationChecked') > 0) {
         if ($vo_result_context->getParameter('availableVisualizationCount') > 0) {
             return $vo_result_context->getParameter('availableVisualizationHTMLSelect');
         } else {
             return null;
         }
     }
     if (!is_array($va_viz) || !sizeof($va_viz)) {
         return null;
     }
     $va_valid_viz_codes = null;
     if (isset($pa_options['data']) && is_subclass_of($pa_options['data'], 'SearchResult')) {
         $va_valid_viz_codes = Visualizer::getVisualizationsForData($pa_options['data']);
     }
     $va_options = array();
     foreach ($va_viz as $vs_viz_code => $va_viz_opt) {
         if (is_array($va_valid_viz_codes) && !in_array($vs_viz_code, $va_valid_viz_codes)) {
             continue;
         }
         $va_options[$va_viz_opt['name']] = $vs_viz_code;
     }
     if (!sizeof($va_options)) {
         if ($vo_result_context) {
             $vo_result_context->setParameter('availableVisualizationChecked', 1);
             $vo_result_context->setParameter('availableVisualizationHTMLSelect', '');
             $vo_result_context->setParameter('availableVisualizationCount', 0);
             $vo_result_context->saveContext();
         }
         return null;
     }
     $vs_html = caHTMLSelect($ps_name, $va_options, $pa_attributes, $pa_options);
     if ($vo_result_context) {
         $vo_result_context->setParameter('availableVisualizationChecked', 1);
         $vo_result_context->setParameter('availableVisualizationHTMLSelect', $vs_html);
         $vo_result_context->setParameter('availableVisualizationCount', sizeof($va_options));
         $vo_result_context->saveContext();
     }
     return $vs_html;
 }
 /**
  * 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
  *  'value' => sets the value of the HTML form element explicitly, otherwise the current value for the setting in the loaded row is used
  */
 public function settingHTMLFormElement($ps_widget_id, $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['value']) && !is_null($pa_options['value'])) {
         $vs_value = $pa_options['value'];
     } else {
         $vs_value = $this->getSetting(trim($ps_setting));
     }
     $vs_element = '';
     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));
             } else {
                 $va_locales = array('_generic' => array());
             }
             foreach ($va_locales as $vs_locale => $va_locale_info) {
                 if ($vb_takes_locale) {
                     $vs_locale_label = " (" . $va_locale_info['name'] . ")";
                     $vs_input_name_suffix = '_' . $vs_locale;
                 } else {
                     $vs_input_name_suffix = $vs_locale_label = '';
                 }
                 $vs_element .= caHTMLTextInput($vs_input_name . $vs_input_name_suffix, array('size' => $va_properties["width"], 'height' => $va_properties["height"], 'value' => $vs_value, 'id' => $vs_input_name . $vs_input_name_suffix)) . "{$vs_locale_label}";
                 // focus code is needed by Firefox for some reason
                 $vs_element .= "<script type='text/javascript'>jQuery('#" . $vs_input_name . $vs_input_name_suffix . "').click(function() { this.focus(); });</script>";
             }
             break;
             # --------------------------------------------
         # --------------------------------------------
         case DT_CHECKBOXES:
             $va_attributes = array('value' => '1');
             if ($vs_value) {
                 $va_attributes['checked'] = '1';
             }
             $vs_element .= caHTMLCheckboxInput($vs_input_name, $va_attributes);
             break;
             # --------------------------------------------
         # --------------------------------------------
         case DT_SELECT:
             if (!is_array($va_properties['options'])) {
                 $va_properties['options'] = array();
             }
             $vs_element .= caHTMLSelect($vs_input_name, $va_properties['options'], array(), array('value' => $vs_value));
             break;
             # --------------------------------------------
         # --------------------------------------------
         default:
             break;
             # --------------------------------------------
     }
     $vs_label = $va_properties['label'];
     $vb_element_is_part_of_label = false;
     if (strpos($vs_label, '^ELEMENT') !== false) {
         $vs_label = str_replace('^ELEMENT', $vs_element, $vs_label);
         $vb_element_is_part_of_label = true;
     }
     $vs_return = "\n" . '<div class="formLabel" id="_widget_setting_' . $ps_setting . '_' . $ps_widget_id . '"><span>' . $vs_label . '</span>';
     if (!$vb_element_is_part_of_label) {
         $vs_return .= '<br />' . $vs_element;
     }
     $vs_return .= '</div>' . "\n";
     TooltipManager::add('#_widget_setting_' . $ps_setting . '_' . $ps_widget_id, "<h3>" . str_replace('^ELEMENT', 'X', $va_properties["label"]) . "</h3>" . $va_properties["description"]);
     return $vs_return;
 }
?>
<div id="searchOptionsBox">
		<div class="bg">
	<?php 
print caFormTag($this->request, 'Index', 'caSearchOptionsForm', null, 'post', 'multipart/form-data', '_top', array('disableUnsavedChangesWarning' => true));
print "<div class='col'>";
print _t("Sort") . ": <select name='sort' onchange='this.form.submit();'>\n";
$vs_current_sort = $vo_result_context->getCurrentSort();
$vs_current_sort_direction = $vo_result_context->getCurrentSortDirection();
if (is_array($this->getVar("sorts")) && sizeof($this->getVar("sorts")) > 0) {
    foreach ($this->getVar("sorts") as $vs_sort => $vs_option) {
        print "<option value='" . $vs_sort . "'" . ($vs_current_sort == $vs_sort ? " SELECTED" : "") . ">" . $vs_option . "</option>";
    }
}
print "</select>\n";
print caHTMLSelect('direction', array('↑' => 'asc', '↓' => 'desc'), array('onchange' => 'this.form.submit();'), array('value' => $vs_current_sort_direction));
print "</div>";
print "<div class='col'>";
$va_items_per_page = $this->getVar("items_per_page");
$vs_current_items_per_page = $vo_result_context->getItemsPerPage();
print _t("Results per page:") . " <select name='n' onchange='this.form.submit();'>\n";
if (is_array($va_items_per_page) && sizeof($va_items_per_page) > 0) {
    foreach ($va_items_per_page as $vn_items_per_p) {
        print "<option value='" . $vn_items_per_p . "' " . ($vn_items_per_p == $vs_current_items_per_page ? "SELECTED='1'" : "") . ">" . $vn_items_per_p . "</option>\n";
    }
}
print "</select>\n";
print "</div>";
print "<div class='col'>";
$va_views = $this->getVar("views");
$vs_current_view = $vo_result_context->getCurrentView();
 	</div>
 	
 	<br style="clear"/>
 	
	<div id="caWorldCatResults" class="bundleContainer">
		<div class="caWorldCatResultsMessage">
			<?php 
print _t('Enter a WorldCat search above to begin');
?>
		</div>
	</div>
	
	<div class='formLabel'>
<?php 
if ($vb_importers_available) {
    print _t('Log level') . ': ' . caHTMLSelect('log_level', caGetLogLevels(), array('id' => 'caLogLevel'), array('value' => $this->getVar('log_level')));
}
?>
	</div>
</form>

<div class="editorBottomPadding"><!-- empty --></div>
 
 <script type="text/javascript">
 	var caWorldCatStartIndex = 0;
 	var caWorldCatLastSearchTerm = '';
 	var caWorldCatNumResultsPerLoad = 25;
 	
 	jQuery(document).ready(function() {
 		jQuery("#caWorldCatTermLookup").on("click", function(e) {
 			caWorldCatStartIndex = 0;
    }
    if ($va_rep['is_primary']) {
        $vn_primary_id = $va_rep['representation_id'];
    }
}
$va_failed_inserts = array();
foreach ($this->request->getActionErrorSubSources('ca_object_representations') as $vs_error_subsource) {
    if (substr($vs_error_subsource, 0, 4) === 'new_') {
        $va_action_errors = $this->request->getActionErrors('ca_object_representations', $vs_error_subsource);
        foreach ($va_action_errors as $o_error) {
            $va_failed_inserts[] = array('icon' => '', '_errors' => array(array('errorDescription' => $o_error->getErrorDescription(), 'errorCode' => $o_error->getErrorNumber())));
        }
    }
}
if ($vb_batch) {
    print "<div class='editorBatchModeControl'>" . _t("In batch") . " " . caHTMLSelect($vs_id_prefix . "_batch_mode", array(_t("do not use") => "_disabled_", _t('add to each item') => '_add_', _t('replace values') => '_replace_', _t('remove all values') => '_delete_'), array('id' => $vs_id_prefix . $t_item->tableNum() . "_rel_batch_mode_select")) . "</div>\n";
    ?>
	<script type="text/javascript">
		jQuery(document).ready(function() {
			jQuery('#<?php 
    print $vs_id_prefix . $t_item->tableNum();
    ?>
_rel_batch_mode_select').change(function() {
				if ((jQuery(this).val() == '_disabled_') || (jQuery(this).val() == '_delete_')) {
					jQuery('#<?php 
    print $vs_id_prefix . $t_item->tableNum() . '_rel';
    ?>
').slideUp(250);
				} else {
					jQuery('#<?php 
    print $vs_id_prefix . $t_item->tableNum() . '_rel';