本文整理汇总了PHP中ca_lists类的典型用法代码示例。如果您正苦于以下问题:PHP ca_lists类的具体用法?PHP ca_lists怎么用?PHP ca_lists使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ca_lists类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: refine
/**
*
*/
public function refine(&$pa_destination_data, $pa_group, $pa_item, $pa_source_data, $pa_options = null)
{
$o_log = isset($pa_options['log']) && is_object($pa_options['log']) ? $pa_options['log'] : null;
// Set place hierarchy
if ($vs_hierarchy = $pa_item['settings']['placeSplitter_placeHierarchy']) {
$vn_hierarchy_id = caGetListItemID('place_hierarchies', $vs_hierarchy);
} else {
// Default to first place hierarchy
$t_list = new ca_lists();
$va_hierarchy_ids = $t_list->getItemsForList('place_hierarchies', array('idsOnly' => true));
$vn_hierarchy_id = array_shift($va_hierarchy_ids);
}
if (!$vn_hierarchy_id) {
if ($o_log) {
$o_log->logError(_t('[placeSplitterRefinery] No place hierarchies are defined'));
}
return array();
}
$pa_options['hierarchyID'] = $vn_hierarchy_id;
$t_place = new ca_places();
if ($t_place->load(array('parent_id' => null, 'hierarchy_id' => $vn_hierarchy_id))) {
$pa_options['defaultParentID'] = $t_place->getPrimaryKey();
}
return caGenericImportSplitter('placeSplitter', 'place', 'ca_places', $this, $pa_destination_data, $pa_group, $pa_item, $pa_source_data, $pa_options);
}
示例2: __construct
public function __construct($ps_widget_path, $pa_settings)
{
$this->title = _t('Records by status');
$this->description = _t('Displays objects or authority items by cataloguing status');
parent::__construct($ps_widget_path, $pa_settings);
$this->opo_config = Configuration::load($ps_widget_path . '/conf/recordsByStatus.conf');
$this->opo_datamodel = Datamodel::load();
# -- get status values
$t_lists = new ca_lists();
$va_statuses = caExtractValuesByUserLocale($t_lists->getItemsForList("workflow_statuses"));
$va_status_info = array();
$va_status_values = array();
foreach ($va_statuses as $i => $va_info) {
$va_status_info[$va_info["item_value"]] = $va_info["name_singular"];
$va_status_values[] = $va_info["item_value"];
}
$this->opa_status_display_names = $va_status_info;
$this->opa_status_values = $va_status_values;
$this->opa_table_display_names = array('ca_objects' => _t('Objects'), 'ca_entities' => _t('Entities'), 'ca_places' => _t('Places'), 'ca_occurrences' => _t('Occurrences'), 'ca_sets' => _t('Sets'), 'ca_collections' => _t('Collections'), 'ca_object_representations' => _t('Object representations'), 'ca_object_lots' => _t('Object lots'));
foreach ($this->opa_table_display_names as $vs_table => $vs_display) {
if (!$this->getRequest() || !$this->getRequest()->user->canDoAction("can_use_records_by_status_widget_{$vs_table}")) {
foreach (BaseWidget::$s_widget_settings['recordsByStatusWidget']["display_type"]["options"] as $vs_setting_display => $vs_setting_table) {
if ($vs_setting_table == $vs_table) {
unset(BaseWidget::$s_widget_settings['recordsByStatusWidget']["display_type"]["options"][$vs_setting_display]);
}
}
}
}
}
示例3: __construct
public function __construct(&$po_request, &$po_response, $pa_view_paths = null)
{
$this->ops_theme = __CA_THEME__;
// get current theme
if (!is_dir(__CA_APP_DIR__ . '/plugins/MetabolicChronology/themes/' . $this->ops_theme . '/views')) {
// if theme is not defined for this plugin, try to use "default" theme
$this->ops_theme = 'default';
}
parent::__construct($po_request, $po_response, array(__CA_APP_DIR__ . '/plugins/MetabolicChronology/themes/' . $this->ops_theme . '/views'));
$this->opo_plugin_config = Configuration::load($this->request->getAppConfig()->get('application_plugins') . '/MetabolicChronology/conf/Chronology.conf');
if (!(bool) $this->opo_plugin_config->get('enabled')) {
die(_t('Metabolic Chronology plugin is not enabled'));
}
$this->_initView($pa_options);
$this->opo_result_context = new ResultContext($po_request, 'ca_objects', 'MetabolicChronology');
MetaTagManager::addLink('stylesheet', $po_request->getBaseUrlPath() . "/app/plugins/MetabolicChronology/themes/" . $this->ops_theme . "/css/chronology.css", 'text/css');
JavascriptLoadManager::register('jcarousel');
JavascriptLoadManager::register('maps');
$t_list = new ca_lists();
$this->opn_silo_type_id = $t_list->getItemIDFromList('collection_types', 'silo');
$this->opn_action_type_id = $t_list->getItemIDFromList('occurrence_types', 'action');
$this->opn_context_type_id = $t_list->getItemIDFromList('occurrence_types', 'context');
$this->opn_yes_list_id = $t_list->getItemIDFromList('yes_no', 'yes');
$t_relationship_types = new ca_relationship_types();
$this->opn_rel_type_action_display_image = $t_relationship_types->getRelationshipTypeID("ca_objects_x_occurrences", "display");
$this->opn_rel_type_action_secondary_images = $t_relationship_types->getRelationshipTypeID("ca_objects_x_occurrences", "secondary");
$va_access_values = caGetUserAccessValues($this->request);
$this->opa_access_values = $va_access_values;
$this->view->setVar('access_values', $va_access_values);
}
示例4: __construct
/**
*
*/
public function __construct(&$po_request, &$po_response, $pa_view_paths = null)
{
$this->ops_theme = __CA_THEME__;
// get current theme
if (!is_dir(__CA_APP_DIR__ . '/plugins/Contribute/themes/' . $this->ops_theme . '/views')) {
// if theme is not defined for this plugin, try to use "default" theme
$this->ops_theme = 'default';
}
parent::__construct($po_request, $po_response, array(__CA_APP_DIR__ . '/plugins/Contribute/themes/' . $this->ops_theme . '/views'));
#$this->opo_plugin_config = Configuration::load($po_request->getAppConfig()->get('application_plugins').'/Contribute/conf/contribute.conf');
if (file_exists($po_request->getAppConfig()->get('application_plugins') . '/Contribute/themes/' . $this->ops_theme . '/conf/contribute.conf')) {
// check if there is a config file in the theme first
$this->opo_plugin_config = Configuration::load($po_request->getAppConfig()->get('application_plugins') . '/Contribute/themes/' . $this->ops_theme . '/conf/contribute.conf');
} else {
$this->opo_plugin_config = Configuration::load($po_request->getAppConfig()->get('application_plugins') . '/Contribute/conf/contribute.conf');
}
if (!(bool) $this->opo_plugin_config->get('enabled')) {
die(_t('Contribute plugin is not enabled'));
}
$vs_default_ui = $this->opo_plugin_config->get('default_ui');
$vs_requested_ui = $this->request->getParameter('ui', pString);
$va_ui_list = $this->opo_plugin_config->getAssoc('uis');
$o_dm = Datamodel::load();
if (isset($va_ui_list[$vs_requested_ui]) && is_array($va_ui_list[$vs_requested_ui])) {
$this->opa_ui_info = $va_ui_list[$vs_requested_ui];
$this->ops_ui_code = $vs_requested_ui;
} else {
if (isset($va_ui_list[$vs_default_ui]) && is_array($va_ui_list[$vs_default_ui])) {
$this->opa_ui_info = $va_ui_list[$vs_default_ui];
} else {
$vs_default_ui = array_shift(array_keys($va_ui_list));
$this->opa_ui_info = $va_ui_list[$vs_default_ui];
}
$this->ops_ui_code = $vs_default_ui;
}
$this->ops_table_name = $this->opa_ui_info['table'];
if (!($this->opo_instance = $o_dm->getInstanceByTableName($this->ops_table_name, true))) {
die(_t('Invalid table "%1" specified in Contribute plugin for form "%2"', $this->ops_table_name, $vs_default_ui));
}
$t_list = new ca_lists();
if (isset($this->opa_ui_info['type']) && $this->opa_ui_info['type']) {
$this->opa_ui_info['type_id'] = $t_list->getItemIDFromList($this->opo_instance->getTypeListCode(), $this->opa_ui_info['type']);
}
if (isset($this->opa_ui_info['representation_type']) && $this->opa_ui_info['representation_type']) {
$this->opa_ui_info['representation_type_id'] = $t_list->getItemIDFromList('object_representation_types', $this->opa_ui_info['representation_type']);
}
ContributePlugin::setUIInfo($this->ops_ui_code, $this->opa_ui_info);
JavascriptLoadManager::register('panel');
MetaTagManager::addLink('stylesheet', $po_request->getBaseUrlPath() . "/app/plugins/Contribute/themes/" . $this->ops_theme . "/css/contribute.css", 'text/css');
$this->request->setParameter('dont_set_pawtucket2_last_page', '1');
// Setting this parameter ensures that the "last page" we (may) redirect to after submission isn't the Contribute form itself
if ($this->opa_ui_info['require_login'] && !$po_request->isLoggedIn()) {
$this->notification->addNotification(_t("You must be logged in to use user contribution features."), __NOTIFICATION_TYPE_ERROR__);
$this->response->setRedirect(caNavUrl($this->request, '', 'LoginReg', 'form'));
return;
}
}
示例5: displaySet
public function displaySet()
{
$pn_set_id = $this->request->getParameter('set_id', pInteger);
$t_set = new ca_sets($pn_set_id);
$t_list = new ca_lists();
$va_access_values = caGetUserAccessValues($this->request);
$this->view->setVar('t_set', $t_set);
$this->view->setVar('set_presentation_types', caExtractValuesByUserLocale($t_list->getItemsForList('set_presentation_types')));
$this->view->setVar('access_values', $va_access_values);
$this->render('features_contents_html.php');
}
示例6: browseName
/**
* Returns string representing the name of the item the browse will return
*
* If $ps_mode is 'singular' [default] then the singular version of the name is returned, otherwise the plural is returned
*/
public function browseName($ps_mode = 'singular')
{
$vb_type_restriction_has_changed = false;
$vn_type_id = $this->opo_result_context->getTypeRestriction($vb_type_restriction_has_changed);
$t_list = new ca_lists();
$t_list->load(array('list_code' => 'occurrence_types'));
$t_list_item = new ca_list_items();
$t_list_item->load(array('list_id' => $t_list->getPrimaryKey(), 'parent_id' => null));
$va_hier = caExtractValuesByUserLocale($t_list_item->getHierarchyWithLabels());
if (!($vs_name = $ps_mode == 'singular' ? $va_hier[$vn_type_id]['name_singular'] : $va_hier[$vn_type_id]['name_plural'])) {
$vs_name = '???';
}
return $vs_name;
}
示例7: testInsertLoadAndDeleteCycleWithCaObjectsModel
public function testInsertLoadAndDeleteCycleWithCaObjectsModel()
{
$t_list = new ca_lists();
$va_object_types = $t_list->getItemsForList('object_types');
$this->assertGreaterThan(0, sizeof($va_object_types), "No object types available");
$va_object_types = caExtractValuesByUserLocale($va_object_types);
$this->assertGreaterThan(0, sizeof($va_object_types), "No locale-filtered object types available");
$vn_locale_id = 1;
$t_object = new ca_objects();
$t_object->setMode(ACCESS_WRITE);
$vn_item_id = 0;
foreach ($va_object_types as $va_object_type) {
if (intval($va_object_type['is_enabled']) === 1) {
$vn_item_id = $va_object_type['item_id'];
}
}
$this->assertGreaterThan(0, $vn_item_id, 'No enabled object type found');
$t_object->set('type_id', $vn_item_id);
$t_object->set('locale_id', $vn_locale_id);
$t_object->set('idno', time());
$t_object->addAttribute(array('description' => 'Test description', 'locale_id' => $vn_locale_id), 'description');
$vb_res = $t_object->insert();
$this->assertTrue($vb_res !== false, 'Insert returned non-true value');
// insert() returns false OR the primary key, therefore simply asserting $vb_res being true doesn't cut it
$this->assertEquals($t_object->numErrors(), 0, "Errors on insert: " . join('; ', $t_object->getErrors()));
$this->opa_test_record_ids['ca_objects'][] = $t_object->getPrimaryKey();
$vb_res = $t_object->addLabel(array('name' => 'Unit test object'), $vn_locale_id, null, true);
$this->assertGreaterThan(0, $vb_res, 'AddLabel returned zero value but should return non-zero label_id: ' . join('; ', $t_object->getErrors()));
$t_object2 = new ca_objects();
$vb_res = $t_object2->load($t_object->getPrimaryKey());
$this->assertTrue($vb_res, 'Load of newly created record failed [record does not seem to exist or return row id was invalid?]');
$this->assertEquals($t_object2->getLabelForDisplay(), 'Unit test object', 'Retrieved row label does not match');
$this->assertEquals($t_object2->getAttributesForDisplay('description'), 'Test description', 'Retrieved value for attribute "description" does not match expected value');
// try to search for it
$o_search = new ObjectSearch();
$qr_hits = $o_search->search("Unit test object");
$this->assertGreaterThan(0, $qr_hits->numHits(), 'Search for ca_object by label found no results');
$vb_found_object = false;
while ($qr_hits->nextHit()) {
if ($qr_hits->get('object_id') == $t_object->getPrimaryKey()) {
$vb_found_object = true;
break;
}
}
$this->assertTrue($vb_found_object, 'ca_object was not in returned search results for ca_object by label');
// try delete
$t_object->delete(true, array('hard' => true));
$this->assertEquals($t_object->numErrors(), 0, "Errors on delete: " . join('; ', $t_object->getErrors()));
}
示例8: __call
/**
*
*/
public function __call($ps_function, $pa_args)
{
$ps_function = strtolower($ps_function);
# --- which type of set is configured for display in gallery section
$t_list = new ca_lists();
$vn_gallery_set_type_id = $t_list->getItemIDFromList('set_types', $this->config->get('gallery_set_type'));
$t_set = new ca_sets();
if ($ps_function == "index") {
if ($vn_gallery_set_type_id) {
$va_sets = caExtractValuesByUserLocale($t_set->getSets(array('table' => 'ca_objects', 'checkAccess' => $this->opa_access_values, 'setType' => $vn_gallery_set_type_id)));
$va_set_first_items = $t_set->getFirstItemsFromSets(array_keys($va_sets), array("version" => "icon", "checkAccess" => $this->opa_access_values));
$o_front_config = caGetFrontConfig();
$vs_front_page_set = $o_front_config->get('front_page_set_code');
$vb_omit_front_page_set = (bool) $this->config->get('omit_front_page_set_from_gallery');
foreach ($va_sets as $vn_set_id => $va_set) {
if ($vb_omit_front_page_set && $va_set['set_code'] == $vs_front_page_set) {
unset($va_sets[$vn_set_id]);
}
}
$this->view->setVar('sets', $va_sets);
$this->view->setVar('first_items_from_sets', $va_set_first_items);
}
MetaTagManager::setWindowTitle($this->request->config->get("app_display_name") . ": " . ($this->config->get('gallery_section_name') ? $this->config->get('gallery_section_name') : _t("Gallery")));
$this->render("Gallery/index_html.php");
} else {
$ps_set_id = $ps_function;
$this->view->setVar("set_id", $ps_set_id);
$t_set->load($ps_set_id);
$this->view->setVar("set", $t_set);
$this->view->setVar("label", $t_set->getLabelForDisplay());
$this->view->setVar("description", $t_set->get($this->config->get('gallery_set_description_element_code')));
$this->view->setVar("set_items", caExtractValuesByUserLocale($t_set->getItems(array("thumbnailVersions" => array("icon", "iconlarge"), "checkAccess" => $this->opa_access_values))));
$pn_set_item_id = $this->request->getParameter('set_item_id', pInteger);
if (!in_array($pn_set_item_id, array_keys($t_set->getItemIDs()))) {
$pn_set_item_id = "";
}
$this->view->setVar("set_item_id", $pn_set_item_id);
MetaTagManager::setWindowTitle($this->request->config->get("app_display_name") . ": " . ($this->config->get('gallery_section_name') ? $this->config->get('gallery_section_name') : _t("Gallery")) . ": " . $t_set->getLabelForDisplay());
$this->render("Gallery/detail_html.php");
}
}
示例9: setUp
public function setUp()
{
$t_list = new ca_lists();
// add a minimal object for testing
$va_object_types = $t_list->getItemsForList('object_types', array('idsOnly' => true, 'enabledOnly' => true));
$t_object = new ca_objects();
$t_object->setMode(ACCESS_WRITE);
$t_object->set('type_id', array_shift($va_object_types));
$t_object->insert();
$this->opn_object_id = $t_object->getPrimaryKey();
$this->assertGreaterThan(0, $this->opn_object_id, 'Object should have a primary key after insert');
// add minimal set
$va_set_types = $t_list->getItemsForList('set_types', array('idsOnly' => true, 'enabledOnly' => true));
$t_set = new ca_sets();
$t_set->setMode(ACCESS_WRITE);
$t_set->set('type_id', array_shift($va_set_types));
$t_set->set('table_num', $t_object->tableNum());
$t_set->insert();
$this->opn_set_id = $t_set->getPrimaryKey();
$this->assertGreaterThan(0, $this->opn_set_id, 'Set should have a primary key after insert');
}
示例10: __construct
public function __construct(&$po_request, &$po_response, $pa_view_paths = null)
{
$this->ops_theme = __CA_THEME__;
// get current theme
if (!is_dir(__CA_APP_DIR__ . '/plugins/NovaMuse/themes/' . $this->ops_theme . '/views')) {
// if theme is not defined for this plugin, try to use "default" theme
$this->ops_theme = 'default';
}
parent::__construct($po_request, $po_response, array(__CA_APP_DIR__ . '/plugins/NovaMuse/themes/' . $this->ops_theme . '/views'));
$this->opo_plugin_config = Configuration::load($this->request->getAppConfig()->get('application_plugins') . '/NovaMuse/conf/NovaMuse.conf');
if (!(bool) $this->opo_plugin_config->get('enabled')) {
die(_t('NovaMuse plugin is not enabled'));
}
MetaTagManager::addLink('stylesheet', $po_request->getBaseUrlPath() . "/app/plugins/NovaMuse/themes/" . $this->ops_theme . "/css/memberMap.css", 'text/css');
JavascriptLoadManager::register('maps');
$this->opo_result_context = new ResultContext($po_request, 'ca_entities', 'member_map');
$t_list = new ca_lists();
$this->opn_member_institution_id = $t_list->getItemIDFromList('entity_types', 'member_institution');
$va_access_values = caGetUserAccessValues($this->request);
$this->opa_access_values = $va_access_values;
$this->view->setVar('access_values', $va_access_values);
}
示例11: __construct
public function __construct(&$po_request, &$po_response, $pa_view_paths = null)
{
$this->ops_theme = __CA_THEME__;
// get current theme
if (!is_dir(__CA_APP_DIR__ . '/plugins/eastend/themes/' . $this->ops_theme . '/views')) {
// if theme is not defined for this plugin, try to use "default" theme
$this->ops_theme = 'default';
}
parent::__construct($po_request, $po_response, array(__CA_APP_DIR__ . '/plugins/eastend/themes/' . $this->ops_theme . '/views'));
MetaTagManager::addLink('stylesheet', $po_request->getBaseUrlPath() . "/app/plugins/eastend/themes/" . $this->ops_theme . "/css/eastend.css", 'text/css');
$this->opo_plugin_config = Configuration::load($this->request->getAppConfig()->get('application_plugins') . '/eastend/conf/eastend.conf');
if (!(bool) $this->opo_plugin_config->get('enabled')) {
die(_t('eastend plugin is not enabled'));
}
// redirect user if not logged in
if ($this->request->config->get('pawtucket_requires_login') && !$this->request->isLoggedIn()) {
$this->response->setRedirect(caNavUrl($this->request, "", "LoginReg", "form"));
}
JavascriptLoadManager::register('cycle');
$t_list = new ca_lists();
$this->view->setVar("user_contributed_source_id", $t_list->getItemIDFromList('object_sources', 'user_contributed'));
$this->view->setVar("user_contributed_other_source_id", $t_list->getItemIDFromList('object_sources', 'user_contributed_other'));
}
示例12: setUp
public function setUp()
{
// don't forget to call parent so that request is set up correctly
parent::setUp();
// search subject table
$this->setPrimaryTable('ca_objects');
/**
* @see http://docs.collectiveaccess.org/wiki/Web_Service_API#Creating_new_records
* @see https://gist.githubusercontent.com/skeidel/3871797/raw/item_request.json
*/
$this->assertGreaterThan(0, $this->addTestRecord('ca_objects', array('intrinsic_fields' => array('type_id' => 'image', 'access' => 1, 'status' => 4))));
$vn_image_type_id = ca_lists::getItemID('object_types', 'image');
// search queries
$this->setSearchQueries(array('ca_objects.type_id:"image"' => 1, 'ca_objects.type_id:image' => 1, 'ca_objects.type_id:"' . $vn_image_type_id . '"' => 1, 'ca_objects.type_id:' . $vn_image_type_id => 1, 'ca_objects.type_id:"' . ($vn_image_type_id - 1) . '"' => 0, 'ca_objects.status:4' => 1, 'ca_objects.status:"4"' => 1, 'ca_objects.status:44' => 0, 'ca_objects.status:"44"' => 0, 'ca_objects.access:1' => 1, 'ca_objects.access:"1"' => 1, 'ca_objects.access:0' => 0, 'ca_objects.access:"0"' => 0, 'ca_objects.is_deaccessioned:"0"' => 1, 'ca_objects.is_deaccessioned:0' => 1));
}
示例13: caProcessRefineryParents
//.........这里部分代码省略.........
$o_log->logError(_t('[%3] Error processing rule "%1" as an error occurred. Error number was "%2"', $va_rule['trigger'], ExpressionParser::$s_last_error, $ps_refinery_name));
}
}
}
$va_match_on = caGetOption("{$ps_refinery_name}_dontMatchOnLabel", $pa_item['settings'], false) ? array('idno') : array('idno', 'label');
$pa_options = array_merge(array('matchOn' => $va_match_on), $pa_options);
switch ($ps_table) {
case 'ca_objects':
$vn_id = DataMigrationUtils::getObjectID($vs_name, $vn_id, $vs_type, $g_ui_locale_id, $va_attributes, $pa_options);
$va_attributes['preferred_labels']['name'] = $va_attributes['_preferred_labels'] = $vs_name;
break;
case 'ca_entities':
$vn_id = DataMigrationUtils::getEntityID($va_entity_label = DataMigrationUtils::splitEntityName($vs_name, $pa_options), $vs_type, $g_ui_locale_id, $va_attributes, $pa_options);
$va_attributes['preferred_labels'] = $va_entity_label;
$va_attributes['_preferred_labels'] = $vs_name;
break;
case 'ca_places':
if (!$vn_id) {
// get place hierarchy root
require_once __CA_MODELS_DIR__ . "/ca_places.php";
$t_place = new ca_places();
if ($o_trans) {
$t_place->setTransaction($o_trans);
}
$vn_id = $pa_options['defaultParentID'];
if (!$vn_id) {
$vn_id = $t_place->getHierarchyRootID($pa_options['hierarchyID']);
}
$va_attributes['parent_id'] = $vn_id;
}
$vn_id = DataMigrationUtils::getPlaceID($vs_name, $vn_id, $vs_type, $g_ui_locale_id, $va_attributes, $pa_options);
$va_attributes['preferred_labels']['name'] = $va_attributes['_preferred_labels'] = $vs_name;
break;
case 'ca_occurrences':
$vn_id = DataMigrationUtils::getOccurrenceID($vs_name, $vn_id, $vs_type, $g_ui_locale_id, $va_attributes, $pa_options);
$va_attributes['preferred_labels']['name'] = $va_attributes['_preferred_labels'] = $vs_name;
break;
case 'ca_collections':
$vn_id = DataMigrationUtils::getCollectionID($vs_name, $vs_type, $g_ui_locale_id, $va_attributes, $pa_options);
$va_attributes['preferred_labels']['name'] = $va_attributes['_preferred_labels'] = $vs_name;
break;
case 'ca_loans':
$vn_id = DataMigrationUtils::getLoanID($vs_name, $vs_type, $g_ui_locale_id, $va_attributes, $pa_options);
$va_attributes['preferred_labels']['name'] = $va_attributes['_preferred_labels'] = $vs_name;
break;
case 'ca_movements':
$vn_id = DataMigrationUtils::getMovementID($vs_name, $vs_type, $g_ui_locale_id, $va_attributes, $pa_options);
$va_attributes['preferred_labels']['name'] = $va_attributes['_preferred_labels'] = $vs_name;
break;
case 'ca_list_items':
if (!$vn_list_id) {
if ($o_log) {
$o_log->logDebug(_t('[importHelpers:caProcessRefineryParents] List was not specified'));
}
return null;
}
if (!$vn_id) {
// get place hierarchy root
require_once __CA_MODELS_DIR__ . "/ca_lists.php";
$t_list = new ca_lists();
if ($o_trans) {
$t_list->setTransaction($o_trans);
}
$vn_id = $t_list->getRootItemIDForList($vn_list_id);
$va_attributes['parent_id'] = $vn_id;
}
$vn_id = DataMigrationUtils::getListItemID($vn_list_id, $vs_name, $vs_type, $g_ui_locale_id, $va_attributes, $pa_options);
$va_attributes['preferred_labels']['name_singular'] = $va_attributes['preferred_labels']['name_plural'] = $vs_name;
break;
case 'ca_storage_locations':
if (!$vn_id) {
// get storage location hierarchy root
require_once __CA_MODELS_DIR__ . "/ca_storage_locations.php";
$t_loc = new ca_storage_locations();
if ($o_trans) {
$t_loc->setTransaction($o_trans);
}
$vn_id = $t_loc->getHierarchyRootID();
$va_attributes['parent_id'] = $vn_id;
}
$vn_id = DataMigrationUtils::getStorageLocationID($vs_name, $vn_id, $vs_type, $g_ui_locale_id, $va_attributes, $pa_options);
$va_attributes['preferred_labels']['name'] = $va_attributes['_preferred_labels'] = $vs_name;
break;
default:
if ($o_log) {
$o_log->logDebug(_t('[importHelpers:caProcessRefineryParents] Invalid table %1', $ps_table));
}
return null;
break;
}
$va_attributes['locale_id'] = $g_ui_locale_id;
if ($o_log) {
$o_log->logDebug(_t('[%6] Got parent %1 (%2) with id %3 and type %4 for %5', $vs_name, $vs_idno, $vn_id, $vs_type, $vs_name, $ps_refinery_name));
}
}
if ($vb_hierarchy_mode) {
return $va_attributes;
}
return $vn_id;
}
示例14: getRelatedItems
//.........这里部分代码省略.........
foreach ($va_get_where as $vs_fld => $vm_val) {
if ($t_rel_item->hasField($vs_fld)) {
$va_wheres[] = "({$vs_related_table_name}.{$vs_fld} = " . (!is_numeric($vm_val) ? "'" . $this->getDb()->escape($vm_val) . "'" : $vm_val) . ")";
}
}
}
if ($vs_idno_fld = $t_rel_item->getProperty('ID_NUMBERING_ID_FIELD')) {
$va_selects[] = "{$vs_related_table}.{$vs_idno_fld}";
}
if ($vs_idno_sort_fld = $t_rel_item->getProperty('ID_NUMBERING_SORT_FIELD')) {
$va_selects[] = "{$vs_related_table}.{$vs_idno_sort_fld}";
}
$va_selects[] = $va_path[1] . '.' . $vs_key;
if (isset($pa_options['fields']) && is_array($pa_options['fields'])) {
$va_selects = array_merge($va_selects, $pa_options['fields']);
}
if (isset($pa_options['checkAccess']) && is_array($pa_options['checkAccess']) && sizeof($pa_options['checkAccess']) && $t_rel_item->hasField('access')) {
$va_wheres[] = "({$vs_related_table}.access IN (" . join(',', $pa_options['checkAccess']) . "))";
}
if ((!isset($pa_options['showDeleted']) || !$pa_options['showDeleted']) && $t_rel_item->hasField('deleted')) {
$va_wheres[] = "({$vs_related_table}.deleted = 0)";
}
if (($va_criteria = isset($pa_options['criteria']) ? $pa_options['criteria'] : null) && is_array($va_criteria) && sizeof($va_criteria)) {
$va_wheres[] = "(" . join(" AND ", $va_criteria) . ")";
}
$va_wheres[] = "(" . $this->tableName() . '.' . $this->primaryKey() . " IN (" . join(",", $va_row_ids) . "))";
$va_selects[] = $t_rel_item->tableName() . ".*";
$vs_cur_table = array_shift($va_path);
$va_joins = array();
// Enforce restrict_to_lists for related list items
if ($vs_related_table_name == 'ca_list_items' && is_array($pa_options['restrictToLists'])) {
$va_list_ids = array();
foreach ($pa_options['restrictToLists'] as $vm_list) {
if ($vn_list_id = ca_lists::getListID($vm_list)) {
$va_list_ids[] = $vn_list_id;
}
}
if (sizeof($va_list_ids)) {
$va_wheres[] = "(ca_list_items.list_id IN (" . join(",", $va_list_ids) . "))";
}
}
foreach ($va_path as $vs_join_table) {
$va_rel_info = $this->getAppDatamodel()->getRelationships($vs_cur_table, $vs_join_table);
$va_joins[] = 'INNER JOIN ' . $vs_join_table . ' ON ' . $vs_cur_table . '.' . $va_rel_info[$vs_cur_table][$vs_join_table][0][0] . ' = ' . $vs_join_table . '.' . $va_rel_info[$vs_cur_table][$vs_join_table][0][1] . "\n";
$vs_cur_table = $vs_join_table;
}
// If we're getting ca_set_items, we have to rename the intrinsic row_id field because the pk is named row_id below. Hence, this hack.
if ($vs_related_table_name == 'ca_set_items') {
$va_selects[] = 'ca_set_items.row_id AS record_id';
}
$va_selects[] = $this->tableName() . '.' . $this->primaryKey() . ' AS row_id';
$vs_order_by = '';
if ($t_item_rel && $t_item_rel->hasField('rank')) {
$vs_order_by = ' ORDER BY ' . $t_item_rel->tableName() . '.rank';
} else {
if ($t_rel_item && ($vs_sort = $t_rel_item->getProperty('ID_NUMBERING_SORT_FIELD'))) {
$vs_order_by = " ORDER BY {$vs_related_table}.{$vs_sort}";
}
}
$vs_sql = "\n\t\t\tSELECT DISTINCT " . join(', ', $va_selects) . "\n\t\t\tFROM " . $this->tableName() . "\n\t\t\t" . join("\n", array_merge($va_joins, $va_joins_post_add)) . "\n\t\t\tWHERE\n\t\t\t\t" . join(' AND ', $va_wheres) . "\n\t\t\t{$vs_order_by}\n\t\t";
$qr_res = $o_db->query($vs_sql);
$va_rels = array();
$vn_c = 0;
if ($vn_start > 0) {
$qr_res->seek($vn_start);
}
示例15: getItemInfoForImport
/**
* Get a record summary that is easier to parse when importing to another system
*/
private function getItemInfoForImport()
{
if (!($t_instance = $this->_getTableInstance($this->ops_table, $this->opn_id))) {
return false;
}
$o_dm = Datamodel::load();
$t_list = new ca_lists();
$t_locales = new ca_locales();
//
// Options
//
if (!($vs_delimiter = $this->opo_request->getParameter('delimiter', pString))) {
$vs_delimiter = "; ";
}
if (!($vs_flatten = $this->opo_request->getParameter('flatten', pString))) {
$vs_flatten = null;
}
$va_flatten = preg_split("![ ]*[;]+[ ]*!", $vs_flatten);
$va_flatten = array_flip($va_flatten);
$va_locales = $t_locales->getLocaleList(array("available_for_cataloguing_only" => true));
$va_return = array();
// allow user-defined template to be passed; allows flexible formatting of returned "display" value
if (!($vs_template = $this->opo_request->getParameter('template', pString))) {
$vs_template = '';
}
if ($vs_template) {
$va_return['display'] = caProcessTemplateForIDs($vs_template, $this->ops_table, array($this->opn_id));
}
// "intrinsic" fields
foreach ($t_instance->getFieldsArray() as $vs_field_name => $va_field_info) {
$vs_list = null;
if (!is_null($vs_val = $t_instance->get($vs_field_name))) {
if (preg_match("/^hier\\_/", $vs_field_name)) {
continue;
}
if (preg_match("/\\_sort\$/", $vs_field_name)) {
continue;
}
if ($vs_field_name == $t_instance->primaryKey()) {
continue;
}
if (isset($va_field_info["LIST_CODE"])) {
// typical example: type_id
$va_item = $t_list->getItemFromListByItemID($va_field_info["LIST_CODE"], $vs_val);
if ($t_item = new ca_list_items($va_item["item_id"])) {
$vs_val = $t_item->get('idno');
}
}
$va_return['intrinsic'][$vs_field_name] = $vs_val;
}
}
// preferred labels
$va_labels = $t_instance->get($this->ops_table . ".preferred_labels", array("returnAllLocales" => true));
$va_labels = end($va_labels);
$vs_display_field_name = $t_instance->getLabelDisplayField();
if (is_array($va_labels)) {
foreach ($va_labels as $vn_locale_id => $va_labels_by_locale) {
foreach ($va_labels_by_locale as $va_tmp) {
$va_label = array();
$va_label['locale'] = $va_locales[$vn_locale_id]["code"];
// add only UI fields to return
foreach (array_merge($t_instance->getLabelUIFields(), array('type_id')) as $vs_label_fld) {
$va_label[$vs_label_fld] = $va_tmp[$vs_label_fld];
}
$va_label[$vs_label_fld] = $va_tmp[$vs_label_fld];
$va_label['label'] = $va_tmp[$vs_display_field_name];
$va_return["preferred_labels"][$va_label['locale']] = $va_label;
}
}
if (isset($va_flatten['locales'])) {
$va_return["preferred_labels"] = array_pop(caExtractValuesByUserLocale(array($va_return["preferred_labels"])));
}
}
// nonpreferred labels
$va_labels = $t_instance->get($this->ops_table . ".nonpreferred_labels", array("returnAllLocales" => true));
$va_labels = end($va_labels);
if (is_array($va_labels)) {
foreach ($va_labels as $vn_locale_id => $va_labels_by_locale) {
foreach ($va_labels_by_locale as $va_tmp) {
$va_label = array();
$va_label['locale'] = $va_locales[$vn_locale_id]["code"];
// add only UI fields to return
foreach (array_merge($t_instance->getLabelUIFields(), array('type_id')) as $vs_label_fld) {
$va_label[$vs_label_fld] = $va_tmp[$vs_label_fld];
}
$va_return["nonpreferred_labels"][$va_label['locale']] = $va_label;
}
}
if (isset($va_flatten['locales'])) {
$va_return["nonpreferred_labels"] = array_pop(caExtractValuesByUserLocale(array($va_return["nonpreferred_labels"])));
}
}
// attributes
$va_codes = $t_instance->getApplicableElementCodes();
foreach ($va_codes as $vs_code) {
if ($va_vals = $t_instance->get($this->ops_table . "." . $vs_code, array("convertCodesToDisplayText" => false, "returnAllLocales" => true))) {
$va_vals_as_text = end($t_instance->get($this->ops_table . "." . $vs_code, array("convertCodesToDisplayText" => true, "returnAllLocales" => true)));
//.........这里部分代码省略.........