<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.4 |
+ | CiviCRM version 4.5 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013 |
+ | Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
* $Id$
*
*/
/**
* Function to build the form
*
- * @return None
+ * @return void
* @access public
*/
public function buildQuickForm() {
CRM_Utils_System::setTitle(ts('Settings - Localization'));
$locales = CRM_Core_I18n::languages();
-
+ $warningTitle = json_encode(ts("Warning"));
$domain = new CRM_Core_DAO_Domain();
$domain->find(TRUE);
if ($domain->locales) {
$this->addElement('select', 'addLanguage', ts('Add Language'), array_merge(array('' => ts('- select -')), array_diff($locales, $lcMessages)));
// add the ability to return to single language
- $warning = ts('WARNING: This will make your CiviCRM installation a single-language one again. THIS WILL DELETE ALL DATA RELATED TO LANGUAGES OTHER THAN THE DEFAULT ONE SELECTED ABOVE (and only that language will be preserved).');
+ $warning = ts('This will make your CiviCRM installation a single-language one again. THIS WILL DELETE ALL DATA RELATED TO LANGUAGES OTHER THAN THE DEFAULT ONE SELECTED ABOVE (and only that language will be preserved).');
$this->assign('warning', $warning);
+ $warning = json_encode($warning);
$this->addElement('checkbox', 'makeSinglelingual', ts('Return to Single Language'),
- NULL, array('onChange' => "if (this.checked) alert('$warning')")
+ NULL, array('onChange' => "if (this.checked) CRM.alert($warning, $warningTitle)")
);
}
else {
// for single-lingual sites, populate default language drop-down with all languages
$this->addElement('select', 'lcMessages', ts('Default Language'), $locales);
- $warning = ts('WARNING: Enabling multiple languages changes the schema of your database, so make sure you know what you are doing when enabling this function; making a database backup is strongly recommended.');
+ $warning = ts('Enabling multiple languages changes the schema of your database, so make sure you know what you are doing when enabling this function; making a database backup is strongly recommended.');
$this->assign('warning', $warning);
-
+ $warning = json_encode($warning);
$validTriggerPermission = CRM_Core_DAO::checkTriggerViewPermission(TRUE);
if ($validTriggerPermission &&
!$config->logging
) {
$this->addElement('checkbox', 'makeMultilingual', ts('Enable Multiple Languages'),
- NULL, array('onChange' => "if (this.checked) alert('$warning')")
+ NULL, array('onChange' => "if (this.checked) CRM.alert($warning, $warningTitle)")
);
}
}
$includeState->setButtonAttributes('remove', array('value' => ts('<< Remove')));
$this->addElement('select', 'defaultContactCountry', ts('Default Country'), array('' => ts('- select -')) + $country);
-
- /***Default State/Province***/
- $stateCountryMap = array();
- $stateCountryMap[] = array(
- 'state_province' => 'defaultContactStateProvince',
- 'country' => 'defaultContactCountry',
- );
-
- $countryDefault = isset($this->_submitValues['defaultContactCountry']) ? $this->_submitValues['defaultContactCountry'] : $config->defaultContactCountry;
-
- if ($countryDefault) {
- $selectStateProvinceOptions = array('' => ts('- select -')) + CRM_Core_PseudoConstant::stateProvinceForCountry($countryDefault);
- }
- else {
- $selectStateProvinceOptions = array('' => ts('- select a country -'));
- }
-
- $i18n->localizeArray($selectStateProvinceOptions, array('context' => 'state_province'));
- asort($selectStateProvinceOptions);
-
- $this->addElement('select', 'defaultContactStateProvince', ts('Default State/Province'), $selectStateProvinceOptions);
-
- // state country js
- CRM_Core_BAO_Address::addStateCountryMap($stateCountryMap);
-
- $defaults = array();
- CRM_Core_BAO_Address::fixAllStateSelects($form, $defaults);
+ $this->addChainSelect('defaultContactStateProvince', array('label' => ts('Default State/Province')));
// we do this only to initialize currencySymbols, kinda hackish but works!
$config->defaultCurrencySymbol();
parent::buildQuickForm();
}
+ /**
+ * @param $fields
+ *
+ * @return array|bool
+ */
static function formRule($fields) {
$errors = array();
if (CRM_Utils_Array::value('monetaryThousandSeparator', $fields) ==
// CRM-7962, CRM-7713, CRM-9004
if (!empty($fields['defaultContactCountry']) &&
- (CRM_Utils_Array::value('countryLimit', $fields) &&
+ (!empty($fields['countryLimit']) &&
(!in_array($fields['defaultContactCountry'], $fields['countryLimit']))
)
) {
unset($values['currencyLimit']);
// make the site multi-lang if requested
- if (CRM_Utils_Array::value('makeMultilingual', $values)) {
+ if (!empty($values['makeMultilingual'])) {
CRM_Core_I18n_Schema::makeMultilingual($values['lcMessages']);
$values['languageLimit'][$values['lcMessages']] = 1;
// make the site single-lang if requested
}
- elseif (CRM_Utils_Array::value('makeSinglelingual', $values)) {
+ elseif (!empty($values['makeSinglelingual'])) {
CRM_Core_I18n_Schema::makeSinglelingual($values['lcMessages']);
$values['languageLimit'] = '';
}