forked from extern/egroupware
Encode square brackets and split names at ][, not just [
This commit is contained in:
parent
89fdaa7691
commit
26c888ccd4
@ -423,14 +423,14 @@ class etemplate_widget
|
||||
{
|
||||
foreach($value as &$val)
|
||||
{
|
||||
$val = "'".str_replace(array("'",'"'),array('\\\'','"'),$val)."'";
|
||||
$val = "'".str_replace(array("'",'"','[',']'),array('\\\'','"','[',']'),$val)."'";
|
||||
}
|
||||
$value = '[ '.implode(', ',$value).' ]';
|
||||
$value = '[ '.implode(', ',$value).' ]';
|
||||
$name = str_replace("'".$matches[1]."'",$value,$name);
|
||||
}
|
||||
else
|
||||
{
|
||||
$value = str_replace(array("'",'"'),array('\\\'','"'),$value);
|
||||
$value = str_replace(array("'",'"','[',']'),array('\\\'','"','[',']'),$value);
|
||||
$name = str_replace(array('{'.$matches[1].'}',$matches[1]),$value,$name);
|
||||
}
|
||||
}
|
||||
@ -465,6 +465,7 @@ class etemplate_widget
|
||||
$name = self::get_array($cont,substr($name,1));
|
||||
}
|
||||
}
|
||||
$name = str_replace(array('[',']'),array('[',']'),$name);
|
||||
return $name;
|
||||
}
|
||||
|
||||
@ -526,7 +527,10 @@ class etemplate_widget
|
||||
*/
|
||||
static function form_name($cname,$name)
|
||||
{
|
||||
$name_parts = explode('[',str_replace(']','',$name));
|
||||
if (count($name_parts = explode('[', $name, 2)) > 1)
|
||||
{
|
||||
$name_parts = array_merge(array($name_parts[0]), explode('][', substr($name_parts[1],0,-1)));
|
||||
}
|
||||
if (!empty($cname))
|
||||
{
|
||||
array_unshift($name_parts,$cname);
|
||||
@ -534,7 +538,7 @@ class etemplate_widget
|
||||
$form_name = array_shift($name_parts);
|
||||
if (count($name_parts))
|
||||
{
|
||||
$form_name .= '['.implode('][',$name_parts).']';
|
||||
$form_name .= '['.implode('][',$name_parts).']';
|
||||
}
|
||||
return $form_name;
|
||||
}
|
||||
@ -559,7 +563,10 @@ class etemplate_widget
|
||||
}
|
||||
if (is_object($idx)) return false; // given an error in php5.2
|
||||
|
||||
$idxs = explode('[',str_replace(']','',$idx));
|
||||
if (count($idxs = explode('[', $idx, 2)) > 1)
|
||||
{
|
||||
$idxs = array_merge(array($idxs[0]), explode('][', substr($idxs[1],0,-1)));
|
||||
}
|
||||
$pos = &$arr;
|
||||
foreach($idxs as $idx)
|
||||
{
|
||||
|
@ -43,7 +43,17 @@ var et2_arrayMgr = Class.extend({
|
||||
if (this.splitIds)
|
||||
{
|
||||
for(var key in _data) {
|
||||
var indexes = key.replace(/]/g,'').split('[');
|
||||
var indexes = key.split('[');
|
||||
if (indexes.length > 1)
|
||||
{
|
||||
indexes = [indexes.shift(), indexes.join('[')];
|
||||
indexes[1] = indexes[1].substring(0,indexes[1].length-6);
|
||||
var children = indexes[1].split('[]');
|
||||
if(children.length)
|
||||
{
|
||||
indexes = jQuery.merge([indexes[0]], children);
|
||||
}
|
||||
}
|
||||
if(indexes.length > 1)
|
||||
{
|
||||
var value = _data[key];
|
||||
@ -142,7 +152,17 @@ var et2_arrayMgr = Class.extend({
|
||||
|
||||
if (this.splitIds)
|
||||
{
|
||||
indexes = _key.replace(/]/g,'').split('[');
|
||||
indexes = _key.split('[');
|
||||
if (indexes.length > 1)
|
||||
{
|
||||
indexes = [indexes.shift(), indexes.join('[')];
|
||||
indexes[1] = indexes[1].substring(0,indexes[1].length-1);
|
||||
var children = indexes[1].split('][');
|
||||
if(children.length)
|
||||
{
|
||||
indexes = jQuery.merge([indexes[0]], children);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var entry = this.data;
|
||||
|
@ -202,6 +202,11 @@ var et2_widget = Class.extend({
|
||||
}
|
||||
}
|
||||
|
||||
if(this.id)
|
||||
{
|
||||
this.id = this.id.replace(/\[/g,'[').replace(/]/g,']');
|
||||
}
|
||||
|
||||
// Add all attributes hidden in the content arrays to the attributes
|
||||
// parameter
|
||||
this.transformAttributes(_attrs);
|
||||
|
@ -195,6 +195,7 @@ var et2_button = et2_baseWidget.extend([et2_IInput, et2_IDetachedDOM], {
|
||||
this.options.onclick = _values["onclick"];
|
||||
}
|
||||
this.btn.bind("click.et2_baseWidget", this, function(e) {
|
||||
e.data.set_id(_values["id"]);
|
||||
return e.data.click.call(e.data,e);
|
||||
});
|
||||
|
||||
|
@ -211,6 +211,8 @@ etemplate2.prototype.submit = function(button)
|
||||
if (canSubmit)
|
||||
{
|
||||
// Button parameter used for submit buttons in datagrid
|
||||
// TODO: This should probably go in nextmatch's getValues(), along with selected rows somehow.
|
||||
// I'm just not sure how.
|
||||
if(button)
|
||||
{
|
||||
values.button = button.id
|
||||
@ -223,7 +225,17 @@ etemplate2.prototype.submit = function(button)
|
||||
}
|
||||
if(target != values)
|
||||
{
|
||||
var indexes = button.id.replace(/]/g,'').split('[');
|
||||
var indexes = button.id.split('[');
|
||||
if (indexes.length > 1)
|
||||
{
|
||||
indexes = [indexes.shift(), indexes.join('[')];
|
||||
indexes[1] = indexes[1].substring(0,indexes[1].length-1);
|
||||
var children = indexes[1].split('][');
|
||||
if(children.length)
|
||||
{
|
||||
indexes = jQuery.merge([indexes[0]], children);
|
||||
}
|
||||
}
|
||||
var idx = '';
|
||||
for(var i = 0; i < indexes.length; i++)
|
||||
{
|
||||
@ -270,11 +282,17 @@ etemplate2.prototype.getValues = function(_root)
|
||||
|
||||
// check if id contains a hierachical name, eg. "button[save]"
|
||||
var id = _widget.id;
|
||||
if (_widget.id.indexOf('[') != -1)
|
||||
var indexes = _widget.id.split('[',2);
|
||||
if (indexes.length > 1)
|
||||
{
|
||||
var parts = _widget.id.replace(/]/g,'').split('[');
|
||||
id = parts.pop();
|
||||
path = path.concat(parts);
|
||||
indexes = [indexes.shift(), indexes.join('[')];
|
||||
indexes[1] = indexes[1].substring(0,indexes[1].length-6);
|
||||
var children = indexes[1].split('[]');
|
||||
if(children.length)
|
||||
{
|
||||
indexes = jQuery.merge([indexes[0]], children);
|
||||
}
|
||||
path = path.concat(indexes);
|
||||
}
|
||||
|
||||
// Set the _target variable to that node
|
||||
|
Loading…
Reference in New Issue
Block a user