本文整理汇总了PHP中ca_locales类的典型用法代码示例。如果您正苦于以下问题:PHP ca_locales类的具体用法?PHP ca_locales怎么用?PHP ca_locales使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ca_locales类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: Get
public function Get()
{
global $g_ui_locale_id;
$ps_query = $this->request->getParameter('q', pString);
$ps_type = $this->request->getParameter('type', pString);
$vo_conf = Configuration::load();
$vs_user = trim($vo_conf->get("geonames_user"));
$va_items = array();
if (unicode_strlen($ps_query) >= 3) {
$vs_base = "http://api.geonames.org/search";
$t_locale = new ca_locales($g_ui_locale_id);
$vs_lang = $t_locale->get("language");
$va_params = array("q" => $ps_query, "lang" => $vs_lang, 'style' => 'full', 'username' => $vs_user);
foreach ($va_params as $vs_key => $vs_value) {
$vs_query_string .= "{$vs_key}=" . urlencode($vs_value) . "&";
}
try {
$vo_xml = new SimpleXMLElement(@file_get_contents("{$vs_base}?{$vs_query_string}"));
//var_dump($vo_result);
foreach ($vo_xml->children() as $vo_child) {
if ($vo_child->getName() != "totalResultsCount") {
$va_items[$vo_child->geonameId . ""] = array('displayname' => $vo_child->name, 'country' => $vo_child->countryName ? $vo_child->countryName : null, 'continent' => $vo_child->continentCode ? $vo_child->continentCode : null, 'fcl' => $vo_child->fclName ? $vo_child->fclName : null, 'lat' => $vo_child->lat ? $vo_child->lat : null, 'lng' => $vo_child->lng ? $vo_child->lng : null, 'idno' => $vo_child->geonameId);
}
}
} catch (Exception $e) {
$va_items[0] = array('displayname' => _t('Could not connect to GeoNames'), 'country' => '', 'continent' => '', 'fcl' => '', 'lat' => '', 'lng' => '', 'idno' => '');
}
}
$this->view->setVar('geonames_list', $va_items);
return $this->render('ajax_geonames_list_html.php');
}
开发者ID:guaykuru,项目名称:pawtucket,代码行数:31,代码来源:GeoNamesController.php
示例2: 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
示例3: Get
public function Get($pa_additional_query_params = null, $pa_options = null)
{
global $g_ui_locale_id;
$vn_max = $this->request->getParameter('maxRows', pInteger) ? $this->request->getParameter('maxRows', pInteger) : 20;
$ps_query = $this->request->getParameter('term', pString);
$ps_gn_elements = urldecode($this->request->getParameter('gnElements', pString));
$ps_gn_delimiter = urldecode($this->request->getParameter('gnDelimiter', pString));
$pa_elements = explode(',', $ps_gn_elements);
$vo_conf = Configuration::load();
$vs_user = trim($vo_conf->get("geonames_user"));
$va_items = array();
if (unicode_strlen($ps_query) >= 3) {
$vs_base = $vo_conf->get('geonames_api_base_url') . '/search';
$t_locale = new ca_locales($g_ui_locale_id);
$vs_lang = $t_locale->get("language");
$va_params = array("q" => $ps_query, "lang" => $vs_lang, 'style' => 'full', 'username' => $vs_user, 'maxRows' => $vn_max);
$vs_query_string = '';
foreach ($va_params as $vs_key => $vs_value) {
$vs_query_string .= "{$vs_key}=" . urlencode($vs_value) . "&";
}
try {
$vs_xml = caQueryExternalWebservice("{$vs_base}?{$vs_query_string}");
$vo_xml = new SimpleXMLElement($vs_xml);
$va_attr = $vo_xml->status ? $vo_xml->status->attributes() : null;
if ($va_attr && isset($va_attr['value']) && (int) $va_attr['value'] > 0) {
$va_items[0] = array('displayname' => _t('Connection to GeoNames with username "%1" was rejected with the message "%2". Check your configuration and make sure your GeoNames.org account is enabled for web services.', $vs_user, $va_attr['message']), 'lat' => '', 'lng' => '');
$va_items[0]['label'] = $va_items[0]['displayname'];
} else {
foreach ($vo_xml->children() as $vo_child) {
if ($vo_child->getName() == "geoname") {
$va_elements = array();
foreach ($pa_elements as $ps_element) {
$vs_val = $vo_child->{trim($ps_element)};
if (strlen(trim($vs_val)) > 0) {
$va_elements[] = trim($vs_val);
}
}
$va_items[(string) $vo_child->geonameId] = array('displayname' => $vo_child->name, 'label' => join($ps_gn_delimiter, $va_elements) . ($vo_child->lat ? " [" . $vo_child->lat . "," : '') . ($vo_child->lng ? $vo_child->lng . "]" : ''), 'lat' => $vo_child->lat ? $vo_child->lat : null, 'lng' => $vo_child->lng ? $vo_child->lng : null, 'id' => (string) $vo_child->geonameId);
}
}
}
} catch (Exception $e) {
$va_items[0] = array('displayname' => _t('Could not connect to GeoNames'), 'lat' => '', 'lng' => '', 'id' => 0);
$va_items[0]['label'] = $va_items[0]['displayname'];
}
}
$this->view->setVar('geonames_list', $va_items);
return $this->render('ajax_geonames_list_html.php');
}
开发者ID:idiscussforum,项目名称:providence,代码行数:49,代码来源:GeoNamesController.php
示例4: 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
示例5: __construct
public function __construct($po_request, $ps_table = "")
{
$this->opo_request = $po_request;
$this->ops_table = $ps_table;
$this->opo_dm = Datamodel::load();
$this->opa_errors = array();
$this->ops_method = $this->opo_request->getRequestMethod();
if (!in_array($this->ops_method, array("PUT", "DELETE", "GET", "POST", "OPTIONS"))) {
$this->addError("Invalid HTTP request method");
}
$this->opn_id = $this->opo_request->getParameter("id", pString);
// we allow for a string to support fetching by idno; typically it's a numeric id
if ($vs_locale = $this->opo_request->getParameter('lang', pString)) {
global $g_ui_locale, $g_ui_locale_id, $_;
$g_ui_locale = $vs_locale;
$t_locale = new ca_locales();
if ($g_ui_locale_id = $t_locale->localeCodeToID($vs_locale)) {
$g_ui_locale = $vs_locale;
if (!initializeLocale($g_ui_locale)) {
die("Error loading locale " . $g_ui_locale);
}
$this->opo_request->reloadAppConfig();
}
}
$vs_post_data = $this->opo_request->getRawPostData();
if (strlen(trim($vs_post_data)) > 0) {
$this->opa_post = json_decode($vs_post_data, true);
if (!is_array($this->opa_post)) {
$this->addError(_t("Data sent via POST doesn't seem to be in JSON format"));
}
} else {
if ($vs_post_data = $this->opo_request->getParameter('source', pString)) {
$this->opa_post = json_decode($vs_post_data, true);
if (!is_array($this->opa_post)) {
$this->addError(_t("Data sent via 'source' parameter doesn't seem to be in JSON format"));
}
} else {
$this->opa_post = array();
}
}
$this->opa_valid_tables = array("ca_objects", "ca_object_lots", "ca_entities", "ca_places", "ca_occurrences", "ca_collections", "ca_list_items", "ca_lists", "ca_object_representations", "ca_storage_locations", "ca_movements", "ca_loans", "ca_tours", "ca_tour_stops", "ca_sets");
if (strlen($ps_table) > 0) {
if (!in_array($ps_table, $this->opa_valid_tables)) {
$this->addError(_t("Table does not exist"));
}
}
}
开发者ID:idiscussforum,项目名称:providence,代码行数:47,代码来源:BaseJSONService.php
示例6: 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
示例7: 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
示例8: __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
示例9: 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
示例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: _processInterstitials
/**
* @param array $pa_options
* @param $t_rel
* @param bool $pb_update
*/
private function _processInterstitials($pa_options, $t_rel, $pb_update)
{
global $g_ui_locale_id;
// Are there interstitials to add?
if (isset($pa_options['interstitialValues']) && is_array($pa_options['interstitialValues'])) {
$t_rel->setMode(ACCESS_WRITE);
foreach ($pa_options['interstitialValues'] as $vs_element => $va_value) {
if ($t_rel->hasField($vs_element)) {
$t_rel->set($vs_element, $va_value);
continue;
}
// Convert a scalar or key-value array to an indexed array with a single element
if (!is_array($va_value) || array_keys($va_value) !== range(0, sizeof($va_value) - 1)) {
$va_value = array($va_value);
}
// Iterate through indexed array
foreach ($va_value as $va_value_instance) {
// Convert scalar to key-value array
if (!is_array($va_value_instance)) {
$va_value_instance = array($vs_element => $va_value_instance);
}
// Ensure we have a locale
if (!isset($va_value_instance['locale_id'])) {
$va_value_instance['locale_id'] = $g_ui_locale_id ? $g_ui_locale_id : ca_locales::getDefaultCataloguingLocaleID();
}
// Create or update the attribute
if ($pb_update) {
$t_rel->editAttribute($va_value_instance, $vs_element);
} else {
$t_rel->addAttribute($va_value_instance, $vs_element);
}
}
}
$t_rel->update();
}
}
开发者ID:idiscussforum,项目名称:providence,代码行数:41,代码来源:BundlableLabelableBaseModelWithAttributes.php
示例12: sortHits
/**
* @param $pa_hits Array of row_ids to sort. *MUST HAVE row_ids AS KEYS, NOT VALUES*
*/
public function sortHits($pa_hits, $ps_field, $ps_direction = 'asc', $pa_options = null)
{
if (!in_array(strtolower($ps_direction), array('asc', 'desc'))) {
$ps_direction = 'asc';
}
if (!is_array($pa_hits) || !sizeof($pa_hits)) {
return $pa_hits;
}
$vs_search_tmp_table = $this->loadListIntoTemporaryResultTable($pa_hits, $pa_options['search']);
$t_table = $this->opo_datamodel->getInstanceByTableNum($this->opn_tablenum, true);
$vs_table_pk = $t_table->primaryKey();
$vs_table_name = $this->ops_tablename;
$va_fields = explode(';', $ps_field);
$va_sorted_hits = array();
$vn_num_locales = ca_locales::numberOfCataloguingLocales();
foreach ($va_fields as $vs_field) {
$va_joins = $va_orderbys = array();
$vs_locale_where = $vs_is_preferred_sql = '';
$va_tmp = explode('.', $vs_field);
// Rewrite for <table>.preferred_labels.* syntax
if ($va_tmp[1] == 'preferred_labels') {
if ($t_labeled_item_table = $this->opo_datamodel->getInstanceByTableName($va_tmp[0], true)) {
if ($t_label_table = $t_labeled_item_table->getLabelTableInstance()) {
$va_tmp2 = array($t_label_table->tableName());
if (isset($va_tmp[2]) && $t_label_table->hasField($va_tmp[2])) {
$va_tmp2[] = $va_tmp[2];
} else {
$va_tmp2[] = $t_labeled_item_table->getLabelDisplayField();
}
$va_tmp = $va_tmp2;
$vs_field = join(".", $va_tmp);
}
}
}
if ($va_tmp[0] == $vs_table_name) {
//
// sort field is in search table
//
if (!$t_table->hasField($va_tmp[1])) {
//
// is it an attribute?
//
$t_element = new ca_metadata_elements();
$vs_sort_element_code = array_pop($va_tmp);
if ($t_element->load(array('element_code' => $vs_sort_element_code))) {
$vn_element_id = $t_element->getPrimaryKey();
if (!($vs_sortable_value_fld = Attribute::getSortFieldForDatatype($t_element->get('datatype')))) {
return $pa_hits;
}
if ((int) $t_element->get('datatype') == 3) {
$vs_sortable_value_fld = 'lil.name_plural';
$vs_sort_field = array_pop(explode('.', $vs_sortable_value_fld));
$vs_locale_where = $vn_num_locales > 1 ? ', lil.locale_id' : '';
$vs_sql = "\n\t\t\t\t\t\t\t\tSELECT attr.row_id, lil.locale_id, lower({$vs_sortable_value_fld}) {$vs_sort_field}\n\t\t\t\t\t\t\t\tFROM ca_attributes attr\n\t\t\t\t\t\t\t\tINNER JOIN ca_attribute_values AS attr_vals ON attr_vals.attribute_id = attr.attribute_id\n\t\t\t\t\t\t\t\tINNER JOIN ca_list_item_labels AS lil ON lil.item_id = attr_vals.item_id\n\t\t\t\t\t\t\t\tINNER JOIN {$vs_browse_tmp_table} ON {$vs_browse_tmp_table}.row_id = attr.row_id\n\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t(attr_vals.element_id = ?) AND (attr.table_num = ?) AND (lil.{$vs_sort_field} IS NOT NULL)\n\t\t\t\t\t\t\t\tORDER BY lil.{$vs_sort_field}\n\t\t\t\t\t\t\t";
} else {
$vs_sortable_value_fld = 'attr_vals.' . $vs_sortable_value_fld;
$vs_sort_field = array_pop(explode('.', $vs_sortable_value_fld));
$vs_locale_where = $vn_num_locales > 1 ? 'attr.locale_id' : '';
$vs_sql = "\n\t\t\t\t\t\t\t\tSELECT attr.row_id, attr.locale_id, lower({$vs_sortable_value_fld}) {$vs_sort_field}\n\t\t\t\t\t\t\t\tFROM ca_attributes attr\n\t\t\t\t\t\t\t\tINNER JOIN ca_attribute_values AS attr_vals ON attr_vals.attribute_id = attr.attribute_id\n\t\t\t\t\t\t\t\tINNER JOIN {$vs_search_tmp_table} ON {$vs_search_tmp_table}.row_id = attr.row_id\n\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t(attr_vals.element_id = ?) AND (attr.table_num = ?) AND (attr_vals.{$vs_sort_field} IS NOT NULL)\n\t\t\t\t\t\t\t\tORDER BY attr_vals.{$vs_sort_field}\n\t\t\t\t\t\t\t";
//print $vs_sql." ; $vn_element_id/; ".$this->opn_tablenum."<br>";
}
$qr_sort = $this->opo_db->query($vs_sql, (int) $vn_element_id, (int) $this->opn_tablenum);
while ($qr_sort->nextRow()) {
$va_row = $qr_sort->getRow();
if (!$va_row['row_id']) {
continue;
}
if ($vn_num_locales > 1) {
$va_sorted_hits[$va_row['row_id']][$va_row['locale_id']] .= trim(str_replace(array("'", '"'), array('', ''), $va_row[$vs_sort_field]));
} else {
$va_sorted_hits[$va_row['row_id']] .= trim(str_replace(array("'", '"'), array('', ''), $va_row[$vs_sort_field]));
}
unset($pa_hits[$va_row['row_id']]);
}
// Add on hits that aren't sorted because they don't have an attribute associated
foreach ($pa_hits as $vn_id => $va_row) {
if (!is_array($va_row)) {
$va_row = array();
}
if ($vn_num_locales > 1) {
$va_sorted_hits[$vn_id][1] = $va_row;
} else {
$va_sorted_hits[$vn_id] = $va_row;
}
}
}
continue;
} else {
$va_field_info = $t_table->getFieldInfo($va_tmp[1]);
if ($va_field_info['START'] && $va_field_info['END']) {
$va_orderbys[] = $va_field_info['START'] . ' ' . $ps_direction;
$va_orderbys[] = $va_field_info['END'] . ' ' . $ps_direction;
} else {
$va_orderbys[] = $vs_field . ' ' . $ps_direction;
}
if ($t_table->hasField('locale_id')) {
$vs_locale_where = ", " . $vs_table_name . ".locale_id";
//.........这里部分代码省略.........
开发者ID:guaykuru,项目名称:pawtucket,代码行数:101,代码来源:SearchEngine.php
示例13: settingHTMLFormElement
/**
* Returns HTML form element for editing of setting
*
* Options:
*
* 'name' => sets the name of the HTML form element explicitly, otherwise 'setting_<name_of_setting>' is used
* 'value' => sets the value of the HTML form element explicitly, otherwise the current value for the setting in the loaded row is used
*/
public function settingHTMLFormElement($ps_widget_id, $ps_setting, $pa_options = null)
{
if (!$this->isValidSetting($ps_setting)) {
return false;
}
$va_available_settings = $this->getAvailableSettings();
$va_properties = $va_available_settings[$ps_setting];
if (isset($pa_options['name'])) {
$vs_input_name = $pa_options['name'];
} else {
$vs_input_name = "setting_{$ps_setting}";
}
if (isset($pa_options['value']) && !is_null($pa_options['value'])) {
$vs_value = $pa_options['value'];
} else {
$vs_value = $this->getSetting(trim($ps_setting));
}
$vs_element = '';
switch ($va_properties['displayType']) {
# --------------------------------------------
case DT_FIELD:
$vb_takes_locale = false;
if (isset($va_properties['takesLocale']) && $va_properties['takesLocale']) {
$vb_takes_locale = true;
$va_locales = ca_locales::getLocaleList(array('sort_field' => '', 'sort_order' => 'asc', 'index_by_code' => true));
} else {
$va_locales = array('_generic' => array());
}
foreach ($va_locales as $vs_locale => $va_locale_info) {
if ($vb_takes_locale) {
$vs_locale_label = " (" . $va_locale_info['name'] . ")";
$vs_input_name_suffix = '_' . $vs_locale;
} else {
$vs_input_name_suffix = $vs_locale_label = '';
}
$vs_element .= caHTMLTextInput($vs_input_name . $vs_input_name_suffix, array('size' => $va_properties["width"], 'height' => $va_properties["height"], 'value' => $vs_value, 'id' => $vs_input_name . $vs_input_name_suffix)) . "{$vs_locale_label}";
// focus code is needed by Firefox for some reason
$vs_element .= "<script type='text/javascript'>jQuery('#" . $vs_input_name . $vs_input_name_suffix . "').click(function() { this.focus(); });</script>";
}
break;
# --------------------------------------------
# --------------------------------------------
case DT_CHECKBOXES:
$va_attributes = array('value' => '1');
if ($vs_value) {
$va_attributes['checked'] = '1';
}
$vs_element .= caHTMLCheckboxInput($vs_input_name, $va_attributes);
break;
# --------------------------------------------
# --------------------------------------------
case DT_SELECT:
if (!is_array($va_properties['options'])) {
$va_properties['options'] = array();
}
$vs_element .= caHTMLSelect($vs_input_name, $va_properties['options'], array(), array('value' => $vs_value));
break;
# --------------------------------------------
# --------------------------------------------
default:
break;
# --------------------------------------------
}
$vs_label = $va_properties['label'];
$vb_element_is_part_of_label = false;
if (strpos($vs_label, '^ELEMENT') !== false) {
$vs_label = str_replace('^ELEMENT', $vs_element, $vs_label);
$vb_element_is_part_of_label = true;
}
$vs_return = "\n" . '<div class="formLabel" id="_widget_setting_' . $ps_setting . '_' . $ps_widget_id . '"><span>' . $vs_label . '</span>';
if (!$vb_element_is_part_of_label) {
$vs_return .= '<br />' . $vs_element;
}
$vs_return .= '</div>' . "\n";
TooltipManager::add('#_widget_setting_' . $ps_setting . '_' . $ps_widget_id, "<h3>" . str_replace('^ELEMENT', 'X', $va_properties["label"]) . "</h3>" . $va_properties["description"]);
return $vs_return;
}
开发者ID:idiscussforum,项目名称:providence,代码行数:85,代码来源:BaseWidget.php
示例14: 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
示例15: 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
示例16: _generateSortableValue
/**
* Returns version of label 'display' field value suitable for sorting
* The sortable value is the same as the display value except when the display value
* starts with a definite article ('the' in English) or indefinite article ('a' or 'an' in English)
* in the locale of the label, in which case the article is moved to the end of the sortable value.
*
* What constitutes an article is defined in the TimeExpressionParser localization files. So if the
* locale of the label doesn't correspond to an existing TimeExpressionParser localization, then
* the users' current locale setting is used.
*/
private function _generateSortableValue()
{
if ($vs_sort_field = $this->getProperty('LABEL_SORT_FIELD')) {
$vs_display_field = $this->getProperty('LABEL_DISPLAY_FIELD');
$o_tep = new TimeExpressionParser();
$t_locale = new ca_locales();
$o_tep->setLanguage($t_locale->localeIDToCode($this->get('locale_id')));
$o_lang_settings = $o_tep->getLanguageSettings();
$vs_display_value = trim(preg_replace('![^\\p{L}0-9 ]+!u', ' ', $this->get($vs_display_field)));
$va_definite_articles = $o_lang_settings->get('definiteArticles');
$va_indefinite_articles = $o_lang_settings->get('indefiniteArticles');
foreach (array($o_lang_settings->get('definiteArticles'), $o_lang_settings->get('indefiniteArticles')) as $va_articles) {
if (is_array($va_articles)) {
foreach ($va_articles as $vs_article) {
if (preg_match('!^(' . $vs_article . ')[ ]+!i', $vs_display_value, $va_matches)) {
$vs_display_value = trim(str_replace($va_matches[1], '', $vs_display_value) . ', ' . $va_matches[1]);
break 2;
}
}
}
}
$this->set($vs_sort_field, $vs_display_value);
}
}
开发者ID:kai-iak,项目名称:providence,代码行数:34,代码来源:BaseLabel.php
示例17: ca_locales
$resp = $app->getResponse();
// TODO: move this into a library so $_, $g_ui_locale_id and $g_ui_locale gets set up automatically
require_once __CA_APP_DIR__ . "/helpers/initializeLocale.php";
$va_ui_locales = $g_request->config->getList('ui_locales');
if ($vs_lang = $g_request->getParameter('lang', pString)) {
if (in_array($vs_lang, $va_ui_locales)) {
$g_request->session->setVar('lang', $vs_lang);
}
}
if (!($g_ui_locale = $g_request->session->getVar('lang'))) {
$g_ui_locale = $va_ui_locales[0];
}
if (!in_array($g_ui_locale, $va_ui_locales)) {
$g_ui_locale = $va_ui_locales[0];
}
$t_locale = new ca_locales();
$g_ui_locale_id = $t_locale->localeCodeToID($g_ui_locale);
// get current UI locale as locale_id (available as global)
$_ = array();
if (file_exists($vs_theme_specific_locale_path = $g_request->getThemeDirectoryPath() . '/locale/' . $g_ui_locale . '/messages.mo')) {
$_[] = new Zend_Translate('gettext', $vs_theme_specific_locale_path, $g_ui_locale);
}
$_[] = new Zend_Translate('gettext', __CA_APP_DIR__ . '/locale/' . $g_ui_locale . '/messages.mo', $g_ui_locale);
if (!initializeLocale($g_ui_locale)) {
die("Error loading locale " . $g_ui_locale);
}
$g_request->reloadAppConfig();
// need to reload app config to reflect current locale
//
// PageFormat plug-in generates header/footer shell around page content
//
开发者ID:ffarago,项目名称:pawtucket2,代码行数:31,代码来源:index.php
示例18: insert
public function insert($pa_options = null)
{
if (!$this->inTransaction()) {
$this->setTransaction(new Transaction());
}
if ($this->get('is_default')) {
$this->getDb()->query("\n\t\t\t\tUPDATE ca_list_items \n\t\t\t\tSET is_default = 0 \n\t\t\t\tWHERE list_id = ?\n\t\t\t", (int) $this->get('list_id'));
}
$vn_rc = parent::insert($pa_options);
if ($this->getPrimaryKey()) {
$t_list = new ca_lists();
$o_trans = $this->getTransaction();
$t_list->setTransaction($o_trans);
if ($t_list->load($this->get('list_id')) && $t_list->get('list_code') == 'place_hierarchies' && $this->get('parent_id')) {
// insert root or place hierarchy when creating non-root items in 'place_hierarchies' list
$t_locale = new ca_locales();
$va_locales = $this->getAppConfig()->getList('locale_defaults');
$vn_locale_id = $t_locale->localeCodeToID($va_locales[0]);
// create root in ca_places
$t_place = new ca_places();
$t_place->setTransaction($o_trans);
$t_place->setMode(ACCESS_WRITE);
$t_place->set('hierarchy_id', $this->getPrimaryKey());
$t_place->set('locale_id', $vn_locale_id);
$t_place->set('type_id', null);
$t_place->set('parent_id', null);
$t_place->set('idno', 'Root node for ' . $this->get('idno'));
$t_place->insert();
if ($t_place->numErrors()) {
$this->delete();
$this->errors = array_merge($this->errors, $t_place->errors);
return false;
}
$t_place->addLabel(array('name' => 'Root node for ' . $this->get('idno')), $vn_locale_id, null, true);
}
}
if ($this->numErrors()) {
$this->getTransaction()->rollback();
} else {
$this->getTransaction()->commit();
$this->_setSettingsForList();
}
return $vn_rc;
}
开发者ID:guaykuru,项目名称:pawtucket,代码行数:44,代码来源:ca_list_items.php
示例19: 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
|
请发表评论