/** * Generates standard-format inspector panels for editors * * @param View $po_view Inspector view object * @param array $pa_options Optional array of options. Supported options are: * backText = a string to use as the "back" button text; default is "Results" * * @return string HTML implementing the inspector */ function caEditorInspector($po_view, $pa_options = null) { require_once __CA_MODELS_DIR__ . '/ca_sets.php'; require_once __CA_MODELS_DIR__ . '/ca_data_exporters.php'; $t_item = $po_view->getVar('t_item'); $vs_table_name = $t_item->tableName(); if (($vs_priv_table_name = $vs_table_name) == 'ca_list_items') { $vs_priv_table_name = 'ca_lists'; } $vn_item_id = $t_item->getPrimaryKey(); $o_result_context = $po_view->getVar('result_context'); $t_ui = $po_view->getVar('t_ui'); $t_type = method_exists($t_item, "getTypeInstance") ? $t_item->getTypeInstance() : null; $vs_type_name = method_exists($t_item, "getTypeName") ? $t_item->getTypeName() : ''; if (!$vs_type_name) { $vs_type_name = $t_item->getProperty('NAME_SINGULAR'); } $va_reps = $po_view->getVar('representations'); $o_dm = Datamodel::load(); if ($t_item->isHierarchical()) { $va_ancestors = $po_view->getVar('ancestors'); $vn_parent_id = $t_item->get($t_item->getProperty('HIERARCHY_PARENT_ID_FLD')); } else { $va_ancestors = array(); $vn_parent_id = null; } // action extra to preserve currently open screen across next/previous links $vs_screen_extra = $po_view->getVar('screen') ? '/' . $po_view->getVar('screen') : ''; if ($vs_type_name == "list item") { $vs_style = "style='height:auto;'"; } if ($vn_item_id | $po_view->request->getAction() === 'Delete') { $vs_buf = '<h3 class="nextPrevious" ' . $vs_style . '>' . caEditorFindResultNavigation($po_view->request, $t_item, $o_result_context, $pa_options) . "</h3>\n"; } $vs_color = null; if ($t_type) { $vs_color = trim($t_type->get('color')); } if (!$vs_color && $t_ui) { $vs_color = trim($t_ui->get('color')); } if (!$vs_color) { $vs_color = "FFFFFF"; } $vs_buf .= "<h4><div id='caColorbox' style='border: 6px solid #{$vs_color};'>\n"; $vs_icon = null; if ($t_type) { $vs_icon = $t_type->getMediaTag('icon', 'icon'); } if (!$vs_icon && $t_ui) { $vs_icon = $t_ui->getMediaTag('icon', 'icon'); } if ($vs_icon) { $vs_buf .= "<div id='inspectoricon' style='border-right: 6px solid #{$vs_color}; border-bottom: 6px solid #{$vs_color}; -moz-border-radius-bottomright: 8px; -webkit-border-bottom-right-radius: 8px;'>\n{$vs_icon}</div>\n"; } if ($po_view->request->getAction() === 'Delete' && $po_view->request->getParameter('confirm', pInteger)) { $vs_buf .= "<strong>" . _t("Deleted %1", $vs_type_name) . "</strong>\n"; $vs_buf .= "<br style='clear: both;'/></div></h4>\n"; } else { if ($vn_item_id) { if (!$po_view->request->config->get("{$vs_priv_table_name}_inspector_disable_headline")) { if ($po_view->request->user->canDoAction("can_edit_" . $vs_priv_table_name) && sizeof($t_item->getTypeList()) > 1) { $vs_buf .= "<strong>" . _t("Editing %1", $vs_type_name) . ": </strong>\n"; } else { $vs_buf .= "<strong>" . _t("Viewing %1", $vs_type_name) . ": </strong>\n"; } } if ($t_item->hasField('is_deaccessioned') && $t_item->get('is_deaccessioned') && $t_item->get('deaccession_date', array('getDirectDate' => true)) <= caDateToHistoricTimestamp(_t('now'))) { // If currently deaccessioned then display deaccession message $vs_buf .= "<br/><div class='inspectorDeaccessioned'>" . _t('Deaccessioned %1', $t_item->get('deaccession_date')) . "</div>\n"; if ($vs_deaccession_notes = $t_item->get('deaccession_notes')) { TooltipManager::add(".inspectorDeaccessioned", $vs_deaccession_notes); } } else { if ($po_view->request->user->canDoAction('can_see_current_location_in_inspector_ca_objects')) { if ($t_ui && method_exists($t_item, "getObjectHistory") && (is_array($va_placements = $t_ui->getPlacementsForBundle('ca_objects_history')) && sizeof($va_placements) > 0)) { // // Output current "location" of object in life cycle. Configuration is taken from a ca_objects_history bundle configured for the current editor // $va_placement = array_shift($va_placements); $va_bundle_settings = $va_placement['settings']; if (is_array($va_history = $t_item->getObjectHistory($va_bundle_settings, array('limit' => 1, 'currentOnly' => true))) && sizeof($va_history) > 0) { $va_current_location = array_shift(array_shift($va_history)); if (!($vs_inspector_current_location_label = $po_view->request->config->get("ca_objects_inspector_current_location_label"))) { $vs_inspector_current_location_label = _t('Current'); } if ($va_current_location['display']) { $vs_buf .= "<div class='inspectorCurrentLocation'><strong>" . $vs_inspector_current_location_label . ':</strong><br/>' . $va_current_location['display'] . "</div>"; } } } elseif (method_exists($t_item, "getLastLocationForDisplay")) { // If no ca_objects_history bundle is configured then display the last storage location if ($vs_current_location = $t_item->getLastLocationForDisplay("<ifdef code='ca_storage_locations.parent.preferred_labels'>^ca_storage_locations.parent.preferred_labels ➜ </ifdef>^ca_storage_locations.preferred_labels.name")) { $vs_buf .= "<br/><div class='inspectorCurrentLocation'>" . _t('Location: %1', $vs_current_location) . "</div>\n"; $vs_full_location_hierarchy = $t_item->getLastLocationForDisplay("^ca_storage_locations.hierarchy.preferred_labels.name%delimiter=_➜_"); if ($vs_full_location_hierarchy !== $vs_current_location) { TooltipManager::add(".inspectorCurrentLocation", $vs_full_location_hierarchy); } } } } } // // Display flags; expressions for these are defined in app.conf in the <table_name>_inspector_display_flags directive // if (is_array($va_display_flags = $po_view->request->config->getAssoc("{$vs_table_name}_inspector_display_flags"))) { $va_display_flag_buf = array(); foreach ($va_display_flags as $vs_exp => $vs_display_flag) { $va_exp_vars = array(); foreach (ExpressionParser::getVariableList($vs_exp) as $vs_var_name) { $va_exp_vars[$vs_var_name] = $t_item->get($vs_var_name, array('returnIdno' => true)); } if (ExpressionParser::evaluate($vs_exp, $va_exp_vars)) { $va_display_flag_buf[] = $t_item->getWithTemplate("{$vs_display_flag}"); } } if (sizeof($va_display_flag_buf) > 0) { $vs_buf .= join("; ", $va_display_flag_buf); } } $vs_label = ''; $vb_dont_use_labels_for_ca_objects = (bool) $t_item->getAppConfig()->get('ca_objects_dont_use_labels'); if (!($vs_table_name === 'ca_objects' && $vb_dont_use_labels_for_ca_objects)) { if ($vs_get_spec = $po_view->request->config->get("{$vs_table_name}_inspector_display_title")) { $vs_label = caProcessTemplateForIDs($vs_get_spec, $vs_table_name, array($t_item->getPrimaryKey())); } else { $va_object_collection_collection_ancestors = $po_view->getVar('object_collection_collection_ancestors'); if ($t_item->tableName() == 'ca_objects' && $t_item->getAppConfig()->get('ca_objects_x_collections_hierarchy_enabled') && is_array($va_object_collection_collection_ancestors) && sizeof($va_object_collection_collection_ancestors)) { $va_collection_links = array(); foreach ($va_object_collection_collection_ancestors as $va_collection_ancestor) { $va_collection_links[] = caEditorLink($po_view->request, $va_collection_ancestor['label'], '', 'ca_collections', $va_collection_ancestor['collection_id']); } $vs_label .= join(" / ", $va_collection_links) . ' > '; } if (method_exists($t_item, 'getLabelForDisplay')) { $vn_parent_index = sizeof($va_ancestors) - 1; if ($vn_parent_id && ($vs_table_name != 'ca_places' || $vn_parent_index > 0)) { $va_parent = $va_ancestors[$vn_parent_index]; $vs_disp_fld = $t_item->getLabelDisplayField(); if ($va_parent['NODE'][$vs_disp_fld] && ($vs_editor_link = caEditorLink($po_view->request, $va_parent['NODE'][$vs_disp_fld], '', $vs_table_name, $va_parent['NODE'][$t_item->primaryKey()]))) { $vs_label .= $vs_editor_link . ' > ' . $t_item->getLabelForDisplay(); } else { $vs_label .= ($va_parent['NODE'][$vs_disp_fld] ? $va_parent['NODE'][$vs_disp_fld] . ' > ' : '') . $t_item->getLabelForDisplay(); } } else { $vs_label .= $t_item->getLabelForDisplay(); if ($vs_table_name === 'ca_editor_uis' && in_array($po_view->request->getAction(), array('EditScreen', 'DeleteScreen', 'SaveScreen'))) { $t_screen = new ca_editor_ui_screens($po_view->request->getParameter('screen_id', pInteger)); if (!($vs_screen_name = $t_screen->getLabelForDisplay())) { $vs_screen_name = _t('new screen'); } $vs_label .= " > " . $vs_screen_name; } } } else { $vs_label .= $t_item->get('name'); } } } $vb_show_idno = (bool) ($vs_idno = $t_item->get($t_item->getProperty('ID_NUMBERING_ID_FIELD'))); if (!$vs_label) { switch ($vs_table_name) { case 'ca_commerce_orders': if ($t_item->get('order_type') == 'L') { if ($vs_org = $t_item->get('billing_organization')) { $vs_label = _t('%5 #%4 on %1 to %2 (%3)', caGetLocalizedDate($t_item->get('created_on', array('getDirectDate' => true)), array('dateFormat' => 'delimited', 'timeOmit' => true)), $t_item->get('billing_fname') . ' ' . $t_item->get('billing_lname'), $vs_org, $t_item->getOrderNumber(), caUcFirstUTF8Safe($t_item->getProperty('NAME_SINGULAR'))); } else { $vs_label = _t('%4 #%3 on %1 to %2', caGetLocalizedDate($t_item->get('created_on', array('getDirectDate' => true)), array('dateFormat' => 'delimited', 'timeOmit' => true)), $t_item->get('billing_fname') . ' ' . $t_item->get('billing_lname'), $t_item->getOrderNumber(), caUcFirstUTF8Safe($t_item->getProperty('NAME_SINGULAR'))); } } else { if ($vs_org = $t_item->get('billing_organization')) { $vs_label = _t('%5 #%4 on %1 from %2 (%3)', caGetLocalizedDate($t_item->get('created_on', array('getDirectDate' => true)), array('dateFormat' => 'delimited', 'timeOmit' => true)), $t_item->get('billing_fname') . ' ' . $t_item->get('billing_lname'), $vs_org, $t_item->getOrderNumber(), caUcFirstUTF8Safe($t_item->getProperty('NAME_SINGULAR'))); } else { $vs_label = _t('%4 #%3 on %1 from %2', caGetLocalizedDate($t_item->get('created_on', array('getDirectDate' => true)), array('dateFormat' => 'delimited', 'timeOmit' => true)), $t_item->get('billing_fname') . ' ' . $t_item->get('billing_lname'), $t_item->getOrderNumber(), caUcFirstUTF8Safe($t_item->getProperty('NAME_SINGULAR'))); } } break; default: if ($vs_table_name === 'ca_objects' && $vb_dont_use_labels_for_ca_objects) { $vs_label = $vs_idno; $vb_show_idno = false; } else { $vs_label = '[' . _t('BLANK') . ']'; } break; } } $vs_buf .= "<div class='recordTitle {$vs_table_name}' style='width:190px; overflow:hidden;'>{$vs_label}" . ($vb_show_idno ? "<a title='{$vs_idno}'>" . ($vs_idno ? " ({$vs_idno})" : '') : "") . "</a></div>"; if ($vs_table_name === 'ca_object_lots' && $t_item->getPrimaryKey()) { $vs_buf .= "<div id='inspectorLotMediaDownload'><strong>" . (($vn_num_objects = $t_item->numObjects()) == 1 ? _t('Lot contains %1 object', $vn_num_objects) : _t('Lot contains %1 objects', $vn_num_objects)) . "</strong>\n"; } if ($po_view->request->config->get("include_custom_inspector")) { if (file_exists($po_view->request->getViewsDirectoryPath() . "/bundles/inspector_info.php")) { $vo_inspector_view = new View($po_view->request, $po_view->request->getViewsDirectoryPath() . "/bundles/"); $vo_inspector_view->setVar('t_item', $t_item); $vs_buf .= $vo_inspector_view->render('inspector_info.php'); } } } else { $vs_parent_name = ''; if ($vn_parent_id = $po_view->request->getParameter('parent_id', pInteger)) { $t_parent = clone $t_item; $t_parent->load($vn_parent_id); $vs_parent_name = $t_parent->getLabelForDisplay(); } $vs_buf .= "<div class='creatingNew'>" . _t("Creating new %1", $vs_type_name) . " " . ($vs_parent_name ? _t("%1 > New %2", $vs_parent_name, $vs_type_name) : '') . "</div>\n"; $vs_buf .= "<br/>\n"; } // ------------------------------------------------------------------------------------- if ($t_item->getPrimaryKey()) { if (sizeof($va_reps) > 0) { $va_imgs = array(); $vs_buf .= "<div id='inspectorMedia'>"; $vn_r = $vn_primary_index = 0; foreach ($va_reps as $va_rep) { if (!($va_rep['info']['preview170']['WIDTH'] && $va_rep['info']['preview170']['HEIGHT'])) { continue; } if ($vb_is_primary = isset($va_rep['is_primary']) && (bool) $va_rep['is_primary']) { $vn_primary_index = $vn_r; } $va_imgs[] = "{url:'" . $va_rep['urls']['preview170'] . "', width: " . $va_rep['info']['preview170']['WIDTH'] . ", height: " . $va_rep['info']['preview170']['HEIGHT'] . ", link: '#', onclick: 'caMediaPanel.showPanel(\\'" . caNavUrl($po_view->request, '*', '*', 'GetMediaOverlay', array($t_item->primaryKey() => $vn_item_id, 'representation_id' => $va_rep['representation_id'])) . "\\')'}"; $vn_r++; } if (sizeof($va_reps) > 1) { $vs_buf .= "\n\t\t\t\t\t<div class='leftScroll'>\n\t\t\t\t\t\t<a href='#' onclick='inspectorInfoRepScroller.scrollToPreviousImage(); return false;'>" . caNavIcon($po_view->request, __CA_NAV_BUTTON_SCROLL_LT__) . "</a>\n\t\t\t\t\t</div>\n\t\t"; } if (sizeof($va_imgs) > 0) { $vs_buf .= "\n\t\t\t\t<div id='inspectorInfoRepScrollingViewer' style='position: relative;'>\n\t\t\t\t\t<div id='inspectorInfoRepScrollingViewerContainer'>\n\t\t\t\t\t\t<div id='inspectorInfoRepScrollingViewerImageContainer'></div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t"; if (sizeof($va_reps) > 1) { $vs_buf .= "\n\t\t\t\t\t<div class='rightScroll'>\n\t\t\t\t\t\t<a href='#' onclick='inspectorInfoRepScroller.scrollToNextImage(); return false;'>" . caNavIcon($po_view->request, __CA_NAV_BUTTON_SCROLL_RT__) . "</a>\n\t\t\t\t\t</div>\n\t\t"; } TooltipManager::add(".leftScroll", _t('Previous')); TooltipManager::add(".rightScroll", _t('Next')); $vs_buf .= "<script type='text/javascript'>"; $vs_buf .= "\n\t\t\t\t\tvar inspectorInfoRepScroller = caUI.initImageScroller([" . join(",", $va_imgs) . "], 'inspectorInfoRepScrollingViewerImageContainer', {\n\t\t\t\t\t\t\tcontainerWidth: 170, containerHeight: 170,\n\t\t\t\t\t\t\timageCounterID: 'inspectorInfoRepScrollingViewerCounter',\n\t\t\t\t\t\t\tscrollingImageClass: 'inspectorInfoRepScrollerImage',\n\t\t\t\t\t\t\tscrollingImagePrefixID: 'inspectorInfoRep',\n\t\t\t\t\t\t\tinitialIndex: {$vn_primary_index}\n\t\t\t\t\t\t\t\n\t\t\t\t\t});\n\t\t\t\t</script>"; } $vs_buf .= "</div>\n"; if ($vs_get_spec = $po_view->request->config->get("{$vs_table_name}_inspector_display_below_media")) { $vs_buf .= caProcessTemplateForIDs($vs_get_spec, $vs_table_name, array($t_item->getPrimaryKey())); } } $vs_buf .= "<div id='toolIcons'>"; if ($vn_item_id) { # --- watch this link $vs_watch = ""; if (in_array($vs_table_name, array('ca_objects', 'ca_object_lots', 'ca_entities', 'ca_places', 'ca_occurrences', 'ca_collections', 'ca_storage_locations'))) { require_once __CA_MODELS_DIR__ . '/ca_watch_list.php'; $t_watch_list = new ca_watch_list(); $vs_watch = "<div class='watchThis'><a href='#' title='" . _t('Add/remove item to/from watch list.') . "' onclick='caToggleItemWatch(); return false;' id='caWatchItemButton'>" . caNavIcon($po_view->request, $t_watch_list->isItemWatched($vn_item_id, $t_item->tableNum(), $po_view->request->user->get("user_id")) ? __CA_NAV_BUTTON_UNWATCH__ : __CA_NAV_BUTTON_WATCH__) . "</a></div>"; $vs_buf .= "\n<script type='text/javascript'>\n\t\tfunction caToggleItemWatch() {\n\t\t\tvar url = '" . caNavUrl($po_view->request, $po_view->request->getModulePath(), $po_view->request->getController(), 'toggleWatch', array($t_item->primaryKey() => $vn_item_id)) . "';\n\t\t\t\n\t\t\tjQuery.getJSON(url, {}, function(data, status) {\n\t\t\t\tif (data['status'] == 'ok') {\n\t\t\t\t\tjQuery('#caWatchItemButton').html((data['state'] == 'watched') ? '" . addslashes(caNavIcon($po_view->request, __CA_NAV_BUTTON_UNWATCH__)) . "' : '" . addslashes(caNavIcon($po_view->request, __CA_NAV_BUTTON_WATCH__)) . "');\n\t\t\t\t} else {\n\t\t\t\t\tconsole.log('Error toggling watch status for item: ' + data['errors']);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\t</script>\n"; } $vs_buf .= "{$vs_watch}\n"; TooltipManager::add("#caWatchItemButton", _t('Watch/Unwatch this record')); if ($po_view->request->user->canDoAction("can_change_type_{$vs_table_name}")) { $vs_buf .= "<div id='inspectorChangeType'><div id='inspectorChangeTypeButton'><a href='#' onclick='caTypeChangePanel.showPanel(); return false;'>" . caNavIcon($po_view->request, __CA_NAV_BUTTON_CHANGE__ . " Change Type", array('title' => _t('Change type'))) . "</a></div></div>\n"; $vo_change_type_view = new View($po_view->request, $po_view->request->getViewsDirectoryPath() . "/bundles/"); $vo_change_type_view->setVar('t_item', $t_item); FooterManager::add($vo_change_type_view->render("change_type_html.php")); TooltipManager::add("#inspectorChangeType", _t('Change Record Type')); } if ($t_item->getPrimaryKey() && $po_view->request->config->get($vs_table_name . '_show_add_child_control_in_inspector')) { $vb_show_add_child_control = true; if (is_array($va_restrict_add_child_control_to_types = $po_view->request->config->getList($vs_table_name . '_restrict_child_control_in_inspector_to_types')) && sizeof($va_restrict_add_child_control_to_types)) { $t_type_instance = $t_item->getTypeInstance(); if (!in_array($t_type_instance->get('idno'), $va_restrict_add_child_control_to_types) && !in_array($t_type_instance->getPrimaryKey(), $va_restrict_add_child_control_to_types)) { $vb_show_add_child_control = false; } } if ($vb_show_add_child_control) { if ((bool) $po_view->request->config->get($vs_table_name . '_enforce_strict_type_hierarchy')) { // strict menu $vs_type_list = $t_item->getTypeListAsHTMLFormElement('type_id', array('style' => 'width: 90px; font-size: 9px;'), array('childrenOfCurrentTypeOnly' => true, 'directChildrenOnly' => $po_view->request->config->get($vs_table_name . '_enforce_strict_type_hierarchy') == '~' ? false : true, 'returnHierarchyLevels' => true, 'access' => __CA_BUNDLE_ACCESS_EDIT__)); } else { // all types $vs_type_list = $t_item->getTypeListAsHTMLFormElement('type_id', array('style' => 'width: 90px; font-size: 9px;'), array('access' => __CA_BUNDLE_ACCESS_EDIT__)); } if ($vs_type_list) { $vs_buf .= "<div id='inspectorCreateChild'><div id='inspectorCreateChildButton'><a href='#' onclick='caCreateChildPanel.showPanel(); return false;'>" . caNavIcon($po_view->request, __CA_NAV_BUTTON_CHILD__, array('title' => _t('Create Child Record'))) . "</a></div></div>\n"; $vo_create_child_view = new View($po_view->request, $po_view->request->getViewsDirectoryPath() . "/bundles/"); $vo_create_child_view->setVar('t_item', $t_item); $vo_create_child_view->setVar('type_list', $vs_type_list); FooterManager::add($vo_create_child_view->render("create_child_html.php")); TooltipManager::add("#inspectorCreateChildButton", _t('Create a child record under this one')); } } } } if ($po_view->request->user->canDoAction('can_duplicate_' . $vs_table_name) && $t_item->getPrimaryKey()) { $vs_buf .= '<div id="caDuplicateItemButton">'; $vs_buf .= caFormTag($po_view->request, 'Edit', 'DuplicateItemForm', $po_view->request->getModulePath() . '/' . $po_view->request->getController(), 'post', 'multipart/form-data', '_top', array('disableUnsavedChangesWarning' => true, 'noTimestamp' => true)); $vs_buf .= caFormSubmitLink($po_view->request, caNavIcon($po_view->request, __CA_NAV_BUTTON_DUPLICATE__), '', 'DuplicateItemForm'); $vs_buf .= caHTMLHiddenInput($t_item->primaryKey(), array('value' => $t_item->getPrimaryKey())); $vs_buf .= caHTMLHiddenInput('mode', array('value' => 'dupe')); $vs_buf .= "</form>"; $vs_buf .= "</div>"; TooltipManager::add("#caDuplicateItemButton", _t('Duplicate this %1', mb_strtolower($vs_type_name, 'UTF-8'))); } // // Download media in lot ($vn_num_objects is only set for object lots) if ($vn_num_objects > 0) { $vs_buf .= "<div id='inspectorLotMediaDownloadButton'>" . caNavLink($po_view->request, caNavIcon($po_view->request, __CA_NAV_BUTTON_DOWNLOAD__), "button", $po_view->request->getModulePath(), $po_view->request->getController(), 'getLotMedia', array('lot_id' => $t_item->getPrimaryKey(), 'download' => 1), array()) . "</div>\n"; TooltipManager::add('#inspectorLotMediaDownloadButton', _t("Download all media associated with objects in this lot")); } // // Download media in set if ($vs_table_name == 'ca_sets' && sizeof($t_item->getItemRowIDs()) > 0) { $vs_buf .= "<div id='inspectorSetMediaDownloadButton'>" . caNavLink($po_view->request, caNavIcon($po_view->request, __CA_NAV_BUTTON_DOWNLOAD__), "button", $po_view->request->getModulePath(), $po_view->request->getController(), 'getSetMedia', array('set_id' => $t_item->getPrimaryKey(), 'download' => 1), array()) . "</div>\n"; TooltipManager::add('#inspectorSetMediaDownloadButton', _t("Download all media associated with records in this set")); } $vs_more_info = ''; // list of sets in which item is a member $t_set = new ca_sets(); if (is_array($va_sets = caExtractValuesByUserLocale($t_set->getSetsForItem($t_item->tableNum(), $t_item->getPrimaryKey(), array('user_id' => $po_view->request->getUserID(), 'access' => __CA_SET_READ_ACCESS__)))) && sizeof($va_sets)) { $va_links = array(); foreach ($va_sets as $vn_set_id => $va_set) { $va_links[] = "<a href='" . caEditorUrl($po_view->request, 'ca_sets', $vn_set_id) . "'>" . $va_set['name'] . "</a>"; } $vs_more_info .= "<div><strong>" . (sizeof($va_links) == 1 ? _t("In set") : _t("In sets")) . "</strong> " . join(", ", $va_links) . "</div>\n"; } // export options if ($vn_item_id && ($vs_select = $po_view->getVar('available_mappings_as_html_select'))) { $vs_more_info .= "<div class='inspectorExportControls'>" . caFormTag($po_view->request, 'exportItem', 'caExportForm', null, 'post', 'multipart/form-data', '_top', array('disableUnsavedChangesWarning' => true)); $vs_more_info .= $vs_select; $vs_more_info .= caHTMLHiddenInput($t_item->primaryKey(), array('value' => $t_item->getPrimaryKey())); $vs_more_info .= caHTMLHiddenInput('download', array('value' => 1)); $vs_more_info .= caFormSubmitLink($po_view->request, 'Export ›', 'button', 'caExportForm'); $vs_more_info .= "</form></div>"; } $va_creation = $t_item->getCreationTimestamp(); $va_last_change = $t_item->getLastChangeTimestamp(); if ($va_creation['timestamp'] || $va_last_change['timestamp']) { $vs_more_info .= "<div class='inspectorChangeDateList'>"; if ($va_creation['timestamp']) { if (!trim($vs_name = $va_creation['fname'] . ' ' . $va_creation['lname'])) { $vs_name = null; } $vs_interval = ($vn_t = time() - $va_creation['timestamp']) == 0 ? _t('Just now') : _t('%1 ago', caFormatInterval($vn_t, 2)); $vs_more_info .= "<div class='inspectorChangeDateListLine' id='caInspectorCreationDate'>" . ($vs_name ? _t('<strong>Created</strong><br/>%1 by %2', $vs_interval, $vs_name) : _t('<strong>Created</strong><br/>%1', $vs_interval)) . "</div>"; TooltipManager::add("#caInspectorCreationDate", "<h2>" . _t('Created on') . "</h2>" . _t('Created on %1', caGetLocalizedDate($va_creation['timestamp'], array('dateFormat' => 'delimited')))); } if ($va_last_change['timestamp'] && $va_creation['timestamp'] != $va_last_change['timestamp']) { if (!trim($vs_name = $va_last_change['fname'] . ' ' . $va_last_change['lname'])) { $vs_name = null; } $vs_interval = ($vn_t = time() - $va_last_change['timestamp']) == 0 ? _t('Just now') : _t('%1 ago', caFormatInterval($vn_t, 2)); $vs_more_info .= "<div class='inspectorChangeDateListLine' id='caInspectorChangeDate'>" . ($vs_name ? _t('<strong>Last changed</strong><br/>%1 by %2', $vs_interval, $vs_name) : _t('<strong>Last changed</strong><br/>%1', $vs_interval)) . "</div>"; TooltipManager::add("#caInspectorChangeDate", "<h2>" . _t('Last changed on') . "</h2>" . _t('Last changed on %1', caGetLocalizedDate($va_last_change['timestamp'], array('dateFormat' => 'delimited')))); } if (method_exists($t_item, 'getMetadataDictionaryRuleViolations') && is_array($va_violations = $t_item->getMetadataDictionaryRuleViolations()) && ($vn_num_violations = sizeof($va_violations)) > 0) { $va_violation_messages = array(); foreach ($va_violations as $vn_violation_id => $va_violation) { $vs_label = $t_item->getDisplayLabel($va_violation['bundle_name']); $va_violation_messages[] = "<li><em><u>{$vs_label}</u></em> " . $va_violation['violationMessage'] . "</li>"; } $vs_more_info .= "<div id='caInspectorViolationsList'>" . ($vs_num_violations_display = "<img src='" . $po_view->request->getThemeUrlPath() . "/graphics/icons/warning_small.gif' border='0'/> " . ($vn_num_violations > 1 ? _t('%1 problems require attention', $vn_num_violations) : _t('%1 problem requires attention', $vn_num_violations))) . "</div>\n"; TooltipManager::add("#caInspectorViolationsList", "<h2>{$vs_num_violations_display}</h2><ol>" . join("\n", $va_violation_messages)) . "</ol>\n"; } $vs_more_info .= "</div>\n"; } if ($vs_get_spec = $po_view->request->config->get("{$vs_table_name}_inspector_display_more_info")) { $vs_more_info .= caProcessTemplateForIDs($vs_get_spec, $vs_table_name, array($t_item->getPrimaryKey())); } if ($vs_more_info) { $vs_buf .= "<div class='button info'><a href='#' id='inspectorMoreInfo'>" . caNavIcon($po_view->request, __CA_NAV_BUTTON_INFO2__) . "</a></div>\n\t\t\t<div id='inspectorInfo' >"; $vs_buf .= $vs_more_info . "</div>\n"; TooltipManager::add("#inspectorMoreInfo", _t('See more information about this record')); } $vs_buf .= "</div><!--End tooIcons-->"; } // ------------------------------------------------------------------------------------- // // Item-specific information // // // Output info for related items // if (!$t_item->getPrimaryKey()) { // only applies to new records $vs_rel_table = $po_view->request->getParameter('rel_table', pString); $vn_rel_type_id = $po_view->request->getParameter('rel_type_id', pString); $vn_rel_id = $po_view->request->getParameter('rel_id', pInteger); if ($vs_rel_table && $po_view->request->datamodel->tableExists($vs_rel_table) && $vn_rel_type_id && $vn_rel_id) { $t_rel = $po_view->request->datamodel->getTableInstance($vs_rel_table); if ($t_rel && $t_rel->load($vn_rel_id)) { $vs_buf .= '<strong>' . _t("Will be related to %1", $t_rel->getTypeName()) . '</strong>: ' . $t_rel->getLabelForDisplay(); } } } // // Output lot info for ca_objects // $vb_is_currently_part_of_lot = true; if (!($vn_lot_id = $t_item->get('lot_id'))) { $vn_lot_id = $po_view->request->getParameter('lot_id', pInteger); $vb_is_currently_part_of_lot = false; } if ($vs_table_name === 'ca_objects' && $vn_lot_id) { require_once __CA_MODELS_DIR__ . '/ca_object_lots.php'; $va_lot_lots = caGetTypeListForUser('ca_object_lots', array('access' => __CA_BUNDLE_ACCESS_READONLY__)); $t_lot = new ca_object_lots($vn_lot_id); if ($t_lot->get('deleted') == 0 && in_array($t_lot->get('type_id'), $va_lot_lots)) { if (!($vs_lot_displayname = $t_lot->get('idno_stub'))) { if (!($vs_lot_displayname = $t_lot->getLabelForDisplay())) { $vs_lot_displayname = "Lot {$vn_lot_id}"; } } if ($vs_lot_displayname) { if (!($vs_part_of_lot_msg = $po_view->request->config->get("ca_objects_inspector_part_of_lot_msg"))) { $vs_part_of_lot_msg = _t('Part of lot'); } if (!($vs_will_be_part_of_lot_msg = $po_view->request->config->get("ca_objects_inspector_will_be_part_of_lot_msg"))) { $vs_will_be_part_of_lot_msg = _t('Will be part of lot'); } $vs_buf .= "<strong>" . ($vb_is_currently_part_of_lot ? $vs_part_of_lot_msg : $vs_will_be_part_of_lot_msg) . "</strong>: " . caNavLink($po_view->request, $vs_lot_displayname, '', 'editor/object_lots', 'ObjectLotEditor', 'Edit', array('lot_id' => $vn_lot_id)); } } } $va_object_container_types = $po_view->request->config->getList('ca_objects_container_types'); $va_object_component_types = $po_view->request->config->getList('ca_objects_component_types'); $vb_can_add_component = $vs_table_name === 'ca_objects' && $t_item->getPrimaryKey() && $po_view->request->user->canDoAction('can_create_ca_objects') && $t_item->canTakeComponents(); if (method_exists($t_item, 'getComponentCount')) { if ($vn_component_count = $t_item->getComponentCount()) { if ($t_ui && ($vs_component_list_screen = $t_ui->getScreenWithBundle("ca_objects_components_list", $po_view->request)) && $vs_component_list_screen !== $po_view->request->getActionExtra()) { $vs_component_count_link = caNavLink($po_view->request, $vn_component_count == 1 ? _t('%1 component', $vn_component_count) : _t('%1 components', $vn_component_count), '', '*', '*', $po_view->request->getAction() . '/' . $vs_component_list_screen, array($t_item->primaryKey() => $t_item->getPrimaryKey())); } else { $vs_component_count_link = $vn_component_count == 1 ? _t('%1 component', $vn_component_count) : _t('%1 components', $vn_component_count); } $vs_buf .= "<br/><strong>" . _t('Has') . ":</strong> {$vs_component_count_link}"; } } if ($vb_can_add_component) { $vs_buf .= ' <a href="#" onclick=\'caObjectComponentPanel.showPanel("' . caNavUrl($po_view->request, '*', 'ObjectComponent', 'Form', array('parent_id' => $t_item->getPrimaryKey())) . '"); return false;\')>' . caNavIcon($po_view->request, __CA_NAV_BUTTON_ADD__) . '</a>'; $vo_change_type_view = new View($po_view->request, $po_view->request->getViewsDirectoryPath() . "/bundles/"); $vo_change_type_view->setVar('t_item', $t_item); FooterManager::add($vo_change_type_view->render("create_component_html.php")); } // // Output lot info for ca_object_lots // if ($vs_table_name === 'ca_object_lots' && $t_item->getPrimaryKey()) { $va_component_types = $po_view->request->config->getList('ca_objects_component_types'); if (is_array($va_component_types) && sizeof($va_component_types)) { $vs_buf .= "<strong>" . (($vn_num_objects = $t_item->numObjects(null, array('return' => 'objects'))) == 1 ? _t('Lot contains %1 object', $vn_num_objects) : _t('Lot contains %1 objects', $vn_num_objects)) . "</strong>\n"; $vs_buf .= "<strong>" . (($vn_num_components = $t_item->numObjects(null, array('return' => 'components'))) == 1 ? _t('Lot contains %1 component', $vn_num_components) : _t('Lot contains %1 components', $vn_num_components)) . "</strong>\n"; } else { $vs_buf .= "<strong>" . (($vn_num_objects = $t_item->numObjects()) == 1 ? _t('Lot contains %1 object', $vn_num_objects) : _t('Lot contains %1 objects', $vn_num_objects)) . "</strong>\n"; } if ((bool) $po_view->request->config->get('allow_automated_renumbering_of_objects_in_a_lot') && ($va_nonconforming_objects = $t_item->getObjectsWithNonConformingIdnos())) { $vs_buf .= '<br/><br/><em>' . (($vn_c = sizeof($va_nonconforming_objects)) == 1 ? _t('There is %1 object with non-conforming numbering', $vn_c) : _t('There are %1 objects with non-conforming numbering', $vn_c)) . "</em>\n"; $vs_buf .= "<a href='#' onclick='jQuery(\"#inspectorNonConformingNumberList\").toggle(250); return false;'>" . caNavIcon($po_view->request, __CA_NAV_BUTTON_ADD__); $vs_buf .= "<div id='inspectorNonConformingNumberList' class='inspectorNonConformingNumberList'><div class='inspectorNonConformingNumberListScroll'><ol>\n"; foreach ($va_nonconforming_objects as $vn_object_id => $va_object_info) { $vs_buf .= '<li>' . caEditorLink($po_view->request, $va_object_info['idno'], '', 'ca_objects', $vn_object_id) . "</li>\n"; } $vs_buf .= "</ol></div>"; $vs_buf .= caNavLink($po_view->request, _t('Re-number objects') . ' ›', 'button', $po_view->request->getModulePath(), $po_view->request->getController(), 'renumberObjects', array('lot_id' => $t_item->getPrimaryKey())); $vs_buf .= "</div>\n"; } require_once __CA_MODELS_DIR__ . '/ca_objects.php'; $t_object = new ca_objects(); $vs_buf .= "<div class='inspectorLotObjectTypeControls'><form action='#' id='caAddObjectToLotForm'>"; if ((bool) $po_view->request->config->get('ca_objects_enforce_strict_type_hierarchy')) { // strict menu $vs_buf .= _t('Add new %1 to lot', $t_object->getTypeListAsHTMLFormElement('type_id', array('id' => 'caAddObjectToLotForm_type_id'), array('childrenOfCurrentTypeOnly' => true, 'directChildrenOnly' => $po_view->request->config->get('ca_objects_enforce_strict_type_hierarchy') == '~' ? false : true, 'returnHierarchyLevels' => true, 'access' => __CA_BUNDLE_ACCESS_EDIT__))); } else { // all types $vs_buf .= _t('Add new %1 to lot', $t_object->getTypeListAsHTMLFormElement('type_id', array('id' => 'caAddObjectToLotForm_type_id'), array('access' => __CA_BUNDLE_ACCESS_EDIT__))); } $vs_buf .= " <a href='#' onclick='caAddObjectToLotForm()'>" . caNavIcon($po_view->request, __CA_NAV_BUTTON_ADD__) . '</a>'; $vs_buf .= "</form></div>\n"; $vs_buf .= "<script type='text/javascript'>\n\tfunction caAddObjectToLotForm() { \n\t\twindow.location='" . caEditorUrl($po_view->request, 'ca_objects', 0, false, array('lot_id' => $t_item->getPrimaryKey(), 'rel' => 1, 'type_id' => '')) . "' + jQuery('#caAddObjectToLotForm_type_id').val();\n\t}\n\tjQuery(document).ready(function() {\n\t\tjQuery('#objectLotsNonConformingNumberList').hide();\n\t});\n</script>\n"; } if ($vs_table_name === 'ca_objects') { // // Output loan info for ca_objects // if ($po_view->request->user->canDoAction('can_manage_clients') && ($va_loan_details = $t_item->isOnLoan())) { $vs_buf .= "<div>" . caNavLink($po_view->request, _t('On loan to %1', $va_loan_details['billing_fname'] . ' ' . $va_loan_details['billing_lname']), 'inspectorOnLoan', 'client/library', 'OrderEditor', 'Edit', array('order_id' => $va_loan_details['order_id'])) . "</div>"; } // // Output checkout info for ca_objects // if ((bool) $po_view->request->config->get('enable_client_services') && ((bool) $po_view->request->config->get('enable_client_services_sales') || (bool) $po_view->request->config->get('enable_client_services_library')) && $t_item->canBeCheckedOut() && ($va_checkout_status = $t_item->getCheckoutStatus(array('returnAsArray' => true)))) { $vs_buf .= "<div class='inspectorCheckedOut'>" . $va_checkout_status['status_display']; if ($va_checkout_status['user_name']) { $vs_buf .= _t("; checked out by %1", $va_checkout_status['user_name']); } $vs_buf .= "</div>"; } } // // Output related objects for ca_object_representations // if ($vs_table_name === 'ca_object_representations') { foreach (array('ca_objects', 'ca_object_lots', 'ca_entities', 'ca_places', 'ca_occurrences', 'ca_collections', 'ca_storage_locations', 'ca_loans', 'ca_movements') as $vs_rel_table) { if (sizeof($va_objects = $t_item->getRelatedItems($vs_rel_table))) { $vs_buf .= "<div><strong>" . _t("Related %1", $o_dm->getTableProperty($vs_rel_table, 'NAME_PLURAL')) . "</strong>: <br/>\n"; $vs_screen = ''; if ($t_ui = ca_editor_uis::loadDefaultUI($vs_rel_table, $po_view->request, null)) { $vs_screen = $t_ui->getScreenWithBundle('ca_object_representations', $po_view->request); } foreach ($va_objects as $vn_rel_id => $va_rel_info) { if ($vs_label = array_shift($va_rel_info['labels'])) { $vs_buf .= caEditorLink($po_view->request, '← ' . $vs_label . ' (' . $va_rel_info['idno'] . ')', '', $vs_rel_table, $va_rel_info[$o_dm->getTablePrimaryKeyName($vs_rel_table)], array(), array(), array('action' => 'Edit' . ($vs_screen ? "/{$vs_screen}" : ""))) . "<br/>\n"; } } $vs_buf .= "</div>\n"; } } } // // Output related object reprsentation for ca_representation_annotation // if ($vs_table_name === 'ca_representation_annotations') { if ($vn_representation_id = $t_item->get('representation_id')) { $vs_buf .= "<div><strong>" . _t("Applied to representation") . "</strong>: <br/>\n"; $t_rep = new ca_object_representations($vn_representation_id); $vs_buf .= caNavLink($po_view->request, '← ' . $t_rep->getLabelForDisplay(), '', 'editor/object_representations', 'ObjectRepresentationEditor', 'Edit/' . $po_view->getVar('representation_editor_screen'), array('representation_id' => $vn_representation_id)) . '<br/>'; $vs_buf .= "</div>\n"; } } // // Output extra useful info for sets // if ($vs_table_name === 'ca_sets') { $vn_set_item_count = $t_item->getItemCount(array('user_id' => $po_view->request->getUserID())); if ($vn_set_item_count > 0 && $po_view->request->user->canDoAction('can_batch_edit_' . $o_dm->getTableName($t_item->get('table_num')))) { $vs_buf .= caNavButton($po_view->request, __CA_NAV_BUTTON_BATCH_EDIT__, _t('Batch edit'), 'editorBatchSetEditorLink', 'batch', 'Editor', 'Edit', array('set_id' => $t_item->getPrimaryKey()), array(), array('icon_position' => __CA_NAV_BUTTON_ICON_POS_LEFT__, 'no_background' => true, 'dont_show_content' => true)); } $vs_buf .= "<div><strong>" . _t("Number of items") . "</strong>: {$vn_set_item_count}<br/>\n"; if ($t_item->getPrimaryKey()) { $vn_set_table_num = $t_item->get('table_num'); $vs_set_table_name = $o_dm->getTableName($vn_set_table_num); $vs_buf .= "<strong>" . _t("Type of content") . "</strong>: " . caGetTableDisplayName($vn_set_table_num) . "<br/>\n"; $vs_buf .= "</div>\n"; } else { if ($vn_set_table_num = $po_view->request->getParameter('table_num', pInteger)) { $vs_buf .= "<div><strong>" . _t("Type of content") . "</strong>: " . caGetTableDisplayName($vn_set_table_num) . "<br/>\n"; $vs_buf .= "</div>\n"; } } $t_user = new ca_users(($vn_user_id = $t_item->get('user_id')) ? $vn_user_id : $po_view->request->getUserID()); if ($t_user->getPrimaryKey()) { $vs_buf .= "<div><strong>" . _t('Owner') . "</strong>: " . $t_user->get('fname') . ' ' . $t_user->get('lname') . "</div>\n"; } if ($po_view->request->user->canDoAction('can_export_' . $vs_set_table_name) && $t_item->getPrimaryKey() && sizeof(ca_data_exporters::getExporters($vn_set_table_num)) > 0) { $vs_buf .= '<div style="border-top: 1px solid #aaaaaa; margin-top: 5px; font-size: 10px; text-align: right;" id="caExportItemButton">'; $vs_buf .= _t('Export this set of records') . " "; $vs_buf .= "<a class='button' onclick='jQuery(\"#exporterFormList\").show();' style='text-align:right;' href='#'>" . caNavIcon($po_view->request, __CA_NAV_BUTTON_ADD__) . "</a>"; $vs_buf .= caFormTag($po_view->request, 'ExportData', 'caExportForm', 'manage/MetadataExport', 'post', 'multipart/form-data', '_top', array('disableUnsavedChangesWarning' => true)); $vs_buf .= "<div id='exporterFormList'>"; $vs_buf .= ca_data_exporters::getExporterListAsHTMLFormElement('exporter_id', $vn_set_table_num, array('id' => 'caExporterList'), array('width' => '135px')); $vs_buf .= caHTMLHiddenInput('set_id', array('value' => $t_item->getPrimaryKey())); $vs_buf .= caFormSubmitLink($po_view->request, _t('Export') . " ›", "button", "caExportForm"); $vs_buf .= "</div>\n"; $vs_buf .= "</form>"; $vs_buf .= "</div>"; $vs_buf .= "<script type='text/javascript'>"; $vs_buf .= "jQuery(document).ready(function() {"; $vs_buf .= "jQuery(\"#exporterFormList\").hide();"; $vs_buf .= "});"; $vs_buf .= "</script>"; } } // // Output extra useful info for set items // if ($vs_table_name === 'ca_set_items') { AssetLoadManager::register("panel"); $t_set = new ca_sets(); if ($t_set->load($vn_set_id = $t_item->get('set_id'))) { $vs_buf .= "<div><strong>" . _t("Part of set") . "</strong>: " . caEditorLink($po_view->request, $t_set->getLabelForDisplay(), '', 'ca_sets', $vn_set_id) . "<br/>\n"; $t_content_instance = $t_item->getAppDatamodel()->getInstanceByTableNum($vn_item_table_num = $t_item->get('table_num')); if ($t_content_instance->load($vn_row_id = $t_item->get('row_id'))) { $vs_label = $t_content_instance->getLabelForDisplay(); if ($vs_id_fld = $t_content_instance->getProperty('ID_NUMBERING_ID_FIELD')) { $vs_label .= " (" . $t_content_instance->get($vs_id_fld) . ")"; } $vs_buf .= "<strong>" . _t("Is %1", caGetTableDisplayName($vn_item_table_num, false) . "</strong>: " . caEditorLink($po_view->request, $vs_label, '', $vn_item_table_num, $vn_row_id)) . "<br/>\n"; } $vs_buf .= "</div>\n"; } } // // Output extra useful info for lists // if ($vs_table_name === 'ca_lists' && $t_item->getPrimaryKey()) { $vs_buf .= "<strong>" . _t("Number of items") . "</strong>: " . $t_item->numItemsInList() . "<br/>\n"; $t_list_item = new ca_list_items(); $t_list_item->load(array('list_id' => $t_item->getPrimaryKey(), 'parent_id' => null)); $vs_type_list = $t_list_item->getTypeListAsHTMLFormElement('type_id', array('style' => 'width: 90px; font-size: 9px;'), array('access' => __CA_BUNDLE_ACCESS_EDIT__)); if ($vs_type_list) { $vs_buf .= '<div style="border-top: 1px solid #aaaaaa; margin-top: 5px; font-size: 10px;">'; $vs_buf .= caFormTag($po_view->request, 'Edit', 'NewChildForm', 'administrate/setup/list_item_editor/ListItemEditor', 'post', 'multipart/form-data', '_top', array('disableUnsavedChangesWarning' => true)); $vs_buf .= _t('Add a %1 to this list', $vs_type_list) . caHTMLHiddenInput($t_list_item->primaryKey(), array('value' => '0')) . caHTMLHiddenInput('parent_id', array('value' => $t_list_item->getPrimaryKey())); $vs_buf .= caFormSubmitLink($po_view->request, caNavIcon($po_view->request, __CA_NAV_BUTTON_ADD__), '', 'NewChildForm'); $vs_buf .= "</form></div>\n"; } } // // Output containing list for list items // if ($vs_table_name === 'ca_list_items') { if ($t_list = $po_view->getVar('t_list')) { $vn_list_id = $t_list->getPrimaryKey(); $vs_buf .= "<strong>" . _t("Part of") . "</strong>: " . caEditorLink($po_view->request, $t_list->getLabelForDisplay(), '', 'ca_lists', $vn_list_id) . "<br/>\n"; if ($t_item->get('is_default')) { $vs_buf .= "<strong>" . _t("Is default for list") . "</strong><br/>\n"; } } } // // Output containing relationship type name for relationship types // if ($vs_table_name === 'ca_relationship_types') { if (!($t_rel_instance = $t_item->getAppDatamodel()->getInstanceByTableNum($t_item->get('table_num'), true))) { if ($vn_parent_id = $po_view->request->getParameter('parent_id', pInteger)) { $t_rel_type = new ca_relationship_types($vn_parent_id); $t_rel_instance = $t_item->getAppDatamodel()->getInstanceByTableNum($t_rel_type->get('table_num'), true); } } if ($t_rel_instance) { $vs_buf .= "<div><strong>" . _t("Is a") . "</strong>: " . $t_rel_instance->getProperty('NAME_SINGULAR') . "<br/></div>\n"; } } // // Output extra useful info for metadata elements // if ($vs_table_name === 'ca_metadata_elements' && $t_item->getPrimaryKey()) { $vs_buf .= "<div><strong>" . _t("Element code") . "</strong>: " . $t_item->get('element_code') . "<br/></div>\n"; if (sizeof($va_uis = $t_item->getUIs()) > 0) { $vs_buf .= "<div><strong>" . _t("Referenced by user interfaces") . "</strong>:<br/>\n"; foreach ($va_uis as $vn_ui_id => $va_ui_info) { $vs_buf .= caNavLink($po_view->request, $va_ui_info['name'], '', 'administrate/setup/interface_screen_editor', 'InterfaceScreenEditor', 'Edit', array('ui_id' => $vn_ui_id, 'screen_id' => $va_ui_info['screen_id'])); $vs_buf .= " (" . $o_dm->getTableProperty($va_ui_info['editor_type'], 'NAME_PLURAL') . ")<br/>\n"; } $vs_buf .= "</div>\n"; } } // // Output related objects for ca_editor_uis and ca_editor_ui_screens // if ($vs_table_name === 'ca_editor_uis') { $vs_buf .= "<div><strong>" . _t("Number of screens") . "</strong>: " . (int) $t_item->getScreenCount() . "\n"; if ($t_item->getPrimaryKey()) { $vs_buf .= "<div><strong>" . _t("Edits") . "</strong>: " . caGetTableDisplayName($t_item->get('editor_type')) . "<br/>\n"; } else { $vs_buf .= "<div><strong>" . _t("Edits") . "</strong>: " . caGetTableDisplayName($po_view->request->getParameter('editor_type', pInteger)) . "<br/>\n"; } $vs_buf .= "</div>\n"; } // // Output related objects for ca_editor_uis and ca_editor_ui_screens // if ($vs_table_name === 'ca_editor_ui_screens') { $t_ui = new ca_editor_uis($vn_ui_id = $t_item->get('ui_id')); $vs_buf .= "<div><strong>" . _t("Part of") . "</strong>: " . caNavLink($po_view->request, $t_ui->getLabelForDisplay(), '', 'administrate/setup/interface_editor', 'InterfaceEditor', 'Edit', array('ui_id' => $vn_ui_id)) . "\n"; $vs_buf .= "</div>\n"; } // // Output extra useful info for bundle displays // if ($vs_table_name === 'ca_bundle_displays') { $vs_buf .= "<div><strong>" . _t("Number of placements") . "</strong>: " . $t_item->getPlacementCount(array('user_id' => $po_view->request->getUserID())) . "<br/>\n"; if ($t_item->getPrimaryKey()) { $vn_content_table_num = $t_item->get('table_num'); $vs_buf .= "<strong>" . _t("Type of content") . "</strong>: " . caGetTableDisplayName($vn_content_table_num) . "\n"; $vs_buf .= "</div>\n"; } else { if ($vn_content_table_num = $po_view->request->getParameter('table_num', pInteger)) { $vs_buf .= "<div><strong>" . _t("Type of content") . "</strong>: " . caGetTableDisplayName($vn_content_table_num) . "\n"; $vs_buf .= "</div>\n"; } } $t_user = new ca_users(($vn_user_id = $t_item->get('user_id')) ? $vn_user_id : $po_view->request->getUserID()); if ($t_user->getPrimaryKey()) { $vs_buf .= "<div><strong>" . _t('Owner') . "</strong>: " . $t_user->get('fname') . ' ' . $t_user->get('lname') . "</div>\n"; } } // // Output extra useful info for search forms // if ($vs_table_name === 'ca_search_forms') { $vs_buf .= "<div><strong>" . _t("Number of placements") . "</strong>: " . $t_item->getPlacementCount(array('user_id' => $po_view->request->getUserID())) . "<br/>\n"; if ($t_item->getPrimaryKey()) { $vn_content_table_num = $t_item->get('table_num'); $vs_buf .= "<strong>" . _t("Searches for") . "</strong>: " . caGetTableDisplayName($vn_content_table_num) . "\n"; $vs_buf .= "</div>\n"; } else { if ($vn_content_table_num = $po_view->request->getParameter('table_num', pInteger)) { $vs_buf .= "<strong>" . _t("Searches for") . "</strong>: " . caGetTableDisplayName($vn_content_table_num) . "\n"; $vs_buf .= "</div>\n"; } } $t_user = new ca_users(($vn_user_id = $t_item->get('user_id')) ? $vn_user_id : $po_view->request->getUserID()); if ($t_user->getPrimaryKey()) { $vs_buf .= "<div><strong>" . _t('Owner') . "</strong>: " . $t_user->get('fname') . ' ' . $t_user->get('lname') . "</div>\n"; } } // // Output extra useful info for tours // if ($vs_table_name === 'ca_tours' && $t_item->getPrimaryKey()) { $vs_buf .= "<br/><strong>" . _t("Number of stops") . "</strong>: " . $t_item->getStopCount() . "<br/>\n"; } // // Output containing tour for tour stops // if ($vs_table_name === 'ca_tour_stops') { $t_tour = new ca_tours($vn_tour_id = $t_item->get('tour_id')); $vs_buf .= "<strong>" . _t("Part of") . "</strong>: " . caEditorLink($po_view->request, $t_tour->getLabelForDisplay(), '', 'ca_tours', $vn_tour_id) . "<br/>\n"; } // // Output extra useful info for bundle mappings // if ($vs_table_name === 'ca_bundle_mappings') { if ($t_item->getPrimaryKey()) { $vn_content_table_num = $t_item->get('table_num'); $vs_buf .= "<br/><strong>" . _t("Type of content") . "</strong>: " . caGetTableDisplayName($vn_content_table_num) . "<br/>\n"; $vs_buf .= "<strong>" . _t("Type") . "</strong>: " . $t_item->getChoiceListValue('direction', $t_item->get('direction')) . "<br/>\n"; $vs_buf .= "<strong>" . _t("Target format") . "</strong>: " . $t_item->get('target') . "<br/>\n"; $va_stats = $t_item->getMappingStatistics(); $vs_buf .= "<div><strong>" . _t("Number of groups") . "</strong>: " . $va_stats['groupCount'] . "<br/>\n"; $vs_buf .= "<strong>" . _t("Number of rules") . "</strong>: " . $va_stats['ruleCount'] . "<br/>\n"; $vs_buf .= "</div>\n"; } else { if ($vn_content_table_num = $po_view->request->getParameter('table_num', pInteger)) { $vs_buf .= "<div><strong>" . _t("Type of content") . "</strong>: " . caGetTableDisplayName($vn_content_table_num) . "<br/>\n"; $vs_buf .= "<strong>" . _t("Type") . "</strong>: " . $t_item->getChoiceListValue('direction', $po_view->request->getParameter('direction', pString)) . "<br/>\n"; $vs_buf .= "<strong>" . _t("Target format") . "</strong>: " . $po_view->request->getParameter('target', pString) . "<br/>\n"; $vs_buf .= "<div><strong>" . _t("Number of groups") . "</strong>: 0<br/>\n"; $vs_buf .= "<strong>" . _t("Number of rules") . "</strong>: 0</div>\n"; $vs_buf .= "</div>\n"; } } } // // Output extra useful info for client services/commerce orders // if ($vs_table_name === 'ca_commerce_orders') { $o_client_services_config = Configuration::load($po_view->request->config->get('client_services_config')); $va_order_totals = $t_item->getOrderTotals(); if ($va_order_totals['fee'] + $va_order_totals['tax'] + $va_order_totals['shipping'] + $va_order_totals['handling'] + $va_order_totals['additional_order_fees'] + $va_order_totals['additional_item_fees'] != 0) { $vs_currency_symbol = $o_client_services_config->get('currency_symbol'); $vs_buf .= "<table style='margin-left: 10px;'>"; $vs_buf .= "<tr><td><strong>" . _t("Items") . '</strong></td><td>' . $vs_currency_symbol . sprintf("%4.2f", $va_order_totals['fee']) . " (" . (int) $va_order_totals['items'] . ")</td></tr>\n"; $vs_buf .= "<tr><td><strong>" . _t("S+H") . '</strong></td><td>' . $vs_currency_symbol . sprintf("%4.2f", $va_order_totals['shipping'] + $va_order_totals['handling']) . "</td></tr>\n"; $vs_buf .= "<tr><td><strong>" . _t("Tax") . '</strong></td><td>' . $vs_currency_symbol . sprintf("%4.2f", $va_order_totals['tax']) . "</td></tr>\n"; $vs_buf .= "<tr><td><strong>" . _t("Addtl fees") . '</strong></td><td>' . $vs_currency_symbol . sprintf("%4.2f", $va_order_totals['additional_order_fees'] + $va_order_totals['additional_item_fees']) . "</td></tr>\n"; $vs_buf .= "<tr><td><strong>" . _t("Total") . '</strong></td><td>' . $vs_currency_symbol . sprintf("%4.2f", $va_order_totals['fee'] + $va_order_totals['tax'] + $va_order_totals['shipping'] + $va_order_totals['handling'] + $va_order_totals['additional_order_fees'] + $va_order_totals['additional_item_fees']) . "</td></tr>\n"; $vs_buf .= "</table>"; $vs_buf .= "<strong>" . $t_item->getFieldInfo('payment_status', 'LABEL') . "</strong>: " . $t_item->getChoiceListValue('payment_status', $t_item->get('payment_status')) . "<br/>\n"; } $vs_buf .= "<br/><strong>" . $t_item->getFieldInfo('order_status', 'LABEL') . "</strong>: " . $t_item->getChoiceListValue('order_status', $t_item->get('order_status')) . "<br/>\n"; if ($vs_shipping_date = $t_item->get('shipping_date', array('dateFormat' => 'delimited', 'timeOmit' => true))) { $vs_buf .= "<strong>" . $t_item->getFieldInfo('shipping_date', 'LABEL') . "</strong>: " . $vs_shipping_date; if ($vs_shipped_on_date = $t_item->get('shipped_on_date', array('dateFormat' => 'delimited'))) { $vs_buf .= " (" . _t('shipped %1', $vs_shipped_on_date) . ")"; } else { $vs_buf .= " (" . _t('not shipped') . ")"; } $vs_buf .= "<br/>\n"; } if (($vn_shipping_method = $t_item->get('shipping_method')) && $t_item->getChoiceListValue('shipping_method', $vn_shipping_method) != 'None') { $vs_buf .= "<strong>" . $t_item->getFieldInfo('shipping_method', 'LABEL') . "</strong>: " . $t_item->getChoiceListValue('shipping_method', $vn_shipping_method) . "<br/>\n"; } } // // Output configurable additional info from config, if set // if ($vs_additional_info = $po_view->request->config->get("{$vs_table_name}_inspector_additional_info")) { if (is_array($vs_additional_info)) { $vs_buf .= "<br/>"; foreach ($vs_additional_info as $vs_info) { $vs_buf .= caProcessTemplateForIDs($vs_info, $vs_table_name, array($t_item->getPrimaryKey()), array('requireLinkTags' => true)) . "<br/>\n"; } } else { $vs_buf .= "<br/>" . caProcessTemplateForIDs($vs_additional_info, $vs_table_name, array($t_item->getPrimaryKey()), array('requireLinkTags' => true)) . "<br/>\n"; } } // ------------------------------------------------------------------------------------- // Export if ($t_item->getPrimaryKey() && $po_view->request->config->get($vs_table_name . '_show_add_child_control_in_inspector')) { $vb_show_add_child_control = true; if (is_array($va_restrict_add_child_control_to_types = $po_view->request->config->getList($vs_table_name . '_restrict_child_control_in_inspector_to_types')) && sizeof($va_restrict_add_child_control_to_types)) { $t_type_instance = $t_item->getTypeInstance(); if (!in_array($t_type_instance->get('idno'), $va_restrict_add_child_control_to_types) && !in_array($t_type_instance->getPrimaryKey(), $va_restrict_add_child_control_to_types)) { $vb_show_add_child_control = false; } } } if ($po_view->request->user->canDoAction('can_export_' . $vs_table_name) && $t_item->getPrimaryKey() && sizeof(ca_data_exporters::getExporters($t_item->tableNum())) > 0) { $vs_buf .= '<div style="border-top: 1px solid #aaaaaa; margin-top: 5px; font-size: 10px; text-align: right;" id="caExportItemButton">'; $vs_buf .= _t('Export this %1', mb_strtolower($vs_type_name, 'UTF-8')) . " "; $vs_buf .= "<a class='button' onclick='jQuery(\"#exporterFormList\").show();' style='text-align:right;' href='#'>" . caNavIcon($po_view->request, __CA_NAV_BUTTON_ADD__) . "</a>"; $vs_buf .= caFormTag($po_view->request, 'ExportSingleData', 'caExportForm', 'manage/MetadataExport', 'post', 'multipart/form-data', '_top', array('disableUnsavedChangesWarning' => true)); $vs_buf .= "<div id='exporterFormList'>"; $vs_buf .= ca_data_exporters::getExporterListAsHTMLFormElement('exporter_id', $t_item->tableNum(), array('id' => 'caExporterList'), array('width' => '120px')); $vs_buf .= caHTMLHiddenInput('item_id', array('value' => $t_item->getPrimaryKey())); $vs_buf .= caFormSubmitLink($po_view->request, _t('Export') . " ›", "button", "caExportForm"); $vs_buf .= "</div>\n"; $vs_buf .= "</form>"; $vs_buf .= "</div>"; $vs_buf .= "<script type='text/javascript'>"; $vs_buf .= "jQuery(document).ready(function() {"; $vs_buf .= "jQuery(\"#exporterFormList\").hide();"; $vs_buf .= "});"; $vs_buf .= "</script>"; } $vs_buf .= "</div></h4>\n"; $vs_buf .= "<script type='text/javascript'>\n\t\t\tvar inspectorCookieJar = jQuery.cookieJar('caCookieJar');"; if ($t_item->getPrimaryKey()) { if ($vs_more_info) { $vs_buf .= "\t\t\t\n\t\t\tif (inspectorCookieJar.get('inspectorMoreInfoIsOpen') == undefined) {\t\t// default is to have info open\n\t\t\t\tinspectorCookieJar.set('inspectorMoreInfoIsOpen', 1);\n\t\t\t}\n\t\t\tif (inspectorCookieJar.get('inspectorMoreInfoIsOpen') == 1) {\n\t\t\t\tjQuery('#inspectorInfo').toggle(0);\n\t\t\t\tjQuery('#inspectorMoreInfo').html('" . addslashes(caNavIcon($po_view->request, __CA_NAV_BUTTON_COLLAPSE__)) . "');\n\t\t\t}\n\t\t\n\t\t\tjQuery('#inspectorMoreInfo').click(function() {\n\t\t\t\tjQuery('#inspectorInfo').slideToggle(350, function() { \n\t\t\t\t\tinspectorCookieJar.set('inspectorMoreInfoIsOpen', (this.style.display == 'block') ? 1 : 0); \n\t\t\t\t\tjQuery('#inspectorMoreInfo').html((this.style.display == 'block') ? '" . addslashes(caNavIcon($po_view->request, __CA_NAV_BUTTON_COLLAPSE__)) . "' : '" . addslashes(caNavIcon($po_view->request, __CA_NAV_BUTTON_INFO2__)) . "');\n\t\t\t\t\tcaResizeSideNav();\n\t\t\t\t}); \n\t\t\t\treturn false;\n\t\t\t});\n\t\t"; } if (sizeof($va_reps)) { $vs_buf .= "\n\t\tif (inspectorCookieJar.get('inspectorShowMediaIsOpen') == undefined) {\t\t// default is to have media open\n\t\t\tinspectorCookieJar.set('inspectorShowMediaIsOpen', 1);\n\t\t}\n\t\t\n\t\tif (inspectorCookieJar.get('inspectorShowMediaIsOpen') == 1) {\n\t\t\tjQuery('#inspectorMedia').toggle();\n\t\t}\n\t\n\t\tjQuery('#caColorbox').on('click', function(e) {\n\t\t\tif (e.altKey) {\n\t\t\t\tjQuery('#inspectorMedia').slideToggle(200, function() { \n\t\t\t\t\tinspectorCookieJar.set('inspectorShowMediaIsOpen', (this.style.display == 'block') ? 1 : 0); \n\t\t\t\t\t\tcaResizeSideNav();\n\t\t\t\t}); \n\t\t\t\treturn false;\n\t\t\t}\n\t\t});\n\t\t\t\t\t"; } } $vs_buf .= "</script>\n"; } $o_app_plugin_manager = new ApplicationPluginManager(); $va_hookAppend = $o_app_plugin_manager->hookAppendToEditorInspector(array("t_item" => $t_item)); if (is_string($va_hookAppend["caEditorInspectorAppend"])) { $vs_buf .= $va_hookAppend["caEditorInspectorAppend"]; } return $vs_buf; }
/** * 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(" ", ($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 ""; }
*/ AssetLoadManager::register('sortableUI'); $vs_id_prefix = $this->getVar('placement_code') . $this->getVar('id_prefix'); $t_instance = $this->getVar('t_instance'); $t_item = $this->getVar('t_item'); // object representation $t_item_label = $t_item->getLabelTableInstance(); $t_item_rel = $this->getVar('t_item_rel'); $t_subject = $this->getVar('t_subject'); // object $vs_add_label = $this->getVar('add_label'); $va_settings = $this->getVar('settings'); $vb_read_only = isset($va_settings['readonly']) && $va_settings['readonly']; $vb_batch = $this->getVar('batch'); // don't allow editing if user doesn't have access to any of the representation types if (sizeof(caGetTypeListForUser('ca_object_representations', array('access' => __CA_BUNDLE_ACCESS_EDIT__))) < 1) { $vb_read_only = true; } if (!in_array($vs_default_upload_type = $this->getVar('defaultRepresentationUploadType'), array('upload', 'url', 'search'))) { $vs_default_upload_type = 'upload'; } $vb_allow_fetching_from_urls = $this->request->getAppConfig()->get('allow_fetching_of_media_from_remote_urls'); // Paging $vn_start = 0; $vn_num_per_page = 20; $vn_primary_id = 0; // generate list of inital form values; the bundle Javascript call will // use the template to generate the initial form $va_rep_type_list = $t_item->getTypeList(); $va_errors = array(); $vn_rep_count = $t_subject->getRepresentationCount($va_settings);
/** * Set up basic "find" action */ public function Index($pa_options = null) { $po_search = isset($pa_options['search']) ? $pa_options['search'] : null; $t_model = $this->opo_datamodel->getInstanceByTableName($this->ops_tablename, true); $vn_display_id = $this->opo_result_context->getCurrentBundleDisplay(); // Make sure user has access to at least one type if (method_exists($t_model, 'getTypeFieldName') && $t_model->getTypeFieldName() && (!is_null($va_types = caGetTypeListForUser($this->ops_tablename, array('access' => __CA_BUNDLE_ACCESS_READONLY__))) && (is_array($va_types) && !sizeof($va_types)))) { $this->response->setRedirect($this->request->config->get('error_display_url') . '/n/2320?r=' . urlencode($this->request->getFullUrlPath())); return; } $va_display_list = array(); $t_display = $this->opo_datamodel->getInstanceByTableName('ca_bundle_displays', true); $t_display->load($vn_display_id); $vs_view = $this->opo_result_context->getCurrentView(); if ($vn_display_id && $t_display->haveAccessToDisplay($this->request->getUserID(), __CA_BUNDLE_DISPLAY_READ_ACCESS__)) { $va_placements = $t_display->getPlacements(array('settingsOnly' => true)); foreach ($va_placements as $vn_placement_id => $va_display_item) { $va_settings = caUnserializeForDatabase($va_display_item['settings']); // get column header text $vs_header = $va_display_item['display']; if (isset($va_settings['label']) && is_array($va_settings['label'])) { $va_tmp = caExtractValuesByUserLocale(array($va_settings['label'])); if ($vs_tmp = array_shift($va_tmp)) { $vs_header = $vs_tmp; } } $va_display_list[$vn_placement_id] = array('placement_id' => $vn_placement_id, 'bundle_name' => $va_display_item['bundle_name'], 'display' => $vs_header, 'settings' => $va_settings); if ($vs_view == 'editable') { $va_display_list[$vn_placement_id] = array_merge($va_display_list[$vn_placement_id], array('allowInlineEditing' => $va_display_item['allowInlineEditing'], 'inlineEditingType' => $va_display_item['inlineEditingType'], 'inlineEditingListValues' => $va_display_item['inlineEditingListValues'])); AssetLoadManager::register('panel'); } } } // // Default display list (if none are specifically defined) // if (!sizeof($va_display_list)) { if ($vs_idno_fld = $t_model->getProperty('ID_NUMBERING_ID_FIELD')) { $va_display_list[$this->ops_tablename . '.' . $vs_idno_fld] = array('placement_id' => $this->ops_tablename . '.' . $vs_idno_fld, 'bundle_name' => $this->ops_tablename . '.' . $vs_idno_fld, 'display' => $t_model->getDisplayLabel($this->ops_tablename . '.' . $vs_idno_fld), 'settings' => array(), 'allowInlineEditing' => true, 'inlineEditingType' => DT_FIELD, 'inlineEditingListValues' => array()); } if (method_exists($t_model, 'getLabelTableInstance') && !($this->ops_tablename === 'ca_objects' && $this->request->config->get('ca_objects_dont_use_labels'))) { $t_label = $t_model->getLabelTableInstance(); $va_display_list[$this->ops_tablename . '.preferred_labels'] = array('placement_id' => $this->ops_tablename . '.preferred_labels', 'bundle_name' => $this->ops_tablename . '.preferred_labels', 'display' => $t_label->getDisplayLabel($t_label->tableName() . '.' . $t_label->getDisplayField()), 'settings' => array(), 'allowInlineEditing' => true, 'inlineEditingType' => DT_FIELD, 'inlineEditingListValues' => array()); } if ($vs_view == 'editable') { AssetLoadManager::register('panel'); } } $this->view->setVar('current_display_list', $vn_display_id); $this->view->setVar('t_display', $t_display); if ($vs_view == 'editable') { $this->view->setVar('columns', $this->getInlineEditColumns($va_display_list, array('request' => $this->request))); $this->view->setVar('columnHeaders', caExtractValuesFromArrayList($va_display_list, 'display', array('preserveKeys' => false))); $this->view->setVar('rowHeaders', array()); } // figure out which items in the display are sortable if (method_exists($t_model, 'getApplicableElementCodes')) { $va_sortable_elements = ca_metadata_elements::getSortableElements($t_model->tableName()); $va_attribute_list = array_flip($t_model->getApplicableElementCodes($this->opo_result_context->getTypeRestriction($vb_dummy), false, false)); $t_label = $t_model->getLabelTableInstance(); $vs_label_table_name = $t_label->tableName(); $vs_label_display_field = $t_label->getDisplayField(); foreach ($va_display_list as $vn_i => $va_display_item) { $va_tmp = explode('.', $va_display_item['bundle_name']); if ($va_tmp[0] === $vs_label_table_name && $va_tmp[1] === $vs_label_display_field || $va_tmp[0] == $this->ops_tablename && $va_tmp[1] === 'preferred_labels') { $va_display_list[$vn_i]['is_sortable'] = true; $va_display_list[$vn_i]['bundle_sort'] = $vs_label_table_name . '.' . $vs_label_display_field; continue; } if ($va_tmp[0] != $this->ops_tablename) { continue; } if ($t_model->hasField($va_tmp[1])) { $va_display_list[$vn_i]['is_sortable'] = true; if ($t_model->hasField($va_tmp[1] . '_sort')) { $va_display_list[$vn_i]['bundle_sort'] = $va_display_item['bundle_name'] . '_sort'; } else { $va_display_list[$vn_i]['bundle_sort'] = $va_display_item['bundle_name']; } continue; } if (isset($va_attribute_list[$va_tmp[1]]) && $va_sortable_elements[$va_attribute_list[$va_tmp[1]]]) { $va_display_list[$vn_i]['is_sortable'] = true; $va_display_list[$vn_i]['bundle_sort'] = $va_display_item['bundle_name']; continue; } } } $this->view->setVar('display_list', $va_display_list); // Get current display list $va_displays = array('0' => _t('Default')); foreach (caExtractValuesByUserLocale($t_display->getBundleDisplays(array('table' => $this->ops_tablename, 'user_id' => $this->request->getUserID(), 'access' => __CA_BUNDLE_DISPLAY_READ_ACCESS__))) as $va_display) { $va_displays[$va_display['display_id']] = $va_display['name']; } $this->view->setVar('display_lists', $va_displays); # --- print forms used for printing search results as labels - in tools show hide under page bar if ((bool) $this->request->config->get('use_legacy_print_labels_generator')) { $this->view->setVar('label_formats', $this->getLegacyPrintForms()); } else { $this->view->setVar('label_formats', caGetAvailablePrintTemplates('labels', array('table' => $this->ops_tablename, 'type' => 'label'))); } # --- export options used to export search results - in tools show hide under page bar $vn_table_num = $this->opo_datamodel->getTableNum($this->ops_tablename); //default export formats, not configureable $va_export_options = array(array('name' => _t('Tab delimited'), 'code' => '_tab'), array('name' => _t('Comma delimited (CSV)'), 'code' => '_csv'), array('name' => _t('Spreadsheet with media icons (XLSX)'), 'code' => '_xlsx')); // merge default formats with drop-in print templates $va_export_options = array_merge($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')); // // Available sets // $t_set = new ca_sets(); $this->view->setVar('available_sets', caExtractValuesByUserLocale($t_set->getSets(array('table' => $this->ops_tablename, 'user_id' => $this->request->getUserID(), 'access' => __CA_SET_EDIT_ACCESS__, 'omitCounts' => true)))); if (strlen($this->ops_tablename) > 0) { if (!$this->request->user->canDoAction("can_edit_{$this->ops_tablename}")) { $this->view->setVar("default_action", "Summary"); } else { $this->view->setVar("default_action", "Edit"); } } $this->view->setVar('result_context', $this->opo_result_context); $this->view->setVar('access_restrictions', AccessRestrictions::load()); }
private function _evaluateRequirements(&$pa_requirements) { if (sizeof($pa_requirements) == 0) { return true; } // empty requirements means anyone may access the nav item $vs_result = $vs_value = null; foreach ($pa_requirements as $vs_requirement => $vs_boolean) { $vs_boolean = strtoupper($vs_boolean) == "AND" ? "AND" : "OR"; $va_tmp = explode(':', $vs_requirement); switch (strtolower($va_tmp[0])) { case 'availabletypes': $vn_min_access = sizeof($va_tmp) >= 3 ? constant($va_tmp[2]) : __CA_BUNDLE_ACCESS_EDIT__; $vn_min_types = sizeof($va_tmp) >= 4 ? (int) $va_tmp[3] : 1; $va_types = caGetTypeListForUser($va_tmp[1], array('access' => $vn_min_access)); $vs_value = sizeof($va_types) >= $vn_min_types ? true : false; break; case 'session': if (isset($va_tmp[2])) { $vs_value = $this->opo_request->session->getVar($va_tmp[1]) == $va_tmp[2] ? true : false; } else { $vs_value = $this->opo_request->session->getVar($va_tmp[1]) ? true : false; } break; case 'action': if ($va_tmp[1]) { $vs_value = $this->opo_request->user->canDoAction($va_tmp[1]) ? 1 : 0; } else { $vs_value = 1; } break; case 'parameter': if (isset($va_tmp[2])) { $vs_value = $this->opo_request->getParameter($va_tmp[1], pString) == $va_tmp[2] ? true : false; } else { $vs_value = $this->opo_request->getParameter($va_tmp[1], pString) ? true : false; } break; case 'configuration': $vs_pref = $va_tmp[1]; if ($vb_not = substr($vs_pref, 0, 1) == '!' ? true : false) { $vs_pref = substr($vs_pref, 1); } if ($vb_not && !intval($this->opo_request->config->get($vs_pref)) || !$vb_not && intval($this->opo_request->config->get($vs_pref))) { $vs_value = true; } else { $vs_value = false; } break; case 'global': if (isset($va_tmp[2])) { $vs_value = $GLOBALS[$va_tmp[1]] == $va_tmp[2] ? true : false; } else { $vs_value = $GLOBALS[$va_tmp[1]] ? true : false; } break; default: $vs_value = $vs_value ? true : false; break; } if (is_null($vs_result)) { $vs_result = $vs_value; } else { if ($vs_boolean == "AND") { $vs_result = $vs_result && $vs_value; } else { $vs_result = $vs_result || $vs_value; } } } return $vs_result; }