当前位置: 首页>>代码示例>>PHP>>正文


PHP ca_list_items::setMode方法代码示例

本文整理汇总了PHP中ca_list_items::setMode方法的典型用法代码示例。如果您正苦于以下问题:PHP ca_list_items::setMode方法的具体用法?PHP ca_list_items::setMode怎么用?PHP ca_list_items::setMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ca_list_items的用法示例。


在下文中一共展示了ca_list_items::setMode方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: switch

        case 'english_used_for':
            switch ($o_xml->nodeType) {
                case XMLReader::ELEMENT:
                    $o_xml->read();
                    $va_subject['use_for_english'][] = $o_xml->value;
                    break;
            }
            break;
            # ---------------------------
    }
}
$o_xml->close();
print "\n\nLINKING TERMS IN HIERARCHY...\n";
$vn_last_message_length = 0;
$t_item = new ca_list_items();
$t_item->setMode(ACCESS_WRITE);
foreach ($va_parent_child_links as $vs_child_id => $vs_parent_id) {
    print str_repeat(chr(8), $vn_last_message_length);
    $vs_message = "\tLINKING {$vs_child_id} to parent {$vs_parent_id}";
    if (($vn_l = 200 - strlen($vs_message)) < 1) {
        $vn_l = 1;
    }
    $vs_message .= str_repeat(' ', $vn_l);
    $vn_last_message_length = strlen($vs_message);
    print $vs_message;
    if (!($vn_child_item_id = $va_aat_id_to_item_id[$vs_child_id])) {
        print "ERROR: no list item id for child_id {$vs_child_id} (were there previous errors?)\n";
        continue;
    }
    if (!($vn_parent_item_id = $va_aat_id_to_item_id[$vs_parent_id])) {
        print "ERROR: no list item id for parent_id {$vs_child_id} (were there previous errors?)\n";
开发者ID:idiscussforum,项目名称:providence,代码行数:31,代码来源:import_aat.php

示例2: 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;
//.........这里部分代码省略.........
开发者ID:idiscussforum,项目名称:providence,代码行数:101,代码来源:supportHelpers.php

示例3: addItem

 /**
  *
  */
 public function addItem($ps_value, $pb_is_enabled = true, $pb_is_default = false, $pn_parent_id = null, $pn_type_id = null, $ps_idno = null, $ps_validation_format = '', $pn_status = 0, $pn_access = 0, $pn_rank = null)
 {
     if (!($vn_list_id = $this->getPrimaryKey())) {
         return null;
     }
     $t_item = new ca_list_items();
     $t_item->setMode(ACCESS_WRITE);
     if ($this->inTransaction()) {
         $t_item->setTransaction($this->getTransaction());
     }
     $t_item->set('list_id', $vn_list_id);
     $t_item->set('item_value', $ps_value);
     $t_item->set('is_enabled', $pb_is_enabled ? 1 : 0);
     $t_item->set('is_default', $pb_is_default ? 1 : 0);
     $t_item->set('parent_id', $pn_parent_id);
     $t_item->set('type_id', $pn_type_id);
     $t_item->set('idno', $ps_idno);
     $t_item->set('validation_format', $ps_validation_format);
     $t_item->set('status', $pn_status);
     $t_item->set('access', $pn_access);
     if (!is_null($pn_rank)) {
         $t_item->set('rank', $pn_rank);
     }
     $vn_item_id = $t_item->insert();
     if ($t_item->numErrors()) {
         $this->errors = array_merge($this->errors, $t_item->errors);
         return false;
     }
     return $t_item;
 }
开发者ID:ffarago,项目名称:pawtucket2,代码行数:33,代码来源:ca_lists.php

示例4: 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:
//.........这里部分代码省略.........
开发者ID:ffarago,项目名称:pawtucket2,代码行数:101,代码来源:supportHelpers.php


注:本文中的ca_list_items::setMode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。