class CRM_Core_I18n_Form extends CRM_Core_Form {
function buildQuickForm() {
$config = CRM_Core_Config::singleton();
+ global $tsLocale;
$this->_locales = array_keys($config->languageLimit);
// get the part of the database we want to edit and validate it
$languages = CRM_Core_I18n::languages(TRUE);
foreach ($this->_locales as $locale) {
- $this->addElement($type, "{$field}_{$locale}", $languages[$locale], array('cols' => 60, 'rows' => 3));
+ $this->addElement($type, "{$field}_{$locale}", $languages[$locale], array('class' => 'huge huge12' . ($locale == $tsLocale ? ' default-lang' : '')));
$this->_defaults["{$field}_{$locale}"] = $dao->$locale;
}
- $this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'isDefault' => TRUE)));
+ $this->addDefaultButtons(ts('Save'), 'next', NULL);
+
+ CRM_Utils_System::setTitle(ts('Languages'));
- global $tsLocale;
- $this->assign('tsLocale', $tsLocale);
$this->assign('locales', $this->_locales);
$this->assign('field', $field);
- $this->assign('context', CRM_Utils_Request::retrieve('context', 'String', $this));
}
/**
$dao = new CRM_Core_DAO();
$query = CRM_Core_DAO::composeQuery($query, $params, TRUE);
$dao->query($query, FALSE);
-
- CRM_Utils_System::civiExit();
}
}
$items[] = "js/jquery/jquery.crmeditable.js";
}
+ // JS for multilingual installations
+ if (!empty($config->languageLimit) && count($config->languageLimit) > 1 && CRM_Core_Permission::check('translate CiviCRM')) {
+ $items[] = "js/crm.multilingual.js";
+ }
+
// Enable administrators to edit option lists in a dialog
if (CRM_Core_Permission::check('administer CiviCRM') && $this->ajaxPopupsEnabled) {
$items[] = "js/crm.optionEdit.js";
--- /dev/null
+// http://civicrm.org/licensing
+// JS needed for multilingual installations
+CRM.$(function($) {
+ // This is largely redundant with what the CRM.popup function would do,
+ // with the difference that this loads unconditionally regardless of ajaxPopupsEnabled setting
+ $('body').on('click', 'a.crm-multilingual-edit-button', function(e) {
+ var $el = $(this),
+ $form = $el.closest('form'),
+ $field = $('#' + $el.data('field'), $form);
+
+ CRM.loadForm($el.attr('href'), {
+ dialog: {width: '50%', height: '50%'}
+ })
+ .on('crmFormLoad', function() {
+ $('.default-lang', this).val($field.val());
+ })
+ .on('crmFormSubmit', function() {
+ $field.val($('.default-lang', this).val());
+ $el.trigger('crmPopupFormSuccess');
+ });
+ e.preventDefault();
+ });
+});
+--------------------------------------------------------------------+
*}
{if $config->languageLimit|@count >= 2 and $translatePermission }
-<a href="#" onclick="loadDialog('{crmURL p='civicrm/i18n' q="reset=1&table=$table&field=$field&id=$id&snippet=1&context=dialog" h=0}', '{$field}'); return false;"><img src="{$config->resourceBase}i/langs.png" /></a><div id="locale-dialog_{$field}" style="display:none"></div>
-
-{literal}
-<script type="text/javascript">
-function loadDialog( url, fieldName ) {
- cj.ajax({
- url: url,
- success: function( content ) {
- cj("#locale-dialog_" +fieldName ).show( ).html( content ).dialog({
- modal : true,
- width : 290,
- height : 290,
- resizable : true,
- beforeclose : function(event, ui) {
- cj(this).dialog("destroy");
- }
- });
- }
- });
-}
-</script>
-{/literal}
+ <a href="{crmURL p='civicrm/i18n' q="reset=1&table=$table&field=$field&id=$id"}" data-field="{$field}" class="crm-hover-button crm-multilingual-edit-button" title="{ts}Languages{/ts}">
+ <img src="{$config->resourceBase}i/langs.png" style="position:relative; top: 2px;"/>
+ </a>
{/if}
<dt>{$form.$elem.label}</dt><dd>{$form.$elem.html}</dd>
{/foreach}
</dl>
- {if $context == 'dialog'}
- <input type="submit" value="Save"/>
- {else}
- {$form.buttons.html}
- {/if}
</fieldset>
-{$form.action}
-{literal}
-<script type="text/javascript">
-var fieldName = "{/literal}{$field}{literal}";
-var tsLocale = "{/literal}{$tsLocale}{literal}";
-var $form = cj('form.{/literal}{$form.formClass}{literal}');
-cj($form).submit(function() {
- cj(this).ajaxSubmit({
- beforeSubmit: function (formData, jqForm, options) {
- var queryString = cj.param(formData);
- var postUrl = cj($form).attr('action');
- cj.ajax({
- type : "POST",
- url : postUrl,
- async : false,
- data : queryString,
- success: function( response ) {
- cj('#' + fieldName).val( cj('#' + fieldName +'_' + tsLocale ).val() );
- cj("#locale-dialog_"+fieldName).dialog("close");
- }
- });
- return false;
- }});
- return false;
-});
-</script>
-{/literal}
+<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>