Fix visible   in all selectboxes - prevent double encoding

This commit is contained in:
Nathan Gray 2012-03-02 22:02:26 +00:00
parent 119aa1c121
commit bade774bfa

View File

@ -116,9 +116,9 @@ class etemplate_widget_menupopup extends etemplate_widget
*/
public function beforeSendToClient($cname)
{
$form_name = self::form_name($cname, $this->id);
if ($this->attrs['type'])
{
$form_name = self::form_name($cname, $this->id);
// += to keep further options set by app code
if (!is_array(self::$request->sel_options[$form_name])) self::$request->sel_options[$form_name] = array();
self::$request->sel_options[$form_name] += self::typeOptions($this->attrs['type'], $this->attrs['options'],
@ -130,6 +130,19 @@ class etemplate_widget_menupopup extends etemplate_widget
self::setElementAttribute($form_name, 'no_lang', $no_lang);
}
}
// Make sure  s, etc. are properly encoded when sent, and not double-encoded
foreach(self::$request->sel_options[$form_name] 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');
}
}
}
/**
@ -291,7 +304,7 @@ class etemplate_widget_menupopup extends etemplate_widget
// we cast $type4 (parent) to int, to get default of 0 if omitted
foreach((array)$categories->return_sorted_array(0,False,'','','',!$type,(int)$type4,true) as $cat)
{
$s = str_repeat(html_entity_decode(' ', ENT_NOQUOTES,'utf-8'),$cat['level']) . stripslashes($cat['name']);
$s = str_repeat(' ',$cat['level']) . stripslashes($cat['name']);
if (categories::is_global($cat))
{