/**
  * Returns HTML bundle for picking representations to attach to an object-* relationship
  *
  * @param object $po_request The current request
  * @param $ps_form_name The name of the HTML form this bundle will be part of
  *
  * @return string HTML for bundle
  */
 public function getRepresentationChooserHTMLFormBundle($po_request, $ps_form_name, $ps_placement_code, $pa_bundle_settings, $pa_options = null)
 {
     $o_view = new View($po_request, $po_request->getViewsDirectoryPath() . '/bundles/');
     $o_view->setVar('lookup_urls', caJSONLookupServiceUrl($po_request, $this->getAppDatamodel()->getTableName($this->get('table_num'))));
     $o_view->setVar('t_subject', $this);
     $vn_object_id = $this->getLeftTableName() == 'ca_objects' ? $this->get($this->getLeftTableFieldName()) : $this->get($this->getRightTableFieldName());
     $o_view->setVar('t_object', $t_object = new ca_objects($vn_object_id));
     $o_view->setVar('id_prefix', $ps_form_name);
     $o_view->setVar('placement_code', $ps_placement_code);
     $o_view->setVar('element_code', caGetOption(array('elementCode', 'element_code'), $pa_bundle_settings, null));
     $o_view->setVar('settings', $pa_bundle_settings);
     return $o_view->render('ca_object_representation_chooser_html.php');
 }
        break;
}
$vb_objects_x_collections_hierarchy_enabled = (bool) $t_subject->getAppConfig()->get('ca_objects_x_collections_hierarchy_enabled');
$vs_disabled_items_mode = $t_subject->getAppConfig()->get($t_subject->tableName() . '_hierarchy_browser_disabled_items_mode');
$vs_disabled_items_mode = $vs_disabled_items_mode ? $vs_disabled_items_mode : 'hide';
$t_object = new ca_objects();
$va_search_lookup_extra_params = array('noInline' => 1);
if ($t_subject->getProperty('HIERARCHY_ID_FLD') && ($vn_hier_id = (int) $t_subject->get($t_subject->getProperty('HIERARCHY_ID_FLD')))) {
    $va_search_lookup_extra_params['currentHierarchyOnly'] = $vn_hier_id;
}
if (in_array($t_subject->tableName(), array('ca_objects', 'ca_collections')) && $vb_objects_x_collections_hierarchy_enabled) {
    $va_lookup_urls = array('search' => caNavUrl($this->request, 'lookup', 'ObjectCollectionHierarchy', 'Get', $va_search_lookup_extra_params), 'levelList' => caNavUrl($this->request, 'lookup', 'ObjectCollectionHierarchy', 'GetHierarchyLevel'), 'ancestorList' => caNavUrl($this->request, 'lookup', 'ObjectCollectionHierarchy', 'GetHierarchyAncestorList'));
    $vs_edit_url = caNavUrl($this->request, 'lookup', 'ObjectCollectionHierarchy', 'Edit') . '/id/';
    $vn_init_id = $t_subject->tableName() . "-" . $pn_id;
} else {
    $va_lookup_urls = caJSONLookupServiceUrl($this->request, $t_subject->tableName(), $va_search_lookup_extra_params);
    $vs_edit_url = caEditorUrl($this->request, $t_subject->tableName());
    $vn_init_id = $pn_id;
}
$vb_strict_type_hierarchy = (bool) $this->request->config->get($t_subject->tableName() . '_enforce_strict_type_hierarchy');
$vs_type_selector = trim($t_subject->getTypeListAsHTMLFormElement("{$vs_id_prefix}type_id", array('id' => "{$vs_id_prefix}typeList"), array('childrenOfCurrentTypeOnly' => $vb_strict_type_hierarchy, 'includeSelf' => !$vb_strict_type_hierarchy, 'directChildrenOnly' => $vb_strict_type_hierarchy)));
$pa_bundle_settings = $this->getVar('settings');
$vb_read_only = isset($pa_bundle_settings['readonly']) && $pa_bundle_settings['readonly'] || $this->request->user->getBundleAccessLevel($t_subject->tableName(), 'hierarchy_location') == __CA_BUNDLE_ACCESS_READONLY__;
$va_errors = array();
if (is_array($va_action_errors = $this->request->getActionErrors('hierarchy_location'))) {
    foreach ($va_action_errors as $o_error) {
        $va_errors[] = $o_error->getErrorDescription();
    }
}
?>
	
Пример #3
0
 /**
  * Return array of columns suitable for use with ca.tableview.js
  * (implements "spreadsheet" editing UI)
  *
  */
 public function getInlineEditColumns($pa_display_list, $pa_options = null)
 {
     $po_request = isset($pa_options['request']) ? $pa_options['request'] : null;
     $va_bundle_names = caExtractValuesFromArrayList($pa_display_list, 'bundle_name', array('preserveKeys' => true));
     $va_column_spec = array();
     foreach ($va_bundle_names as $vn_placement_id => $vs_bundle_name) {
         if (!(bool) $pa_display_list[$vn_placement_id]['allowInlineEditing']) {
             // Read only
             $va_column_spec[] = array('data' => str_replace(".", "-", $vs_bundle_name), 'readOnly' => !(bool) $pa_display_list[$vn_placement_id]['allowInlineEditing']);
             continue;
         }
         switch ($pa_display_list[$vn_placement_id]['inlineEditingType']) {
             case DT_SELECT:
                 $va_column_spec[] = array('data' => str_replace(".", "-", $vs_bundle_name), 'readOnly' => false, 'type' => 'DT_SELECT', 'source' => $pa_display_list[$vn_placement_id]['inlineEditingListValues'], 'strict' => true);
                 break;
             case DT_LOOKUP:
                 if ($po_request) {
                     $va_urls = caJSONLookupServiceUrl($po_request, 'ca_list_items');
                     $va_column_spec[] = array('data' => str_replace(".", "-", $vs_bundle_name), 'readOnly' => false, 'type' => 'DT_LOOKUP', 'list' => $pa_display_list[$vn_placement_id]['inlineEditingList'], 'lookupURL' => $va_urls['search'], 'strict' => false);
                 }
                 break;
             default:
                 $va_column_spec[] = array('data' => str_replace(".", "-", $vs_bundle_name), 'readOnly' => false, 'type' => 'DT_FIELD');
                 break;
         }
     }
     return $va_column_spec;
 }
Пример #4
0
	</div>
	<div class="quickAddSectionBox" id="{$vs_form_name}Container<?php 
print $vs_field_name_prefix . $vs_n;
?>
">
		<div class="quickAddFormTopPadding"><!-- empty --></div>
			<div class="quickAddErrorContainer" id="<?php 
print $vs_form_name;
?>
Errors<?php 
print $vs_field_name_prefix . $vs_n;
?>
"> </div>
<?php 
// Output hierarchy browser
$va_lookup_urls = caJSONLookupServiceUrl($this->request, 'ca_storage_locations');
?>
	<div class='bundleLabel'><span class="formLabelText" id="ObjectEditorForm_ca_entities"><?php 
print _t('Location in hierarchy');
?>
</span><br/>
		<div class="bundleContainer">
			<div class="caItemList">
				<div class="hierarchyBrowserContainer">
					<div id="caQuickAdd<?php 
print $vs_form_name;
?>
HierarchyBrowser" class="hierarchyBrowserSmall">
						<!-- Content for hierarchy browser is dynamically inserted here by ca.hierbrowser -->
					</div><!-- end hierbrowser -->
					<div>
 /**
  * Returns HTML bundle for adding/editing/deleting placements from a display
  *
  * @param object $po_request The current request
  * @param $ps_form_name The name of the HTML form this bundle will be part of
  * @return string HTML for bundle
  */
 public function getBundleDisplayHTMLFormBundle($po_request, $ps_form_name, $ps_placement_code, $pa_options = null)
 {
     if (!$this->haveAccessToDisplay($po_request->getUserID(), __CA_BUNDLE_DISPLAY_EDIT_ACCESS__)) {
         return null;
     }
     $o_view = new View($po_request, $po_request->getViewsDirectoryPath() . '/bundles/');
     $o_view->setVar('lookup_urls', caJSONLookupServiceUrl($po_request, $this->getAppDatamodel()->getTableName($this->get('table_num'))));
     $o_view->setVar('t_display', $this);
     $o_view->setVar('placement_code', $ps_placement_code);
     $o_view->setVar('id_prefix', $ps_form_name);
     return $o_view->render('ca_bundle_display_placements.php');
 }
 /**
  * @param string $ps_bundle_name
  * @param string $ps_placement_code
  * @param array $pa_bundle_settings
  * @param array $pa_options Supported options are:
  *		config
  *		viewPath
  *		graphicsPath
  *		request
  */
 public function getBundleFormHTML($ps_bundle_name, $ps_placement_code, $pa_bundle_settings, $pa_options, &$ps_bundle_label = null)
 {
     global $g_ui_locale;
     $vb_batch = isset($pa_options['batch']) && $pa_options['batch'] ? true : false;
     // Check if user has access to this bundle
     if ($pa_options['request']->user->getBundleAccessLevel($this->tableName(), $ps_bundle_name) == __CA_BUNDLE_ACCESS_NONE__) {
         return;
     }
     $vb_read_only_because_deaccessioned = $this->hasField('is_deaccessioned') && (bool) $this->getAppConfig()->get('deaccession_dont_allow_editing') && (bool) $this->get('is_deaccessioned');
     if ($vb_read_only_because_deaccessioned && $ps_bundle_name != 'ca_objects_deaccession') {
         $pa_bundle_settings['readonly'] = true;
     }
     // Check if user has access to this type
     // The type id is not set for batch edits so skip this check for those.
     if (!$vb_batch && (bool) $this->getAppConfig()->get('perform_type_access_checking')) {
         $vn_type_access = $pa_options['request']->user->getTypeAccessLevel($this->tableName(), $this->getTypeID());
         if ($vn_type_access == __CA_BUNDLE_ACCESS_NONE__) {
             return;
         }
         if ($vn_type_access == __CA_BUNDLE_ACCESS_READONLY__) {
             $pa_bundle_settings['readonly'] = true;
         }
     }
     // Check if user has access to this source
     if ((bool) $this->getAppConfig()->get('perform_source_access_checking')) {
         $vn_source_access = $pa_options['request']->user->getSourceAccessLevel($this->tableName(), $this->getSourceID());
         if ($vn_source_access == __CA_BUNDLE_ACCESS_NONE__) {
             return;
         }
         if ($vn_source_access == __CA_BUNDLE_ACCESS_READONLY__) {
             $pa_bundle_settings['readonly'] = true;
         }
     }
     if ((bool) $this->getAppConfig()->get('perform_item_level_access_checking') && $this->getPrimaryKey()) {
         $vn_item_access = $this->checkACLAccessForUser($pa_options['request']->user);
         if ($vn_item_access == __CA_ACL_NO_ACCESS__) {
             return;
         }
         if ($vn_item_access == __CA_ACL_READONLY_ACCESS__) {
             $pa_bundle_settings['readonly'] = true;
         }
     }
     $va_info = $this->getBundleInfo($ps_bundle_name);
     if (!($vs_type = $va_info['type'])) {
         return null;
     }
     if (isset($pa_options['config']) && is_object($pa_options['config'])) {
         $o_config = $pa_options['config'];
     } else {
         $o_config = $this->getAppConfig();
     }
     if (!($vs_required_marker = $o_config->get('required_field_marker'))) {
         $vs_required_marker = '[' . _t('REQUIRED') . ']';
     }
     $vs_label = $vs_label_text = null;
     $ps_bundle_name_proc = str_replace("ca_attribute_", "", $ps_bundle_name);
     $va_violations = null;
     if (($va_dictionary_entry = ca_metadata_dictionary_entries::getEntry($ps_bundle_name_proc, $pa_bundle_settings)) || ($va_dictionary_entry = ca_metadata_dictionary_entries::getEntry($this->tableName() . '.' . $ps_bundle_name_proc, $pa_bundle_settings))) {
         $pa_bundle_settings['definition'][$g_ui_locale] = $va_dictionary_entry['settings']['definition'];
         if ($va_dictionary_entry['settings']['mandatory']) {
             $pa_bundle_settings['definition'][$g_ui_locale] = $this->getAppConfig()->get('required_field_marker') . $pa_bundle_settings['definition'][$g_ui_locale];
         }
         $va_violations = $this->getMetadataDictionaryRuleViolations($ps_bundle_name);
         if (is_array($va_violations) && sizeof($va_violations)) {
             $va_violation_text = array();
             foreach ($va_violations as $va_violation) {
                 $va_violation_text[] = "<li class='caMetadataDictionaryViolation'><span class='caMetadataDictionaryViolation" . ucfirst(strtolower($va_violation['level'])) . "'>" . $va_violation['levelDisplay'] . '</span>: ' . $va_violation['violationMessage'] . "</li>";
             }
             $pa_bundle_settings['definition'][$g_ui_locale] = "<div class='caMetadataDictionaryViolationsList'><div class='caMetadataDictionaryViolationsListHeading'>" . _t('These problems require attention:') . "</div><ol>" . join("\n", $va_violation_text) . "</ol></div>\n" . $pa_bundle_settings['definition'][$g_ui_locale] . "<br style='clear: both;'/>";
         }
         if (!caGetOption($g_ui_locale, $pa_bundle_settings['description'], null)) {
             $pa_bundle_settings['description'][$g_ui_locale] = $va_dictionary_entry['settings']['definition'];
         }
     }
     // is label for this bundle forced in bundle settings?
     if (isset($pa_bundle_settings['label']) && isset($pa_bundle_settings['label'][$g_ui_locale]) && $pa_bundle_settings['label'][$g_ui_locale]) {
         $vs_label = $vs_label_text = $pa_bundle_settings['label'][$g_ui_locale];
     }
     // Set bundle level documentation URL
     $vs_documentation_url = trim(isset($pa_bundle_settings['documentation_url']) && $pa_bundle_settings['documentation_url'] ? $pa_bundle_settings['documentation_url'] : '');
     $vs_element = '';
     $va_errors = array();
     switch ($vs_type) {
         # -------------------------------------------------
         case 'preferred_label':
         case 'nonpreferred_label':
             if (is_array($va_error_objects = $pa_options['request']->getActionErrors($ps_bundle_name)) && sizeof($va_error_objects)) {
                 $vs_display_format = $o_config->get('bundle_element_error_display_format');
                 foreach ($va_error_objects as $o_e) {
                     $va_errors[] = $o_e->getErrorDescription();
                 }
             } else {
                 $vs_display_format = $o_config->get('bundle_element_display_format');
             }
             $pa_options['dontCache'] = true;
             // we *don't* want to cache labels here
             $vs_element = $vs_type === 'preferred_label' ? $this->getPreferredLabelHTMLFormBundle($pa_options['request'], $pa_options['formName'], $ps_placement_code, $pa_bundle_settings, $pa_options) : $this->getNonPreferredLabelHTMLFormBundle($pa_options['request'], $pa_options['formName'], $ps_placement_code, $pa_bundle_settings, $pa_options);
             $vs_field_id = "ca_{$vs_type}_" . $pa_options['formName'] . "_{$ps_placement_code}";
             if (!$vs_label_text) {
                 $vs_label_text = $va_info['label'];
             }
             $vs_label = '<span class="formLabelText" id="' . $vs_field_id . '">' . $vs_label_text . '</span>';
             if ($vs_type == 'preferred_label' && $o_config->get('show_required_field_marker') && $o_config->get('require_preferred_label_for_' . $this->tableName())) {
                 $vs_label .= ' ' . $vs_required_marker;
             }
             $vs_description = isset($pa_bundle_settings['description'][$g_ui_locale]) ? $pa_bundle_settings['description'][$g_ui_locale] : null;
             if ($vs_label && $vs_description) {
                 TooltipManager::add('#' . $vs_field_id, "<h3>{$vs_label_text}</h3>{$vs_description}");
             }
             break;
             # -------------------------------------------------
         # -------------------------------------------------
         case 'intrinsic':
             if (isset($pa_bundle_settings['label'][$g_ui_locale]) && $pa_bundle_settings['label'][$g_ui_locale]) {
                 $pa_options['label'] = $pa_bundle_settings['label'][$g_ui_locale];
             }
             if (!$pa_options['label']) {
                 $pa_options['label'] = $this->getFieldInfo($ps_bundle_name, 'LABEL');
             }
             $vs_view_path = isset($pa_options['viewPath']) && $pa_options['viewPath'] ? $pa_options['viewPath'] : $pa_options['request']->getViewsDirectoryPath();
             $o_view = new View($pa_options['request'], "{$vs_view_path}/bundles/");
             $va_lookup_url_info = caJSONLookupServiceUrl($pa_options['request'], $this->tableName());
             if ($this->getFieldInfo($ps_bundle_name, 'IDENTITY')) {
                 $o_view->setVar('form_element', ($vn_id = (int) $this->get($ps_bundle_name)) ? $vn_id : "&lt;" . _t('Not yet issued') . "&gt;");
             } else {
                 $vb_read_only = $pa_bundle_settings['readonly'] || $pa_options['request']->user->getBundleAccessLevel($this->tableName(), $ps_bundle_name) == __CA_BUNDLE_ACCESS_READONLY__ ? true : false;
                 $va_additional_field_options = array();
                 if ($vn_width = caGetOption('width', $pa_bundle_settings)) {
                     $va_additional_field_options['width'] = $vn_width;
                 }
                 if ($vn_height = caGetOption('height', $pa_bundle_settings)) {
                     $va_additional_field_options['height'] = $vn_height;
                 }
                 $o_view->setVar('form_element', $this->htmlFormElement($ps_bundle_name, $this->getProperty('ID_NUMBERING_ID_FIELD') == $ps_bundle_name ? $o_config->get('idno_element_display_format_without_label') : $o_config->get('bundle_element_display_format_without_label'), array_merge(array('readonly' => $vb_read_only, 'error_icon' => $pa_options['request']->getThemeUrlPath() . "/graphics/icons/warning_small.gif", 'progress_indicator' => $pa_options['request']->getThemeUrlPath() . "/graphics/icons/indicator.gif", 'lookup_url' => $va_lookup_url_info['intrinsic'], 'name' => $ps_placement_code . $pa_options['formName'] . $ps_bundle_name), $pa_options, $va_additional_field_options)));
             }
             $o_view->setVar('errors', $pa_options['request']->getActionErrors($ps_bundle_name));
             if (method_exists($this, "getDefaultMediaPreviewVersion")) {
                 $o_view->setVar('display_media', $this->getMediaTag($ps_bundle_name, $this->getDefaultMediaPreviewVersion($ps_bundle_name)));
             }
             $vs_field_id = 'ca_intrinsic_' . $pa_options['formName'] . '_' . $ps_placement_code;
             $vs_label = '<span class="formLabelText" id="' . $vs_field_id . '">' . $pa_options['label'] . '</span>';
             if ($o_config->get('show_required_field_marker')) {
                 if ($this->getFieldInfo($ps_bundle_name, 'FIELD_TYPE') == FT_TEXT && is_array($va_bounds = $this->getFieldInfo($ps_bundle_name, 'BOUNDS_LENGTH')) && $va_bounds[0] > 0) {
                     $vs_label .= ' ' . $vs_required_marker;
                 } else {
                     if (in_array($this->getFieldInfo($ps_bundle_name, 'FIELD_TYPE'), array(FT_NUMBER, FT_HISTORIC_DATERANGE, FT_DATERANGE)) && !$this->getFieldInfo($ps_bundle_name, 'IS_NULL')) {
                         $vs_label .= ' ' . $vs_required_marker;
                     }
                 }
             }
             // Set access inheritance default
             if ((bool) $this->getAppConfig()->get($this->tableName() . '_allow_access_inheritance') && $this->hasField('access_inherit_from_parent') && !$this->getPrimaryKey()) {
                 $this->set('access_inherit_from_parent', (bool) $this->getAppConfig()->get($this->tableName() . '_access_inheritance_default') ? 1 : 0);
             }
             $o_view->setVar('bundle_name', $ps_bundle_name);
             $o_view->setVar('id_prefix', $pa_options['formName']);
             $o_view->setVar('placement_code', $ps_placement_code);
             $o_view->setVar('settings', $pa_bundle_settings);
             $o_view->setVar('t_instance', $this);
             $o_view->setVar('batch', (bool) (isset($pa_options['batch']) && $pa_options['batch']));
             $vs_element = $o_view->render('intrinsic.php', true);
             $vs_description = isset($pa_bundle_settings['description'][$g_ui_locale]) && $pa_bundle_settings['description'][$g_ui_locale] ? $pa_bundle_settings['description'][$g_ui_locale] : $this->getFieldInfo($ps_bundle_name, 'DESCRIPTION');
             if ($pa_options['label'] && $vs_description) {
                 TooltipManager::add('#' . $vs_field_id, "<h3>" . $pa_options['label'] . "</h3>{$vs_description}");
             }
             if (isset($pa_bundle_settings['forACLAccessScreen']) && $pa_bundle_settings['forACLAccessScreen']) {
                 $vs_display_format = '^ELEMENT';
             } else {
                 $vs_display_format = $o_config->get('bundle_element_display_format');
             }
             break;
             # -------------------------------------------------
         # -------------------------------------------------
         case 'attribute':
             // bundle names for attributes are simply element codes prefixed with 'ca_attribute_'
             // since getAttributeHTMLFormBundle() takes a straight element code we have to strip the prefix here
             $vs_attr_element_code = str_replace('ca_attribute_', '', $ps_bundle_name);
             $vs_display_format = $o_config->get('bundle_element_display_format');
             $vs_element = $this->getAttributeHTMLFormBundle($pa_options['request'], $pa_options['formName'], $vs_attr_element_code, $ps_placement_code, $pa_bundle_settings, $pa_options);
             $vs_field_id = 'ca_attribute_' . $pa_options['formName'] . '_' . $vs_attr_element_code;
             if (!$vs_label_text) {
                 $vs_label_text = $this->getAttributeLabel($vs_attr_element_code);
             }
             if ($vb_batch) {
                 $t_element = $this->_getElementInstance($vs_attr_element_code);
                 $va_type_restrictions = $t_element->getTypeRestrictionsForDisplay($this->tableNum());
                 if (sizeof($va_type_restrictions)) {
                     $vs_restriction_list = join("; ", $va_type_restrictions);
                     $vs_label = '<span class="formLabelText" id="' . $vs_field_id . '">' . $vs_label_text . '</span> <span class="formLabelSubtext" id="subtext_' . $vs_field_id . '">(' . caTruncateStringWithEllipsis($vs_restriction_list, 75) . ')</span>';
                     TooltipManager::add("#subtext_{$vs_field_id}", "<h3>" . _t("Restricted to types") . "</h3>" . join("<br/>", $va_type_restrictions));
                 } else {
                     $vs_label = '<span class="formLabelText" id="' . $vs_field_id . '">' . $vs_label_text . '</span>';
                 }
             } else {
                 $vs_label = '<span class="formLabelText" id="' . $vs_field_id . '">' . $vs_label_text . '</span>';
             }
             // fall back to element description if applicable
             $vs_description = isset($pa_bundle_settings['description'][$g_ui_locale]) && $pa_bundle_settings['description'][$g_ui_locale] ? $pa_bundle_settings['description'][$g_ui_locale] : $this->getAttributeDescription($vs_attr_element_code);
             $vs_documentation_url = trim(isset($pa_bundle_settings['documentation_url']) && $pa_bundle_settings['documentation_url'] ? $pa_bundle_settings['documentation_url'] : ($vs_documentation_url = $this->getAttributeDocumentationUrl($vs_attr_element_code)));
             if ($t_element = $this->_getElementInstance($vs_attr_element_code)) {
                 if ($o_config->get('show_required_field_marker') && ($t_element->getSetting('minChars') > 0 || (bool) $t_element->getSetting('mustNotBeBlank') || (bool) $t_element->getSetting('requireValue'))) {
                     $vs_label .= ' ' . $vs_required_marker;
                 }
             }
             if ($vs_label_text && $vs_description) {
                 TooltipManager::add('#' . $vs_field_id, "<h3>{$vs_label_text}</h3>{$vs_description}");
             }
             break;
             # -------------------------------------------------
         # -------------------------------------------------
         case 'related_table':
             if (is_array($va_error_objects = $pa_options['request']->getActionErrors($ps_bundle_name, 'general')) && sizeof($va_error_objects)) {
                 $vs_display_format = $o_config->get('bundle_element_error_display_format');
                 foreach ($va_error_objects as $o_e) {
                     $va_errors[] = $o_e->getErrorDescription();
                 }
             } else {
                 $vs_display_format = $o_config->get('bundle_element_display_format');
             }
             switch ($ps_bundle_name) {
                 # -------------------------------
                 case 'ca_object_representations':
                     $pa_options['start'] = 0;
                     $pa_options['limit'] = 20;
                     $vs_element = $this->getRelatedHTMLFormBundle($pa_options['request'], $pa_options['formName'], $ps_bundle_name, $ps_placement_code, $pa_bundle_settings, $pa_options);
                     break;
                 case 'ca_entities':
                 case 'ca_places':
                 case 'ca_occurrences':
                 case 'ca_objects':
                 case 'ca_collections':
                 case 'ca_list_items':
                 case 'ca_storage_locations':
                 case 'ca_loans':
                 case 'ca_movements':
                 case 'ca_tour_stops':
                     if ($this->_CONFIG->get($ps_bundle_name . '_disable')) {
                         return '';
                     }
                     // don't display if master "disable" switch is set
                     $pa_options['start'] = 0;
                     $vs_element = $this->getRelatedHTMLFormBundle($pa_options['request'], $pa_options['formName'], $ps_bundle_name, $ps_placement_code, $pa_bundle_settings, $pa_options);
                     break;
                     # -------------------------------
                 # -------------------------------
                 case 'ca_object_lots':
                     if ($this->_CONFIG->get($ps_bundle_name . '_disable')) {
                         break;
                     }
                     // don't display if master "disable" switch is set
                     $pa_lot_options = array('batch' => $vb_batch);
                     if ($this->tableName() != 'ca_object_lots' && ($vn_lot_id = $pa_options['request']->getParameter('lot_id', pInteger))) {
                         $pa_lot_options['force'][] = $vn_lot_id;
                     }
                     $vs_element = $this->getRelatedHTMLFormBundle($pa_options['request'], $pa_options['formName'], $ps_bundle_name, $ps_placement_code, $pa_bundle_settings, $pa_lot_options);
                     break;
                     # -------------------------------
                 # -------------------------------
                 case 'ca_representation_annotations':
                     //if (!method_exists($this, "getAnnotationType") || !$this->getAnnotationType()) { continue; }	// don't show bundle if this representation doesn't support annotations
                     //if (!method_exists($this, "useBundleBasedAnnotationEditor") || !$this->useBundleBasedAnnotationEditor()) { continue; }	// don't show bundle if this representation doesn't use bundles to edit annotations
                     $pa_options['fields'] = array('ca_representation_annotations.status', 'ca_representation_annotations.access', 'ca_representation_annotations.props', 'ca_representation_annotations.representation_id');
                     $vs_element = $this->getRepresentationAnnotationHTMLFormBundle($pa_options['request'], $pa_options['formName'], $ps_placement_code, $pa_bundle_settings, $pa_options);
                     break;
                     # -------------------------------
                 # -------------------------------
                 default:
                     $vs_element = "'{$ps_bundle_name}' is not a valid related-table bundle name";
                     break;
                     # -------------------------------
             }
             if (!$vs_label_text) {
                 $vs_label_text = $va_info['label'];
             }
             $vs_label = '<span class="formLabelText" id="' . $pa_options['formName'] . '_' . $ps_placement_code . '">' . $vs_label_text . '</span>';
             $vs_description = isset($pa_bundle_settings['description'][$g_ui_locale]) && $pa_bundle_settings['description'][$g_ui_locale] ? $pa_bundle_settings['description'][$g_ui_locale] : null;
             if ($vs_label_text && $vs_description) {
                 TooltipManager::add('#' . $pa_options['formName'] . '_' . $ps_placement_code, "<h3>{$vs_label}</h3>{$vs_description}");
             }
             break;
             # -------------------------------------------------
         # -------------------------------------------------
         case 'special':
             if (is_array($va_error_objects = $pa_options['request']->getActionErrors($ps_bundle_name, 'general')) && sizeof($va_error_objects)) {
                 $vs_display_format = $o_config->get('bundle_element_error_display_format');
                 foreach ($va_error_objects as $o_e) {
                     $va_errors[] = $o_e->getErrorDescription();
                 }
             } else {
                 $vs_display_format = $o_config->get('bundle_element_display_format');
             }
             $vb_read_only = $pa_options['request']->user->getBundleAccessLevel($this->tableName(), $ps_bundle_name) == __CA_BUNDLE_ACCESS_READONLY__ ? true : false;
             if (!$pa_bundle_settings['readonly']) {
                 $pa_bundle_settings['readonly'] = !isset($pa_bundle_settings['readonly']) || !$pa_bundle_settings['readonly'] ? $vb_read_only : true;
             }
             switch ($ps_bundle_name) {
                 # -------------------------------
                 // This bundle is only available when editing objects of type ca_representation_annotations
                 case 'ca_representation_annotation_properties':
                     if ($vb_batch) {
                         return null;
                     }
                     // not supported in batch mode
                     if (!$this->useInEditor()) {
                         return null;
                     }
                     foreach ($this->getPropertyList() as $vs_property) {
                         $vs_element .= $this->getPropertyHTMLFormBundle($pa_options['request'], $pa_options['formName'], $ps_placement_code, $vs_property, $pa_options);
                     }
                     break;
                     # -------------------------------
                     // This bundle is only available when editing objects of type ca_sets
                 # -------------------------------
                 // This bundle is only available when editing objects of type ca_sets
                 case 'ca_set_items':
                     if ($vb_batch) {
                         return null;
                     }
                     // not supported in batch mode
                     $vs_element .= $this->getSetItemHTMLFormBundle($pa_options['request'], $pa_options['formName'], $ps_placement_code, $pa_options, $pa_bundle_settings);
                     break;
                     # -------------------------------
                     // This bundle is only available for types which support set membership
                 # -------------------------------
                 // This bundle is only available for types which support set membership
                 case 'ca_sets':
                     require_once __CA_MODELS_DIR__ . "/ca_sets.php";
                     // need to include here to avoid dependency errors on parse/compile
                     $t_set = new ca_sets();
                     $vs_element .= $t_set->getItemSetMembershipHTMLFormBundle($pa_options['request'], $pa_options['formName'], $ps_placement_code, $this->tableNum(), $this->getPrimaryKey(), $pa_options['request']->getUserID(), $pa_bundle_settings, $pa_options);
                     break;
                     # -------------------------------
                     // This bundle is only available when editing objects of type ca_editor_uis
                 # -------------------------------
                 // This bundle is only available when editing objects of type ca_editor_uis
                 case 'ca_editor_ui_screens':
                     if ($vb_batch) {
                         return null;
                     }
                     // not supported in batch mode
                     $vs_element .= $this->getScreenHTMLFormBundle($pa_options['request'], $pa_options['formName'], $ps_placement_code, $pa_options);
                     break;
                     # -------------------------------
                     // This bundle is only available when editing objects of type ca_editor_uis
                 # -------------------------------
                 // This bundle is only available when editing objects of type ca_editor_uis
                 case 'ca_editor_ui_type_restrictions':
                     if ($vb_batch) {
                         return null;
                     }
                     // not supported in batch mode
                     $vs_element .= $this->getTypeRestrictionsHTMLFormBundle($pa_options['request'], $pa_options['formName'], $ps_placement_code, $pa_options);
                     break;
                     # -------------------------------
                     // This bundle is only available when editing objects of type ca_editor_ui_screens
                 # -------------------------------
                 // This bundle is only available when editing objects of type ca_editor_ui_screens
                 case 'ca_editor_ui_screen_type_restrictions':
                     $t_editor = new ca_editor_uis($this->get('ui_id'));
                     $vs_element .= $this->getTypeRestrictionsHTMLFormBundle($pa_options['request'], $pa_options['formName'], $ps_placement_code, $pa_options);
                     break;
                     # -------------------------------
                     // This bundle is only available when editing objects of type ca_editor_ui_screens
                 # -------------------------------
                 // This bundle is only available when editing objects of type ca_editor_ui_screens
                 case 'ca_editor_ui_bundle_placements':
                     if ($vb_batch) {
                         return null;
                     }
                     // not supported in batch mode
                     $vs_element .= $this->getPlacementsHTMLFormBundle($pa_options['request'], $pa_options['formName'], $ps_placement_code, $pa_options);
                     break;
                     # -------------------------------
                     // This bundle is only available when editing objects of type ca_tours
                 # -------------------------------
                 // This bundle is only available when editing objects of type ca_tours
                 case 'ca_tour_stops_list':
                     if ($vb_batch) {
                         return null;
                     }
                     // not supported in batch mode
                     $vs_element .= $this->getTourStopHTMLFormBundle($pa_options['request'], $pa_options['formName'], $ps_placement_code, $pa_options);
                     break;
                     # -------------------------------
                     // Hierarchy navigation bar for hierarchical tables
                 # -------------------------------
                 // Hierarchy navigation bar for hierarchical tables
                 case 'hierarchy_navigation':
                     if ($vb_batch) {
                         return null;
                     }
                     // not supported in batch mode
                     if ($this->isHierarchical()) {
                         $vs_element .= $this->getHierarchyNavigationHTMLFormBundle($pa_options['request'], $pa_options['formName'], $ps_placement_code, array(), $pa_bundle_settings, $pa_options);
                     }
                     break;
                     # -------------------------------
                     // Hierarchical item location control
                 # -------------------------------
                 // Hierarchical item location control
                 case 'hierarchy_location':
                     if ($vb_batch) {
                         return null;
                     }
                     // not supported in batch mode
                     if ($this->isHierarchical()) {
                         $vs_element .= $this->getHierarchyLocationHTMLFormBundle($pa_options['request'], $pa_options['formName'], $ps_placement_code, array(), $pa_bundle_settings, $pa_options);
                     }
                     break;
                     # -------------------------------
                     // This bundle is only available when editing objects of type ca_search_forms
                 # -------------------------------
                 // This bundle is only available when editing objects of type ca_search_forms
                 case 'ca_search_form_placements':
                     if ($vb_batch) {
                         return null;
                     }
                     // not supported in batch mode
                     //if (!$this->getPrimaryKey()) { return ''; }
                     $vs_element .= $this->getSearchFormHTMLFormBundle($pa_options['request'], $pa_options['formName'], $ps_placement_code, $pa_options);
                     break;
                     # -------------------------------
                     // This bundle is only available when editing objects of type ca_bundle_displays
                 # -------------------------------
                 // This bundle is only available when editing objects of type ca_bundle_displays
                 case 'ca_bundle_display_placements':
                     if ($vb_batch) {
                         return null;
                     }
                     // not supported in batch mode
                     //if (!$this->getPrimaryKey()) { return ''; }
                     $vs_element .= $this->getBundleDisplayHTMLFormBundle($pa_options['request'], $pa_options['formName'], $ps_placement_code, $pa_options);
                     break;
                     # -------------------------------
                     // This bundle is only available when editing objects of type ca_bundle_displays
                 # -------------------------------
                 // This bundle is only available when editing objects of type ca_bundle_displays
                 case 'ca_bundle_display_type_restrictions':
                     $vs_element .= $this->getTypeRestrictionsHTMLFormBundle($pa_options['request'], $pa_options['formName'], $ps_placement_code, $pa_options);
                     break;
                     # -------------------------------
                     //
                 # -------------------------------
                 //
                 case 'ca_users':
                     if (!$pa_options['request']->user->canDoAction('is_administrator') && $pa_options['request']->getUserID() != $this->get('user_id')) {
                         return '';
                     }
                     // don't allow setting of per-user access if user is not owner
                     $vs_element .= $this->getUserHTMLFormBundle($pa_options['request'], $pa_options['formName'], $ps_placement_code, $this->tableNum(), $this->getPrimaryKey(), $pa_options['request']->getUserID(), $pa_options);
                     break;
                     # -------------------------------
                     //
                 # -------------------------------
                 //
                 case 'ca_user_groups':
                     if (!$pa_options['request']->user->canDoAction('is_administrator') && $pa_options['request']->getUserID() != $this->get('user_id')) {
                         return '';
                     }
                     // don't allow setting of group access if user is not owner
                     $vs_element .= $this->getUserGroupHTMLFormBundle($pa_options['request'], $pa_options['formName'], $ps_placement_code, $this->tableNum(), $this->getPrimaryKey(), $pa_options['request']->getUserID(), $pa_options);
                     break;
                     # -------------------------------
                 # -------------------------------
                 case 'settings':
                     if ($vb_batch) {
                         return null;
                     }
                     // not supported in batch mode
                     $vs_element .= $this->getHTMLSettingFormBundle($pa_options['request'], $pa_options['formName'], $ps_placement_code, $this->tableNum(), $pa_options);
                     break;
                     # -------------------------------
                     // This bundle is only available when editing objects of type ca_object_representations
                 # -------------------------------
                 // This bundle is only available when editing objects of type ca_object_representations
                 case 'ca_object_representations_media_display':
                     if ($vb_batch) {
                         return null;
                     }
                     // not supported in batch mode
                     $vs_element .= $this->getMediaDisplayHTMLFormBundle($pa_options['request'], $pa_options['formName'], $ps_placement_code, $pa_bundle_settings, $pa_options);
                     break;
                     # -------------------------------
                     // This bundle is only available when editing objects of type ca_object_representations
                 # -------------------------------
                 // This bundle is only available when editing objects of type ca_object_representations
                 case 'ca_object_representation_captions':
                     if ($vb_batch) {
                         return null;
                     }
                     // not supported in batch mode
                     if (!$this->representationIsOfClass("video")) {
                         return '';
                     }
                     $vs_element .= $this->getCaptionHTMLFormBundle($pa_options['request'], $pa_options['formName'], $ps_placement_code, $pa_bundle_settings, $pa_options);
                     break;
                     # -------------------------------
                     // This bundle is only available for objects
                 # -------------------------------
                 // This bundle is only available for objects
                 case 'ca_commerce_order_history':
                     if ($vb_batch) {
                         return null;
                     }
                     // not supported in batch mode
                     if (!$pa_options['request']->user->canDoAction('can_manage_clients')) {
                         break;
                     }
                     $vs_label_text = $pa_bundle_settings['order_type'][0] == 'O' ? _t('Order history') : _t('Loan history');
                     $vs_element .= $this->getCommerceOrderHistoryHTMLFormBundle($pa_options['request'], $pa_options['formName'], $ps_placement_code, $pa_bundle_settings, $pa_options);
                     break;
                     # -------------------------------
                     // This bundle is only available for objects
                 # -------------------------------
                 // This bundle is only available for objects
                 case 'ca_objects_components_list':
                     if ($vb_batch) {
                         return null;
                     }
                     // not supported in batch mode
                     if (!$pa_options['request']->user->canDoAction('can_edit_ca_objects')) {
                         break;
                     }
                     if (!$this->canTakeComponents()) {
                         return null;
                     }
                     $vs_element .= $this->getComponentListHTMLFormBundle($pa_options['request'], $pa_options['formName'], $ps_placement_code, $pa_bundle_settings, $pa_options);
                     break;
                     # -------------------------------
                     // This bundle is only available for objects
                 # -------------------------------
                 // This bundle is only available for objects
                 case 'ca_objects_location':
                     // storage location via ca_objects_x_storage_locations or ca_movements_x_objects
                     if ($vb_batch) {
                         return null;
                     }
                     // not supported in batch mode
                     if (!$this->getPrimaryKey()) {
                         return null;
                     }
                     // not supported for new records
                     if (!$pa_options['request']->user->canDoAction('can_edit_ca_objects')) {
                         break;
                     }
                     $vs_element .= $this->getObjectLocationHTMLFormBundle($pa_options['request'], $pa_options['formName'], $ps_placement_code, $pa_bundle_settings, $pa_options);
                     break;
                     # -------------------------------
                     // This bundle is only available for objects
                 # -------------------------------
                 // This bundle is only available for objects
                 case 'ca_objects_history':
                     // summary of object accession, movement, exhibition and deaccession
                     if ($vb_batch) {
                         return null;
                     }
                     // not supported in batch mode
                     if (!$this->getPrimaryKey()) {
                         return null;
                     }
                     // not supported for new records
                     if (!$pa_options['request']->user->canDoAction('can_edit_ca_objects')) {
                         break;
                     }
                     $vs_element .= $this->getObjectHistoryHTMLFormBundle($pa_options['request'], $pa_options['formName'], $ps_placement_code, $pa_bundle_settings, $pa_options);
                     break;
                     # -------------------------------
                     // This bundle is only available for objects
                 # -------------------------------
                 // This bundle is only available for objects
                 case 'ca_objects_deaccession':
                     // object deaccession information
                     if (!$vb_batch && !$this->getPrimaryKey()) {
                         return null;
                     }
                     // not supported for new records
                     if (!$pa_options['request']->user->canDoAction('can_edit_ca_objects')) {
                         break;
                     }
                     $vs_element .= $this->getObjectDeaccessionHTMLFormBundle($pa_options['request'], $pa_options['formName'], $ps_placement_code, $pa_bundle_settings, $pa_options);
                     break;
                     # -------------------------------
                     // This bundle is only available for objects
                 # -------------------------------
                 // This bundle is only available for objects
                 case 'ca_object_checkouts':
                     // object checkout information
                     if ($vb_batch) {
                         return null;
                     }
                     // not supported in batch mode
                     if (!$vb_batch && !$this->getPrimaryKey()) {
                         return null;
                     }
                     // not supported for new records
                     if (!$pa_options['request']->user->canDoAction('can_edit_ca_objects')) {
                         break;
                     }
                     $vs_element .= $this->getObjectCheckoutsHTMLFormBundle($pa_options['request'], $pa_options['formName'], $ps_placement_code, $pa_bundle_settings, $pa_options);
                     break;
                     # -------------------------------
                     // This bundle is only available for relationships that include an object on one end
                 # -------------------------------
                 // This bundle is only available for relationships that include an object on one end
                 case 'ca_object_representation_chooser':
                     if ($vb_batch) {
                         return null;
                     }
                     // not supported in batch mode
                     $vs_element .= $this->getRepresentationChooserHTMLFormBundle($pa_options['request'], $pa_options['formName'], $ps_placement_code, $pa_bundle_settings, $pa_options);
                     break;
                     # -------------------------------
                     // This bundle is only available items that can be used as authority references (object, entities, occurrences, list items, etc.)
                 # -------------------------------
                 // This bundle is only available items that can be used as authority references (object, entities, occurrences, list items, etc.)
                 case 'authority_references_list':
                     $vs_element .= $this->getAuthorityReferenceListHTMLFormBundle($pa_options['request'], $pa_options['formName'], $ps_placement_code, $pa_bundle_settings, $pa_options);
                     break;
                     # -------------------------------
                 # -------------------------------
                 default:
                     $vs_element = "'{$ps_bundle_name}' is not a valid bundle name";
                     break;
                     # -------------------------------
             }
             if (!$vs_label_text) {
                 $vs_label_text = $va_info['label'];
             }
             $vs_label = '<span class="formLabelText" id="' . $pa_options['formName'] . '_' . $ps_placement_code . '">' . $vs_label_text . '</span>';
             $vs_description = isset($pa_bundle_settings['description'][$g_ui_locale]) && $pa_bundle_settings['description'][$g_ui_locale] ? $pa_bundle_settings['description'][$g_ui_locale] : null;
             if ($vs_label_text && $vs_description) {
                 TooltipManager::add('#' . $pa_options['formName'] . '_' . $ps_placement_code, "<h3>{$vs_label}</h3>{$vs_description}");
             }
             break;
             # -------------------------------------------------
         # -------------------------------------------------
         default:
             return "'{$ps_bundle_name}' is not a valid bundle name";
             break;
             # -------------------------------------------------
     }
     if ($vs_documentation_url) {
         // catch doc URL without protocol aka starting with letters but not http/https
         if (preg_match("!^[a-z]!", $vs_documentation_url) && !preg_match("!^http[s]?://!", $vs_documentation_url)) {
             $vs_documentation_url = "http://" . $vs_documentation_url;
         }
         $vs_documentation_link = "<a class='bundleDocumentationLink' href='{$vs_documentation_url}' target='_blank'>documentation</a>";
     }
     if (is_array($va_violations) && sizeof($va_violations)) {
         $vs_label .= "<img src='" . $pa_options['request']->getThemeUrlPath() . "/graphics/icons/warning_small.gif' style='margin-left: 5px;' onclick='jQuery(this).parent().find(\".caMetadataDictionaryDefinitionToggle\").click();  return false;'/>";
     }
     $vs_output = str_replace("^ELEMENT", $vs_element, $vs_display_format);
     $vs_output = str_replace("^ERRORS", join('; ', $va_errors), $vs_output);
     $vs_output = str_replace("^LABEL", $vs_label, $vs_output);
     $vs_output = str_replace("^DOCUMENTATIONLINK", $vs_documentation_link, $vs_output);
     $ps_bundle_label = $vs_label_text;
     return caGetOption('contentOnly', $pa_options, false) ? $vs_element : $vs_output;
 }
Пример #7
0
 /**
  * Return HTML form elements for all elements using the current format, type and value
  *
  * @param string $ps_name Name of form element. Is used as a prefix for each form element. The number element name will be used as a suffix for each.
  * @param array $pa_errors Passed-by-reference array. Will contain any validation errors for the value, indexed by element.
  * @param array $pa_options Options include:
  *		id_prefix = Prefix to add to element ID attributes. [Default is null]
  *		for_search_form = Generate a blank form for search. [Default is false]
  *		show_errors = Include error messages next to form elements. [Default is false]
  *		error_icon = Icon to display next to error messages; should be ready-to-display HTML. [Default is null]
  *		readonly = Make all form elements read-only. [Default is false]
  *		request = the current request (an instance of RequestHTTP) [Default is null]
  *		check_for_dupes = perform live checking for duplicate numbers. [Default is false]
  *		progress_indicator = URL for spinner graphic to use while running duplicate number check. [Default is null] 
  *		table = Table to perform duplicate number check in. [Default is null]
  *		search_url = Search service URL to use when performing duplicate number check. [Default is null]
  *		row_id = ID of row to exclude from duplicate number check (typically the current record id). [Default is null]
  *		context_id = context ID of row to exclude from duplicate number check (typically the current record context). [Default is null]
  * @return string HTML output
  */
 public function htmlFormElement($ps_name, &$pa_errors = null, $pa_options = null)
 {
     if (!is_array($pa_options)) {
         $pa_options = array();
     }
     $vs_id_prefix = isset($pa_options['id_prefix']) ? $pa_options['id_prefix'] : null;
     $vb_generate_for_search_form = isset($pa_options['for_search_form']) ? true : false;
     $pa_errors = $this->validateValue($this->getValue());
     $vs_separator = $this->getSeparator();
     $va_element_vals = $this->explodeValue($this->getValue());
     if (!is_array($va_elements = $this->getElements())) {
         $va_elements = array();
     }
     $va_element_controls = $va_element_control_names = array();
     $vn_i = 0;
     $vb_next_in_seq_is_present = false;
     foreach ($va_elements as $vs_element_name => $va_element_info) {
         if ($va_element_info['type'] == 'SERIAL' && $va_element_vals[$vn_i] == '') {
             $vb_next_in_seq_is_present = true;
         }
         $vs_tmp = $this->genNumberElement($vs_element_name, $ps_name, $va_element_vals[$vn_i], $vs_id_prefix, $vb_generate_for_search_form, $pa_options);
         $va_element_control_names[] = $ps_name . '_' . $vs_element_name;
         if ($pa_options['show_errors'] && isset($pa_errors[$vs_element_name])) {
             $vs_error_message = preg_replace("/[\"\\']+/", "", $pa_errors[$vs_element_name]);
             if ($pa_options['error_icon']) {
                 $vs_tmp .= "<a href='#'\" id='caIdno_{$vs_id_prefix}_{$ps_name}'><img src='" . $pa_options['error_icon'] . "' border='0'/></a>";
             } else {
                 $vs_tmp .= "<a href='#'\" id='caIdno_{$vs_id_prefix}_{$ps_name}'>[" . _t('Error') . "]</a>";
             }
             TooltipManager::add("#caIdno_{$vs_id_prefix}_{$ps_name}", "<h2>" . _t('Error') . "</h2>{$vs_error_message}");
         }
         $va_element_controls[] = $vs_tmp;
         $vn_i++;
     }
     if (sizeof($va_elements) < sizeof($va_element_vals) && (bool) $this->getFormatPropery('allow_extra_elements', array('default' => 1))) {
         $va_extra_vals = array_slice($va_element_vals, sizeof($va_elements));
         if (($vn_extra_size = (int) $this->getFormatPropery('extra_element_width', array('default' => 10))) < 1) {
             $vn_extra_size = 10;
         }
         foreach ($va_extra_vals as $vn_i => $vs_extra_val) {
             $va_element_controls[] = "<input type='text' name='{$ps_name}_extra_{$vn_i}' id='{$ps_name}_extra_{$vn_i}' value='" . htmlspecialchars($vs_extra_val, ENT_QUOTES, 'UTF-8') . "' size='{$vn_extra_size}'" . ($pa_options['readonly'] ? ' disabled="1" ' : '') . ">";
             $va_element_control_names[] = $ps_name . '_extra_' . $vn_i;
         }
     }
     $vs_js = '';
     if ($pa_options['check_for_dupes'] && !$vb_next_in_seq_is_present) {
         $va_ids = array();
         foreach ($va_element_control_names as $vs_element_control_name) {
             $va_ids[] = "'#" . $vs_id_prefix . $vs_element_control_name . "'";
         }
         $vs_js = '<script type="text/javascript" language="javascript">' . "\n// <![CDATA[\n";
         $va_lookup_url_info = caJSONLookupServiceUrl($pa_options['request'], $pa_options['table']);
         $vs_js .= "\n\t\t\t\tcaUI.initIDNoChecker({\n\t\t\t\t\terrorIcon: '" . $pa_options['error_icon'] . "',\n\t\t\t\t\tprocessIndicator: '" . $pa_options['progress_indicator'] . "',\n\t\t\t\t\tidnoStatusID: 'idnoStatus',\n\t\t\t\t\tlookupUrl: '" . $va_lookup_url_info['idno'] . "',\n\t\t\t\t\tsearchUrl: '" . $pa_options['search_url'] . "',\n\t\t\t\t\tidnoFormElementIDs: [" . join(',', $va_ids) . "],\n\t\t\t\t\tseparator: '" . $this->getSeparator() . "',\n\t\t\t\t\trow_id: " . intval($pa_options['row_id']) . ",\n\t\t\t\t\tcontext_id: " . intval($pa_options['context_id']) . ",\n\n\t\t\t\t\tsingularAlreadyInUseMessage: '" . addslashes(_t('Identifier is already in use')) . "',\n\t\t\t\t\tpluralAlreadyInUseMessage: '" . addslashes(_t('Identifier is already in use %1 times')) . "'\n\t\t\t\t});\n\t\t\t";
         $vs_js .= "// ]]>\n</script>\n";
     }
     return join($vs_separator, $va_element_controls) . $vs_js;
 }
Пример #8
0
 */
JavascriptLoadManager::register('hierBrowser');
JavascriptLoadManager::register('tabUI');
$t_subject = $this->getVar('t_subject');
$pa_ancestors = $this->getVar('ancestors');
$pn_id = $this->getVar('id');
$ps_id_prefix = $this->getVar('placement_code') . $this->getVar('id_prefix') . 'HierNavigation';
$va_lookup_urls = caJSONLookupServiceUrl($this->request, $t_subject->tableName(), array('noInline' => 1));
$pa_bundle_settings = $this->getVar('settings');
$vb_objects_x_collections_hierarchy_enabled = (bool) $t_subject->getAppConfig()->get('ca_objects_x_collections_hierarchy_enabled');
if (in_array($t_subject->tableName(), array('ca_objects', 'ca_collections')) && $vb_objects_x_collections_hierarchy_enabled) {
    $va_lookup_urls = array('search' => caNavUrl($this->request, 'lookup', 'ObjectCollectionHierarchy', 'Get'), 'levelList' => caNavUrl($this->request, 'lookup', 'ObjectCollectionHierarchy', 'GetHierarchyLevel'), 'ancestorList' => caNavUrl($this->request, 'lookup', 'ObjectCollectionHierarchy', 'GetHierarchyAncestorList'));
    $vs_edit_url = caNavUrl($this->request, 'lookup', 'ObjectCollectionHierarchy', 'Edit') . '/id/';
    $vn_init_id = $t_subject->tableName() . "-" . $pn_id;
} else {
    $va_lookup_urls = caJSONLookupServiceUrl($this->request, $t_subject->tableName(), array('noInline' => 1));
    $vs_edit_url = caEditorUrl($this->request, $t_subject->tableName());
    $vn_init_id = $pn_id;
}
print caEditorBundleShowHideControl($this->request, $ps_id_prefix . $t_subject->tableNum() . 'HierNavigation');
?>
	
	<div class="bundleContainer" id="<?php 
print $ps_id_prefix . $t_subject->tableNum();
?>
HierNavigation">
		<div class="hierNav">
<?php 
if ($pn_id > 0) {
    ?>
			<div class="buttonPosition" <?php 
<?php 
print $vs_control_box = caFormControlBox(caFormSubmitButton($this->request, __CA_NAV_BUTTON_SAVE__, _t("Save"), 'ElementsForm') . ' ' . caNavButton($this->request, __CA_NAV_BUTTON_CANCEL__, _t("Cancel"), '', 'administrate/setup', 'Elements', 'Index', array('element_id' => 0)), '', caNavButton($this->request, __CA_NAV_BUTTON_DELETE__, _t("Delete"), '', 'administrate/setup', 'Elements', 'Delete', array('element_id' => $vn_element_id)));
print caFormTag($this->request, 'Save', 'ElementsForm');
?>

<div class="bundleLabel">
	<span class="formLabelText" id="_ca_metadata_element_labels_"><?php 
print _t("Labels");
?>
</span>
<?php 
print $t_element->getPreferredLabelHTMLFormBundle($this->request, 'element_labels', 'element_labels');
?>
</div>
<?php 
$va_lookup_url_info = caJSONLookupServiceUrl($this->request, $t_element->tableName());
$va_options = array('error_icon' => $this->request->getThemeUrlPath() . "/graphics/icons/warning_small.gif", 'progress_indicator' => $this->request->getThemeUrlPath() . "/graphics/icons/indicator.gif", 'lookup_url' => $va_lookup_url_info['intrinsic'], 'no_tooltips' => false);
foreach ($t_element->getFormFields() as $vs_f => $va_user_info) {
    print $t_element->htmlFormElement($vs_f, null, array_merge($va_options, array('field_errors' => $this->request->getActionErrors('field_' . $vs_f))));
}
if ($vn_parent_id) {
    print caHTMLHiddenInput('parent_id', array('value' => $vn_parent_id));
}
if (!is_array($va_available_settings = $this->getVar('available_settings'))) {
    $va_available_settings = array();
}
?>
		<div id='elementSettingsForm' class='formSettings'>
			<div class='formLabel'><span id="_ca_metadata_element_labels_"><?php 
print _t("Datatype-specific options");
?>
Пример #10
0
 /**
  * Renders and returns HTML form bundle for management of items in the currently loaded set
  * 
  * @param object $po_request The current request object
  * @param string $ps_form_name The name of the form in which the bundle will be rendered
  *
  * @return string Rendered HTML bundle for display
  */
 public function getSetItemHTMLFormBundle($po_request, $ps_form_name, $ps_placement_code, $pa_options = null, $pa_bundle_settings = null)
 {
     if ($this->getItemCount() > 50) {
         $vs_thumbnail_version = 'tiny';
     } else {
         $vs_thumbnail_version = "thumbnail";
     }
     $o_view = new View($po_request, $po_request->getViewsDirectoryPath() . '/bundles/');
     $o_view->setVar('t_set', $this);
     $o_view->setVar('id_prefix', $ps_form_name);
     $o_view->setVar('placement_code', $ps_placement_code);
     $o_view->setVar('request', $po_request);
     if ($this->getPrimaryKey()) {
         $va_items = caExtractValuesByUserLocale($this->getItems(array('thumbnailVersion' => $vs_thumbnail_version, 'user_id' => $po_request->getUserID(), 'template' => caGetOption('displayTemplate', $pa_bundle_settings, null))), null, null, array());
         $o_view->setVar('items', $va_items);
     } else {
         $o_view->setVar('items', array());
     }
     $o_view->setVar('settings', $pa_bundle_settings);
     if ($t_row = $this->getItemTypeInstance()) {
         $o_view->setVar('t_row', $t_row);
         $o_view->setVar('type_singular', $t_row->getProperty('NAME_SINGULAR'));
         $o_view->setVar('type_plural', $t_row->getProperty('NAME_PLURAL'));
     }
     $o_view->setVar('lookup_urls', caJSONLookupServiceUrl($po_request, $this->_DATAMODEL->getTableName($this->get('table_num'))));
     return $o_view->render('ca_set_items.php');
 }
Пример #11
0
 /**
  * Returns HTML bundle for adding/editing/deleting placements from a form
  *
  * @param object $po_request The current request
  * @param $ps_form_name The name of the HTML form this bundle will be part of
  * @return string HTML for bundle
  */
 public function getSearchFormHTMLFormBundle($po_request, $ps_form_name, $pa_options = null)
 {
     if (!$this->haveAccessToForm($po_request->getUserID(), __CA_SEARCH_FORM_EDIT_ACCESS__)) {
         return null;
     }
     $vs_view_path = isset($pa_options['viewPath']) && $pa_options['viewPath'] ? $pa_options['viewPath'] : $po_request->getViewsDirectoryPath();
     $o_view = new View($po_request, "{$vs_view_path}/bundles/");
     $o_view->setVar('lookup_urls', caJSONLookupServiceUrl($po_request, $this->_DATAMODEL->getTableName($this->get('table_num'))));
     $o_view->setVar('t_form', $this);
     $o_view->setVar('id_prefix', $ps_form_name);
     return $o_view->render('ca_search_form_placements.php');
 }
Пример #12
0
 * 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
 *
 * ----------------------------------------------------------------------
 */
$t_subject = $this->getVar('t_subject');
$vs_table = $t_subject->tableName();
$va_lookup_urls = caJSONLookupServiceUrl($this->request, $vs_table, array('noInline' => 1));
$vo_result_context = $this->getVar('result_context');
$vs_type_id_form_element = '';
if ($vn_type_id = intval($this->getVar('type_id'))) {
    $vs_type_id_form_element = '<input type="hidden" name="type_id" value="' . $vn_type_id . '"/>';
}
if (!$this->request->isAjax()) {
    if (!$this->getVar('uses_hierarchy_browser')) {
        ?>
		<?php 
        print caFormTag($this->request, 'Index', 'BasicSearchForm', null, 'post', 'multipart/form-data', '_top', array('disableUnsavedChangesWarning' => true));
        print caFormControlBox('<div class="simple-search-box">' . _t('Search') . ': <input type="text" id="BasicSearchInput" name="search" value="' . htmlspecialchars($this->getVar('search'), ENT_QUOTES, 'UTF-8') . '" size="40"/>' . $vs_type_id_form_element . '</div>', '<a href="#" onclick="caSaveSearch(\'BasicSearchForm\', jQuery(\'#BasicSearchInput\').val(), [\'search\']); return false;" class="button">' . _t('Save search') . ' &rsaquo;</a>', caFormSubmitButton($this->request, __CA_NAV_BUTTON_SEARCH__, _t("Search"), 'BasicSearchForm'));
        ?>
		</form>
	<?php 
    } else {
Пример #13
0
	
	<div class="quickAddFormTopPadding"><!-- empty --></div>
	<div class="quickAddErrorContainer" id="<?php 
print $vs_form_name;
?>
Errors<?php 
print $vs_field_name_prefix . $vs_n;
?>
"> </div>
	<div class="quickAddSectionBox" id="{$vs_form_name}Container<?php 
print $vs_field_name_prefix . $vs_n;
?>
">
<?php 
// Output hierarchy browser
$va_lookup_urls = caJSONLookupServiceUrl($this->request, 'ca_places');
?>
	<div class='bundleLabel'><span class="formLabelText"><?php 
print _t('Location in hierarchy');
?>
</span><br/>
		<div class="bundleContainer">
			<div class="caItemList">
				<div class="hierarchyBrowserContainer">
					<div id="caQuickAdd<?php 
print $vs_form_name;
?>
HierarchyBrowser" class="hierarchyBrowserSmall">
						<!-- Content for hierarchy browser is dynamically inserted here by ca.hierbrowser -->
					</div><!-- end hierbrowser -->
					<div>
Пример #14
0
 /**
  * Returns HTML form input widget for bundle specified by standard "get" bundle code (eg. <table_name>.<bundle_name> format) suitable
  * for use in a simple data entry form, such as the front-end "contribute" user-provided content submission form
  *
  * This method handles generation of search form widgets for intrinsic fields in the primary table. If this method can't handle 
  * the bundle (because it is not an intrinsic field in the primary table...) it will return null.
  *
  * @param $po_request HTTPRequest
  * @param $ps_field string
  * @param $pa_options array
  * @return string HTML text of form element. Will return null if it is not possible to generate an HTML form widget for the bundle.
  * 
  */
 public function htmlFormElementForSimpleForm($po_request, $ps_field, $pa_options = null)
 {
     if (!is_array($pa_options)) {
         $pa_options = array();
     }
     if (isset($pa_options['width'])) {
         if ($va_dim = caParseFormElementDimension($pa_options['width'])) {
             if ($va_dim['type'] == 'pixels') {
                 unset($pa_options['width']);
                 $pa_options['maxPixelWidth'] = $va_dim['dimension'];
             }
         }
     }
     $va_tmp = explode('.', $ps_field);
     if ($va_tmp[0] != $this->tableName()) {
         return null;
     }
     if ($this->hasField($va_tmp[1])) {
         if (caGetOption('asArrayElement', $pa_options, false)) {
             $ps_field .= "[]";
         }
         if ($this->getProperty('ID_NUMBERING_ID_FIELD') == $va_tmp[1]) {
             $va_lookup_url_info = caJSONLookupServiceUrl($po_request, $this->tableName());
             return $this->htmlFormElement($va_tmp[1], $this->getAppConfig()->get('idno_element_display_format_without_label'), array_merge($pa_options, array('name' => $ps_field, 'error_icon' => $po_request->getThemeUrlPath() . "/graphics/icons/warning_small.gif", 'progress_indicator' => $po_request->getThemeUrlPath() . "/graphics/icons/indicator.gif", 'id' => str_replace(".", "_", $ps_field), 'classname' => isset($pa_options['class']) ? $pa_options['class'] : '', 'value' => isset($pa_options['values'][$ps_field]) ? $pa_options['values'][$ps_field] : '', 'width' => isset($pa_options['width']) && $pa_options['width'] > 0 ? $pa_options['width'] : 30, 'height' => isset($pa_options['height']) && $pa_options['height'] > 0 ? $pa_options['height'] : 1, 'no_tooltips' => true, 'lookup_url' => $va_lookup_url_info['intrinsic'], 'request' => $po_request)));
         }
         return $this->htmlFormElement($va_tmp[1], '^ELEMENT', array_merge($pa_options, array('name' => $ps_field, 'id' => str_replace(".", "_", $ps_field), 'classname' => isset($pa_options['class']) ? $pa_options['class'] : '', 'value' => isset($pa_options['values'][$ps_field]) ? $pa_options['values'][$ps_field] : '', 'width' => isset($pa_options['width']) && $pa_options['width'] > 0 ? $pa_options['width'] : 30, 'height' => isset($pa_options['height']) && $pa_options['height'] > 0 ? $pa_options['height'] : 1, 'no_tooltips' => true)));
     }
     return null;
 }
 *
 * ----------------------------------------------------------------------
 */
$va_facet = $this->getVar('grouped_facet');
$vs_facet_name = $this->getVar('facet_name');
$va_facet_info = $this->getVar('facet_info');
$vs_grouping_field = $this->getVar('grouping');
$vs_group_mode = $va_facet_info["group_mode"];
$t_item = $this->getVar('t_item');
$t_subject = $this->getVar('t_subject');
$va_types = $this->getVar('type_list');
$va_relationship_types = $this->getVar('relationship_type_list');
$va_row_size = $this->request->config->get('browse_row_size');
$va_td_width = intval(100 / $va_row_size);
$vb_individual_group_display = (bool) $this->getVar('individual_group_display');
$va_service_urls = caJSONLookupServiceUrl($this->request, $va_facet_info['table'], array('noInline' => 1, 'noSymbols' => 1));
if (!$va_facet || !$vs_facet_name) {
    print _t('No facet defined');
    return;
}
$vm_modify_id = $this->getVar('modify') ? $this->getVar('modify') : '0';
?>
<script type="text/javascript">
	function caUpdateFacetDisplay(grouping) {
		caUIBrowsePanel.showBrowsePanel('<?php 
print $vs_facet_name;
?>
', <?php 
print intval($vm_modify_id) > 0 ? 'true' : 'false';
?>
, <?php 
Пример #16
0
/**
 *
 */
function caDeleteRemapper($po_request, $t_instance)
{
    $vs_instance_table = $t_instance->tableName();
    $vn_count = 0;
    $va_buf = array();
    switch ($vs_instance_table) {
        case 'ca_relationship_types':
            // get # of relationships using this type
            $vn_rel_count = $t_instance->getRelationshipCountForType();
            $t_rel_instance = $t_instance->getAppDatamodel()->getInstanceByTableNum($t_instance->get('table_num'));
            if (!$t_rel_instance->load($t_instance->get('table_num'))) {
                return '';
            }
            if ($vn_rel_count == 1) {
                $va_buf[] = _t("Type is used by %1 %2", $vn_rel_count, $t_rel_instance->getProperty('NAME_PLURAL')) . "<br>\n";
            } else {
                $va_buf[] = _t("Type is used by %1 %2", $vn_rel_count, $t_rel_instance->getProperty('NAME_PLURAL')) . "<br>\n";
            }
            $vn_count += $vn_rel_count;
            $vs_typename = _t('relationship type');
            break;
        default:
            // Check relationships
            $va_tables = array('ca_objects', 'ca_object_lots', 'ca_entities', 'ca_places', 'ca_occurrences', 'ca_collections', 'ca_storage_locations', 'ca_list_items', 'ca_loans', 'ca_movements', 'ca_tours', 'ca_tour_stops', 'ca_object_representations');
            if (!in_array($t_instance->tableName(), $va_tables)) {
                return null;
            }
            foreach ($va_tables as $vs_table) {
                $va_items = $t_instance->getRelatedItems($vs_table);
                if (!($vn_c = sizeof($va_items))) {
                    continue;
                }
                if ($vn_c == 1) {
                    $va_buf[] = _t("Has %1 relationship to %2", $vn_c, caGetTableDisplayName($vs_table, true)) . "<br>\n";
                } else {
                    $va_buf[] = _t("Has %1 relationships to %2", $vn_c, caGetTableDisplayName($vs_table, true)) . "<br>\n";
                }
                $vn_count += $vn_c;
            }
            // Check attributes
            if ($vn_datatype = $t_instance->authorityElementDatatype()) {
                if ($vn_c = $t_instance->getAuthorityElementReferences(array('countOnly' => true))) {
                    if ($vn_c == 1) {
                        $va_buf[] = _t("Is referenced %1 time", $vn_c) . "<br>\n";
                    } else {
                        $va_buf[] = _t("Is referenced %1 times", $vn_c) . "<br>\n";
                    }
                    $vn_count += $vn_c;
                }
            }
            $vs_typename = $t_instance->getTypeName();
    }
    $vs_output = '';
    if (sizeof($va_buf)) {
        // add autocompleter for remapping
        if ($vn_count == 1) {
            $vs_output .= "<h3 id='caDeleteReferenceCount'>" . _t('This %1 is referenced %2 time', $vs_typename, $vn_count) . ". " . _t('When deleting this %1:', $vs_typename) . "</h3>\n";
        } else {
            $vs_output .= "<h3 id='caDeleteReferenceCount'>" . _t('This %1 is referenced %2 times', $vs_typename, $vn_count) . ". " . _t('When deleting this %1:', $vs_typename) . "</h3>\n";
        }
        $vs_output .= caHTMLRadioButtonInput('referenceHandling', array('value' => 'delete', 'checked' => 1, 'id' => 'caReferenceHandlingDelete')) . ' ' . _t('remove all references') . "<br/>\n";
        $vs_output .= caHTMLRadioButtonInput('referenceHandling', array('value' => 'remap', 'id' => 'caReferenceHandlingRemap')) . ' ' . _t('transfer references to') . ' ' . caHTMLTextInput('remapTo', array('value' => '', 'size' => 40, 'id' => 'remapTo', 'class' => 'lookupBg', 'disabled' => 1));
        $vs_output .= "<a href='#' class='button' onclick='jQuery(\"#remapToID\").val(\"\"); jQuery(\"#remapTo\").val(\"\"); jQuery(\"#caReferenceHandlingClear\").css(\"display\", \"none\"); return false;' style='display: none;' id='caReferenceHandlingClear'>" . _t('Clear') . '</a>';
        $vs_output .= caHTMLHiddenInput('remapToID', array('value' => '', 'id' => 'remapToID'));
        $vs_output .= "<script type='text/javascript'>";
        $va_service_info = caJSONLookupServiceUrl($po_request, $t_instance->tableName(), array('noSymbols' => 1, 'noInline' => 1, 'exclude' => (int) $t_instance->getPrimaryKey(), 'table_num' => (int) $t_instance->get('table_num')));
        $vs_output .= "jQuery(document).ready(function() {";
        $vs_output .= "jQuery('#remapTo').autocomplete(\n\t\t\t\t\t{\n\t\t\t\t\t\tsource: '" . $va_service_info['search'] . "', html: true,\n\t\t\t\t\t\tminLength: 3, delay: 800,\n\t\t\t\t\t\tselect: function(event, ui) {\n\t\t\t\t\t\t\tjQuery('#remapToID').val(ui.item.id);\n\t\t\t\t\t\t\tjQuery('#caReferenceHandlingClear').css('display', 'inline');\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t);";
        $vs_output .= "jQuery('#caReferenceHandlingRemap').click(function() {\n\t\t\t\tjQuery('#remapTo').attr('disabled', false);\n\t\t\t});\n\t\t\tjQuery('#caReferenceHandlingDelete').click(function() {\n\t\t\t\tjQuery('#remapTo').attr('disabled', true);\n\t\t\t});\n\t\t\t";
        $vs_output .= "});";
        $vs_output .= "</script>\n";
        TooltipManager::add('#caDeleteReferenceCount', "<h2>" . _t('References to this %1', $t_instance->getProperty('NAME_SINGULAR')) . "</h2>\n" . join("\n", $va_buf));
    }
    return $vs_output;
}
Пример #17
0
 *
 * ----------------------------------------------------------------------
 */
JavascriptLoadManager::register('hierBrowser');
JavascriptLoadManager::register('tabUI');
$t_subject = $this->getVar('t_subject');
$vs_subject_label = $t_subject->getLabelForDisplay();
if (($vs_priv_table = $t_subject->tableName()) == 'ca_list_items') {
    $vs_priv_table = 'ca_lists';
}
// actions happen to be on names for ca_lists for ca_list_items
$pn_parent_id = $this->getVar('parent_id');
$pa_ancestors = $this->getVar('ancestors');
$pn_id = $this->getVar('id');
$ps_id_prefix = $this->getVar('placement_code') . $this->getVar('id_prefix') . 'HierLocation';
$va_lookup_urls = caJSONLookupServiceUrl($this->request, $t_subject->tableName());
$vb_strict_type_hierarchy = (bool) $this->request->config->get($t_subject->tableName() . '_enforce_strict_type_hierarchy');
$vs_type_selector = trim($t_subject->getTypeListAsHTMLFormElement("{$ps_id_prefix}type_id", array('id' => "{$ps_id_prefix}typeList"), array('childrenOfCurrentTypeOnly' => $vb_strict_type_hierarchy, 'includeSelf' => !$vb_strict_type_hierarchy, 'directChildrenOnly' => $vb_strict_type_hierarchy)));
$pa_bundle_settings = $this->getVar('settings');
$vb_read_only = isset($pa_bundle_settings['readonly']) && $pa_bundle_settings['readonly'] || $this->request->user->getBundleAccessLevel($t_subject->tableName(), 'hierarchy_location') == __CA_BUNDLE_ACCESS_READONLY__;
$va_errors = array();
if (is_array($va_action_errors = $this->request->getActionErrors('hierarchy_location'))) {
    foreach ($va_action_errors as $o_error) {
        $va_errors[] = $o_error->getErrorDescription();
    }
}
?>
	
<script type="text/javascript">
	//
	// Handle browse header scrolling