a few compatbility methods and hacks to get old etemplates to behaves a bit more like eT2

This commit is contained in:
Ralf Becker 2013-05-03 11:50:40 +00:00
parent 005d5ed090
commit 1b3c934823
2 changed files with 59 additions and 9 deletions

View File

@ -301,9 +301,9 @@ class boetemplate extends soetemplate
* @param string $attr attribute-name
* @return mixed the attribute or False if named cell not found
*/
function &get_cell_attribute($name,$attr)
function &getElementAttribute($name,$attr)
{
return $this->set_cell_attribute($name,$attr,NULL);
return $this->setElementAttribute($name,$attr,NULL);
}
/**
@ -314,7 +314,7 @@ class boetemplate extends soetemplate
* @param mixed $val if not NULL sets attribute else returns it
* @return mixed number of changed cells or False, if none changed
*/
function &set_cell_attribute($name,$attr,$val)
function &setElementAttribute($name,$attr,$val)
{
//echo "<p>set_cell_attribute(tpl->name=$this->name, name='$name', attr='$attr',val='$val')</p>\n";
@ -335,11 +335,54 @@ class boetemplate extends soetemplate
* @param boolean $disabled=true disable or enable a cell, default true=disable
* @return mixed number of changed cells or False, if none changed
*/
function disable_cells($name,$disabled=True)
function disableElement($name,$disabled=True)
{
return $this->set_cell_attribute($name,'disabled',$disabled);
}
/**
* Returns reference to an attribute in a named cell
*
* Currently we always return a reference to an not set value, unless it was set before.
* We do not return a reference to the actual cell, as it get's contructed on client-side!
*
* @param string $name cell-name
* @param string $attr attribute-name
* @return mixed reference to attribute, usually NULL
* @deprecated use getElementAttribute($name, $attr)
*/
public function &get_cell_attribute($name,$attr)
{
return self::getElementAttribute($name, $attr);
}
/**
* set an attribute in a named cell if val is not NULL else return the attribute
*
* @param string $name cell-name
* @param string $attr attribute-name
* @param mixed $val if not NULL sets attribute else returns it
* @return reference to attribute
* @deprecated use setElementAttribute($name, $attr, $val)
*/
public function &set_cell_attribute($name,$attr,$val)
{
return self::setElementAttribute($name, $attr, $val);
}
/**
* disables all cells with name == $name
*
* @param sting $name cell-name
* @param boolean $disabled=true disable or enable a cell, default true=disable
* @return reference to attribute
* @deprecated use disableElement($name, $disabled=true)
*/
public function disable_cells($name,$disabled=True)
{
return self::disableElement($name, $disabled);
}
/**
* set one or more attibutes for row $n
*
@ -1097,7 +1140,7 @@ if (!function_exists('set_cell_attribute_helper'))
function &set_cell_attribute_helper(&$widget,&$extra)
{
// extra = array(0=>n,1=>name,2=>attr,3=>value)
if ($widget['name'] == $extra[1])
if ($widget['name'] == $extra[1] || $widget['type'] == 'tab' && strpos($widget['name'], $extra[1].'=') === 0)
{
if (is_null($extra[3]))
{

View File

@ -312,7 +312,7 @@ class etemplate_old extends boetemplate
if($output_mode == 2)
{
$html .= "\n".'<script language="javascript">'."\n";
$html .= 'egw.LAB.wait(function() { popup_resize();});'."\n";
$html .= 'egw.LAB.wait($j(document).ready(function() { popup_resize();}));'."\n";
$html .= '</script>';
}
@ -788,7 +788,7 @@ class etemplate_old extends boetemplate
if (!(list($r_key) = each($data))) // no further row
{
if (!(($this->autorepeat_idx($cols['A'],0,$r,$idx,$idx_cname,false,$content) && $idx_cname) ||
(substr($cols['A']['type'],1) == 'box' && $this->autorepeat_idx($cols['A'][1],0,$r,$idx,$idx_cname,false,$content) && $idx_cname) ||
(in_array($cols['A']['type'], array('vbox','hbox','box')) && $this->autorepeat_idx($cols['A'][1],0,$r,$idx,$idx_cname,false,$content) && $idx_cname) ||
($this->autorepeat_idx($cols['B'],1,$r,$idx,$idx_cname,false,$content) && $idx_cname)) ||
!$this->isset_array($content,$idx_cname))
{
@ -1091,6 +1091,10 @@ class etemplate_old extends boetemplate
{
$cell['onchange'] = $this->expand_name($cell['onchange'],$show_c,$show_row,$content['.c'],$content['.row'],$content);
}
if ($cell['type'][0] == '@')
{
$cell['type'] = $this->expand_name($t=$cell['type'],$show_c,$show_row,$content['.c'],$content['.row'],$content);
}
// the while loop allows to build extensions from other extensions
// please note: only the first extension's post_process function is called !!!
list($type,$sub_type) = explode('-',$cell['type']);
@ -1270,6 +1274,7 @@ class etemplate_old extends boetemplate
case 'hidden':
case 'passwd':
case 'text': // size: [length][,maxLength[,preg[,html5type]]]
case 'textbox':
$autocompletion_off='';
if ($type == 'passwd') $autocompletion_off='autocomplete="off"';
$cell_opts = $c = self::csv_split($cell_options); // allows to enclose preg in quote to allow comma
@ -2058,9 +2063,9 @@ class etemplate_old extends boetemplate
$sels += $cell['sel_options'];
}
}
if (isset($this->sel_options[$name]) && is_array($this->sel_options[$name]))
if (($options = self::get_array($this->sel_options, $name)) && is_array($options))
{
$sels += $this->sel_options[$name];
$sels += $options;
}
else
{
@ -2082,6 +2087,7 @@ class etemplate_old extends boetemplate
{
$sels += $content["options-$name"];
}
//error_log(__METHOD__."(, '$name') returning ".array2string($sels));
return $sels;
}
@ -2266,6 +2272,7 @@ class etemplate_old extends boetemplate
case 'float':
case 'passwd':
case 'text':
case 'textbox':
case 'hidden':
case 'textarea':
case 'colorpicker':