mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-08 09:05:16 +01:00
multiple tpls in file get are now automaticaly load, even if name != filename
This commit is contained in:
parent
730ce71b8b
commit
ee31b85185
@ -54,16 +54,22 @@
|
||||
/*!
|
||||
@function boetemplate
|
||||
@abstract constructor of class
|
||||
@param $name name of etemplate or array with name and other keys
|
||||
@param $load_via name/array with keys of other etemplate to load in order to get $name
|
||||
@discussion Calls the constructor of soetemplate
|
||||
*/
|
||||
function boetemplate()
|
||||
function boetemplate($name='',$load_via='')
|
||||
{
|
||||
$this->soetemplate();
|
||||
|
||||
$this->public_functions += array(
|
||||
'disable_cells' => True,
|
||||
'set_cell_attribute' => True
|
||||
);
|
||||
$this->soetemplate();
|
||||
|
||||
if (empty($name) || !$this->read($name,'','',0,'',$load_via))
|
||||
{
|
||||
$this->init($name);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -466,13 +472,8 @@
|
||||
//if (is_array($name)) $version = $name['version']; echo "<p>read_from_cache(,,,version='$version'): ";
|
||||
if ($cname = $this->in_cache($name,$template,$lang,$group))
|
||||
{
|
||||
reset($this->db_cols);
|
||||
while (list($db_col,$col) = each($this->db_cols))
|
||||
{
|
||||
$this->$col = $GLOBALS['phpgw_info']['etemplate']['cache'][$cname][$col];
|
||||
}
|
||||
$this->rows = count($this->data) - 1;
|
||||
$this->cols = count($this->data[1]); // 1 = first row, not 0
|
||||
$this->init($GLOBALS['phpgw_info']['etemplate']['cache'][$cname]);
|
||||
|
||||
return True;
|
||||
}
|
||||
return False;
|
||||
@ -482,14 +483,21 @@
|
||||
@function read
|
||||
@abstract Reads an eTemplate from the cache or database / filesystem (and updates the cache)
|
||||
@param as discripted in soetemplate::read
|
||||
@param $load_via name/array of keys of etemplate to load in order to get $name (only as second try!)
|
||||
@result True if a fitting template is found, else False
|
||||
*/
|
||||
function read($name,$template='default',$lang='default',$group=0,$version='')
|
||||
function read($name,$template='default',$lang='default',$group=0,$version='',$load_via='')
|
||||
{
|
||||
if (!$this->read_from_cache($name,$template,$lang,$group,$version))
|
||||
{
|
||||
if (!soetemplate::read($name,$template,$lang,$group,$version))
|
||||
{
|
||||
if ($load_via && (is_string($load_via) ||
|
||||
!isset($load_via['tpls_in_file']) || $load_via['tpls_in_file'] > 1))
|
||||
{
|
||||
soetemplate::read($load_via);
|
||||
return $this->read_from_cache($name,$template,$lang,$group,$version);
|
||||
}
|
||||
return False;
|
||||
}
|
||||
$this->store_in_cache();
|
||||
|
@ -31,7 +31,7 @@
|
||||
{
|
||||
}
|
||||
|
||||
function pre_process(&$cell,&$value,&$extension_data,&$readonlys)
|
||||
function pre_process(&$cell,&$value,&$extension_data,&$readonlys,&$tmpl)
|
||||
{
|
||||
//echo "<p>nextmatch_widget.pre_process: value = "; _debug_array($value);
|
||||
// save values in persistent extension_data to be able use it in post_process
|
||||
@ -51,6 +51,8 @@
|
||||
{
|
||||
$value['template'] = $cell['size'];
|
||||
}
|
||||
$value['template'] = new etemplate($value['template'],$tmpl->as_array());
|
||||
|
||||
$nextmatch = new etemplate('etemplate.nextmatch_widget');
|
||||
if ($value['no_cat'])
|
||||
{
|
||||
@ -81,7 +83,7 @@
|
||||
return False; // NO extra Label
|
||||
}
|
||||
|
||||
function post_process(&$cell,&$value,&$extension_data,&$loop)
|
||||
function post_process(&$cell,&$value,&$extension_data,&$loop,&$tmpl)
|
||||
{
|
||||
//echo "<p>nextmatch_widget.post_process: value = "; _debug_array($value);
|
||||
|
||||
|
@ -114,6 +114,16 @@
|
||||
return array('type' => 'label', 'name' => '');
|
||||
}
|
||||
|
||||
/*!
|
||||
@function set_rows_cols()
|
||||
@abstract initialises rows & cols from the size of the data-array
|
||||
*/
|
||||
function set_rows_cols()
|
||||
{
|
||||
$this->rows = count($this->data) - 1;
|
||||
$this->cols = count($this->data[1]); // 1 = first row, not 0
|
||||
}
|
||||
|
||||
/*!
|
||||
@function init
|
||||
@abstract initialises all internal data-structures of the eTemplate and sets the keys
|
||||
@ -136,8 +146,11 @@
|
||||
{
|
||||
$this->lang = '';
|
||||
}
|
||||
$this->tpls_in_file = is_array($name) ? $name['tpls_in_file'] : 0;
|
||||
|
||||
if (is_array($name) && isset($name['data']))
|
||||
{
|
||||
$this->set_rows_cols();
|
||||
return; // data already set
|
||||
}
|
||||
$this->size = $this->style = '';
|
||||
@ -258,12 +271,16 @@
|
||||
{
|
||||
$this->xul_io = CreateObject('etemplate.xul_io');
|
||||
}
|
||||
if (!is_array($this->xul_io->import(&$this,$xul)))
|
||||
$loaded = $this->xul_io->import(&$this,$xul);
|
||||
|
||||
if (!is_array($loaded))
|
||||
{
|
||||
return False;
|
||||
}
|
||||
$this->name = $app . '.' . $name; // if template was copied or app was renamed
|
||||
|
||||
$this->tpls_in_file = count($loaded);
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
@ -353,8 +370,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->rows = count($this->data) - 1;
|
||||
$this->cols = count($this->data[1]); // 1 = first row, not 0
|
||||
$this->set_rows_cols();
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -408,6 +424,9 @@
|
||||
{
|
||||
$arr['data'] = serialize($arr['data']);
|
||||
}
|
||||
if ($this->tpls_in_file) {
|
||||
$arr['tpls_in_file'] = $this->tpls_in_file;
|
||||
}
|
||||
return $arr;
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@
|
||||
{
|
||||
}
|
||||
|
||||
function pre_process(&$cell,&$value,&$extension_data,&$readonlys)
|
||||
function pre_process(&$cell,&$value,&$extension_data,&$readonlys,&$tmpl)
|
||||
{
|
||||
$labels = explode('|',$cell['label']);
|
||||
$helps = explode('|',$cell['help']);
|
||||
@ -83,7 +83,8 @@
|
||||
|
||||
$tab_widget = new etemplate('etemplate.tab_widget');
|
||||
$tab_widget->set_cell_attribute('@tabs','name',$tabs);
|
||||
$tab_widget->set_cell_attribute('@body','name',$selected_tab);
|
||||
$tab_widget->set_cell_attribute('@body','name',
|
||||
$tmpl->tpls_in_file > 1 ? new etemplate($selected_tab,$tmpl->as_array()) : $selected_tab);
|
||||
|
||||
$cell['type'] = 'template';
|
||||
$cell['name'] = $tab_widget;
|
||||
@ -92,13 +93,13 @@
|
||||
return False; // NO extra Label
|
||||
}
|
||||
|
||||
function post_process(&$cell,&$value,&$extension_data,&$loop)
|
||||
function post_process(&$cell,&$value,&$extension_data,&$loop,&$tmpl)
|
||||
{
|
||||
$old_value = array(
|
||||
'_tab_widget' => array(
|
||||
$extension_data => array(True)
|
||||
));
|
||||
$this->pre_process($cell,$old_value,$extension_data,$dummy);
|
||||
$this->pre_process($cell,$old_value,$extension_data,$dummy,$tmpl);
|
||||
|
||||
if (is_array($value['_tab_widget']))
|
||||
{
|
||||
|
@ -34,12 +34,14 @@
|
||||
// 3=calls to show_cell and process_show_cell, or template-name or cell-type
|
||||
var $html,$sbox; // instance of html / sbox2-class
|
||||
var $loop = 0; // set by process_show if an other Exec-ProcessExec loop is needed
|
||||
|
||||
/*!
|
||||
@function etemplate
|
||||
@abstract constructor of etemplate class, reads an eTemplate if $name is given
|
||||
@param as soetemplate.read
|
||||
@param $name name of etemplate or array with name and other keys
|
||||
@param $load_via name/array with keys of other etemplate to load in order to get $name
|
||||
*/
|
||||
function etemplate($name='',$template='default',$lang='default',$group=0,$version='',$rows=2,$cols=2)
|
||||
function etemplate($name='',$load_via='')
|
||||
{
|
||||
$this->public_functions += array(
|
||||
'exec' => True,
|
||||
@ -47,16 +49,10 @@
|
||||
'show' => True,
|
||||
'process_show' => True,
|
||||
);
|
||||
$this->boetemplate();
|
||||
$this->html = CreateObject('etemplate.html'); // should be in the api (older version in infolog)
|
||||
$this->sbox = CreateObject('etemplate.sbox2'); // older version is in the api
|
||||
|
||||
if (empty($name) || !$this->read($name,$template,$lang,$group,$version))
|
||||
{
|
||||
$this->init($name,$template,$lang,$group,$version,$rows,$cols);
|
||||
return False;
|
||||
}
|
||||
return True;
|
||||
$this->boetemplate($name,$load_via);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -366,7 +362,8 @@
|
||||
(isset($this->extension[$cell['type']]) || $this->loadExtension($cell['type'],$this)))
|
||||
{
|
||||
$extra_label = $this->extension[$cell['type']]->pre_process($cell,$value,
|
||||
$GLOBALS['phpgw_info']['etemplate']['extension_data'][$cell['type']][$cell['name']],$readonlys[$name]);
|
||||
$GLOBALS['phpgw_info']['etemplate']['extension_data'][$cell['type']][$cell['name']],
|
||||
$readonlys[$name],$this);
|
||||
if (strstr($name,'|'))
|
||||
{
|
||||
$content = $this->complete_array_merge($content,$value);
|
||||
@ -498,7 +495,7 @@
|
||||
{
|
||||
$readonlys['__ALL__'] = True;
|
||||
}
|
||||
$templ = is_object($cell['name']) ? $cell['name'] : new etemplate($cell['name']);
|
||||
$templ = is_object($cell['name']) ? $cell['name'] : new etemplate($cell['name'],$this->as_array());
|
||||
$html .= $templ->show($content,$sel_options,$readonlys,$cname,$show_c,$show_row);
|
||||
break;
|
||||
case 'select': // size:[linesOnMultiselect]
|
||||
@ -758,7 +755,7 @@
|
||||
}
|
||||
$this->extension[$cell['type']]->post_process($cell,$value,
|
||||
$GLOBALS['phpgw_info']['etemplate']['extension_data'][$cell['type']][$cell['name']],
|
||||
$GLOBALS['phpgw_info']['etemplate']['loop']);
|
||||
$GLOBALS['phpgw_info']['etemplate']['loop'],$this);
|
||||
|
||||
if ($this->debug > 1 || $this->debug && $this->debug == $this->name)
|
||||
{
|
||||
@ -796,7 +793,7 @@
|
||||
}
|
||||
break;
|
||||
case 'template':
|
||||
$templ = is_object($cell['name']) ? $cell['name'] : new etemplate($name);
|
||||
$templ = is_object($cell['name']) ? $cell['name'] : new etemplate($cell['name'],$this->as_array());
|
||||
$templ->process_show($value,$readonlys);
|
||||
if ($templ->loop)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user