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


PHP ca_locales::getLocaleList方法代码示例

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


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

示例1: setSettingsFromHTMLForm

 /**
  * Sets and saves form element settings, taking parameters off of the request as needed. Does an update()
  * on the ca_search_forms instance to save settings to the database
  */
 public function setSettingsFromHTMLForm($po_request, $pa_options = null)
 {
     $va_locales = ca_locales::getLocaleList(array('sort_field' => '', 'sort_order' => 'asc', 'index_by_code' => true, 'available_for_cataloguing_only' => true));
     $va_available_settings = $this->getAvailableSettings();
     $this->o_instance->setMode(ACCESS_WRITE);
     $va_values = array();
     $vs_id_prefix = caGetOption('id', $pa_options, 'setting');
     $vs_placement_code = caGetOption('placement_code', $pa_options, '');
     foreach (array_keys($va_available_settings) as $vs_setting) {
         $va_properties = $va_available_settings[$vs_setting];
         if (isset($va_properties['takesLocale']) && $va_properties['takesLocale']) {
             foreach ($va_locales as $vs_locale => $va_locale_info) {
                 $va_values[$vs_setting][$va_locale_info['locale_id']] = $po_request->getParameter("{$vs_placement_code}{$vs_id_prefix}{$vs_setting}_{$vs_locale}", pString);
             }
         } else {
             if (isset($va_properties['useRelationshipTypeList']) && $va_properties['useRelationshipTypeList'] && $va_properties['height'] > 1 || isset($va_properties['useList']) && $va_properties['useList'] && $va_properties['height'] > 1 || isset($va_properties['showLists']) && $va_properties['showLists'] && $va_properties['height'] > 1 || isset($va_properties['showVocabularies']) && $va_properties['showVocabularies'] && $va_properties['height'] > 1) {
                 $va_values[$vs_setting] = $po_request->getParameter("{$vs_placement_code}{$vs_id_prefix}{$vs_setting}", pArray);
             } else {
                 $va_values = array($vs_setting => $po_request->getParameter("{$vs_placement_code}{$vs_id_prefix}{$vs_setting}", pString));
             }
         }
         foreach ($va_values as $vs_setting_key => $vs_value) {
             $this->setSetting($vs_setting, $vs_value);
         }
     }
     return true;
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:31,代码来源:ApplicationToolSettings.php

示例2: ListLocales

 public function ListLocales()
 {
     AssetLoadManager::register('tableList');
     $t_locale = $this->getLocaleObject();
     $vs_sort_field = $this->request->getParameter('sort', pString);
     $this->view->setVar('locale_list', ca_locales::getLocaleList(array('sort_field' => $vs_sort_field, 'sort_order' => 'asc', 'index_by_code' => false)));
     $this->render('locale_list_html.php');
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:8,代码来源:LocalesController.php

示例3: __construct

 public function __construct($po_engine_result = null, $pa_tables = null)
 {
     parent::__construct($po_engine_result, $pa_tables);
     $this->opo_list = new ca_lists();
     $this->opa_locales = ca_locales::getLocaleList();
     $this->ops_label_table_name = method_exists($this->opo_subject_instance, "getLabelTableName") ? $this->opo_subject_instance->getLabelTableName() : null;
     $this->ops_label_display_field = method_exists($this->opo_subject_instance, "getLabelDisplayField") ? $this->opo_subject_instance->getLabelDisplayField() : null;
 }
开发者ID:ffarago,项目名称:pawtucket2,代码行数:8,代码来源:BaseSearchResult.php

示例4: loadLocales

 public function loadLocales()
 {
     require_once __CA_MODELS_DIR__ . "/ca_locales.php";
     $t_locale = new ca_locales();
     $va_locales = $t_locale->getLocaleList(array('index_by_code' => true));
     if (!$va_locales) {
         return $this->processLocales();
     }
     foreach ($va_locales as $vs_code => $va_locale) {
         $this->opa_locales[$vs_code] = $va_locale['locale_id'];
     }
     return true;
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:13,代码来源:Updater.php

示例5: testDataExporterCanLoadFromFile

 /**
  * @link http://clangers.collectiveaccess.org/jira/browse/PROV-1026
  */
 public function testDataExporterCanLoadFromFile()
 {
     $t_locale = new ca_locales();
     $va_locales = $t_locale->getLocaleList();
     $vn_locale_id = key($va_locales);
     $t_exporter = new ca_data_exporters();
     $va_errors = array();
     ca_data_exporters::loadExporterFromFile(__DIR__ . '/data/list_item_export_mapping.xlsx', $va_errors, array('locale_id' => $vn_locale_id));
     $vo_exporter = ca_data_exporters::loadExporterByCode('testmappingforunittests');
     $this->assertEmpty($va_errors, 'Should be no error messages');
     $this->assertTrue(is_object($vo_exporter), 'Should have found an exporter by the correct name');
     $this->assertInstanceOf('ca_data_exporters', $vo_exporter, 'Incorrect type loaded');
     $vo_exporter->setMode(ACCESS_WRITE);
     $vo_exporter->delete(true, array('hard' => true));
     $vo_exporter = $t_exporter->load(array('exporter_code' => 'testmappingforunittests'));
     $this->assertFalse($vo_exporter, 'Should no longer have an exporter loaded');
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:20,代码来源:ca_data_exportersTest.php

示例6: getLocaleList

 /**
  * Get a list of available languages
  *
  * @param array $pa_options List of options. Possible keys:
  *   - sort_field: field to sort on
  *   - sort_direction: direction to sort on
  *   - index_by_code: use code as array keys
  *   - return_display_values: add language display value to result
  *   - available_for_cataloguing_only: only return languages that are used for cataloguing
  * @return array List of available language
  */
 public function getLocaleList($pa_options = null)
 {
     return ca_locales::getLocaleList($pa_options);
 }
开发者ID:kai-iak,项目名称:pawtucket2,代码行数:15,代码来源:ItemInfoService.php

示例7: getDefaultLocaleList

 /**
  *
  */
 public function getDefaultLocaleList()
 {
     global $g_ui_locale_id;
     $va_locale_dedup = array();
     if ($g_ui_locale_id) {
         $va_locale_dedup[$g_ui_locale_id] = true;
     }
     $va_locales = ca_locales::getLocaleList();
     if (is_array($va_locale_defaults = $this->getAppConfig()->getList('locale_defaults'))) {
         foreach ($va_locale_defaults as $vs_locale_default) {
             $va_locale_dedup[$va_locales[$vs_locale_default]] = true;
         }
     }
     foreach ($va_locales as $vn_locale_id => $vs_locale_code) {
         $va_locale_dedup[$vn_locale_id] = true;
     }
     return array_keys($va_locale_dedup);
 }
开发者ID:samrahman,项目名称:providence,代码行数:21,代码来源:BaseModel.php

示例8: locale_id

 /** 
 		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

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

示例10: addDefaultLabel

 /** 
  * Creates a default label when none exists
  *
  * @param int $pn_locale_id Locale id to use for default label. If not set the user's current locale is used.
  * @return boolean True on success, false on error. Success occurs when a default label is successfully added or when a default label is not required. false is only returned when an actionable error state occurs (eg. a blank label is not allowed, or the addition of the default label fails for some reason)
  */
 public function addDefaultLabel($pn_locale_id = null)
 {
     global $g_ui_locale_id;
     if (!$this->getPreferredLabelCount()) {
         $va_locale_list = ca_locales::getLocaleList();
         if ($pn_locale_id && isset($va_locale_list[$pn_locale_id])) {
             $vn_locale_id = $pn_locale_id;
         } else {
             if ($g_ui_locale_id) {
                 $vn_locale_id = $g_ui_locale_id;
             } else {
                 $va_tmp = array_keys($va_locale_list);
                 $vn_locale_id = array_shift($va_tmp);
             }
         }
         if (!(bool) $this->getAppConfig()->get('require_preferred_label_for_' . $this->tableName())) {
             // only try to add a default when a label is not mandatory
             return $this->addLabel(array($this->getLabelDisplayField() => '[' . _t('BLANK') . ']'), $vn_locale_id, null, true);
         } else {
             $this->postError(1130, _t('Label must not be blank'), 'LabelableBaseModelWithAttributes->addDefaultLabel()', $this->tableName() . '.preferred_labels');
             return false;
         }
     }
     return true;
 }
开发者ID:kai-iak,项目名称:pawtucket2,代码行数:31,代码来源:LabelableBaseModelWithAttributes.php

示例11: array

         $vs_setting_value = array($vs_setting_value);
     }
     $va_type_list = $t_mapping_instance->getTypeList();
     $va_list = array();
     foreach ($vs_setting_value as $vn_type_id) {
         if (!$va_type_list[$vn_type_id]['idno']) {
             continue;
         }
         $va_list[] = $va_type_list[$vn_type_id]['idno'];
     }
     if (is_array($va_list) && sizeof($va_list)) {
         print $va_setting_info['label'] . " = " . join("; ", $va_list) . "<br/>\n";
     }
     break;
 case 'defaultLocale':
     $va_locale_list = $t_locale->getLocaleList();
     if (isset($va_locale_list[$vs_setting_value])) {
         print $va_setting_info['label'] . " = " . $va_locale_list[$vs_setting_value]['name'] . "<br/>\n";
     }
     break;
 case 'removeExistingRelationshipsOnUpdate':
 case 'removeExistingAttributesOnUpdate':
     print $va_setting_info['label'] . " = " . ((bool) $vs_setting_value ? _t('yes') : _t('no')) . "<br/>\n";
     break;
 default:
     if (is_array($vs_setting_value) && sizeof($vs_setting_value)) {
         print $va_setting_info['label'] . " = " . join("; ", $vs_setting_value) . "<br/>\n";
     } else {
         if (strlen($vs_setting_value)) {
             print $va_setting_info['label'] . " = " . $vs_setting_value . "<br/>\n";
         }
开发者ID:guaykuru,项目名称:pawtucket,代码行数:31,代码来源:summary_html.php

示例12: savePlacementsFromHTMLForm

 public function savePlacementsFromHTMLForm($po_request, $ps_form_prefix, $ps_placement_code)
 {
     if ($vs_bundles = $po_request->getParameter("{$ps_placement_code}{$ps_form_prefix}displayBundleList", pString)) {
         $va_bundles = explode(';', $vs_bundles);
         $t_display = new ca_bundle_displays($this->getPrimaryKey());
         if ($this->inTransaction()) {
             $t_display->setTransaction($this->getTransaction());
         }
         $va_placements = $t_display->getPlacements(array('user_id' => $po_request->getUserID()));
         // remove deleted bundles
         foreach ($va_placements as $vn_placement_id => $va_bundle_info) {
             if (!in_array($va_bundle_info['bundle_name'] . '_' . $va_bundle_info['placement_id'], $va_bundles)) {
                 $t_display->removePlacement($va_bundle_info['placement_id'], array('user_id' => $po_request->getUserID()));
                 if ($t_display->numErrors()) {
                     $this->errors = $t_display->errors;
                     return false;
                 }
             }
         }
         $va_locale_list = ca_locales::getLocaleList(array('index_by_code' => true));
         $va_available_bundles = $t_display->getAvailableBundles();
         foreach ($va_bundles as $vn_i => $vs_bundle) {
             // get settings
             if (preg_match('!^(.*)_([\\d]+)$!', $vs_bundle, $va_matches)) {
                 $vn_placement_id = (int) $va_matches[2];
                 $vs_bundle = $va_matches[1];
             } else {
                 $vn_placement_id = null;
             }
             $vs_bundle_proc = str_replace(".", "_", $vs_bundle);
             $va_settings = array();
             foreach ($_REQUEST as $vs_key => $vs_val) {
                 if (preg_match("!^{$vs_bundle_proc}_([\\d]+)_([^\\d]+.*)\$!", $vs_key, $va_matches)) {
                     // is this locale-specific?
                     if (preg_match('!(.*)_([a-z]{2}_[A-Z]{2})$!', $va_matches[2], $va_locale_matches)) {
                         $vn_locale_id = isset($va_locale_list[$va_locale_matches[2]]) ? (int) $va_locale_list[$va_locale_matches[2]]['locale_id'] : 0;
                         $va_settings[(int) $va_matches[1]][$va_locale_matches[1]][$vn_locale_id] = $vs_val;
                     } else {
                         $va_settings[(int) $va_matches[1]][$va_matches[2]] = $vs_val;
                     }
                 }
             }
             if ($vn_placement_id === 0) {
                 $t_display->addPlacement($vs_bundle, $va_settings[$vn_placement_id], $vn_i + 1, array('user_id' => $po_request->getUserID(), 'additional_settings' => $va_available_bundles[$vs_bundle]['settings']));
                 if ($t_display->numErrors()) {
                     $this->errors = $t_display->errors;
                     return false;
                 }
             } else {
                 $t_placement = new ca_bundle_display_placements($vn_placement_id, $va_available_bundles[$vs_bundle]['settings']);
                 if ($this->inTransaction()) {
                     $t_placement->setTransaction($this->getTransaction());
                 }
                 $t_placement->setMode(ACCESS_WRITE);
                 $t_placement->set('rank', $vn_i + 1);
                 if (is_array($va_settings[$vn_placement_id])) {
                     //foreach($va_settings[$vn_placement_id] as $vs_setting => $vs_val) {
                     foreach ($t_placement->getAvailableSettings() as $vs_setting => $va_setting_info) {
                         $vs_val = isset($va_settings[$vn_placement_id][$vs_setting]) ? $va_settings[$vn_placement_id][$vs_setting] : null;
                         $t_placement->setSetting($vs_setting, $vs_val);
                     }
                 }
                 $t_placement->update();
                 if ($t_placement->numErrors()) {
                     $this->errors = $t_placement->errors;
                     return false;
                 }
             }
         }
     }
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:71,代码来源:ca_bundle_displays.php

示例13: getItemInfoForEdit

 /**
  * Get a record summary that looks reasonably close to what we expect to be passed to the
  * PUT portion of this very service. With this hack editing operations should be easier to handle.
  */
 private function getItemInfoForEdit()
 {
     if (!($t_instance = $this->_getTableInstance($this->ops_table, $this->opn_id))) {
         return false;
     }
     $t_list = new ca_lists();
     $t_locales = new ca_locales();
     $va_locales = $t_locales->getLocaleList(array("available_for_cataloguing_only" => true));
     $va_return = array();
     // "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;
             }
             $va_return['intrinsic_fields'][$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);
     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 ($t_instance->getLabelUIFields() as $vs_label_fld) {
                     $va_label[$vs_label_fld] = $va_tmp[$vs_label_fld];
                 }
                 $va_return["preferred_labels"][] = $va_label;
             }
         }
     }
     // 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 ($t_instance->getLabelUIFields() as $vs_label_fld) {
                     $va_label[$vs_label_fld] = $va_tmp[$vs_label_fld];
                 }
                 $va_return["nonpreferred_labels"][] = $va_label;
             }
         }
     }
     // representations for objects
     if ($this->ops_table == "ca_objects") {
         $va_return['representations'] = $t_instance->getRepresentations();
     }
     // 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_by_locale = end($va_vals);
             // I seriously have no idea what that additional level of nesting in the return format is for
             foreach ($va_vals_by_locale as $vn_locale_id => $va_locale_vals) {
                 foreach ($va_locale_vals as $vs_val_id => $va_actual_data) {
                     if (!is_array($va_actual_data)) {
                         continue;
                     }
                     $vs_locale_code = isset($va_locales[$vn_locale_id]["code"]) ? $va_locales[$vn_locale_id]["code"] : "none";
                     $va_return['attributes'][$vs_code][] = array_merge(array('locale' => $vs_locale_code), $va_actual_data);
                 }
             }
         }
     }
     // relationships
     // yes, not all combinations between these tables have
     // relationships but it also doesn't hurt to query
     foreach ($this->opa_valid_tables as $vs_rel_table) {
         //
         // set-related hacks
         if ($this->ops_table == "ca_sets" && $vs_rel_table == "ca_tours") {
             // throw SQL error in getRelatedItems
             continue;
         }
         $va_related_items = $t_instance->get($vs_rel_table, array("returnAsArray" => true));
         if ($this->ops_table == "ca_objects" && $vs_rel_table == "ca_object_representations") {
             $va_return['representations'] = $t_instance->getRepresentations(array('preview170', 'medium'));
         }
         if (is_array($va_related_items) && sizeof($va_related_items) > 0) {
             // most of the fields are usually empty because they are not supported on UI level
             foreach ($va_related_items as $va_rel_item) {
                 $va_item_add = array();
//.........这里部分代码省略.........
开发者ID:ffarago,项目名称:pawtucket2,代码行数:101,代码来源:ItemService.php

示例14: caExtractValuesByLocale

/**
 *
 * @param $pa_locale_rules - Associative array defining which locales to extract, and how to fall back to alternative locales should your preferred locales not exist in $pa_values
 * @param $pa_values - Associative array keyed by unique item_id and then locale code (eg. en_US) or locale_id; the values can be anything - string, numbers, objects, arrays, etc.
 * @param $pa_options [optional] - Associative array of options; available options are:
 *									'returnList' = return an indexed array of found values rather than an associative array keys on unique item_id [default is false]
 *									'debug' = print debugging information [default is false]
 * @return Array - an array of found values keyed by unique item_id; or an indexed list of found values if option 'returnList' is passed in $pa_options
 */
function caExtractValuesByLocale($pa_locale_rules, $pa_values, $pa_options = null)
{
    if (!is_array($pa_values)) {
        return array();
    }
    $va_locales = ca_locales::getLocaleList();
    if (!is_array($pa_options)) {
        $pa_options = array();
    }
    if (!isset($pa_options['returnList'])) {
        $pa_options['returnList'] = false;
    }
    if (!is_array($pa_values)) {
        return array();
    }
    $va_values = array();
    foreach ($pa_values as $vm_id => $va_value_list_by_locale) {
        if (sizeof($va_value_list_by_locale) == 1) {
            // Don't bother looking if there's just a single value
            $va_values[$vm_id] = array_pop($va_value_list_by_locale);
            continue;
        }
        foreach ($va_value_list_by_locale as $pm_locale => $vm_value) {
            // convert locale_id to locale string
            if (is_numeric($pm_locale)) {
                if (!$va_locales[$pm_locale]) {
                    continue;
                }
                // invalid locale_id?
                $vs_locale = $va_locales[$pm_locale]['language'] . '_' . $va_locales[$pm_locale]['country'];
            } else {
                $vs_locale = $pm_locale;
            }
            // try to find values for preferred locale
            if (isset($pa_locale_rules['preferred'][$vs_locale]) && $pa_locale_rules['preferred'][$vs_locale]) {
                $va_values[$vm_id] = $vm_value;
                break;
            }
            // try fallback locales
            if (isset($pa_locale_rules['fallback'][$vs_locale]) && $pa_locale_rules['fallback'][$vs_locale]) {
                $va_values[$vm_id] = $vm_value;
            }
        }
        if (!isset($va_values[$vm_id])) {
            // desperation mode: pick an available locale
            $va_values[$vm_id] = array_pop($va_value_list_by_locale);
        }
    }
    return $pa_options['returnList'] ? array_values($va_values) : $va_values;
}
开发者ID:kai-iak,项目名称:providence,代码行数:59,代码来源:displayHelpers.php

示例15: savePlacementsFromHTMLForm

 public function savePlacementsFromHTMLForm($po_request, $ps_form_prefix, $ps_placement_code)
 {
     if ($vs_bundles = $po_request->getParameter("{$ps_placement_code}{$ps_form_prefix}displayBundleList", pString)) {
         $va_bundles = explode(';', $vs_bundles);
         $t_screen = new ca_editor_ui_screens($this->getPrimaryKey());
         $va_placements = $t_screen->getPlacements(array('user_id' => $po_request->getUserID()));
         // remove deleted bundles
         foreach ($va_placements as $vn_placement_id => $va_bundle_info) {
             if (!in_array($va_bundle_info['bundle_name'] . '_' . $va_bundle_info['placement_id'], $va_bundles)) {
                 $t_screen->removePlacement($va_bundle_info['placement_id'], array('user_id' => $po_request->getUserID()));
                 if ($t_screen->numErrors()) {
                     $this->errors = $t_screen->errors;
                     return false;
                 }
             }
         }
         $va_locale_list = ca_locales::getLocaleList(array('index_by_code' => true));
         $va_available_bundles = $t_screen->getAvailableBundles();
         foreach ($va_bundles as $vn_i => $vs_bundle) {
             // get settings
             if (preg_match('!^(.*)_([\\d]+)$!', $vs_bundle, $va_matches)) {
                 $vn_placement_id = (int) $va_matches[2];
                 $vs_bundle = $va_matches[1];
             } else {
                 $vn_placement_id = null;
             }
             $vs_bundle_proc = str_replace(".", "_", $vs_bundle);
             $va_settings = array();
             foreach ($_REQUEST as $vs_key => $vs_val) {
                 if (preg_match("!^{$vs_bundle_proc}_([\\d]+)_(.*)\$!", $vs_key, $va_matches)) {
                     // is this locale-specific?
                     if (preg_match('!(.*)_([a-z]{2}_[A-Z]{2})$!', $va_matches[2], $va_locale_matches)) {
                         $vn_locale_id = isset($va_locale_list[$va_locale_matches[2]]) ? (int) $va_locale_list[$va_locale_matches[2]]['locale_id'] : 0;
                         // NOTE: we set keys for both locale_id (which how other placement-using editor like ca_search_forms and
                         // ca_bundle_displays do) *AND* the locale code (eg. "en_US"). This is because the settings created in profile and
                         // in pre v1.1 systems are keyed by code, not locale_id. There's nothing wrong with using code - it's just as unique as the locale_id
                         // and it's convenient to use both interchangeably in any event.
                         //
                         $va_settings[(int) $va_matches[1]][$va_locale_matches[1]][$vn_locale_id] = $va_settings[(int) $va_matches[1]][$va_locale_matches[1]][$va_locale_matches[2]] = $vs_val;
                     } else {
                         $va_settings[(int) $va_matches[1]][$va_matches[2]] = $vs_val;
                     }
                 }
             }
             if ($vn_placement_id === 0) {
                 $t_screen->addPlacement($vs_bundle, $vs_bundle . ($vn_i + 1), $va_settings[$vn_placement_id], $vn_i + 1, array('user_id' => $po_request->getUserID(), 'additional_settings' => $va_available_bundles[$vs_bundle]['settings']));
                 if ($t_screen->numErrors()) {
                     $this->errors = $t_screen->errors;
                     return false;
                 }
             } else {
                 $t_placement = new ca_editor_ui_bundle_placements($vn_placement_id, $va_available_bundles[$vs_bundle]['settings']);
                 $t_placement->setMode(ACCESS_WRITE);
                 $t_placement->set('rank', $vn_i + 1);
                 if (is_array($va_settings[$vn_placement_id])) {
                     foreach ($t_placement->getAvailableSettings() as $vs_setting => $va_setting_info) {
                         $vs_val = isset($va_settings[$vn_placement_id][$vs_setting]) ? $va_settings[$vn_placement_id][$vs_setting] : null;
                         $t_placement->setSetting($vs_setting, $vs_val);
                     }
                 }
                 $t_placement->update();
                 if ($t_placement->numErrors()) {
                     $this->errors = $t_placement->errors;
                     return false;
                 }
             }
         }
     }
     return true;
 }
开发者ID:kai-iak,项目名称:pawtucket2,代码行数:70,代码来源:ca_editor_ui_screens.php


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