本文整理汇总了PHP中ca_sets::getSetsForItem方法的典型用法代码示例。如果您正苦于以下问题:PHP ca_sets::getSetsForItem方法的具体用法?PHP ca_sets::getSetsForItem怎么用?PHP ca_sets::getSetsForItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ca_sets
的用法示例。
在下文中一共展示了ca_sets::getSetsForItem方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: caEditorInspector
//.........这里部分代码省略.........
$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));
示例2: caExtractValuesByUserLocale
<?php
$t_object = $this->getVar("item");
$vn_object_id = $t_object->get('ca_objects.object_id');
$va_comments = $this->getVar("comments");
$pn_rep_id = $this->getVar("representation_id");
$va_export_formats = $this->getVar('export_formats');
$vs_export_format_select = $this->getVar('export_format_select');
$t_set = new ca_sets();
$va_sets = caExtractValuesByUserLocale($t_set->getSetsForItem("ca_objects", $t_object->get("object_id"), array("user_id" => $this->request->user->get("user_id"))));
$va_lightbox_crumbs = array();
foreach ($va_sets as $vn_set_id => $va_set) {
$va_lightbox_crumbs[] = caNavLink($this->request, _t("Lightbox"), "", "", "Sets", "Index") . " → " . caNavLink($this->request, $va_set["name"], "", "", "Sets", "SetDetail", array("set_id" => $vn_set_id)) . " → " . $t_object->get("ca_objects.preferred_labels.name");
}
$vs_lightbox_crumbs = "";
if (sizeof($va_lightbox_crumbs)) {
$vs_lightbox_crumbs = join("<br/>", $va_lightbox_crumbs);
}
?>
<div class="row">
<div class='col-xs-1 col-sm-1 col-md-1 col-lg-1'>
<div class="detailNavBgLeft">
{{{resultsLink}}}<div class='detailPrevLink'>{{{previousLink}}}</div>
</div><!-- end detailNavBgLeft -->
</div><!-- end col -->
<div class='col-xs-10 col-sm-10 col-md-10 col-lg-10'>
</div>
<div class='col-xs-1 col-sm-1 col-md-1 col-lg-1'>
<div class="detailNavBgRight">
{{{nextLink}}}
示例3: getSetsForItem
/**
* Returns list of sets item is member of
*
* @param string $type can be one of: ["ca_objects", "ca_entities", "ca_places", "ca_occurrences", "ca_collections", "ca_list_items", "ca_object_representations", "ca_storage_locations", "ca_movements", "ca_loans", "ca_tours", "ca_tour_stops"]
* @param int $item_id primary key
* @return array
*/
public function getSetsForItem($type, $item_id)
{
if (!$this->getTableInstance($type, $item_id)) {
throw new SoapFault("Server", "Invalid type or ID");
}
$t_set = new ca_sets();
return $t_set->getSetsForItem($type, $item_id, array('user_id' => $this->opo_request->getUserID()));
}
示例4: saveBundlesForScreen
//.........这里部分代码省略.........
$va_bundle_settings = $va_bundle_info['settings'];
break;
}
}
switch ($vs_f) {
# -------------------------------------
// This bundle is only available when editing objects of type ca_representation_annotations
case 'ca_representation_annotation_properties':
if ($vb_batch) {
break;
}
// not supported in batch mode
if (!$this->useInEditor()) {
break;
}
foreach ($this->getPropertyList() as $vs_property) {
$this->setPropertyValue($vs_property, $po_request->getParameter("{$vs_placement_code}{$vs_form_prefix}{$vs_property}", pString));
}
if (!$this->validatePropertyValues()) {
$po_request->addActionErrors($this->errors(), 'ca_representation_annotation_properties', 'general');
}
$this->update();
break;
# -------------------------------------
// This bundle is only available for types which support set membership
# -------------------------------------
// This bundle is only available for types which support set membership
case 'ca_sets':
// check for existing labels to delete (no updating supported)
require_once __CA_MODELS_DIR__ . '/ca_sets.php';
require_once __CA_MODELS_DIR__ . '/ca_set_items.php';
$t_set = new ca_sets();
if (!$vb_batch) {
$va_sets = caExtractValuesByUserLocale($t_set->getSetsForItem($this->tableNum(), $this->getPrimaryKey(), array('user_id' => $po_request->getUserID())));
foreach ($va_sets as $vn_set_id => $va_set_info) {
$vn_item_id = $va_set_info['item_id'];
if ($po_request->getParameter("{$vs_placement_code}{$vs_form_prefix}_set_id_{$vn_item_id}_delete", pString)) {
// delete
$t_set->load($va_set_info['set_id']);
$t_set->removeItem($this->getPrimaryKey(), $po_request->getUserID());
// remove *all* instances of the item in the set, not just the specified id
if ($t_set->numErrors()) {
$po_request->addActionErrors($t_set->errors(), $vs_f);
}
}
}
}
if ($vb_batch) {
$vs_batch_mode = $_REQUEST["{$vs_placement_code}{$vs_form_prefix}_batch_mode"];
if ($vs_batch_mode == '_disabled_') {
break;
}
if ($vs_batch_mode == '_replace_') {
$t_set->removeItemFromAllSets($this->tableNum(), $this->getPrimaryKey());
}
if ($vs_batch_mode == '_delete_') {
$t_set->removeItemFromAllSets($this->tableNum(), $this->getPrimaryKey());
break;
}
}
foreach ($_REQUEST as $vs_key => $vs_value) {
if (!preg_match("/{$vs_placement_code}{$vs_form_prefix}_set_id_new_([\\d]+)/", $vs_key, $va_matches)) {
continue;
}
$vn_c = intval($va_matches[1]);
if ($vn_new_set_id = $po_request->getParameter("{$vs_placement_code}{$vs_form_prefix}_set_id_new_{$vn_c}", pString)) {
示例5: processExporterItem
/**
* Processes single exporter item for a given record
*
* @param int $pn_item_id Primary of exporter item
* @param int $pn_table_num Table num of item to export
* @param int $pn_record_id Primary key value of item to export
* @param array $pa_options
* ignoreContext = don't switch context even though context may be set for current item
* relationship_type_id, relationship_type_code, relationship_typename =
* if this export is a sub-export (context-switch), we have no way of knowing the relationship
* to the 'parent' element in the export, so there has to be a means to pass it down to make it accessible
* attribute_id = signals that this is an export relative to a specific attribute instance
* this triggers special behavior that allows getting container values in a kind of sub-export
* it's really only useful for Containers but in theory can be any attribute
* logger = KLogger instance to use for logging. This option is mandatory!
* @return array Item info
*/
public function processExporterItem($pn_item_id, $pn_table_num, $pn_record_id, $pa_options = array())
{
$o_log = caGetOption('logger', $pa_options);
// always set by exportRecord()
$vb_ignore_context = caGetOption('ignoreContext', $pa_options);
$vn_attribute_id = caGetOption('attribute_id', $pa_options);
$o_log->logInfo(_t("Export mapping processor called with parameters [exporter_item_id:%1 table_num:%2 record_id:%3]", $pn_item_id, $pn_table_num, $pn_record_id));
$t_exporter_item = ca_data_exporters::loadExporterItemByID($pn_item_id);
$t_instance = ca_data_exporters::loadInstanceByID($pn_record_id, $pn_table_num);
// switch context to a different set of records if necessary and repeat current exporter item for all those selected records
// (e.g. hierarchy children or related items in another table, restricted by types or relationship types)
if (!$vb_ignore_context && ($vs_context = $t_exporter_item->getSetting('context'))) {
$va_restrict_to_types = $t_exporter_item->getSetting('restrictToTypes');
$va_restrict_to_rel_types = $t_exporter_item->getSetting('restrictToRelationshipTypes');
$va_restrict_to_bundle_vals = $t_exporter_item->getSetting('restrictToBundleValues');
$va_check_access = $t_exporter_item->getSetting('checkAccess');
$va_sort = $t_exporter_item->getSetting('sort');
$vn_new_table_num = $this->getAppDatamodel()->getTableNum($vs_context);
$vb_context_is_related_table = false;
$va_related = null;
if ($vn_new_table_num) {
// switch to new table
$vs_key = $this->getAppDatamodel()->getTablePrimaryKeyName($vs_context);
} else {
// this table, i.e. hierarchy context switch
$vs_key = $t_instance->primaryKey();
}
$o_log->logInfo(_t("Initiating context switch to '%1' for mapping ID %2 and record ID %3. The processor now tries to find matching records for the switch and calls itself for each of those items.", $vs_context, $pn_item_id, $pn_record_id));
switch ($vs_context) {
case 'children':
$va_related = $t_instance->getHierarchyChildren();
break;
case 'parent':
$va_related = array();
if ($vs_parent_id_fld = $t_instance->getProperty("HIERARCHY_PARENT_ID_FLD")) {
$va_related[] = array($vs_key => $t_instance->get($vs_parent_id_fld));
}
break;
case 'ancestors':
$va_parents = $t_instance->getHierarchyAncestors(null, array('idsOnly' => true));
$va_related = array();
foreach (array_unique($va_parents) as $vn_pk) {
$va_related[] = array($vs_key => intval($vn_pk));
}
break;
case 'ca_sets':
$t_set = new ca_sets();
$va_set_options = array();
if (isset($va_restrict_to_types[0])) {
// the utility used below doesn't support passing multiple types so we just pass the first.
// this should be enough for 99.99% of the actual use cases anyway
$va_set_options['setType'] = $va_restrict_to_types[0];
}
$va_set_options['checkAccess'] = $va_check_access;
$va_set_options['setIDsOnly'] = true;
$va_set_ids = $t_set->getSetsForItem($pn_table_num, $t_instance->getPrimaryKey(), $va_set_options);
$va_related = array();
foreach (array_unique($va_set_ids) as $vn_pk) {
$va_related[] = array($vs_key => intval($vn_pk));
}
break;
case 'ca_list_items.firstLevel':
if ($t_instance->tableName() == 'ca_lists') {
$o_dm = Datamodel::load();
$va_related = array();
$va_items_legacy_format = $t_instance->getListItemsAsHierarchy(null, array('maxLevels' => 1, 'dontIncludeRoot' => true));
$vn_new_table_num = $o_dm->getTableNum('ca_list_items');
$vs_key = 'item_id';
foreach ($va_items_legacy_format as $va_item_legacy_format) {
$va_related[$va_item_legacy_format['NODE']['item_id']] = $va_item_legacy_format['NODE'];
}
break;
} else {
return array();
}
break;
default:
if ($vn_new_table_num) {
$va_options = array('restrictToTypes' => $va_restrict_to_types, 'restrictToRelationshipTypes' => $va_restrict_to_rel_types, 'restrictToBundleValues' => $va_restrict_to_bundle_vals, 'checkAccess' => $va_check_access, 'sort' => $va_sort);
$o_log->logDebug(_t("Calling getRelatedItems with options: %1.", print_r($va_options, true)));
$va_related = $t_instance->getRelatedItems($vs_context, $va_options);
$vb_context_is_related_table = true;
} else {
//.........这里部分代码省略.........
示例6: array
}
}
if ($vs_style_display) {
print "<H6>" . _t("Style/Movement") . "</H6>";
print $vs_style_display;
}
}
$va_collections = $t_object->get("ca_collections", array("returnAsArray" => true, "checkAccess" => $va_access_values, "sort" => "ca_collections.preferred_labels.name"));
if (sizeof($va_collections)) {
print "<H6>Collection" . (sizeof($va_collections) > 1 ? "s" : "") . "</H6>";
foreach ($va_collections as $va_collection) {
print caDetailLink($this->request, $va_collection["name"], "", "ca_collections", $va_collection["collection_id"]) . "<br/>";
}
}
$t_set = new ca_sets();
$va_galleries = caExtractValuesByUserLocale($t_set->getSetsForItem("ca_objects", $t_object->get("object_id"), array("checkAccess" => $va_access_values, "setType" => "public_presentation")));
if (sizeof($va_galleries)) {
print "<H6>Galler" . (sizeof($va_galleries) > 1 ? "ies" : "y") . "</H6>";
foreach ($va_galleries as $va_gallery) {
print caNavLink($this->request, $va_gallery["name"], "", "", "Gallery", $va_gallery["set_id"]) . "<br/>";
}
}
if ($va_themes = $t_object->get("ca_objects.steelcase_themes", array("returnAsArray" => true, "convertCodesToDisplayText" => false))) {
$i = 0;
$vs_theme_display = "";
foreach ($va_themes as $vn_theme_id => $va_theme) {
$i++;
$vs_theme = $t_lists->getItemFromListForDisplayByItemID("custom_subject", $va_theme["steelcase_themes"]);
if (trim($vs_theme)) {
$vs_theme_display .= caNavLink($this->request, $vs_theme, "", "", "Browse", "Objects", array("facet" => "theme_facet", "id" => $va_theme["steelcase_themes"]));
if ($i < sizeof($va_themes)) {
示例7: processExporterItem
/**
* @param array $pa_options
* ignoreContext = don't switch context even though context may be set for current item
*/
public function processExporterItem($pn_item_id, $pn_table_num, $pn_record_id, $pa_options = array())
{
$vb_ignore_context = isset($pa_options['ignoreContext']) && $pa_options['ignoreContext'];
$t_exporter_item = ca_data_exporters::loadExporterItemByID($pn_item_id);
$t_instance = ca_data_exporters::loadInstanceByID($pn_record_id, $pn_table_num);
// switch context to a different set of records if necessary and repeat current exporter item for all those selected records
// (e.g. hierarchy children or related items in another table, restricted by types or relationship types)
if (!$vb_ignore_context && ($vs_context = $t_exporter_item->getSetting('context'))) {
$va_restrict_to_types = $t_exporter_item->getSetting('restrictToTypes');
$va_restrict_to_rel_types = $t_exporter_item->getSetting('restrictToRelationshipTypes');
$va_check_access = $t_exporter_item->getSetting('checkAccess');
$vn_new_table_num = $this->getAppDatamodel()->getTableNum($vs_context);
if ($vn_new_table_num) {
// switch to new table
$vs_key = $this->getAppDatamodel()->getTablePrimaryKeyName($vs_context);
} else {
// this table, i.e. hierarchy context switch
$vs_key = $t_instance->primaryKey();
$vn_new_table_num = $pn_table_num;
}
switch ($vs_context) {
case 'children':
$va_related = $t_instance->getHierarchyChildren();
break;
case 'parent':
$va_related = array();
if ($vs_parent_id_fld = $t_instance->getProperty("HIERARCHY_PARENT_ID_FLD")) {
$va_related[] = array($vs_key => $t_instance->get($vs_parent_id_fld));
}
break;
case 'ancestors':
$va_parents = $t_instance->getHierarchyAncestors(null, array('idsOnly' => true));
$va_related = array();
foreach (array_unique($va_parents) as $vn_pk) {
$va_related[] = array($vs_key => intval($vn_pk));
}
break;
case 'ca_sets':
$t_set = new ca_sets();
$va_set_options = array();
if (isset($va_restrict_to_types[0])) {
// the utility used below doesn't support passing multiple types so we just pass the first.
// this should be enough for 99.99% of the actual use cases anyway
$va_set_options['setType'] = $va_restrict_to_types[0];
}
$va_set_options['checkAccess'] = $va_check_access;
$va_set_options['setIDsOnly'] = true;
$va_set_ids = $t_set->getSetsForItem($pn_table_num, $t_instance->getPrimaryKey(), $va_set_options);
$va_related = array();
foreach (array_unique($va_set_ids) as $vn_pk) {
$va_related[] = array($vs_key => intval($vn_pk));
}
break;
default:
// plain old related table
if ($vn_new_table_num) {
$va_related = $t_instance->getRelatedItems($vs_context, array('restrictToTypes' => $va_restrict_to_types, 'restrictToRelationshipTypes' => $va_restrict_to_rel_types, 'checkAccess' => $va_check_access));
} else {
return array();
}
break;
}
$va_info = array();
if (is_array($va_related)) {
foreach ($va_related as $va_rel) {
$va_rel_export = $this->processExporterItem($pn_item_id, $vn_new_table_num, $va_rel[$vs_key], array_merge(array('ignoreContext' => true), $pa_options));
$va_info = array_merge($va_info, $va_rel_export);
}
}
return $va_info;
}
// end switch context
// Don't prevent context switches for children of context-switched exporter items. This way you can
// build cascades for jobs like exporting objects related to the creator of the record in question.
unset($pa_options['ignoreContext']);
$va_item_info = array();
$vs_source = $t_exporter_item->get('source');
$vs_element = $t_exporter_item->get('element');
$vb_repeat = $t_exporter_item->getSetting('repeat_element_for_multiple_values');
// if omitIfEmpty is set and returns nothing, we ignore this exporter item and all children
if ($vs_omit_if_empty = $t_exporter_item->getSetting('omitIfEmpty')) {
if (!(strlen($t_instance->get($vs_omit_if_empty)) > 0)) {
return array();
}
}
// always return URL for export, not an HTML tag
$va_get_options = array('returnURL' => true);
if ($t_exporter_item->getSetting('convertCodesToDisplayText')) {
$va_get_options['convertCodesToDisplayText'] = true;
}
if ($vs_delimiter = $t_exporter_item->getSetting("delimiter")) {
$va_get_options['delimiter'] = $vs_delimiter;
}
if ($vs_template = $t_exporter_item->getSetting('template')) {
$va_get_options['template'] = $vs_template;
}
//.........这里部分代码省略.........
示例8: processExporterItem
/**
* Processes single exporter item for a given record
*
* @param int $pn_item_id Primary of exporter item
* @param int $pn_table_num Table num of item to export
* @param int $pn_record_id Primary key value of item to export
* @param array $pa_options
* ignoreContext = don't switch context even though context may be set for current item
* relationship_type_id, relationship_type_code, relationship_typename =
* if this export is a sub-export (context-switch), we have no way of knowing the relationship
* to the 'parent' element in the export, so there has to be a means to pass it down to make it accessable
* logger = KLogger instance to use for logging. This option is mandatory!
* @return array Item info
*/
public function processExporterItem($pn_item_id, $pn_table_num, $pn_record_id, $pa_options = array())
{
$o_log = caGetOption('logger', $pa_options);
// always set by exportRecord()
$vb_ignore_context = caGetOption('ignoreContext', $pa_options);
$o_log->logInfo(_t("Export mapping processor called with parameters [exporter_item_id:%1 table_num:%2 record_id:%3]", $pn_item_id, $pn_table_num, $pn_record_id));
$t_exporter_item = ca_data_exporters::loadExporterItemByID($pn_item_id);
$t_instance = ca_data_exporters::loadInstanceByID($pn_record_id, $pn_table_num);
// switch context to a different set of records if necessary and repeat current exporter item for all those selected records
// (e.g. hierarchy children or related items in another table, restricted by types or relationship types)
if (!$vb_ignore_context && ($vs_context = $t_exporter_item->getSetting('context'))) {
$va_restrict_to_types = $t_exporter_item->getSetting('restrictToTypes');
$va_restrict_to_rel_types = $t_exporter_item->getSetting('restrictToRelationshipTypes');
$va_check_access = $t_exporter_item->getSetting('checkAccess');
$vn_new_table_num = $this->getAppDatamodel()->getTableNum($vs_context);
$vb_context_is_related_table = false;
if ($vn_new_table_num) {
// switch to new table
$vs_key = $this->getAppDatamodel()->getTablePrimaryKeyName($vs_context);
} else {
// this table, i.e. hierarchy context switch
$vs_key = $t_instance->primaryKey();
$vn_new_table_num = $pn_table_num;
}
$o_log->logInfo(_t("Initiating context switch to '%1' for mapping ID %2 and record ID %3. The processor now tries to find matching records for the switch and calls himself for each of those items.", $vs_context, $pn_item_id, $pn_record_id));
switch ($vs_context) {
case 'children':
$va_related = $t_instance->getHierarchyChildren();
break;
case 'parent':
$va_related = array();
if ($vs_parent_id_fld = $t_instance->getProperty("HIERARCHY_PARENT_ID_FLD")) {
$va_related[] = array($vs_key => $t_instance->get($vs_parent_id_fld));
}
break;
case 'ancestors':
$va_parents = $t_instance->getHierarchyAncestors(null, array('idsOnly' => true));
$va_related = array();
foreach (array_unique($va_parents) as $vn_pk) {
$va_related[] = array($vs_key => intval($vn_pk));
}
break;
case 'ca_sets':
$t_set = new ca_sets();
$va_set_options = array();
if (isset($va_restrict_to_types[0])) {
// the utility used below doesn't support passing multiple types so we just pass the first.
// this should be enough for 99.99% of the actual use cases anyway
$va_set_options['setType'] = $va_restrict_to_types[0];
}
$va_set_options['checkAccess'] = $va_check_access;
$va_set_options['setIDsOnly'] = true;
$va_set_ids = $t_set->getSetsForItem($pn_table_num, $t_instance->getPrimaryKey(), $va_set_options);
$va_related = array();
foreach (array_unique($va_set_ids) as $vn_pk) {
$va_related[] = array($vs_key => intval($vn_pk));
}
break;
default:
// plain old related table
if ($vn_new_table_num) {
$va_related = $t_instance->getRelatedItems($vs_context, array('restrictToTypes' => $va_restrict_to_types, 'restrictToRelationshipTypes' => $va_restrict_to_rel_types, 'checkAccess' => $va_check_access));
$vb_context_is_related_table = true;
} else {
return array();
}
break;
}
$va_info = array();
if (is_array($va_related)) {
$o_log->logDebug(_t("The current mapping will now be repreated for these items: %1", print_r($va_related, true)));
foreach ($va_related as $va_rel) {
// if we're dealing with a related table, pass on some info the relationship type to the context-switched invocation of processExporterItem(),
// because we can't access that information from the related item simply because we don't exactly know where the call originated
if ($vb_context_is_related_table) {
$pa_options['relationship_typename'] = $va_rel['relationship_typename'];
$pa_options['relationship_type_code'] = $va_rel['relationship_type_code'];
$pa_options['relationship_type_id'] = $va_rel['relationship_type_id'];
}
$va_rel_export = $this->processExporterItem($pn_item_id, $vn_new_table_num, $va_rel[$vs_key], array_merge(array('ignoreContext' => true), $pa_options));
$va_info = array_merge($va_info, $va_rel_export);
}
} else {
$o_log->logDebug(_t("No matching related items found for last context switch"));
}
return $va_info;
//.........这里部分代码省略.........