本文整理汇总了PHP中ca_lists::set方法的典型用法代码示例。如果您正苦于以下问题:PHP ca_lists::set方法的具体用法?PHP ca_lists::set怎么用?PHP ca_lists::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ca_lists
的用法示例。
在下文中一共展示了ca_lists::set方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetchAndImport
private function fetchAndImport($pa_item_queue, $po_client, $pa_config, $pa_tables, $ps_code)
{
if (!is_array($pa_tables)) {
$pa_tables = array();
}
$t_rel_type = new ca_relationship_types();
$vs_base_url = $pa_config['baseUrl'];
$o_dm = Datamodel::load();
$t_locale = new ca_locales();
$t_list = new ca_lists();
$vn_source_id = $t_list->getItemIDFromList('object_sources', $pa_config['code']);
$pn_rep_type_id = $t_list->getItemIDFromList('object_representation_types', 'front');
foreach ($pa_item_queue as $vn_i => $va_item) {
$vs_table = $va_item['table'];
$va_import_relationships_from = $pa_config['importRelatedFor'][$va_item['table']];
print "oo";
print_r($va_import_relationships_from);
$vn_id = $va_item['id'];
if (!$vn_id) {
print "[Notice] SKIP CAUSE NO ID ({$ps_code})\n";
continue;
}
if (isset($this->opa_processed_records[$vs_table . '/' . $vn_id])) {
continue;
}
$vs_idno = trim((string) $va_item['idno']);
try {
$o_xml = $po_client->getItem($vs_table, $vn_id)->get();
} catch (exception $e) {
print "[ERROR] While trying to get item information: " . $e->getMessage() . "\n";
continue;
}
$o_item = $o_xml->getItem;
$t_instance = $o_dm->getInstanceByTableName($vs_table, false);
$t_instance_label = $t_instance->getLabelTableInstance();
// Look for existing record
$vb_skip = false;
$vb_update = false;
$vs_label_fld = $t_instance->getLabelDisplayField();
$vs_label = (string) $o_item->preferred_labels->en_US->{$vs_label_fld};
print "[Notice] Processing [{$vs_table}] {$vs_label} [{$vs_idno}] ({$ps_code})\n";
$t_instance_label->clear();
if ($vs_idno && ($vs_table == 'ca_objects' && $t_instance->load(array('idno' => $vs_idno)) || $vs_table != 'ca_objects' && $t_instance->load(array('idno' => $vs_idno)))) {
if ($t_instance->hasField('deleted') && $t_instance->get('deleted') == 1) {
$t_instance->set('deleted', 0);
}
//print "[Notice] Update [{$vs_idno}] for {$vs_table} 'cause it already exists ({$ps_code})\n";
if (!$t_instance->getPrimaryKey()) {
$vb_skip = true;
print "[ERROR] Could not load instance for [{$vs_idno}]\n";
}
$vb_update = true;
$t_instance->setMode(ACCESS_WRITE);
// Clear labels
$t_instance->removeAllLabels();
if ($t_instance->numErrors()) {
print "[ERROR] Could not remove labels for updating: " . join("; ", $t_instance->getErrors()) . "\n";
}
// Clear attributes
$t_instance->removeAttributes(null, array('dontCheckMinMax' => true));
if ($t_instance->numErrors()) {
print "[ERROR] Could not remove attributes for updating: " . join("; ", $t_instance->getErrors()) . "\n";
}
// Clear relationships
if (is_array($va_import_relationships_from)) {
foreach ($va_import_relationships_from as $vs_rel_table => $va_table_info) {
$t_instance->removeRelationships($vs_rel_table);
if ($t_instance->numErrors()) {
print "[ERROR] Could not remove {$vs_rel_table} relationships for updating: " . join("; ", $t_instance->getErrors()) . "\n";
}
}
}
if ($t_instance->tableName() == 'ca_objects') {
//$t_instance->set('source_id', $vn_source_id);
}
$t_instance->update();
if ($t_instance->numErrors()) {
print "[ERROR] Could not clear record for updating: " . join("; ", $t_instance->getErrors()) . "\n";
}
}
// create new one
if (!$vb_update) {
$t_instance->clear();
if ($t_instance->tableName() == 'ca_objects') {
//$t_instance->set('source_id', $vn_source_id);
}
}
$t_instance->setMode(ACCESS_WRITE);
// add intrinsics
switch ($vs_table) {
case 'ca_collections':
$va_intrinsics = array('status', 'access', 'idno');
break;
case 'ca_occurrences':
$va_intrinsics = array('status', 'access', 'idno');
break;
case 'ca_objects':
$va_intrinsics = array('status', 'access', 'idno');
break;
case 'ca_entities':
//.........这里部分代码省略.........
示例2: die
require_once __CA_MODELS_DIR__ . '/ca_list_items_x_list_items.php';
require_once __CA_MODELS_DIR__ . '/ca_relationship_types.php';
$_ = new Zend_Translate('gettext', __CA_APP_DIR__ . '/locale/en_US/messages.mo', 'en_US');
$t_locale = new ca_locales();
$pn_en_locale_id = $t_locale->loadLocaleByCode('en_US');
if (!($pn_nl_locale_id = $t_locale->loadLocaleByCode('nl_NL'))) {
$pn_nl_locale_id = $t_locale->loadLocaleByCode('nl_BE');
}
if (!$pn_nl_locale_id) {
die("ERROR: You can only import the Dutch-language AAT into an installation configured to support the nl_NL (Netherlands) or nl_BE (Vlaams Belgium) locale. Add one of these locales to your system and try again.\n");
}
// create vocabulary list record (if it doesn't exist already)
$t_list = new ca_lists();
if (!$t_list->load(array('list_code' => 'aat_nl'))) {
$t_list->setMode(ACCESS_WRITE);
$t_list->set('list_code', 'aat_nl');
$t_list->set('is_system_list', 0);
$t_list->set('is_hierarchical', 1);
$t_list->set('use_as_vocabulary', 1);
$t_list->insert();
if ($t_list->numErrors()) {
print "ERROR: couldn't create ca_list row for AAT: " . join('; ', $t_list->getErrors()) . "\n";
die;
}
$t_list->addLabel(array('name' => 'Art & Architecture Thesaurus [Nederlands]'), $pn_en_locale_id, null, true);
}
$vn_list_id = $t_list->getPrimaryKey();
// get list item types (should be defined by base installation profile [base.profile])
// if your installation didn't use a profile inheriting from base.profile then you should make sure
// that a list with code='list_item_types' is defined and the following four item codes are defined.
// If these are not defined then the AAT will still import, but without any distinction between
示例3: join
$t_list->addLabel(array('name' => 'Place hierarchies'), $pn_en_locale_id, null, true);
}
$vn_list_id = $t_list->getPrimaryKey();
// create place hierarchy
if (!($vn_tgn_id = caGetListItemID('place_hierarchies', 'tgn'))) {
$t_tgn = $t_list->addItem('tgn', true, false, null, null, 'tgn');
$t_tgn->addLabel(array('name_singular' => 'Thesaurus of Geographic Names', 'name_plural' => 'Thesaurus of Geographic Names'), $pn_en_locale_id, null, true);
$vn_tgn_id = $t_tgn->getPrimaryKey();
} else {
$t_tgn = new ca_list_items($vn_tgn_id);
}
// Create list for place types (if it doesn't exist already)
$t_place_types = new ca_lists();
if (!$t_place_types->load(array('list_code' => 'tgn_place_types'))) {
$t_place_types->setMode(ACCESS_WRITE);
$t_place_types->set('list_code', 'tgn_place_types');
$t_place_types->set('is_system_list', 1);
$t_place_types->set('is_hierarchical', 1);
$t_place_types->set('use_as_vocabulary', 1);
$t_place_types->insert();
if ($t_place_types->numErrors()) {
print "[Error] couldn't create ca_list row for place types: " . join('; ', $t_place_types->getErrors()) . "\n";
die;
}
$t_place_types->addLabel(array('name' => 'Getty TGN place types'), $pn_en_locale_id, null, true);
}
$vn_place_type_list_id = $t_place_types->getPrimaryKey();
// load places
$o_xml = new XMLReader();
print "[Notice] READING TGN TERMS...\n";
$vn_last_message_length = 0;
示例4: refine
/**
*
*/
public function refine(&$pa_destination_data, $pa_group, $pa_item, $pa_source_data, $pa_options = null)
{
global $g_ui_locale_id;
$vs_delimiter = caGetOption('delimiter', $pa_options, null);
if (!($pn_locale_id = ca_locales::getDefaultCataloguingLocaleID())) {
$pn_locale_id = $g_ui_locale_id;
}
$o_log = isset($pa_options['log']) && is_object($pa_options['log']) ? $pa_options['log'] : null;
$t_mapping = caGetOption('mapping', $pa_options, null);
if ($t_mapping) {
$o_dm = Datamodel::load();
if ($t_mapping->get('table_num') != $o_dm->getTableNum('ca_list_items')) {
if ($o_log) {
$o_log->logError(_t("listItemIndentedHierarchyBuilder refinery may only be used in imports to ca_list_items"));
}
return null;
}
}
$va_group_dest = explode(".", $pa_group['destination']);
$vs_terminal = array_pop($va_group_dest);
$pm_value = $pa_source_data[$pa_item['source']];
// Get list of fields to insert
if (!is_array($va_levels = $pa_item['settings']['listItemIndentedHierarchyBuilder_levels'])) {
if ($o_log) {
$o_log->logError(_t("listItemIndentedHierarchyBuilder requires levels option be set to a list of data source placeholders"));
}
return null;
} else {
$va_level_types = $pa_item['settings']['listItemIndentedHierarchyBuilder_levelTypes'];
}
// Get list, or create if it doesn't already exist
if (!($vs_list_code = $pa_item['settings']['listItemIndentedHierarchyBuilder_list'])) {
if ($o_log) {
$o_log->logError(_t("listItemIndentedHierarchyBuilder requires list option be set"));
}
return null;
}
$t_list = new ca_lists();
if (!$t_list->load(array('list_code' => $vs_list_code))) {
// create list
$t_list->set('list_code', $vs_list_code);
$t_list->setMode(ACCESS_WRITE);
$t_list->insert();
if ($t_list->numErrors()) {
if ($o_log) {
$o_log->logError(_t("listItemIndentedHierarchyBuilder could not create list %1: %2", $vs_list_code, join("; ", $t_list->getErrors())));
}
return null;
}
$t_list->addLabel(array('name' => caUcFirstUTF8Safe($vs_list_code)), $pn_locale_id, null, true);
if ($t_list->numErrors()) {
if ($o_log) {
$o_log->logError(_t("listItemIndentedHierarchyBuilder could not create list label %1: %2", $vs_list_code, join("; ", $t_list->getErrors())));
}
return null;
}
}
// Handle each level
if (!is_array($va_level_values = listItemIndentedHierarchyBuilderRefinery::$opa_level_values)) {
$va_level_values = $va_level_value_ids = array();
}
$va_level_value_ids = listItemIndentedHierarchyBuilderRefinery::$opa_level_value_ids;
$vn_max_level = 0;
$vn_parent_id = null;
foreach ($va_levels as $vn_i => $vs_level_placeholder) {
$vs_level_value = null;
if (strlen($vs_level_placeholder)) {
if ($vs_level_value = BaseRefinery::parsePlaceholder($vs_level_placeholder, $pa_source_data, $pa_item, 0, array('reader' => caGetOption('reader', $pa_options, null), 'returnAsString' => true))) {
if (!$vn_parent_id && isset(listItemIndentedHierarchyBuilderRefinery::$opa_level_value_ids[$vn_i - 1])) {
$vn_parent_id = listItemIndentedHierarchyBuilderRefinery::$opa_level_value_ids[$vn_i - 1];
}
$vs_type = isset($va_level_types[$vn_i]) ? $va_level_types[$vn_i] : null;
if ($vn_item_id = DataMigrationUtils::getListItemID($vs_list_code, preg_replace("![^A-Za-z0-9_]+!", "_", $vs_level_value), $vs_type, $pn_locale_id, array('is_enabled' => 1, 'parent_id' => $vn_parent_id, 'preferred_labels' => array('name_singular' => $vs_level_value, 'name_plural' => $vs_level_value)), array('matchOnIdno' => true, 'log' => $o_log, 'transaction' => caGetOption('transaction', $pa_options, null), 'importEvent' => caGetOption('event', $pa_options, null), 'importEventSource' => 'listItemIndentedHierarchyBuilder'))) {
$vn_parent_id = $vn_item_id;
$va_level_values[$vn_i] = $vs_level_value;
$va_level_value_ids[$vn_i] = $vn_item_id;
$vn_max_level = $vn_i;
}
}
}
}
listItemIndentedHierarchyBuilderRefinery::$opa_level_values = array_slice($va_level_values, 0, $vn_max_level + 1);
listItemIndentedHierarchyBuilderRefinery::$opa_level_value_ids = array_slice($va_level_value_ids, 0, $vn_max_level + 1);
if ($pa_item['settings']['listItemIndentedHierarchyBuilder_list'] == 'returnData') {
return $vn_parent_id;
}
return null;
}
示例5: caLoadULAN
/**
*
*
* @return string
*/
function caLoadULAN($ps_path_to_ulan_data = null, $ps_path_to_ulan_config = null, $pa_options = null)
{
require_once __CA_LIB_DIR__ . '/core/Db.php';
require_once __CA_LIB_DIR__ . '/core/Configuration.php';
require_once __CA_LIB_DIR__ . '/ca/Utils/DataMigrationUtils.php';
require_once __CA_MODELS_DIR__ . '/ca_locales.php';
require_once __CA_MODELS_DIR__ . '/ca_entities.php';
require_once __CA_MODELS_DIR__ . '/ca_entities_x_entities.php';
require_once __CA_MODELS_DIR__ . '/ca_lists.php';
require_once __CA_MODELS_DIR__ . '/ca_list_items.php';
require_once __CA_MODELS_DIR__ . '/ca_list_items_x_list_items.php';
require_once __CA_MODELS_DIR__ . '/ca_relationship_types.php';
$t = new Timer();
$o_log = new KLogger(__CA_APP_DIR__ . '/log', KLogger::INFO);
$va_parent_child_links = array();
$va_item_item_links = array();
$va_ulan_id_to_item_id = array();
$o_log->logInfo("Starting import of Getty ULAN");
define('__CA_DONT_DO_SEARCH_INDEXING__', true);
$_ = new Zend_Translate('gettext', __CA_APP_DIR__ . '/locale/en_US/messages.mo', 'en_US');
$t_locale = new ca_locales();
$pn_en_locale_id = $t_locale->loadLocaleByCode('en_US');
if (!($o_config = Configuration::load($ps_path_to_ulan_config))) {
$o_log->logError("Could not load ULAN import configuration file");
die("ERROR: Could not load ULAN import configuration\n");
}
$vs_ulan_import_mode = $o_config->get('ulan_import_target');
$t_list = null;
if ($vs_ulan_import_mode == 'ca_entities') {
$va_ulan_types = $o_config->getAssoc('ulan_entity_types');
$va_mapping = $o_config->getAssoc('ulan_entity_mapping');
} elseif ($vs_ulan_import_mode == 'ca_list_items') {
$va_ulan_types = $o_config->getAssoc('ulan_list_item_types');
if (!($vs_ulan_list_code = $o_config->get('ulan_import_list'))) {
$vs_ulan_list_code = 'ULAN';
}
// create vocabulary list record (if it doesn't exist already)
$t_list = new ca_lists();
if (!$t_list->load(array('list_code' => $vs_ulan_list_code))) {
$t_list->setMode(ACCESS_WRITE);
$t_list->set('list_code', $vs_ulan_list_code);
$t_list->set('is_system_list', 0);
$t_list->set('is_hierarchical', 1);
$t_list->set('use_as_vocabulary', 1);
$t_list->insert();
if ($t_list->numErrors()) {
$o_log->logError("Could not create list record for ULAN: " . join('; ', $t_list->getErrors()));
die("ERROR: couldn't create ca_list row for ULAN: " . join('; ', $t_list->getErrors()) . "\n");
}
$t_list->addLabel(array('name' => 'Union List of Artist Names'), $pn_en_locale_id, null, true);
}
$vn_list_id = $t_list->getPrimaryKey();
$va_mapping = $o_config->getAssoc('ulan_list_item_mapping');
} else {
$o_log->logError("Invalid ULAN import mode {$vs_ulan_import_mode}");
die("ERROR: invalid ULAN import mode {$vs_ulan_import_mode}\n");
}
$vn_last_message_length = 0;
$vn_term_count = 0;
$va_subject = array();
foreach (array('ULAN1.xml', 'ULAN2.xml', 'ULAN3.xml') as $vs_file) {
if (!$ps_path_to_ulan_data) {
$ps_path_to_ulan_data = ".";
}
if (!file_exists($ps_path_to_ulan_data . "/{$vs_file}")) {
$o_log->logError("Could not find ULAN data file {$vs_file}");
print "[ERROR] cannot find ULAN data.\n";
continue;
}
$o_log->logInfo("Processing ULAN file {$vs_file}");
print "[Notice] Processing ULAN file {$vs_file}\n";
// load
$o_xml = new XMLReader();
$o_xml->open($ps_path_to_ulan_data . '/' . $vs_file);
while ($o_xml->read()) {
switch ($o_xml->name) {
# ---------------------------
case 'Subject':
if ($o_xml->nodeType == XMLReader::END_ELEMENT) {
if (in_array($va_subject['subject_id'], array('500000000', '500000001'))) {
break;
}
// skip top-level root
$vs_preferred_term = $va_subject['preferred_term'];
$pb_is_enabled = false;
switch ($va_subject['record_type']) {
case 'Person':
default:
$vn_type_id = $va_ulan_types['Person'];
$pb_is_enabled = true;
break;
case 'Corporate Body':
$vn_type_id = $va_ulan_types['Corporate Body'];
$pb_is_enabled = true;
break;
//.........这里部分代码省略.........
示例6: caLoadAAT
/**
*
*
* @return string
*/
function caLoadAAT($ps_path_to_aat_data = null, $pa_options = null)
{
if (!$ps_path_to_aat_data) {
$ps_path_to_aat_data = "./AAT.xml";
}
if (!file_exists($ps_path_to_aat_data)) {
die("ERROR: cannot find AAT data.\n");
}
require_once __CA_LIB_DIR__ . '/core/Db.php';
require_once __CA_MODELS_DIR__ . '/ca_locales.php';
require_once __CA_MODELS_DIR__ . '/ca_lists.php';
require_once __CA_MODELS_DIR__ . '/ca_list_items.php';
require_once __CA_MODELS_DIR__ . '/ca_list_items_x_list_items.php';
require_once __CA_MODELS_DIR__ . '/ca_relationship_types.php';
$_ = new Zend_Translate('gettext', __CA_APP_DIR__ . '/locale/en_US/messages.mo', 'en_US');
$t_locale = new ca_locales();
$pn_en_locale_id = $t_locale->loadLocaleByCode('en_US');
// create vocabulary list record (if it doesn't exist already)
$t_list = new ca_lists();
if (!$t_list->load(array('list_code' => 'aat'))) {
$t_list->setMode(ACCESS_WRITE);
$t_list->set('list_code', 'aat');
$t_list->set('is_system_list', 0);
$t_list->set('is_hierarchical', 1);
$t_list->set('use_as_vocabulary', 1);
$t_list->insert();
if ($t_list->numErrors()) {
print "ERROR: couldn't create ca_list row for AAT: " . join('; ', $t_list->getErrors()) . "\n";
die;
}
$t_list->addLabel(array('name' => 'Art & Architecture Thesaurus'), $pn_en_locale_id, null, true);
}
$vn_list_id = $t_list->getPrimaryKey();
// get list item types (should be defined by base installation profile [base.profile])
// if your installation didn't use a profile inheriting from base.profile then you should make sure
// that a list with code='list_item_types' is defined and the following four item codes are defined.
// If these are not defined then the AAT will still import, but without any distinction between
// terms, facets and guide terms
$vn_list_item_type_concept = $t_list->getItemIDFromList('list_item_types', 'concept');
$vn_list_item_type_facet = $t_list->getItemIDFromList('list_item_types', 'facet');
$vn_list_item_type_guide_term = $t_list->getItemIDFromList('list_item_types', 'guide_term');
$vn_list_item_type_hierarchy_name = $t_list->getItemIDFromList('list_item_types', 'hierarchy_name');
// get list item label types (should be defined by base installation profile [base.profile])
// if your installation didn't use a profile inheriting from base.profile then you should make sure
// that a list with code='list_item_label_types' is defined and the following four item codes are defined.
// If these are not defined then the AAT will still import, but without any distinction between
// terms, facets and guide terms
$vn_list_item_label_type_uf = $t_list->getItemIDFromList('list_item_label_types', 'uf');
$vn_list_item_label_type_alt = $t_list->getItemIDFromList('list_item_label_types', 'alt');
// get list item-to-item relationship type (should be defined by base installation profile [base.profile])
// if your installation didn't use a profile inheriting from base.profile then you should make sure
// that a ca_list_items_x_list_items relationship type with code='related' is defined. Otherwise import of term-to-term
// relationships will fail.
$t_rel_types = new ca_relationship_types();
$vn_list_item_relation_type_id_related = $t_rel_types->getRelationshipTypeID('ca_list_items_x_list_items', 'related');
// load voc_terms
$o_xml = new XMLReader();
$o_xml->open($ps_path_to_aat_data);
print "READING AAT TERMS...\n";
$va_parent_child_links = array();
$va_item_item_links = array();
$va_aat_id_to_item_id = array();
$vn_last_message_length = 0;
$va_subject = array();
$vn_term_count = 0;
while ($o_xml->read()) {
switch ($o_xml->name) {
# ---------------------------
case 'Subject':
if ($o_xml->nodeType == XMLReader::END_ELEMENT) {
if ($va_subject['subject_id'] == '300000000') {
break;
}
// skip top-level root
$vs_preferred_term = $va_subject['preferred_term'];
switch ($va_subject['record_type']) {
case 'Concept':
$vn_type_id = $vn_list_item_type_hierarchy_name;
$pb_is_enabled = true;
break;
case 'Facet':
$vn_type_id = $vn_list_item_type_facet;
$vs_preferred_term = '<' . $vs_preferred_term . '>';
$pb_is_enabled = false;
break;
case 'Guide Term':
$vn_type_id = $vn_list_item_type_guide_term;
$vs_preferred_term = '<' . $vs_preferred_term . '>';
$pb_is_enabled = false;
break;
case 'Hierarchy Name':
$vn_type_id = $vn_list_item_type_hierarchy_name;
$pb_is_enabled = false;
break;
default:
//.........这里部分代码省略.........