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


PHP ca_locales::loadLocaleByCode方法代码示例

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


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

示例1: getPreferredDisplayLocaleIDs

 /**
  *
  */
 public function getPreferredDisplayLocaleIDs($pn_item_locale_id = null)
 {
     $vs_mode = $this->getPreference('cataloguing_display_label_mode');
     $va_locale_ids = array();
     switch ($vs_mode) {
         case 'cataloguing_locale':
             if ($vs_locale = $this->getPreference('cataloguing_locale')) {
                 $t_locale = new ca_locales();
                 if ($t_locale->loadLocaleByCode($vs_locale)) {
                     $va_locale_ids[$t_locale->getPrimaryKey()] = true;
                 }
             }
             break;
         case 'item_locale':
             if ($pn_item_locale_id) {
                 $va_locale_ids[$pn_item_locale_id] = true;
             }
             break;
         case 'cataloguing_and_item_locale':
         default:
             if ($vs_locale = $this->getPreference('cataloguing_locale')) {
                 $t_locale = new ca_locales();
                 if ($t_locale->loadLocaleByCode($vs_locale)) {
                     $va_locale_ids[$t_locale->getPrimaryKey()] = true;
                 }
             }
             if ($pn_item_locale_id) {
                 $va_locale_ids[$pn_item_locale_id] = true;
             }
             break;
     }
     return array_keys($va_locale_ids);
 }
开发者ID:kai-iak,项目名称:providence,代码行数:36,代码来源:ca_users.php

示例2: getUILocales

 /** 
 		Returns a list of locale_ids to use for UI presentation in priority order
 		This will include the user's selected locale if one in logged in, as well as
 		the default locale_id(s) as configured in app.conf or global.conf
 		using the 'locale_defaults' directive. If no locales are set then a full list
 		of locale_ids is returned.
 */
 public function getUILocales()
 {
     $va_locale_codes = array();
     $va_locale_ids = array();
     if ($this->isLoggedIn()) {
         $va_locale_codes[] = $this->user->getPreference('ui_locale');
     }
     if ($va_tmp = $this->config->getList('locale_defaults')) {
         $va_locale_codes = array_merge($va_locale_codes, $va_tmp);
     }
     $t_locale = new ca_locales();
     if (sizeof($va_locale_codes) == 0) {
         foreach (ca_locales::getLocaleList() as $vn_locale_id => $va_locale_info) {
             $va_locale_ids[] = $vn_locale_id;
         }
     } else {
         foreach ($va_locale_codes as $vs_locale_code) {
             if ($vn_locale_id = $t_locale->loadLocaleByCode($vs_locale_code)) {
                 $va_locale_ids[] = $vn_locale_id;
             }
         }
     }
     if (!sizeof($va_locale_ids)) {
         die("No locales configured?");
     }
     return $va_locale_ids;
 }
开发者ID:samrahman,项目名称:providence,代码行数:34,代码来源:RequestHTTP.php

示例3: die

 *
 * ----------------------------------------------------------------------
 */
require_once "../../../setup.php";
if (!file_exists('./AAT.xml')) {
    die("ERROR: you must place the AAT.xml data file in the same directory as this script.\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');
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();
开发者ID:idiscussforum,项目名称:providence,代码行数:31,代码来源:import_aat.php

示例4: join

// Set to null to not import georefs.
$vs_georef_element_code = 'georeference';
// Code for relationship type to relate place types to.
// Set to null to not import place types
$vs_place_type_relationship_code = 'describes';
// ---------------------------------------------------------------------------
require_once __CA_LIB_DIR__ . '/core/Db.php';
require_once __CA_LIB_DIR__ . '/core/Utils/CLIProgressBar.php';
require_once __CA_LIB_DIR__ . '/ca/Utils/DataMigrationUtils.php';
require_once __CA_MODELS_DIR__ . '/ca_locales.php';
require_once __CA_MODELS_DIR__ . '/ca_places.php';
require_once __CA_MODELS_DIR__ . '/ca_places_x_places.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 place hierarchy (if it doesn't exist already)
$t_list = new ca_lists();
if (!$t_list->load(array('list_code' => 'place_hierarchies'))) {
    $t_list->setMode(ACCESS_WRITE);
    $t_list->set('list_code', 'place_hierarchies');
    $t_list->set('is_system_list', 1);
    $t_list->set('is_hierarchical', 1);
    $t_list->set('use_as_vocabulary', 0);
    $t_list->insert();
    if ($t_list->numErrors()) {
        print "[Error] couldn't create ca_list row for place hierarchies: " . join('; ', $t_list->getErrors()) . "\n";
        die;
    }
    $t_list->addLabel(array('name' => 'Place hierarchies'), $pn_en_locale_id, null, true);
}
开发者ID:idiscussforum,项目名称:providence,代码行数:31,代码来源:import_tgn.php

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

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

示例7: updateRelationshipTypes

 /**
  *
  * @return string HTML to display after update
  */
 public function updateRelationshipTypes()
 {
     $t_locale = new ca_locales();
     $o_config = Configuration::load();
     $pn_locale_id = $t_locale->loadLocaleByCode($o_config->get('locale_default'));
     // default locale_id
     $o_db = new Db();
     $o_dm = Datamodel::load();
     $va_tables = $o_dm->getTableNames();
     foreach ($va_tables as $vs_table) {
         if (!preg_match('!_x_!', $vs_table)) {
             continue;
         }
         require_once __CA_MODELS_DIR__ . "/{$vs_table}.php";
         if (!($t_table = new $vs_table())) {
             continue;
         }
         $vs_pk = $t_table->primaryKey();
         $vn_table_num = $t_table->tableNum();
         // Create root ca_relationship_types row for table
         $t_root = new ca_relationship_types();
         if (!$t_root->load(array('type_code' => 'root_for_table_' . $vn_table_num))) {
             $t_root->logChanges(false);
             $t_root->setMode(ACCESS_WRITE);
             $t_root->set('table_num', $vn_table_num);
             $t_root->set('type_code', 'root_for_table_' . $vn_table_num);
             $t_root->set('rank', 1);
             $t_root->set('is_default', 0);
             $t_root->set('parent_id', null);
             $t_root->insert();
             if ($t_root->numErrors()) {
                 $this->opa_error_messages[] = _t("Could not create root for relationship %1: %2", $vs_table, join('; ', $t_root->getErrors()));
                 continue;
             }
             $t_root->addLabel(array('typename' => 'Root for table ' . $vn_table_num, 'typename_reverse' => 'Root for table ' . $vn_table_num), $pn_locale_id, null, true);
             if ($t_root->numErrors()) {
                 $this->opa_error_messages[] = _t("Could not add label to root for relationship %1: %2", $vs_table, join('; ', $t_root->getErrors()));
             }
         }
         $vn_root_id = $t_root->getPrimaryKey();
         // Move existing types under root
         $qr_types = $o_db->query("\n\t\t\t\t\tUPDATE ca_relationship_types\n\t\t\t\t\tSET parent_id = ?, hier_type_id = ?\n\t\t\t\t\tWHERE\n\t\t\t\t\t\t(table_num = ?) AND (type_id <> ?)\n\t\t\t\t", (int) $vn_root_id, (int) $vn_root_id, (int) $vn_table_num, (int) $vn_root_id);
     }
     $t_root->rebuildAllHierarchicalIndexes();
     return sizeof($this->opa_error_messages) ? false : true;
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:50,代码来源:VersionUpdate49.php


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