From 26c66d12d74ce0d582bbf383c6c229d2f7648f7b Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Sun, 28 Apr 2013 12:39:58 +0000 Subject: [PATCH] create static method etemplate_widget_menupopup::fix_encoded_options(), so apps can call that for cases it is not called automatically (eg. autorepeated rows) --- .../class.etemplate_widget_menupopup.inc.php | 33 ++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/etemplate/inc/class.etemplate_widget_menupopup.inc.php b/etemplate/inc/class.etemplate_widget_menupopup.inc.php index 8af8d44a8b..9c37010dfa 100644 --- a/etemplate/inc/class.etemplate_widget_menupopup.inc.php +++ b/etemplate/inc/class.etemplate_widget_menupopup.inc.php @@ -157,17 +157,7 @@ class etemplate_widget_menupopup extends etemplate_widget $options = (self::$request->sel_options[$form_name] ? $form_name : $this->id); if(is_array(self::$request->sel_options[$options])) { - foreach(self::$request->sel_options[$options] as &$label) - { - if(!is_array($label)) - { - $label = html_entity_decode($label, ENT_NOQUOTES,'utf-8'); - } - elseif($label['label']) - { - $label['label'] = html_entity_decode($label['label'], ENT_NOQUOTES,'utf-8'); - } - } + self::fix_encoded_options(self::$request->sel_options[$options]); // Turn on search, if there's a lot of rows if(count(self::$request->sel_options[$options]) >= self::SEARCH_ROW_LIMIT) @@ -177,6 +167,27 @@ class etemplate_widget_menupopup extends etemplate_widget } } + /** + * Fix already html-encoded options, eg. "&nbps" + * + * @param array $options + */ + public static function fix_encoded_options(array &$options) + { + foreach($options as &$label) + { + // optgroup or values for keys "label" and "title" + if(is_array($label)) + { + self::fix_encoded_options($label); + } + else + { + $label = html_entity_decode($label, ENT_NOQUOTES, 'utf-8'); + } + } + } + /** * Get options from $sel_options array for a given selectbox name *