From 76b4a2ce06a05f614a1e4cd771cae07d6f8fe14a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 27 Aug 2017 12:52:26 +0200 Subject: [PATCH] Can set language file to use for label key of extra field --- htdocs/core/actions_extrafields.inc.php | 12 ++-- htdocs/core/tpl/admin_extrafields_add.tpl.php | 22 ++++---- .../core/tpl/admin_extrafields_edit.tpl.php | 55 +++++++++---------- htdocs/langs/en_US/admin.lang | 1 + 4 files changed, 46 insertions(+), 44 deletions(-) diff --git a/htdocs/core/actions_extrafields.inc.php b/htdocs/core/actions_extrafields.inc.php index 278a931b437..96dd3e3f7b9 100644 --- a/htdocs/core/actions_extrafields.inc.php +++ b/htdocs/core/actions_extrafields.inc.php @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . * or see http://www.gnu.org/ - * + * * $elementype must be defined. */ @@ -158,12 +158,11 @@ if ($action == 'add') $params['options'][$key] = $value; } } - $result=$extrafields->addExtraField( GETPOST('attrname', 'alpha'), GETPOST('label', 'alpha'), $type, - GETPOST('pos', 'alpha'), + GETPOST('pos', 'int'), $extrasize, $elementtype, (GETPOST('unique', 'alpha')?1:0), @@ -175,8 +174,8 @@ if ($action == 'add') (GETPOST('list', 'alpha')?1:0), (GETPOST('ishidden', 'alpha')?1:0), GETPOST('computed_value','alpha'), - (GETPOST('entitycurrentorall', 'alpha')?0:'') - + (GETPOST('entitycurrentorall', 'alpha')?0:''), + GETPOST('langfile', 'alpha') ); if ($result > 0) { @@ -338,7 +337,8 @@ if ($action == 'update') (GETPOST('ishidden', 'alpha')?1:0), GETPOST('default_value','alpha'), GETPOST('computed_value','alpha'), - (GETPOST('entitycurrentorall', 'alpha')?0:'') + (GETPOST('entitycurrentorall', 'alpha')?0:''), + GETPOST('langfile') ); if ($result > 0) { diff --git a/htdocs/core/tpl/admin_extrafields_add.tpl.php b/htdocs/core/tpl/admin_extrafields_add.tpl.php index ce63a3a0902..a7f98bdba72 100644 --- a/htdocs/core/tpl/admin_extrafields_add.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_add.tpl.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2010-2017 Laurent Destailleur * Copyright (C) 2012 Regis Houssin * Copyright (C) 2016 Charlie Benke * @@ -56,11 +56,11 @@ // Case of computed field console.log(type); - if (type == '' || type == 'varchar' || type == 'int' || type == 'double' || type == 'price') { - jQuery("tr.extra_computed_value").show(); + if (type == '' || type == 'varchar' || type == 'int' || type == 'double' || type == 'price') { + jQuery("tr.extra_computed_value").show(); } else { computed_value.val(''); jQuery("tr.extra_computed_value").hide(); - } + } if (computed_value.val()) { console.log("We enter a computed formula"); @@ -75,7 +75,7 @@ jQuery("#default_value, #unique, #required, #alwayseditable, #ishidden, #list").attr('disabled', false); jQuery("tr.extra_default_value, tr.extra_unique, tr.extra_required, tr.extra_alwayseditable, tr.extra_ishidden, tr.extra_list").show(); } - + if (type == 'date') { size.val('').prop('disabled', true); unique.removeAttr('disabled'); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide(); } else if (type == 'datetime') { size.val('').prop('disabled', true); unique.removeAttr('disabled'); jQuery("#value_choice").hide(); jQuery("#helpchkbxlst").hide();} else if (type == 'double') { size.val('24,8').removeAttr('disabled'); unique.removeAttr('disabled'); jQuery("#value_choice").hide(); jQuery("#helpchkbxlst").hide();} @@ -90,8 +90,8 @@ else if (type == 'checkbox') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();} else if (type == 'chkbxlst') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").show();jQuery("#helplink").hide();} else if (type == 'link') { size.val('').prop('disabled', true); unique.removeAttr('disabled'); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").show();} - else if (type == 'separate') { - size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); required.val('').prop('disabled', true); + else if (type == 'separate') { + size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); required.val('').prop('disabled', true); jQuery("#value_choice").hide();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide(); } else { // type = string @@ -102,12 +102,12 @@ if (type == 'separate') { required.removeAttr('checked').prop('disabled', true); alwayseditable.removeAttr('checked').prop('disabled', true); list.val('').prop('disabled', true); - jQuery('#size, #default_value').val('').prop('disabled', true); + jQuery('#size, #default_value').val('').prop('disabled', true); } else { default_value.removeAttr('disabled'); - required.removeAttr('disabled'); alwayseditable.removeAttr('disabled'); list.val('').removeAttr('disabled'); + required.removeAttr('disabled'); alwayseditable.removeAttr('disabled'); list.val('').removeAttr('disabled'); } } init_typeoffields(''); @@ -158,7 +158,9 @@ -trans("Position"); ?> +trans("Position"); ?> + +trans("LanguageFile"); ?> textwithpicto($langs->trans("ComputedFormula"), $langs->trans("ComputedFormulaDesc"), 1, 'help', '', 0, 2, 'tooltipcompute'); ?>"> diff --git a/htdocs/core/tpl/admin_extrafields_edit.tpl.php b/htdocs/core/tpl/admin_extrafields_edit.tpl.php index 5a9a5b43d93..beb1e34055e 100644 --- a/htdocs/core/tpl/admin_extrafields_edit.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_edit.tpl.php @@ -54,11 +54,11 @@ ?> // Case of computed field - if (type == 'varchar' || type == 'int' || type == 'double' || type == 'price') { - jQuery("tr.extra_computed_value").show(); + if (type == 'varchar' || type == 'int' || type == 'double' || type == 'price') { + jQuery("tr.extra_computed_value").show(); } else { computed_value.val(''); jQuery("tr.extra_computed_value").hide(); - } + } if (computed_value.val()) { console.log("We enter a computed formula"); @@ -73,7 +73,7 @@ jQuery("#default_value, #unique, #required, #alwayseditable, #ishidden, #list").attr('disabled', false); jQuery("tr.extra_default_value, tr.extra_unique, tr.extra_required, tr.extra_alwayseditable, tr.extra_ishidden, tr.extra_list").show(); } - + if (type == 'date') { size.val('').prop('disabled', true); unique.removeAttr('disabled'); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide(); } else if (type == 'datetime') { size.val('').prop('disabled', true); unique.removeAttr('disabled'); jQuery("#value_choice").hide(); jQuery("#helpchkbxlst").hide();} else if (type == 'double') { size.removeAttr('disabled'); unique.removeAttr('disabled'); jQuery("#value_choice").hide(); jQuery("#helpchkbxlst").hide();} @@ -91,19 +91,19 @@ else if (type == 'separate') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); required.val('').prop('disabled', true); default_value.val('').prop('disabled', true); jQuery("#value_choice").hide();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();} else { // type = string size.val('').prop('disabled', true); - unique.removeAttr('disabled'); + unique.removeAttr('disabled'); } if (type == 'separate') { - required.removeAttr('checked').prop('disabled', true); alwayseditable.removeAttr('checked').prop('disabled', true); list.val('').prop('disabled', true); - jQuery('#size, #default_value').val('').prop('disabled', true); + required.removeAttr('checked').prop('disabled', true); alwayseditable.removeAttr('checked').prop('disabled', true); list.val('').prop('disabled', true); + jQuery('#size, #default_value').val('').prop('disabled', true); } else { default_value.removeAttr('disabled'); - required.removeAttr('disabled'); alwayseditable.removeAttr('disabled'); list.val('').removeAttr('disabled'); - } + required.removeAttr('disabled'); alwayseditable.removeAttr('disabled'); list.val('').removeAttr('disabled'); + } } init_typeoffields(jQuery("#type").val()); jQuery("#type").change(function() { @@ -113,7 +113,7 @@ // If we enter a formula, we disable other fields jQuery("#computed_value").keyup(function() { init_typeoffields(jQuery('#type').val()); - }); + }); }); @@ -129,23 +129,20 @@ attribute_type[$attrname]; -$size=$extrafields->attribute_size[$attrname]; -$computed=$extrafields->attribute_computed[$attrname]; -$default=$extrafields->attribute_default[$attrname]; -$unique=$extrafields->attribute_unique[$attrname]; -$required=$extrafields->attribute_required[$attrname]; -$pos=$extrafields->attribute_pos[$attrname]; -$alwayseditable=$extrafields->attribute_alwayseditable[$attrname]; -$param=$extrafields->attribute_param[$attrname]; -$perms=$extrafields->attribute_perms[$attrname]; -$list=$extrafields->attribute_list[$attrname]; -if (! empty($conf->global->MAIN_CAN_HIDE_EXTRAFIELDS)) { - $ishidden=$extrafields->attribute_hidden[$attrname]; -} -if ($conf->multicompany->enabled) { - $entitycurrentorall=$extrafields->attribute_entityid[$attrname]; -} +$type=$extrafields->attributes[$elementtype]['type'][$attrname]; +$size=$extrafields->attributes[$elementtype]['size'][$attrname]; +$computed=$extrafields->attributes[$elementtype]['computed'][$attrname]; +$default=$extrafields->attributes[$elementtype]['default'][$attrname]; +$unique=$extrafields->attributes[$elementtype]['unique'][$attrname]; +$required=$extrafields->attributes[$elementtype]['required'][$attrname]; +$pos=$extrafields->attributes[$elementtype]['pos'][$attrname]; +$alwayseditable=$extrafields->attributes[$elementtype]['alwayseditable'][$attrname]; +$param=$extrafields->attributes[$elementtype]['param'][$attrname]; +$perms=$extrafields->attributes[$elementtype]['perms'][$attrname]; +$langfile=$extrafields->attributes[$elementtype]['langfile'][$attrname]; +$list=$extrafields->attributes[$elementtype]['list'][$attrname]; +$ishidden=$extrafields->attributes[$elementtype]['hidden'][$attrname]; +$entitycurrentorall=$extrafields->attributes[$elementtype]['entityid'][$attrname]; if((($type == 'select') || ($type == 'checkbox') || ($type == 'radio')) && is_array($param)) { @@ -220,7 +217,9 @@ else - + + + diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 84ee52167a9..b4cce97957a 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -345,6 +345,7 @@ AddCRIfTooLong=There is no automatic wrapping, so if line is out of page on docu ConfirmPurge=Are you sure you want to execute this purge?
This will delete definitely all your data files with no way to restore them (ECM files, attached files...). MinLength=Minimum length LanguageFilesCachedIntoShmopSharedMemory=Files .lang loaded in shared memory +LanguageFile=Language file ExamplesWithCurrentSetup=Examples with current running setup ListOfDirectories=List of OpenDocument templates directories ListOfDirectoriesForModelGenODT=List of directories containing templates files with OpenDocument format.

Put here full path of directories.
Add a carriage return between eah directory.
To add a directory of the GED module, add here DOL_DATA_ROOT/ecm/yourdirectoryname.

Files in those directories must end with .odt or .ods.
trans("Position"); ?>
trans("Position"); ?>
trans("LanguageFile"); ?>
textwithpicto($langs->trans("ComputedFormula"), $langs->trans("ComputedFormulaDesc"), 1, 'help', '', 0, 2, 'tooltipcompute'); ?>