From f8f7d1621ed453b63eab86ebb05c40bb8c66a57f Mon Sep 17 00:00:00 2001 From: nathan Date: Wed, 13 Jul 2022 10:52:11 -0600 Subject: [PATCH] Preferences: Get preferences mostly displaying again There's still something wrong validation. --- .../etemplate/et2_core_legacyJSFunctions.ts | 7 ++- .../inc/class.preferences_hooks.inc.php | 18 +++---- .../inc/class.preferences_settings.inc.php | 50 +++++++++++-------- preferences/templates/default/settings.xet | 3 +- 4 files changed, 46 insertions(+), 32 deletions(-) diff --git a/api/js/etemplate/et2_core_legacyJSFunctions.ts b/api/js/etemplate/et2_core_legacyJSFunctions.ts index 1f9d62c540..ff69bddfbf 100644 --- a/api/js/etemplate/et2_core_legacyJSFunctions.ts +++ b/api/js/etemplate/et2_core_legacyJSFunctions.ts @@ -36,10 +36,15 @@ export function et2_compileLegacyJS(_code, _widget, _context) { // Get the content array manager for the widget var mgr = _widget.getArrayMgr("content"); - if (mgr) + if(mgr) { _code = mgr.expandName(_code); } + // If replacement cleared the code, skip the rest + if(!_code) + { + return false; + } } // Context is the context in which the function will run. Set context to diff --git a/preferences/inc/class.preferences_hooks.inc.php b/preferences/inc/class.preferences_hooks.inc.php index c865143793..5c43015bb1 100644 --- a/preferences/inc/class.preferences_hooks.inc.php +++ b/preferences/inc/class.preferences_hooks.inc.php @@ -299,15 +299,15 @@ class preferences_hooks 'default'=> $lang, ), 'country' => array( - 'type' => 'select-country', - 'label' => 'Country', - 'name' => 'country', - 'help' => 'In which country are you. This is used to set certain defaults for you.', - 'xmlrpc' => True, - 'admin' => False, - 'values' => array(''), - 'default'=> strtoupper($country), - 'attributes' => array ( + 'type' => 'et2-select-country', + 'label' => 'Country', + 'name' => 'country', + 'help' => 'In which country are you. This is used to set certain defaults for you.', + 'xmlrpc' => True, + 'admin' => False, + 'values' => array(), + 'default' => strtoupper($country), + 'attributes' => array( 'tags' => true ) ), diff --git a/preferences/inc/class.preferences_settings.inc.php b/preferences/inc/class.preferences_settings.inc.php index fb286e8e55..c52aa9a238 100644 --- a/preferences/inc/class.preferences_settings.inc.php +++ b/preferences/inc/class.preferences_settings.inc.php @@ -431,14 +431,13 @@ class preferences_settings $setting['run_lang'] = false; // already done now // handle as textarea case 'textarea': - $setting['type'] = is_a($tpl, 'etemplate') ? 'textarea' : 'textbox'; - $tpl->setElementAttribute($tab.'['.$setting['name'].']', 'multiline', 'true'); - $tpl->setElementAttribute($tab. '[' . $setting['name'] . ']','width', '99%' ); + $setting['type'] = is_a($tpl, 'etemplate') ? 'textarea' : 'et2-textbox'; + $tpl->setElementAttribute($tab . '[' . $setting['name'] . ']', 'multiline', 'true'); // anyway setting via css: width: 99%, height: 5em // for old eT use size attribute - if (is_a($tpl, 'etemplate') && (!empty($setting['cols']) || !empty($setting['rows']))) + if(is_a($tpl, 'etemplate') && (!empty($setting['cols']) || !empty($setting['rows']))) { - $setting['size'] = $setting['rows'].','.$setting['cols']; + $setting['size'] = $setting['rows'] . ',' . $setting['cols']; } break; case 'password': @@ -446,33 +445,41 @@ class preferences_settings case 'vfs_dir': case 'vfs_dirs': case 'input': - $setting['type'] = 'textbox'; + $setting['type'] = 'et2-textbox'; break; case 'check': - $setting['type'] = 'select'; + $setting['type'] = 'et2-select'; $setting['values'] = array('1' => lang('yes'), '0' => lang('no')); break; + case 'select': + $setting['type'] = 'et2-select'; + break; case 'multiselect': - $setting['type'] = 'select'; - $tpl->setElementAttribute($tab.'['.$setting['name'].']', 'rows', 5); - if (!isset($setting['size'])) $setting['size'] = '5'; // old eT + $setting['type'] = 'et2-select'; + $tpl->setElementAttribute($tab . '[' . $setting['name'] . ']', 'multiple', true); break; case 'color': - $setting['type'] = 'colorpicker'; + $setting['type'] = 'et2-colorpicker'; break; case 'date-duration': - if (!isset($setting['size'])) $setting['size'] = 'm,dhm,24,1'; + if(!isset($setting['size'])) + { + $setting['size'] = 'm,dhm,24,1'; + } $attrs = explode(',', $setting['size']); foreach(array("data_format","display_format", "hours_per_day", "empty_not_0", "short_labels") as $n => $name) { if ((string)$attrs[$n] !== '') $tpl->setElementAttribute($tab.'['.$setting['name'].']', $name, $attrs[$n]); } + $setting['type'] = 'et2-date-duration'; break; case 'taglist': - if ($setting['no_sel_options']) + if($setting['no_sel_options']) { - $tpl->setElementAttribute ($tab.'['.$setting['name'].']', 'autocomplete_url', ''); + $tpl->setElementAttribute($tab . '[' . $setting['name'] . ']', 'autocomplete_url', ''); } + $setting['type'] = 'et2-select'; + $tpl->setElementAttribute($tab . '[' . $setting['name'] . ']', 'multiple', true); break; } // move values/options to sel_options array @@ -517,14 +524,15 @@ class preferences_settings $setting['help'] = lang($setting['help']); } $content[$tab][] = array( - 'name' => $setting['name'], - 'type' => $setting['type'], - 'label' => preg_replace('||i', "\n", $setting['label']), - 'help' => lang($setting['help']), // is html - 'default' => (string)$default !== '' ? lang('Default').': '.$default : null, - 'onchange' => $setting['onchange'], - 'attributes' => $setting['attributes'] + 'name' => $setting['name'], + 'type' => $setting['type'], + 'label' => preg_replace('||i', "\n", $setting['label']), + 'help' => lang($setting['help']), // is html + 'default' => (string)$default !== '' ? lang('Default') . ': ' . $default : null, + 'onchange' => $setting['onchange'] ); + + // 'attributes' => $setting['attributes'] //error_log("appname=$appname, attribute=$attribute, setting=".array2string($setting)); $content[$tab][$setting['name']] = $GLOBALS['egw']->preferences->{$attribute}[$appname][$setting['name']]; //if ($old_type == 'multiselect') $content[$tab][$setting['name']] = explode(',', $content[$tab][$setting['name']]); diff --git a/preferences/templates/default/settings.xet b/preferences/templates/default/settings.xet index e8a1e1b3cc..752a420585 100644 --- a/preferences/templates/default/settings.xet +++ b/preferences/templates/default/settings.xet @@ -16,7 +16,8 @@ - +