Sugar and module builder supports field specific help that will be shown as tooltip of a control in the different views. There is unfortunately no localization support for this in sugar (meaning that the tooltips will always be in one language).
This posting and hack adds that localization support of vardefs field help text.
The way this works is:
1. Create or edit a field in Module Builder. (You will notice a new help text & help label field.)
2. The default language help text needs to be entered in help text. (There is no need to modify help label name.)
3. Save the field.
4. Go to labels localization screen, change the desired language, find the field help label and enter localized value then save the label. Put the field in one of the layouts. Then deploy package.
5. Based on login language, help tool tip value will be shown from language file.
This customization is nonupgrade safe.
The following files have been modified
1. include/EditView/EditView2.php
a. Following block added in function display to assign localized help value to editview.
//HACK : -- Add localization to vardef field_help
foreach($this->fieldDefs as $key => $val){
$tempk = ''; $tempv='';
if(isset($this->fieldDefs[$key]['help'])){
$tempk = $this->fieldDefs[$key]['help'];
}else{
$tempk = "LBL_".mb_strtoupper($this->fieldDefs[$key]['name'])."_HELP";
}
$tempv = translate($tempk, $this->module);
if($tempv!=$tempk){
//HACK :-- Translating help fields
//$this->fieldDefs[$key]['help'] = $tempv;
if($this->fieldDefs[$key]['type']=='radioenum'){
$this->fieldDefs[$key]['help'] = $tempk;
}else{
$this->fieldDefs[$key]['help'] = "{php}echo smarty_function_sugar_translate(array('label' => '$tempk' ,'module' => '$this->module'), \$this);{/php}";
}
//HACK : -- Add localization to vardef field_help
}else{
$this->fieldDefs[$key]['help'] ='';
}
if(isset($this->fieldDefs[$key]['validation']['functionName']) && !empty($this->fieldDefs[$key]['validation']['functionName'])){
if(isset($this->fieldDefs[$key]['customjs'])){
$tempscript.='{literal}<script type="text/javascript" language="Javascript">'.html_entity_decode($this->fieldDefs[$key]['customjs'],ENT_QUOTES).'</script>{/literal}';
}
if(isset($this->fieldDefs[$key]['validation'])&& is_array($this->fieldDefs[$key]['validation'])!=true){
$this->fieldDefs[$key]['validation'] = unserialize(html_entity_decode($this->fieldDefs[$key]['validation']));
}
}
}
$this->th->ss->assign('scriptBlocks', $tempscript);
//HACK :
2. include/SearchForm/SearchForm2.php
a. Following block added in function display to assign localized help value to editview.
//HACK : -- Add localization to vardef field_help
foreach($this->fieldDefs as $key => $val){
$tempk = ''; $tempv='';
if(isset($this->fieldDefs[$key]['help'])){
$tempk = $this->fieldDefs[$key]['help'];
}else{
$tempk = "LBL_".mb_strtoupper($this->fieldDefs[$key]['name'])."_HELP";
}
$tempv = translate($tempk, $this->module);
if($tempv!=$tempk){
//HACK :-- Translating help fields
//$this->fieldDefs[$key]['help'] = $tempv;
if($this->fieldDefs[$key]['type']=='radioenum'){
$this->fieldDefs[$key]['help'] = $tempk;
}else{
$this->fieldDefs[$key]['help'] = "{php}echo smarty_function_sugar_translate(array('label' => '$tempk' ,'module' => '$this->module'), \$this);{/php}";
}
//HACK : -- Add localization to vardef field_help
}else{
$this->fieldDefs[$key]['help'] ='';
}
}
//HACK :
3. modules/DynamicFields/DynamicField.php
a. In function addFieldObject, value of $fmd->help set from $field->help_label.
//HACK : -- Add localization to vardef field_help
$fmd->help = $field->help_label;
//HACK : -- Add localization to vardef field_help
4. modules/DynamicFields/templates/Fields/Forms/coreTop.tpl
a. Template modified for help label & its automatic assignment of value based on its field name.
<table width="100%">
<tr>
<td class='mbLBL' width='30%' >{$MOD.COLUMN_TITLE_NAME}:</td>
<td>
{if $hideLevel == 0}
{* HACK: -- Add localization to vardef field_help
Added javascript statement for automatic help label assignment *}
<input id="field_name_id" maxlength=30 type="text" name="name" value="{$vardef.name}" onchange="document.getElementById('label_key_id').value = 'LBL_'+document.getElementById('field_name_id').value.toUpperCase();
document.getElementById('label_value_id').value = document.getElementById('field_name_id').value.replace(/_/,' ');
document.getElementById('field_name_id').value = document.getElementById('field_name_id').value.toLowerCase();
document.getElementById('help_key_id').value = 'LBL_'+(document.getElementById('field_name_id').value.toUpperCase())+'_HELP';" />
{* HACK: *}
{else}
{* HACK: -- Add localization to vardef field_help
Added javascript statement for automatic help label assignment *}
<input id= "field_name_id" maxlength=30 type="hidden" name="name" value="{$vardef.name}"
onchange="document.getElementById('label_key_id').value = 'LBL_'+document.getElementById('field_name_id').value.toUpperCase();
document.getElementById('label_value_id').value = document.getElementById('field_name_id').value.replace(/_/,' ');
document.getElementById('field_name_id').value = document.getElementById('field_name_id').value.toLowerCase();
document.getElementById('help_key_id').value = 'LBL_'+(document.getElementById('field_name_id').value.toUpperCase())+'_HELP';"/>{$vardef.name}{/if}
{* HACK: *}
<script>
addToValidate('popup_form', 'name', 'DBName', true,'{$MOD.COLUMN_TITLE_NAME} [a-zA-Z_]' );
addToValidateIsInArray('popup_form', 'name', 'in_array', true,'{$MOD.ERR_RESERVED_FIELD_NAME}', '{$field_name_exceptions}', 'u==');
</script>
</td>
</tr>
<tr>
<td class='mbLBL'>{$MOD.COLUMN_TITLE_DISPLAY_LABEL}:</td>
<td>
<input id="label_value_id" type="text" name="labelValue" value="{$lbl_value}">
</td>
</tr>
<tr>
<td class='mbLBL'>{$MOD.COLUMN_TITLE_LABEL}:</td>
<td>
{if $hideLevel < 5}
<input id ="label_key_id" type="text" name="label" value="{$vardef.vname}">
{else}
<input id ="label_key_id" type="hidden" name="label" value="{$vardef.vname}">{$vardef.vname}
{/if}
</td>
</tr>
{* HACK: -- Add localization to vardef field_help ,Course module Accounting type does not work *}
<tr>
<td class='mbLBL'>{$MOD.COLUMN_TITLE_HELP_TEXT}:</td>
<td>
<input type="text" id="help_value_id" name="help" value="{$vardef.help}" onchange="if(document.getElementById('help_key_id').value == '') document.getElementById('help_key_id').value='LBL_'+(document.getElementById('field_name_id').value.toUpperCase())+'_HELP';">
</td>
</tr>
<tr>
<td class='mbLBL'>{$MOD.COLUMN_TITLE_HELP_LABEL}:</td>
<td>{if $hideLevel < 5 }
<input type="text" id="help_key_id" name="help_label" value="{$vardef.help_label}">
{else}
<input type="hidden" id="help_key_id" name="help_label" value="{$vardef.help_label}">{$vardef.help_label}
{/if}
</td>
</tr>
{* HACK: *}
<tr>
<td class='mbLBL'>{$MOD.COLUMN_TITLE_COMMENT_TEXT}:</td><td>{if $hideLevel < 5 }<input type="text" name="comments" value="{$vardef.comments}">{else}<input type="hidden" name="comment" value="{$vardef.comment}">{$vardef.comment}{/if}
</td>
</tr>
5. modules/DynamicFields/templates/Fields/TemplateField.php
a. New class variable added
//HACK : -- Add localization to vardef field_help
// for initialisation of bean value.
var $help_label ='';
//HACK : -- Add localization to vardef field_help
b. New key value pair added to array for new vardef property help_label
var $vardef_map = array(
'name'=>'name',
'label'=>'vname',
// bug 15801 - need to ALWAYS keep default and default_value consistent as some methods/classes use one, some use another...
'default_value'=>'default',
'default'=>'default_value',
//'default_value'=>'default_value',
//'default'=>'default_value',
'len'=>'len',
'required'=>'required',
'type'=>'type',
'audited'=>'audited',
'massupdate'=>'massupdate',
'options'=>'ext1',
'help'=>'help',
'comments'=>'comment',
'importable'=>'importable',
'duplicate_merge'=>'duplicate_merge',
//'duplicate_merge_dom_value'=>'duplicate_merge', //bug #14897
'reportable' => 'reportable',
'min'=>'ext1',
'max'=>'ext2',
'ext2'=>'ext2',
'ext4'=>'ext4',
//'disable_num_format'=>'ext3',
'ext3'=>'ext3',
'label_value'=>'label_value',
//HACK : -- Add localization to vardef field_help
//used for vardef mapping.
'help_label'=>'help_label',
//HACK :
);
6. modules/EditCustomFields/FieldsMetaData.php
a. In class FieldsMetaData 2 new class variable added.
//HACK : -- Add localization to vardef field_help
var $help;
var $help_label;
//HACK : -- Add localization to vardef field_help
b. 2 New key value pair added to array for new vardef property .
var $column_fields = array(
'id',
'name',
'vname',
'custom_module',
'type',
'len',
'required',
'default_value',
'deleted',
'ext1',
'ext2',
'ext3',
//HACK : -- Add localization to vardef field_help
'help',
'help_label',
//HACK :
'audited',
'massupdate',
'duplicate_merge',
'reportable',
);
7. modules/EditCustomFields/language/en_us.lang.php
a. Help label
// HACK : -- Add localization to vardef field_help
// label for the new help label
$mod_strings['COLUMN_TITLE_HELP_LABEL'] = 'Help Label';
// HACK : -- Add localization to vardef field_help
8. modules/EditCustomFields/vardefs.php
a. New field added for help_label.
// HACK : -- Add localization to vardef field_help
// Added for adding new field help label in module builder.
$dictionary['FieldsMetaData']['fields']['help_label']=array('name' =>'help_label' ,'type' =>'varchar','vname'=>'COLUMN_TITLE_LABEL', 'len'=>'255');
// HACK : -- Add localization to vardef field_help
9. modules/ModuleBuilder/controller.php
a. function action_SaveLabel modified to set value of help_label.
// HACK : -- Add localization to vardef field_help
if (isset($_REQUEST['help_label']) && isset ($_REQUEST['help' ])){
if(empty($_REQUEST['help_label'])){
$_REQUEST['help_label']="LBL_".$_REQUEST['name']."_HELP";
}
$_REQUEST [ "label_" . $_REQUEST['help_label'] ] = $_REQUEST [ 'help' ] ;
}
// HACK : -- Add localization to vardef field_help
b. function action_SaveField is modified to set help_label value in vardefs before saving mbvardefs & value of label in language file of current language before saving modue.
//HACK : -- Add localization to vardef field_help
if(isset($_REQUEST['help_label']) && empty($_REQUEST['help_label']))
$_REQUEST['help_label']="LBL_".mb_strtoupper($_REQUEST['name'])."_HELP";
$module->mbvardefs->vardef['fields'][$_REQUEST['name']]['help']=$_REQUEST['help_label'];
//HACK :
$module->mbvardefs->save () ;
// get the module again to refresh the labels we might have saved with the $field->save (e.g., for address fields)
$module = & $mb->getPackageModule ( $_REQUEST [ 'view_package' ], $_REQUEST [ 'view_module' ] ) ;
if (isset ( $_REQUEST [ 'label' ] ) && isset ( $_REQUEST [ 'labelValue' ] ))
$module->setLabel ( $GLOBALS [ 'current_language' ], $_REQUEST [ 'label' ], $_REQUEST [ 'labelValue' ] ) ;
//HACK : -- Add localization to vardef field_help
//setting the help text and label for current language.
if (isset($_REQUEST['help_label']) && isset ($_REQUEST['help']))
$module->setLabel($GLOBALS['current_language'],$_REQUEST['help_label'],$_REQUEST['help']);
//HACK :
10. modules/ModuleBuilder/views/view.modulefield.php
a. Code block added to set value fo $vardef[‘help’] and $vardef[‘help_label’]. Following code block is for studio code.
//HACK : -- Add localization to vardef field_help
$temp_var_help_translation='';
if(isset($vardef['help'])){
if(!empty($vardef['help'])){
$temp_var_help_translation=translate(mb_strtoupper($vardef['help']),$moduleName);
if($temp_var_help_translation != mb_strtoupper($vardef['help'])){
$vardef['help_label']=$vardef['help'];
$vardef['help']=$temp_var_help_translation;
}else{
$vardef['help_label']=$vardef['help'];
$vardef['help']='';
}
}
}elseif(!empty($vardef['name'])){
$tempkey="LBL_".mb_strtoupper($vardef['name'])."_HELP";
$temp_var_help_translation = translate(mb_strtoupper($tempkey),$moduleName);
if($temp_var_help_translation != mb_strtoupper($tempkey)){
$vardef['help_label']=$tempkey;
$vardef['help']=$temp_var_help_translation;
}else{
$vardef['help_label']=$tempkey;
$vardef['help']='';
}
}
//HACK :
b. Code block added to set value fo $vardef[‘help’] and $vardef[‘help_label’]. Following code block is for module builder code.
//HACK : -- Add localization to vardef field_help
$temp_var_help_translation='';
if(isset($vardef['help'])){
if(!empty($vardef['help'])){
//HACK:Upgrade sugarbase to SugarCRM 5.5
$temp_var_help_translation=$module->getLabel($GLOBALS['current_language'],$vardef['help']);
//HACK:Upgrade sugarbase to SugarCRM 5.5
if(!empty($temp_var_help_translation)){
$vardef['help_label']=$vardef['help'];
$vardef['help']=$temp_var_help_translation;
}else{
$vardef['help_label']=$vardef['help'];
$vardef['help']='';
}
}
}elseif(!empty($vardef['name'])){
$tempkey="LBL_".mb_strtoupper($vardef['name'])."_HELP";
//HACK:Upgrade sugarbase to SugarCRM 5.5
$temp_var_help_translation=$module->getLabel($GLOBALS['current_language'],$tempkey);
//HACK:Upgrade sugarbase to SugarCRM 5.5
if(!empty($temp_var_help_translation)){
$vardef['help_label']=$tempkey;
$vardef['help']=$temp_var_help_translation;
}else{
$vardef['help_label']=$tempkey;
$vardef['help']='';
}
}
//HACK :
11. Add new field in fields_meta_data table by running following query.
ALTER TABLE fields_meta_data
add column help_label varchar (255) Null
Changes made in language file & vardefs files are not upgrade safe. While building package move it to upgrade-safe files.
And finally the SVN diff containing the changes
Index: include/EditView/EditView2.php
===================================================================
--- include/EditView/EditView2.php (revision 1)
+++ include/EditView/EditView2.php (working copy)
@@ -447,6 +447,38 @@
$this->th->ss->assign('offset', $this->offset + 1);
$this->th->ss->assign('APP', $app_strings);
$this->th->ss->assign('MOD', $mod_strings);
+ //HACK : -- Add localization to vardef field_help
+ foreach($this->fieldDefs as $key => $val){
+ $tempk = ''; $tempv='';
+ if(isset($this->fieldDefs[$key]['help'])){
+ $tempk = $this->fieldDefs[$key]['help'];
+ }else{
+ $tempk = "LBL_".mb_strtoupper($this->fieldDefs[$key]['name'])."_HELP";
+ }
+ $tempv = translate($tempk, $this->module);
+ if($tempv!=$tempk){
+ //HACK :-- Translating help fields
+ //$this->fieldDefs[$key]['help'] = $tempv;
+ if($this->fieldDefs[$key]['type']=='radioenum'){
+ $this->fieldDefs[$key]['help'] = $tempk;
+ }else{
+ $this->fieldDefs[$key]['help'] = "{php}echo smarty_function_sugar_translate(array('label' => '$tempk' ,'module' => '$this->module'), \$this);{/php}";
+ }
+ //HACK :
+ }else{
+ $this->fieldDefs[$key]['help'] ='';
+ }
+ if(isset($this->fieldDefs[$key]['validation']['functionName']) && !empty($this->fieldDefs[$key]['validation']['functionName'])){
+ if(isset($this->fieldDefs[$key]['customjs'])){
+ $tempscript.='{literal}<script type="text/javascript" language="Javascript">'.html_entity_decode($this->fieldDefs[$key]['customjs'],ENT_QUOTES).'</script>{/literal}';
+ }
+ if(isset($this->fieldDefs[$key]['validation'])&& is_array($this->fieldDefs[$key]['validation'])!=true){
+ $this->fieldDefs[$key]['validation'] = unserialize(html_entity_decode($this->fieldDefs[$key]['validation']));
+ }
+ }
+ }
+ $this->th->ss->assign('scriptBlocks', $tempscript);
+ //HACK :
$this->th->ss->assign('fields', $this->fieldDefs);
$this->th->ss->assign('sectionPanels', $this->sectionPanels);
$this->th->ss->assign('returnModule', $this->returnModule);
Index: include/SearchForm/SearchForm2.php
===================================================================
--- include/SearchForm/SearchForm2.php (revision 1)
+++ include/SearchForm/SearchForm2.php (working copy)
@@ -161,7 +161,29 @@
if($this->nbTabs>1){
$this->th->ss->assign('TABS', $this->_displayTabs($this->module . '|' . $this->displayView));
}
-
+ //HACK : -- Add localization to vardef field_help
+ foreach($this->fieldDefs as $key => $val){
+ $tempk = ''; $tempv='';
+ if(isset($this->fieldDefs[$key]['help'])){
+ $tempk = $this->fieldDefs[$key]['help'];
+ }else{
+ $tempk = "LBL_".mb_strtoupper($this->fieldDefs[$key]['name'])."_HELP";
+ }
+ $tempv = translate($tempk, $this->module);
+ if($tempv!=$tempk){
+ //HACK :-- Translating help fields
+ //$this->fieldDefs[$key]['help'] = $tempv;
+ if($this->fieldDefs[$key]['type']=='radioenum'){
+ $this->fieldDefs[$key]['help'] = $tempk;
+ }else{
+ $this->fieldDefs[$key]['help'] = "{php}echo smarty_function_sugar_translate(array('label' => '$tempk' ,'module' => '$this->module'), \$this);{/php}";
+ }
+ //HACK :
+ }else{
+ $this->fieldDefs[$key]['help'] ='';
+ }
+ }
+ //HACK :
$this->th->ss->assign('fields', $this->fieldDefs);
$this->th->ss->assign('customFields', $this->customFieldDefs);
$this->th->ss->assign('formData', $this->formData);
Index: modules/DynamicFields/DynamicField.php
===================================================================
--- modules/DynamicFields/DynamicField.php (revision 1)
+++ modules/DynamicFields/DynamicField.php (working copy)
@@ -507,7 +507,9 @@
$fmd->name = $db_name;
$fmd->vname = $label;
$fmd->type = $field->type;
- $fmd->help = $field->help;
+ //HACK : -- Add localization to vardef field_help
+ $fmd->help = $field->help_label;
+ //HACK :
if (!empty($field->len))
$fmd->len = $field->len; // tyoung bug 15407 - was being set to $field->size so changes weren't being saved
$fmd->required = ($field->required ? 1 : 0);
Index: modules/DynamicFields/templates/Fields/Forms/coreTop.tpl
===================================================================
--- modules/DynamicFields/templates/Fields/Forms/coreTop.tpl (revision 1)
+++ modules/DynamicFields/templates/Fields/Forms/coreTop.tpl (working copy)
@@ -44,19 +44,22 @@
<td class='mbLBL' width='30%' >{$MOD.COLUMN_TITLE_NAME}:</td>
<td>
{if $hideLevel == 0}
- <input id="field_name_id" maxlength=30 type="text" name="name" value="{$vardef.name}"
- onchange="
- document.getElementById('label_key_id').value = 'LBL_'+document.getElementById('field_name_id').value.toUpperCase();
+ {* HACK: -- Add localization to vardef field_help
+ Added javascript statement for automatic help label assignment *}
+ <input id="field_name_id" maxlength=30 type="text" name="name" value="{$vardef.name}" onchange="document.getElementById('label_key_id').value = 'LBL_'+document.getElementById('field_name_id').value.toUpperCase();
document.getElementById('label_value_id').value = document.getElementById('field_name_id').value.replace(/_/,' ');
- document.getElementById('field_name_id').value = document.getElementById('field_name_id').value.toLowerCase();" />
+ document.getElementById('field_name_id').value = document.getElementById('field_name_id').value.toLowerCase();
+ document.getElementById('help_key_id').value = 'LBL_'+(document.getElementById('field_name_id').value.toUpperCase())+'_HELP';" />
+ {* HACK: *}
{else}
+ {* HACK: -- Add localization to vardef field_help
+ Added javascript statement for automatic help label assignment *}
<input id= "field_name_id" maxlength=30 type="hidden" name="name" value="{$vardef.name}"
- onchange="
- document.getElementById('label_key_id').value = 'LBL_'+document.getElementById('field_name_id').value.toUpperCase();
+ onchange="document.getElementById('label_key_id').value = 'LBL_'+document.getElementById('field_name_id').value.toUpperCase();
document.getElementById('label_value_id').value = document.getElementById('field_name_id').value.replace(/_/,' ');
- document.getElementById('field_name_id').value = document.getElementById('field_name_id').value.toLowerCase();"/>
- {$vardef.name}
- {/if}
+ document.getElementById('field_name_id').value = document.getElementById('field_name_id').value.toLowerCase();
+ document.getElementById('help_key_id').value = 'LBL_'+(document.getElementById('field_name_id').value.toUpperCase())+'_HELP';"/>{$vardef.name}{/if}
+ {* HACK: *}
<script>
addToValidate('popup_form', 'name', 'DBName', true,'{$MOD.COLUMN_TITLE_NAME} [a-zA-Z_]' );
addToValidateIsInArray('popup_form', 'name', 'in_array', true,'{$MOD.ERR_RESERVED_FIELD_NAME}', '{$field_name_exceptions}', 'u==');
@@ -79,11 +82,25 @@
{/if}
</td>
</tr>
+{* HACK: -- Add localization to vardef field_help ,Course module Accounting type does not work *}
<tr>
- <td class='mbLBL'>{$MOD.COLUMN_TITLE_HELP_TEXT}:</td><td>{if $hideLevel < 5 }<input type="text" name="help" value="{$vardef.help}">{else}<input type="hidden" name="help" value="{$vardef.help}">{$vardef.help}{/if}
+ <td class='mbLBL'>{$MOD.COLUMN_TITLE_HELP_TEXT}:</td>
+ <td>
+ <input type="text" id="help_value_id" name="help" value="{$vardef.help}" onchange="if(document.getElementById('help_key_id').value == '') document.getElementById('help_key_id').value='LBL_'+(document.getElementById('field_name_id').value.toUpperCase())+'_HELP';">
</td>
</tr>
+
<tr>
+ <td class='mbLBL'>{$MOD.COLUMN_TITLE_HELP_LABEL}:</td>
+ <td>{if $hideLevel < 5 }
+ <input type="text" id="help_key_id" name="help_label" value="{$vardef.help_label}">
+ {else}
+ <input type="hidden" id="help_key_id" name="help_label" value="{$vardef.help_label}">{$vardef.help_label}
+ {/if}
+ </td>
+</tr>
+{* HACK: *}
+<tr>
<td class='mbLBL'>{$MOD.COLUMN_TITLE_COMMENT_TEXT}:</td><td>{if $hideLevel < 5 }<input type="text" name="comments" value="{$vardef.comments}">{else}<input type="hidden" name="comment" value="{$vardef.comment}">{$vardef.comment}{/if}
</td>
</tr>
Index: modules/DynamicFields/templates/Fields/TemplateField.php
===================================================================
--- modules/DynamicFields/templates/Fields/TemplateField.php (revision 1)
+++ modules/DynamicFields/templates/Fields/TemplateField.php (working copy)
@@ -67,6 +67,10 @@
var $reportable = false;
var $label_value = '';
var $help = '';
+ //HACK : -- Add localization to vardef field_help
+ // for initialisation of bean value.
+ var $help_label ='';
+ //HACK :
var $vardef_map = array(
'name'=>'name',
@@ -95,6 +99,11 @@
//'disable_num_format'=>'ext3',
'ext3'=>'ext3',
'label_value'=>'label_value',
+
+ //HACK : -- Add localization to vardef field_help
+ //used for vardef mapping.
+ 'help_label'=>'help_label',
+ //HACK :
);
/*
HTML FUNCTIONS
Index: modules/EditCustomFields/FieldsMetaData.php
===================================================================
--- modules/EditCustomFields/FieldsMetaData.php (revision 1)
+++ modules/EditCustomFields/FieldsMetaData.php (working copy)
@@ -60,6 +60,10 @@
var $ext1;
var $ext2;
var $ext3;
+ //HACK : -- Add localization to vardef field_help
+ var $help;
+ var $help_label;
+ //HACK :
var $audited;
var $duplicate_merge;
var $reportable;
@@ -81,6 +85,10 @@
'ext1',
'ext2',
'ext3',
+ //HACK : -- Add localization to vardef field_help
+ 'help',
+ 'help_label',
+ //HACK :
'audited',
'massupdate',
'duplicate_merge',
Index: modules/EditCustomFields/language/en_us.lang.php
===================================================================
--- modules/EditCustomFields/language/en_us.lang.php (revision 1)
+++ modules/EditCustomFields/language/en_us.lang.php (working copy)
@@ -92,4 +92,9 @@
'LBL_DEPENDENT_TRIGGER'=>'Trigger',
'LBL_BTN_EDIT_VISIBILITY'=>'Edit Visibility',
);
+
+// HACK : -- Add localization to vardef field_help
+// label for the new help label
+$mod_strings['COLUMN_TITLE_HELP_LABEL'] = 'Help Label';
+// HACK :
?>
Index: modules/EditCustomFields/vardefs.php
===================================================================
--- modules/EditCustomFields/vardefs.php (revision 1)
+++ modules/EditCustomFields/vardefs.php (working copy)
@@ -66,4 +66,8 @@
array('name' => 'idx_meta_cm_del', 'type' => 'index', 'fields' => array('custom_module', 'deleted')),
),
);
+// HACK : -- Add localization to vardef field_help
+// Added for adding new field help label in module builder.
+$dictionary['FieldsMetaData']['fields']['help_label']=array('name' =>'help_label' ,'type' =>'varchar','vname'=>'COLUMN_TITLE_LABEL', 'len'=>'255');
+// HACK : -- Add localization to vardef field_help
?>
Index: modules/ModuleBuilder/controller.php
===================================================================
--- modules/ModuleBuilder/controller.php (revision 1)
+++ modules/ModuleBuilder/controller.php (working copy)
@@ -269,6 +269,14 @@
if (! empty ( $_REQUEST [ 'view_module' ] ) && !empty($_REQUEST [ 'labelValue' ]))
{
$_REQUEST [ "label_" . $_REQUEST [ 'label' ] ] = $_REQUEST [ 'labelValue' ] ;
+ // HACK : -- Add localization to vardef field_help
+ if (isset($_REQUEST['help_label']) && isset ($_REQUEST['help' ])){
+ if(empty($_REQUEST['help_label'])){
+ $_REQUEST['help_label']="LBL_".$_REQUEST['name']."_HELP";
+ }
+ $_REQUEST [ "label_" . $_REQUEST['help_label'] ] = $_REQUEST [ 'help' ] ;
+ }
+ // HACK :
require_once 'modules/ModuleBuilder/parsers/parser.label.php' ;
$parser = new ParserLabel ( $_REQUEST['view_module'] , isset ( $_REQUEST [ 'view_package' ] ) ? $_REQUEST [ 'view_package' ] : null ) ;
$parser->handleSave ( $_REQUEST, $GLOBALS [ 'current_language' ] ) ;
@@ -332,11 +340,22 @@
$mb = new ModuleBuilder ( ) ;
$module = & $mb->getPackageModule ( $_REQUEST [ 'view_package' ], $_REQUEST [ 'view_module' ] ) ;
$field->save ( $module ) ;
+ //HACK : -- Add localization to vardef field_help
+ if(isset($_REQUEST['help_label']) && empty($_REQUEST['help_label']))
+ $_REQUEST['help_label']="LBL_".mb_strtoupper($_REQUEST['name'])."_HELP";
+
+ $module->mbvardefs->vardef['fields'][$_REQUEST['name']]['help']=$_REQUEST['help_label'];
+ //HACK :
$module->mbvardefs->save () ;
// get the module again to refresh the labels we might have saved with the $field->save (e.g., for address fields)
$module = & $mb->getPackageModule ( $_REQUEST [ 'view_package' ], $_REQUEST [ 'view_module' ] ) ;
if (isset ( $_REQUEST [ 'label' ] ) && isset ( $_REQUEST [ 'labelValue' ] ))
$module->setLabel ( $GLOBALS [ 'current_language' ], $_REQUEST [ 'label' ], $_REQUEST [ 'labelValue' ] ) ;
+ //HACK : -- Add localization to vardef field_help
+ //setting the help text and label for current language.
+ if (isset($_REQUEST['help_label']) && isset ($_REQUEST['help']))
+ $module->setLabel($GLOBALS['current_language'],$_REQUEST['help_label'],$_REQUEST['help']);
+ //HACK :
$module->save();
}
$this->view = 'modulefields' ;
Index: modules/ModuleBuilder/views/view.modulefield.php
===================================================================
--- modules/ModuleBuilder/views/view.modulefield.php (revision 1)
+++ modules/ModuleBuilder/views/view.modulefield.php (working copy)
@@ -145,6 +145,31 @@
if(!empty($vardef['vname'])){
$fv->ss->assign('lbl_value', htmlentities(translate($vardef['vname'], $moduleName), ENT_QUOTES, 'UTF-8'));
}
+ //HACK : -- Add localization to vardef field_help
+ $temp_var_help_translation='';
+ if(isset($vardef['help'])){
+ if(!empty($vardef['help'])){
+ $temp_var_help_translation=translate(mb_strtoupper($vardef['help']),$moduleName);
+ if($temp_var_help_translation != mb_strtoupper($vardef['help'])){
+ $vardef['help_label']=$vardef['help'];
+ $vardef['help']=$temp_var_help_translation;
+ }else{
+ $vardef['help_label']=$vardef['help'];
+ $vardef['help']='';
+ }
+ }
+ }elseif(!empty($vardef['name'])){
+ $tempkey="LBL_".mb_strtoupper($vardef['name'])."_HELP";
+ $temp_var_help_translation = translate(mb_strtoupper($tempkey),$moduleName);
+ if($temp_var_help_translation != mb_strtoupper($tempkey)){
+ $vardef['help_label']=$tempkey;
+ $vardef['help']=$temp_var_help_translation;
+ }else{
+ $vardef['help_label']=$tempkey;
+ $vardef['help']='';
+ }
+ }
+ //HACK :
//$package = new stdClass;
//$package->name = 'studio';
//$fv->ss->assign('package', $package);
@@ -186,6 +211,35 @@
$fv->ss->assign('module', $module);
$fv->ss->assign('package', $package);
$fv->ss->assign('MB','1');
+ //HACK : -- Add localization to vardef field_help
+ $temp_var_help_translation='';
+ if(isset($vardef['help'])){
+ if(!empty($vardef['help'])){
+ //HACK:Upgrade sugarbase to SugarCRM 5.5
+ $temp_var_help_translation=$module->getLabel($GLOBALS['current_language'],$vardef['help']);
+ //HACK:Upgrade sugarbase to SugarCRM 5.5
+ if(!empty($temp_var_help_translation)){
+ $vardef['help_label']=$vardef['help'];
+ $vardef['help']=$temp_var_help_translation;
+ }else{
+ $vardef['help_label']=$vardef['help'];
+ $vardef['help']='';
+ }
+ }
+ }elseif(!empty($vardef['name'])){
+ $tempkey="LBL_".mb_strtoupper($vardef['name'])."_HELP";
+ //HACK:Upgrade sugarbase to SugarCRM 5.5
+ $temp_var_help_translation=$module->getLabel($GLOBALS['current_language'],$tempkey);
+ //HACK:Upgrade sugarbase to SugarCRM 5.5
+ if(!empty($temp_var_help_translation)){
+ $vardef['help_label']=$tempkey;
+ $vardef['help']=$temp_var_help_translation;
+ }else{
+ $vardef['help_label']=$tempkey;
+ $vardef['help']='';
+ }
+ }
+ //HACK :
if(isset($vardef['vname']))
$fv->ss->assign('lbl_value', htmlentities($module->getLabel('en_us',$vardef['vname']), ENT_QUOTES, 'UTF-8'));