[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] etemplate index.php inc/class.boetemplate.inc.p...
From: |
Sigurd Nes |
Subject: |
[Phpgroupware-cvs] etemplate index.php inc/class.boetemplate.inc.p... |
Date: |
Sun, 11 Feb 2007 21:58:04 +0000 |
CVSROOT: /sources/phpgroupware
Module name: etemplate
Changes by: Sigurd Nes <sigurdne> 07/02/11 21:58:04
Modified files:
. : index.php
inc : class.boetemplate.inc.php class.editor.inc.php
class.etemplate.inc.php class.html.inc.php
class.soetemplate.inc.php
class.uietemplate.inc.php
setup : setup.inc.php
Log message:
notices and merging with old head
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/etemplate/index.php?cvsroot=phpgroupware&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/etemplate/inc/class.boetemplate.inc.php?cvsroot=phpgroupware&r1=1.41&r2=1.42
http://cvs.savannah.gnu.org/viewcvs/etemplate/inc/class.editor.inc.php?cvsroot=phpgroupware&r1=1.41&r2=1.42
http://cvs.savannah.gnu.org/viewcvs/etemplate/inc/class.etemplate.inc.php?cvsroot=phpgroupware&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/etemplate/inc/class.html.inc.php?cvsroot=phpgroupware&r1=1.27&r2=1.28
http://cvs.savannah.gnu.org/viewcvs/etemplate/inc/class.soetemplate.inc.php?cvsroot=phpgroupware&r1=1.34&r2=1.35
http://cvs.savannah.gnu.org/viewcvs/etemplate/inc/class.uietemplate.inc.php?cvsroot=phpgroupware&r1=1.75&r2=1.76
http://cvs.savannah.gnu.org/viewcvs/etemplate/setup/setup.inc.php?cvsroot=phpgroupware&r1=1.17&r2=1.18
Patches:
Index: index.php
===================================================================
RCS file: /sources/phpgroupware/etemplate/index.php,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- index.php 10 Feb 2007 16:03:45 -0000 1.7
+++ index.php 11 Feb 2007 21:58:04 -0000 1.8
@@ -13,7 +13,7 @@
* the Free Software Foundation; either version 2 of the License, or *
* at your option) any later version. *
\**********************************************************************/
- /* $Id: index.php,v 1.7 2007/02/10 16:03:45 sigurdne Exp $ */
+ /* $Id: index.php,v 1.8 2007/02/11 21:58:04 sigurdne Exp $ */
$GLOBALS['phpgw_info']['flags'] = array(
'currentapp' => 'etemplate',
@@ -22,4 +22,4 @@
);
include('../header.inc.php');
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction=etemplate.editor.edit');
+
$GLOBALS['phpgw']->redirect_link('/index.php',array('menuaction'=>'etemplate.editor.edit'));
Index: inc/class.boetemplate.inc.php
===================================================================
RCS file: /sources/phpgroupware/etemplate/inc/class.boetemplate.inc.php,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -b -r1.41 -r1.42
--- inc/class.boetemplate.inc.php 10 Feb 2007 16:03:46 -0000 1.41
+++ inc/class.boetemplate.inc.php 11 Feb 2007 21:58:04 -0000 1.42
@@ -13,7 +13,7 @@
* the Free Software Foundation; either version 2 of the License, or *
* at your option) any later version. *
\**********************************************************************/
- /* $Id: class.boetemplate.inc.php,v 1.41 2007/02/10 16:03:46 sigurdne Exp $ */
+ /* $Id: class.boetemplate.inc.php,v 1.42 2007/02/11 21:58:04 sigurdne Exp $ */
include_once(PHPGW_INCLUDE_ROOT .
'/etemplate/inc/class.soetemplate.inc.php');
@@ -112,8 +112,13 @@
@param $cont content array of the template, you might use it to
generate button-names with
@param id values in it: "del[$cont[id]]" expands to
"del[123]" if $cont = array('id' => 123)
*/
+
function expand_name($name,$c,$row,$c_='',$row_='',$cont='')
{
+ if(empty($name))
+ {
+ return '';
+ }
if (strstr($name,'$') !== False)
{
if (!$cont)
@@ -122,8 +127,8 @@
}
$col = $this->num2chrs($c-1); // $c-1 to get:
0:'@', 1:'A', ...
$col_ = $this->num2chrs($c_-1);
- $row_cont = $cont[$row];
- $col_row_cont = $cont[$col.$row];
+ $row_cont = isset($cont[$row]) ? $cont[$row] :
0;
+ $col_row_cont = isset($cont[$col.$row]) ?
$cont[$col.$row] : 0;
eval('$name = "'.$name.'";');
}
@@ -159,7 +164,21 @@
*/
function
autorepeat_idx($cell,$c,$r,&$idx,&$idx_cname,$check_col=False)
{
- $org_idx = $idx = $cell[ $cell['type'] == 'template' ?
'size' : 'name' ];
+ $org_idx = $idx = '';
+ if($cell['type'] == 'template')
+ {
+ if(isset($cell['size']))
+ {
+ $org_idx = $idx = $cell['size'];
+ }
+ }
+ else
+ {
+ if(isset($cell['name']))
+ {
+ $org_idx = $idx = $cell['name'];
+ }
+ }
$idx = $this->expand_name($idx,$c,$r);
if (!($komma = strpos($idx,',')))
Index: inc/class.editor.inc.php
===================================================================
RCS file: /sources/phpgroupware/etemplate/inc/class.editor.inc.php,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -b -r1.41 -r1.42
--- inc/class.editor.inc.php 10 Feb 2007 16:03:46 -0000 1.41
+++ inc/class.editor.inc.php 11 Feb 2007 21:58:04 -0000 1.42
@@ -13,7 +13,7 @@
* the Free Software Foundation; either version 2 of the License, or *
* at your option) any later version. *
\**********************************************************************/
- /* $Id: class.editor.inc.php,v 1.41 2007/02/10 16:03:46 sigurdne Exp $ */
+ /* $Id: class.editor.inc.php,v 1.42 2007/02/11 21:58:04 sigurdne Exp $ */
class editor
@@ -100,6 +100,135 @@
reset($this->options);
while (list($n,$opt) = each($this->options))
{
+ $content['options'][$opt] = $this->options[$n];
+ }
+ $cols_spanned = array();
+ $no_button = array();
+ if (isset($this->etemplate->data[0]))
+ {
+ while (list($row,$cols) = each($this->etemplate->data))
+ {
+ if ($this->etemplate->rows <= 1)
+ {
+ $no_button["Row$row"]['delete_row[1]']
= True;
+ }
+ if ($row > 1)
+ {
+ $no_button["Row$row"]['insert_row[0]']
= True;
+ }
+ $content["Row$row"] = array(
+ 'height' => array("h$row" =>
isset($this->etemplate->data[0]["h$row"]) ? $this->etemplate->data[0]["h$row"]
: ''),
+ 'class' => array("c$row" =>
isset($this->etemplate->data[0]["c$row"]) ? $this->etemplate->data[0]["c$row"]
: '')
+ );
+ for ($spanned = $c = 0; $c <
$this->etemplate->cols; ++$c)
+ {
+ if (!(list($col,$cell) = each($cols)))
+ {
+ $cell =
$this->etemplate->empty_cell(); // if cell gots lost, create it empty
+ $col =
$this->etemplate->num2chrs($c);
+ }
+ if (--$spanned > 0) // preserv
spanned cells
+ {
+ while(list($k,$v) =
each($cell)) // so spanned (not shown) cells got
+ {
// reported back like regular one
+
$cols_spanned[$col.$row][$k] = $v;
+ }
+ }
+ else
+ {
+ if(isset($cell['span']))
+ {
+ $spanned =
$cell['span'] == 'all' ? $this->etemplate->cols-$c : 0+$cell['span'];
+ }
+ else
+ {
+ $spanned = 0;
+ }
+ if(isset($cell['type']) &&
$cell['type'])
+ {
+ switch($cell['type'])
// load a cell-type-specific tpl
+ {
+ case 'vbox':
+ case 'hbox':
+ case 'deck':
+
$cell['cell_tpl'] = '.vbox';
+ break;
+ }
+ }
+ $content[$col.$row] = $cell;
+ }
+ if ($row == 1)
+ {
+ $content["Col$col"] =
array('width' => array($col => isset($this->etemplate->data[0][$col]) ?
$this->etemplate->data[0][$col] : ''));
+ if ($this->etemplate->cols <= 1)
+ {
+
$no_button["Col$col"]['delete_col[1]'] = True;
+ }
+ if ($c > 0)
+ {
+
$no_button["Col$col"]['insert_col[0]'] = True;
+ }
+ }
+ }
+ }
+ }
+ $no_button['ColA']['exchange_col[1]'] =
$no_button['Row1']['exchange_row[1]'] = True;
+
+ if ($this->debug)
+ {
+ echo 'editor.edit: content =';
_debug_array($content);
+ }
+ $types =
array_merge($this->etemplate->types,$this->extensions);
+ unset($types['**loaded**']);
+
$this->editor->exec('etemplate.editor.process_edit',$content,
+ array(
+ 'type' => $types,
+ 'align' => $this->aligns,
+ 'overflow' => $this->overflows
+ ),
+ $no_button,$cols_spanned +
array('**extensions**' => $this->extensions));
+ }
+
+
+ function edit_16($msg = '')
+ {
+ if (isset($_GET['name']) &&
!$this->etemplate->read($_GET))
+ {
+ $msg .= lang('Error: Template not found !!!');
+ }
+ if (!is_array($this->extensions))
+ {
+ $this->extensions =
$this->scan_for_extensions();
+ if (count($this->extensions))
+ {
+ $msg .= lang('Extensions loaded:') . '
' . implode(', ',$this->extensions);
+ $msg_ext_loaded = True;
+ }
+ }
+ list($app) = explode('.',$this->etemplate->name);
+ if ($app && $app != 'etemplate')
+ {
+ $GLOBALS['phpgw']->translation->add_app($app);
// load translations for app
+ }
+ if ($app && $app != 'etemplate' &&
is_array($this->extensions) &&
+ (!is_array($this->extensions['**loaded**']) ||
!$this->extensions['**loaded**'][$app]))
+ {
+ $extensions = $this->scan_for_extensions($app);
+ if (count($extensions))
+ {
+ $msg .=
(!$msg_ext_loaded?lang('Extensions loaded:').' ':', ') . implode(',
',$extensions);
+ $this->extensions += $extensions;
+ }
+ $this->extensions['**loaded**'][$app] = True;
+ }
+ $content = $this->etemplate->as_array() + array(
+ 'cols' => $this->etemplate->cols,
+ 'msg' => $msg
+ );
+ $options = explode(',',$this->etemplate->size);
+ reset($this->options);
+ while (list($n,$opt) = each($this->options))
+ {
$content['options'][$opt] = $options[$n];
}
$cols_spanned = array();
@@ -139,7 +268,9 @@
}
else
{
- $spanned = $cell['span'] ==
'all' ? $this->etemplate->cols-$c : 0+$cell['span'];
+ $span = isset($cell['span']) &&
$cell['span'] ? $cell['span'] : 0;
+ $spanned = $span == 'all' ?
$this->etemplate->cols-$c : 0+$span;
+ unset($span);
switch($cell['type']) // load
a cell-type-specific tpl
{
@@ -361,7 +492,7 @@
$this->etemplate->cols.', data =';
_debug_array($this->etemplate->data);
}
// Execute the action resulting from the submit-button
- if ($content['read'])
+ if (isset($content['read']) && $content['read'])
{
if ($content['version'] != '')
{
@@ -400,12 +531,12 @@
$msg = lang("newer version '%1' exists
!!!",$newest_version);
}
}
- elseif ($content['delete'])
+ elseif (isset($content['delete']) && $content['delete'])
{
$this->delete();
return;
}
- elseif ($content['dump'])
+ elseif (isset($content['dump']) && $content['dump'])
{
list($name) = explode('.',$content['name']);
if (empty($name) ||
address@hidden(PHPGW_SERVER_ROOT.'/'.$name))
@@ -417,7 +548,7 @@
$msg =
$this->etemplate->dump2setup($content['name']);
}
}
- elseif ($content['save'])
+ elseif (isset($content['save']) && $content['save'])
{
if (!$this->etemplate->modified_set ||
!$this->etemplate->modified)
{
@@ -426,12 +557,12 @@
$ok =
$this->etemplate->save(trim($content['name']),trim($content['template']),trim($content['lang']),intval($content['group']),trim($content['version']));
$msg = $ok ? lang('Template saved') :
lang('Error: while saveing !!!');
}
- elseif ($content['show'])
+ elseif (isset($content['show']) && $content['show'])
{
$this->show();
return;
}
- elseif ($content['langfile'])
+ elseif (isset($content['langfile']) &&
$content['langfile'])
{
list($name) = explode('.',$content['name']);
if (empty($name) ||
address@hidden(PHPGW_SERVER_ROOT.'/'.$name))
@@ -468,20 +599,20 @@
}
}
}
- elseif ($content['export_xml'])
+ elseif (isset($content['export_xml']) &&
$content['export_xml'])
{
$msg = $this->export_xml();
}
- elseif ($content['import_xml'])
+ elseif (isset($content['import_xml']) &&
$content['import_xml'])
{
$msg =
$this->import_xml($content['file']['tmp_name']);
}
- elseif ($content['db_tools'])
+ elseif (isset($content['db_tools']) &&
$content['db_tools'])
{
ExecMethod('etemplate.db_tools.edit');
return;
}
- $this->edit($msg);
+ $this->edit(isset($msg) ? $msg : '');
}
function export_xml()
Index: inc/class.etemplate.inc.php
===================================================================
RCS file: /sources/phpgroupware/etemplate/inc/class.etemplate.inc.php,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- inc/class.etemplate.inc.php 10 Feb 2007 16:03:46 -0000 1.8
+++ inc/class.etemplate.inc.php 11 Feb 2007 21:58:04 -0000 1.9
@@ -13,14 +13,14 @@
* the Free Software Foundation; either version 2 of the License, or *
* at your option) any later version. *
\**********************************************************************/
- /* $Id: class.etemplate.inc.php,v 1.8 2007/02/10 16:03:46 sigurdne Exp $ */
+ /* $Id: class.etemplate.inc.php,v 1.9 2007/02/11 21:58:04 sigurdne Exp $ */
if (!function_exists('get_var'))
{
include_once('get_var.php');
}
$ui = ''; // html UI, which UI to use, should come from api and be in
$GLOBALS['phpgw']???
- if ($_ENV['DISPLAY'] && isset($_SERVER['_']))
+ if (isset($_ENV['DISPLAY']) && $_ENV['DISPLAY'] && isset($_SERVER['_']))
{
$ui = '_gtk';
}
Index: inc/class.html.inc.php
===================================================================
RCS file: /sources/phpgroupware/etemplate/inc/class.html.inc.php,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -b -r1.27 -r1.28
--- inc/class.html.inc.php 10 Feb 2007 16:03:46 -0000 1.27
+++ inc/class.html.inc.php 11 Feb 2007 21:58:04 -0000 1.28
@@ -13,7 +13,7 @@
* the Free Software Foundation; either version 2 of the License, or *
* at your option) any later version. *
\**********************************************************************/
- /* $Id: class.html.inc.php,v 1.27 2007/02/10 16:03:46 sigurdne Exp $ */
+ /* $Id: class.html.inc.php,v 1.28 2007/02/11 21:58:04 sigurdne Exp $ */
class html
{
@@ -90,6 +90,7 @@
{
$vars = array( $vars => $value );
}
+ $html = '';
foreach($vars as $name => $value)
{
if (is_array($value))
@@ -169,15 +170,20 @@
@example =
'http://domain/phpgw-path/index.php?menuaction=infolog.uiinfolog.get_list&info_id=123'
@result absolut link already run through $phpgw->link
*/
- function link($url,$vars='')
+ function link($url, $vars='')
{
- //echo "<p>html::link(url='$url',vars='"; print_r($vars); echo
"')</p>\n";
+ //echo "<p>html::link(url='$url',vars='"; print_r($vars); echo
"')</p>\n" . _debug_array(debug_backtrace());
if (!is_array($vars))
{
- parse_str($vars,$vars);
+ parse_str($vars, $vars);
}
+
+ if(strpos('?',$url) > 0)
+ {
list($url,$v) = explode('?',$url); // url may contain
additional vars
- if ($v)
+ }
+
+ if (isset($v))
{
parse_str($v,$v);
$vars += $v;
@@ -231,6 +237,50 @@
{
continue;
// parameter
}
+ if(isset($rows['.'.$key]))
+ {
+ $html .= $no_table_tr && $key == 1 ? '' :
"\t<TR ".$rows['.'.$key].">\n";
+ }
+
+ foreach($row as $key => $cell)
+ {
+ if ($key[0] == '.')
+ {
+ continue;
// parameter
+ }
+ $table_pos = strpos($cell,'<TABLE');
+ $td_pos = strpos($cell,'<TD');
+ if ($td_pos !== False && ($table_pos === False
|| $td_pos < $table_pos))
+ {
+ $html .= $cell;
+ }
+ else
+ {
+ $html .= "\t\t<TD
".$row['.'.$key].">$cell</TD>\n";
+ }
+ }
+ $html .= "\t</TR>\n";
+ }
+ $html .= "</TABLE>\n";
+
+ if ($no_table_tr)
+ {
+ $html = substr($html,0,-16);
+ }
+ return $html;
+ }
+
+
+ function table_16($rows,$options = '',$no_table_tr=False)
+ {
+ $html = $no_table_tr ? '' : "<TABLE $options>\n";
+
+ foreach($rows as $key => $row)
+ {
+ if (!is_array($row))
+ {
+ continue;
// parameter
+ }
$html .= $no_table_tr && $key == 1 ? '' : "\t<TR
".$rows['.'.$key].">\n";
foreach($row as $key => $cell)
@@ -337,6 +387,7 @@
if (!is_array($options)) $options = explode(',',$options);
if (!is_array($names)) $names = explode(',',$names);
+ $html = '';
while (list($n,$val) = each($options))
if ($val != '' && $names[$n] != '')
$html .= ' '.$names[$n].'="'.$val.'"';
Index: inc/class.soetemplate.inc.php
===================================================================
RCS file: /sources/phpgroupware/etemplate/inc/class.soetemplate.inc.php,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -b -r1.34 -r1.35
--- inc/class.soetemplate.inc.php 10 Feb 2007 16:03:46 -0000 1.34
+++ inc/class.soetemplate.inc.php 11 Feb 2007 21:58:04 -0000 1.35
@@ -13,7 +13,7 @@
* the Free Software Foundation; either version 2 of the License, or *
* at your option) any later version. *
\**********************************************************************/
- /* $Id: class.soetemplate.inc.php,v 1.34 2007/02/10 16:03:46 sigurdne Exp $ */
+ /* $Id: class.soetemplate.inc.php,v 1.35 2007/02/11 21:58:04 sigurdne Exp $ */
/*!
@class soetemplate
@@ -101,6 +101,7 @@
*/
function num2chrs($num)
{
+ $chrs = '';
$min = ord('A');
$max = ord('Z') - $min + 1;
if ($num >= $max)
@@ -183,6 +184,61 @@
$this->cols = count($this->data[1]); // 1 = first row,
not 0
}
+ /**
+ * initialises all internal data-structures of the eTemplate
and sets the keys
+ *
+ * @param $name name of the eTemplate or array with the keys or
all data
+ * @param $template,$lang,$group,$version see class
+ * @param $rows,$cols initial size of the template
+ */
+ function
init($name='',$template='',$lang='',$group=0,$version='',$rows=1,$cols=1)
+ {
+ reset($this->db_cols);
+ while (list($db_col,$col) = each($this->db_cols))
+ {
+ if(is_array($name))
+ {
+ if(isset($name[$col]))
+ {
+ $this->$col = $name[$col];
+ }
+ }
+ else
+ {
+ if(isset($$col))
+ {
+ $this->$col = $$col;
+ }
+ }
+ }
+ if ($this->template == 'default')
+ {
+ $this->template = '';
+ }
+ if ($this->lang == 'default')
+ {
+ $this->lang = '';
+ }
+ $this->tpls_in_file = is_array($name) &&
isset($name['tpls_in_file']) ? $name['tpls_in_file'] : 0;
+
+ if (is_array($name) && isset($name['data']))
+ {
+ $this->set_rows_cols();
+ return; // data already set
+ }
+ $this->size = $this->style = '';
+ $this->data = array(0 => array());
+ $this->rows = $rows < 0 ? 1 : $rows;
+ $this->cols = $cols < 0 ? 1 : $cols;
+ for ($row = 1; $row <= $rows; ++$row)
+ {
+ for ($col = 0; $col < $cols; ++$col)
+ {
+
$this->data[$row][$this->num2chrs($col)] = $this->empty_cell();
+ }
+ }
+ }
+
/*!
@function init
@abstract initialises all internal data-structures of the
eTemplate and sets the keys
@@ -191,7 +247,7 @@
@param $template,$lang,$group,$version see class
@param $rows,$cols initial size of the template
*/
- function
init($name='',$template='',$lang='',$group=0,$version='',$rows=1,$cols=1)
+ function
init_16($name='',$template='',$lang='',$group=0,$version='',$rows=1,$cols=1)
{
reset($this->db_cols);
while (list($db_col,$col) = each($this->db_cols))
@@ -243,8 +299,9 @@
{
echo
"<p>soetemplate::read('$this->name','$this->template','$this->lang',$this->group,'$this->version')</p>\n";
}
- if
(($GLOBALS['phpgw_info']['server']['eTemplate-source'] == 'files' ||
-
$GLOBALS['phpgw_info']['server']['eTemplate-source'] == 'xslt') &&
$this->readfile())
+ if
(isset($GLOBALS['phpgw_info']['server']['eTemplate-source'])
+ &&
($GLOBALS['phpgw_info']['server']['eTemplate-source'] == 'files' ||
$GLOBALS['phpgw_info']['server']['eTemplate-source'] == 'xslt')
+ && $this->readfile())
{
return True;
}
@@ -469,7 +526,7 @@
$this->data[$row][$col]['type'] = $cell['type'][0];
//echo "corrected in
$this->name cell $col$row attribute type<br>\n";
}
- if (is_array($cell['align']))
+ if (isset($cell['align']) &&
is_array($cell['align']))
{
$this->data[$row][$col]['align'] = $cell['align'][0];
//echo "corrected in
$this->name cell $col$row attribute align<br>\n";
@@ -525,7 +582,7 @@
{
if ($col != 'data' || $data_too)
{
- $arr[$col] = $this->$col;
+ $arr[$col] = isset($this->$col) ?
$this->$col : '';
}
}
if ($data_too == 2)
@@ -901,7 +958,7 @@
{
list($app) = explode('.',$app);
- if (!$app ||
$GLOBALS['phpgw_info']['etemplate']['import_tested'][$app])
+ if ((!isset($app) || !$app) ||
(isset($GLOBALS['phpgw_info']['etemplate']['import_tested'][$app]) &&
$GLOBALS['phpgw_info']['etemplate']['import_tested'][$app]))
{
return ''; // ensure test is done only
once per call and app
}
@@ -909,6 +966,7 @@
$path =
PHPGW_SERVER_ROOT."/$app/setup/etemplates.inc.php";
+ $ret = '';
if ($time = @filemtime($path))
{
$templ = new soetemplate(".$app",'','##');
Index: inc/class.uietemplate.inc.php
===================================================================
RCS file: /sources/phpgroupware/etemplate/inc/class.uietemplate.inc.php,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -b -r1.75 -r1.76
--- inc/class.uietemplate.inc.php 10 Feb 2007 16:03:46 -0000 1.75
+++ inc/class.uietemplate.inc.php 11 Feb 2007 21:58:04 -0000 1.76
@@ -13,7 +13,7 @@
* the Free Software Foundation; either version 2 of the License, or *
* at your option) any later version. *
\**********************************************************************/
- /* $Id: class.uietemplate.inc.php,v 1.75 2007/02/10 16:03:46 sigurdne Exp $ */
+ /* $Id: class.uietemplate.inc.php,v 1.76 2007/02/11 21:58:04 sigurdne Exp $ */
include_once(PHPGW_INCLUDE_ROOT .
'/etemplate/inc/class.boetemplate.inc.php');
@@ -129,6 +129,113 @@
$this->html->form($this->include_java_script(1).
$this->show($this->complete_array_merge($content,$changes),$sel_options,$readonlys,'exec'),array(
'etemplate_exec_id' => $id
+ ),'/etemplate/process_exec.php',
array('menuaction' => $method),'eTemplate',
$GLOBALS['phpgw_info']['etemplate']['form_options']);
+
//_debug_array($GLOBALS['phpgw_info']['etemplate']['to_process']);
+ if ($this->stable)
+ {
+ $hooked =
$GLOBALS['phpgw']->template->get_var('phpgw_body');
+ if
(address@hidden'phpgw_info']['etemplate']['hooked'] && !$return_html)
+ {
+
$GLOBALS['phpgw_info']['flags']['java_script'] =
isset($GLOBALS['phpgw_info']['flags']['java_script']) ?
$GLOBALS['phpgw_info']['flags']['java_script'] : '' .
$this->include_java_script(2);
+
$GLOBALS['phpgw']->common->phpgw_header();
+ }
+ else
+ {
+ $html =
$this->include_java_script(2).$html; // better than nothing
+ }
+ }
+ else
+ {
+ $hooked =
$GLOBALS['phpgw']->xslttpl->get_var('phpgw');
+ $hooked = $hooked['body_data'];
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('java_script' =>
$GLOBALS['phpgw_info']['flags']['java_script'].$this->include_java_script(2)));
+ }
+
+ $tmpa = explode(',',$this->size);
+ $width = isset($tmpa[0]) ? $tmpa[0] : '';
+ $height = isset($tmpa[1]) ? $tmpa[1] : '';
+ $overflow = isset($tmpa[6]) ? $tmpa[6] : '';
+ unset($tmpa);
+ if ($overflow)
+ {
+ $html =
$this->html->div($html,'STYLE="'.($width?"width: $width;
":'').($height?"height: $height; ":'')."overflow: $overflow;\"");
+ }
+ $id = $this->save_appsession($this->as_array(1) + array(
+ 'readonlys' => $readonlys,
+ 'content' => $content,
+ 'changes' => $changes,
+ 'sel_options' => $sel_options,
+ 'preserv' => $preserv,
+ 'extension_data' =>
isset($GLOBALS['phpgw_info']['etemplate']['extension_data']) ?
$GLOBALS['phpgw_info']['etemplate']['extension_data'] : '',
+ 'to_process' =>
isset($GLOBALS['phpgw_info']['etemplate']['to_process']) ?
$GLOBALS['phpgw_info']['etemplate']['to_process'] : '',
+ 'java_script' =>
isset($GLOBALS['phpgw_info']['etemplate']['java_script']) ?
$GLOBALS['phpgw_info']['etemplate']['java_script'] : '',
+ 'dom_enabled' =>
isset($GLOBALS['phpgw_info']['etemplate']['dom_enabled']) ?
$GLOBALS['phpgw_info']['etemplate']['dom_enabled'] : '',
+ 'method' => $method,
+ 'hooked' => $hooked != '' ? $hooked :
isset($GLOBALS['phpgw_info']['etemplate']['hook_content']) ?
$GLOBALS['phpgw_info']['etemplate']['hook_content'] : ''
+ ),$id);
+
+ if ($return_html)
+ {
+ return $html;
+ }
+ if ($this->stable)
+ {
+ if
(address@hidden'phpgw_info']['etemplate']['hooked'])
+ {
+ echo parse_navbar();
+ }
+ echo
(isset($GLOBALS['phpgw_info']['etemplate']['hook_content']) ?
$GLOBALS['phpgw_info']['etemplate']['hook_content'] : '')
+ . $html;
+
+ if
(address@hidden'phpgw_info']['etemplate']['hooked'] &&
+ (!isset($_GET['menuaction']) ||
strstr($_SERVER['PHP_SELF'],'process_exec.php')))
+ {
+
$GLOBALS['phpgw']->common->phpgw_footer();
+ }
+ }
+ else
+ {
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('body_data' => $html));
+
$GLOBALS['phpgw']->xslttpl->add_file('app_data');
+ $GLOBALS['phpgw']->xslttpl->pparse();
+ }
+ }
+
+ function
exec_16($method,$content,$sel_options='',$readonlys='',$preserv='',$changes='',$return_html=False)
+ {
+ //echo "<br>globals[java_script] =
'".$GLOBALS['phpgw_info']['etemplate']['java_script']."', this->java_script() =
'".$this->java_script()."'\n";
+ if (!$sel_options)
+ {
+ $sel_options = array();
+ }
+ if (!$readonlys)
+ {
+ $readonlys = array();
+ }
+ if (!$preserv)
+ {
+ $preserv = array();
+ }
+ if (!$changes)
+ {
+ $changes = array();
+ }
+ if (isset($content['app_header']))
+ {
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
$content['app_header'];
+ }
+ if ($GLOBALS['phpgw_info']['flags']['currentapp'] !=
'etemplate')
+ {
+
$GLOBALS['phpgw']->translation->add_app('etemplate'); // some extensions have
own texts
+ }
+ $id = $this->appsession_id();
+ $GLOBALS['phpgw_info']['etemplate']['loop'] = False;
+ $GLOBALS['phpgw_info']['etemplate']['form_options'] =
''; // might be set in show
+ $GLOBALS['phpgw_info']['etemplate']['to_process'] =
array();
+ $html = ($this->stable ?
$this->html->themeStyles()."\n\n" : ''). // so they get included once
+ $this->html->form($this->include_java_script(1).
+
$this->show($this->complete_array_merge($content,$changes),$sel_options,$readonlys,'exec'),array(
+ 'etemplate_exec_id' => $id
),'/etemplate/process_exec.php?menuaction='.$method,'','eTemplate',$GLOBALS['phpgw_info']['etemplate']['form_options']);
//_debug_array($GLOBALS['phpgw_info']['etemplate']['to_process']);
if ($this->stable)
@@ -232,7 +339,7 @@
$content =
$this->complete_array_merge($session_data['changes'],$content);
//echo "process_exec($this->name)
merge(changes,content) ="; _debug_array($content);
- if ($GLOBALS['phpgw_info']['etemplate']['loop'])
+ if (isset($GLOBALS['phpgw_info']['etemplate']['loop'])
&& $GLOBALS['phpgw_info']['etemplate']['loop'])
{
if ($session_data['hooked'] != '') // set
previous phpgw_body if we are called as hook
{
@@ -278,23 +385,22 @@
//echo "<p>check_disabled: '".($not?'!':'')."$disabled'
= '$val' ".(count($vals) == 1 ? '' : ($not?'!':'=')."= '$check_val'")." =
".($result?'True':'False')."</p>\n";
return $result;
}
-
- /*!
- @function show
- @abstract creates HTML from an eTemplate
- @discussion This is done by calling show_cell for each cell in
the form. show_cell itself
- @discussion calls show recursivly for each included eTemplate.
- @discussion You can use it in the UI-layer of an app, just make
shure to call process_show !!!
- @discussion This is intended as internal function and should
NOT be called by new app's direct,
- @discussion as it deals with HTML and is so UI-dependent, use
exec instead.
- @param $content array with content for the cells, keys are the
names given in the cells/form elements
- @param $sel_options array with options for the selectboxes,
keys are the name of the selectbox
- @param $readonlys array with names of cells/form-elements to be
not allowed to change
- @param This is to facilitate complex ACL's which
denies access on field-level !!!
- @param $cname basename of names for form-elements, means index
in $_POST
- @param eg. $cname='cont', element-name = 'name' returned
content in $_POST['cont']['name']
- @param $show_xxx row,col name/index for name expansion
- @result the generated HTML
+ /**
+ * creates HTML from an eTemplate
+ *
+ * This is done by calling show_cell for each cell in the form.
show_cell itself
+ * calls show recursivly for each included eTemplate.
+ * You can use it in the UI-layer of an app, just make shure to
call process_show !!!
+ * This is intended as internal function and should NOT be
called by new app's direct,
+ * as it deals with HTML and is so UI-dependent, use exec
instead.
+ * @param $content array with content for the cells, keys are
the names given in the cells/form elements
+ * @param $sel_options array with options for the selectboxes,
keys are the name of the selectbox
+ * @param $readonlys array with names of cells/form-elements to
be not allowed to change
+ * @param This is to facilitate complex ACL's which
denies access on field-level !!!
+ * @param $cname basename of names for form-elements, means
index in $_POST
+ * @param eg. $cname='cont', element-name = 'name'
returned content in $_POST['cont']['name']
+ * @param $show_xxx row,col name/index for name expansion
+ * @return the generated HTML
*/
function
show($content,$sel_options='',$readonlys='',$cname='',$show_c=0,$show_row=0,
$no_table_tr=False,$tr_class='')
@@ -342,122 +448,960 @@
}
else
{
- $cols = &$this->data[$r_key];
- list($height,$disabled) =
explode(',',$opts["h$row"]);
- $class = $no_table_tr ? $tr_class :
$opts["c$row"];
+ $cols = &$this->data[$r_key];
+ if(isset($opts["h$row"]))
+ {
+ list($height,$disabled) =
explode(',',$opts["h$row"]);
+ }
+ else
+ {
+ $height ='';
+ $disabled= '';
+ }
+ if(isset($opts["c$row"]))
+ {
+ $class = $no_table_tr ?
$tr_class : $opts["c$row"];
+ }
+ else
+ {
+ $class = '';
+ }
+ }
+ if ($disabled != '' &&
$this->check_disabled($disabled,$content))
+ {
+ continue; // row is disabled
+ }
+ if(!isset($rows[".$row"]))
+ {
+ $rows[".$row"] = '';
+ }
+ $rows[".$row"] .=
$this->html->formatOptions($height,'HEIGHT');
+ list($cl) = explode(',',$class);
+ if ($cl == 'nmr' || $cl == 'row')
+ {
+ $cl = 'row_'.(@$nmr_alternate++ & 1 ?
'off' : 'on'); // alternate color
+ }
+ $cl = isset($this->class_conf[$cl]) ?
$this->class_conf[$cl] : $cl;
+ $rows[".$row"] .=
$this->html->formatOptions($cl,'CLASS');
+ $rows[".$row"] .=
$this->html->formatOptions($class,',VALIGN');
+
+ reset ($cols);
+ $row_data = array();
+ for ($c = 0; True /*list($col,$cell) =
each($cols)*/; ++$c)
+ {
+ $col = $this->num2chrs($c);
+ if (!(list($c_key) = each($cols)))
// no further cols
+ {
+ if
(!$this->autorepeat_idx($cell,$c,$r,$idx,$idx_cname,True) ||
+
!$this->isset_array($content,$idx))
+ {
+ break; // no
auto-col-repeat
+ }
+ }
+ else if(isset($c_key) &&
isset($cols[$c_key]))
+ {
+ $cell = &$cols[$c_key];
+ if(isset($opts[$col]))
+ {
+ $col_disabled = '';
+ $tmp =
explode(',',$opts[$col]);
+ $col_width = $tmp[0];
+ if ( count($tmp) == 2 )
+ {
+ $col_disabled =
$tmp[1];
+ }
+ unset($tmp);
+ }
+ else
+ {
+ $col_width=0;
+ $col_disabled=false;
+ }
+
+ if (!isset($cell['height']))
// if not set, cell-height = height of row
+ {
+ $cell['height'] =
$height;
+ }
+ if (!isset($cell['width']))
// if not set, cell-width = width of column or table
+ {
+ if(isset($cell['span']))
+ {
+ list($col_span)
= explode(',',$cell['span']);
+ }
+ else
+ {
+ $col_span = '';
+ }
+ if ($col_span == 'all'
&& !$c)
+ {
+
list($cell['width']) = explode(',',$this->size);
+ }
+ else
+ {
+ $cell['width']
= $col_width;
+ }
+ }
+ }
+ if ( isset($cell['type']) &&
isset($cell['onchange'])
+ && $cell['type'] == 'template'
&& $cell['onchange'])
+ {
+ $cell['tr_class'] = $cl;
+ }
+ if ($col_disabled != '' &&
$this->check_disabled($col_disabled,$content))
+ {
+ continue; // col is
disabled
+ }
+ $row_data[$col] =
$this->show_cell($cell,$content,$sel_options,$readonlys,$cname,
+ $c,$r,$span);
+ if ($row_data[$col] == '' &&
$this->rows == 1)
+ {
+ unset($row_data[$col]); // omit
empty/disabled cells if only one row
+ continue;
+ }
+ if(!isset($row_data[".$col"]))
+ {
+ $row_data[".$col"] = '';
+ }
+ if (isset($cell['onclick']) &&
$cell['onclick']) // can only be set via source at the moment
+ {
+ $row_data[".$col"] .= '
onClick="'.$cell['onclick'].'"';
+
+ if ($cell['id'])
+ {
+ $row_data[".$col"] .= '
ID="'.$cell['id'].'"';
+ }
+ }
+ $colspan = $span == 'all' ?
$this->cols-$c : 0+$span;
+ if ($colspan > 1)
+ {
+ $row_data[".$col"] .= "
COLSPAN=\"$colspan\"";
+ for ($i = 1; $i < $colspan;
++$i,++$c)
+ {
+ each($cols); // skip
next cell(s)
+ }
+ }
+ else
+ {
+ if(isset($opts[$col]))
+ {
+ $disable = '';
+ $tmp = explode(',',
$opts[$col]);
+ $width = $tmp[0];
+ if ( count($tmp) == 2 )
+ {
+ $disable =
$tmp[2];
+ }
+ unset($tmp);
+
+ if ($width)
// width only once for a non colspan cell
+ {
+
$row_data[".$col"] .= " width=\"$width\"";
+ $opts[$col] =
"0,$disable";
+ }
+ }
+ }
+ if(isset($cell['align']))
+ {
+ $row_data[".$col"] .=
$this->html->formatOptions($cell['align'],'ALIGN');
+ }
+ if(isset($cell['span']))
+ {
+ $cl =
explode(',',$cell['span']);
+ $cl = isset($cl[1]) ? $cl[1] :
'';
+ $cl =
$this->expand_name(isset($this->class_conf[$cl]) ? $this->class_conf[$cl] : $cl,
+
$c,$r,$show_c,$show_row,$content);
+ $row_data[".$col"] .=
$this->html->formatOptions($cl,'CLASS');
+ }
+ }
+ $rows[$row] = $row_data;
+ }
+ if (
!isset($GLOBALS['phpgw_info']['etemplate']['styles_included'][$this->name])
+ ||
!$GLOBALS['phpgw_info']['etemplate']['styles_included'][$this->name] )
+ {
+ $style = $this->html->style($this->style);
+
$GLOBALS['phpgw_info']['etemplate']['styles_included'][$this->name] = True;
+ }
+ $html =
$this->html->table($rows,$this->html->formatOptions($this->size,'WIDTH,HEIGHT,BORDER,CLASS,CELLSPACING,CELLPADDING'),$no_table_tr);
+
+ $tmpa = explode(',',$this->size);
+ $width = isset($tmpa[0]) ? $tmpa[0] : '';
+ $height = isset($tmpa[1]) ? $tmpa[1] : '';
+ $overflow = isset($tmpa[6]) ? $tmpa[6] : '';
+ unset($tmpa);
+
+ if (!empty($overflow)) {
+ $div_style=' STYLE="'.($width?"width: $width;
":'').($height ? "height: $height; ":'')."overflow: $overflow\"";
+ $html = $this->html->div($html,$div_style);
+ }
+ $style = isset($style) ? $style : '';
+ return "\n\n<!-- BEGIN $this->name
-->\n$style\n".$html."<!-- END $this->name -->\n\n";
+ }
+
+
+ /*!
+ @function show
+ @abstract creates HTML from an eTemplate
+ @discussion This is done by calling show_cell for each cell in
the form. show_cell itself
+ @discussion calls show recursivly for each included eTemplate.
+ @discussion You can use it in the UI-layer of an app, just make
shure to call process_show !!!
+ @discussion This is intended as internal function and should
NOT be called by new app's direct,
+ @discussion as it deals with HTML and is so UI-dependent, use
exec instead.
+ @param $content array with content for the cells, keys are the
names given in the cells/form elements
+ @param $sel_options array with options for the selectboxes,
keys are the name of the selectbox
+ @param $readonlys array with names of cells/form-elements to be
not allowed to change
+ @param This is to facilitate complex ACL's which
denies access on field-level !!!
+ @param $cname basename of names for form-elements, means index
in $_POST
+ @param eg. $cname='cont', element-name = 'name' returned
content in $_POST['cont']['name']
+ @param $show_xxx row,col name/index for name expansion
+ @result the generated HTML
+ */
+ function
show_16($content,$sel_options='',$readonlys='',$cname='',$show_c=0,$show_row=0,
+ $no_table_tr=False,$tr_class='')
+ {
+ if (!$sel_options)
+ {
+ $sel_options = array();
+ }
+ if (!$readonlys)
+ {
+ $readonlys = array();
+ }
+ if (is_int($this->debug) && $this->debug >= 1 ||
$this->debug == $this->name && $this->name)
+ {
+ echo "<p>etemplate.show($this->name): $cname
=\n"; _debug_array($content);
+ }
+ if (!is_array($content))
+ {
+ $content = array(); // happens if incl.
template has no content
+ }
+ $content += array( // for var-expansion in names
in show_cell
+ '.c' => $show_c,
+ '.col' => $this->num2chrs($show_c-1),
+ '.row' => $show_row
+ );
+ reset($this->data);
+ if (isset($this->data[0]))
+ {
+ list(,$opts) = each($this->data);
+ }
+ else
+ {
+ $opts = array();
+ }
+ for ($r = 0; $row = 1+$r /*list($row,$cols) =
each($this->data)*/; ++$r)
+ {
+ if (!(list($r_key) = each($this->data)))
// no further row
+ {
+ if
(!($this->autorepeat_idx($cols['A'],0,$r,$idx,$idx_cname) && $idx_cname) &&
+
!($this->autorepeat_idx($cols['B'],1,$r,$idx,$idx_cname) && $idx_cname) ||
+
!$this->isset_array($content,$idx))
+ {
+ break;
// no auto-row-repeat
+ }
+ }
+ else
+ {
+ $cols = &$this->data[$r_key];
+ list($height,$disabled) =
explode(',',$opts["h$row"]);
+ $class = $no_table_tr ? $tr_class :
$opts["c$row"];
+ }
+ if ($disabled != '' &&
$this->check_disabled($disabled,$content))
+ {
+ continue; // row is disabled
+ }
+ $rows[".$row"] .=
$this->html->formatOptions($height,'HEIGHT');
+ list($cl) = explode(',',$class);
+ if ($cl == 'nmr' || $cl == 'row')
+ {
+ $cl = 'row_'.($nmr_alternate++ & 1 ?
'off' : 'on'); // alternate color
+ }
+ $cl = isset($this->class_conf[$cl]) ?
$this->class_conf[$cl] : $cl;
+ $rows[".$row"] .=
$this->html->formatOptions($cl,'CLASS');
+ $rows[".$row"] .=
$this->html->formatOptions($class,',VALIGN');
+
+ reset ($cols);
+ $row_data = array();
+ for ($c = 0; True /*list($col,$cell) =
each($cols)*/; ++$c)
+ {
+ $col = $this->num2chrs($c);
+ if (!(list($c_key) = each($cols)))
// no further cols
+ {
+ if
(!$this->autorepeat_idx($cell,$c,$r,$idx,$idx_cname,True) ||
+
!$this->isset_array($content,$idx))
+ {
+ break; // no
auto-col-repeat
+ }
+ }
+ else
+ {
+ $cell = &$cols[$c_key];
+ list($col_width,$col_disabled)
= explode(',',$opts[$col]);
+
+ if (!isset($cell['height']) ||
!$cell['height']) // if not set, cell-height = height of row
+ {
+ $cell['height'] =
$height;
+ }
+ if (!isset($cell['width']) ||
!$cell['width']) // if not set, cell-width = width of column or table
+ {
+ list($col_span) =
explode(',',$cell['span']);
+ if ($col_span == 'all'
&& !$c)
+ {
+
list($cell['width']) = explode(',',$this->size);
+ }
+ else
+ {
+ $cell['width']
= $col_width;
+ }
+ }
+ }
+ if ($cell['type'] == 'template' &&
$cell['onchange'])
+ {
+ $cell['tr_class'] = $cl;
+ }
+ if ($col_disabled != '' &&
$this->check_disabled($col_disabled,$content))
+ {
+ continue; // col is
disabled
+ }
+ $row_data[$col] =
$this->show_cell($cell,$content,$sel_options,$readonlys,$cname,
+ $c,$r,$span);
+ if ($row_data[$col] == '' &&
$this->rows == 1)
+ {
+ unset($row_data[$col]); // omit
empty/disabled cells if only one row
+ continue;
+ }
+ if ($cell['onclick']) // can only be
set via source at the moment
+ {
+ $row_data[".$col"] .= '
onClick="'.$cell['onclick'].'"';
+
+ if ($cell['id'])
+ {
+ $row_data[".$col"] .= '
ID="'.$cell['id'].'"';
+ }
+ }
+ $colspan = $span == 'all' ?
$this->cols-$c : 0+$span;
+ if ($colspan > 1)
+ {
+ $row_data[".$col"] .= "
COLSPAN=\"$colspan\"";
+ for ($i = 1; $i < $colspan;
++$i,++$c)
+ {
+ each($cols); // skip
next cell(s)
+ }
+ }
+ else
+ {
+ list($width,$disable) =
explode(',',$opts[$col]);
+ if ($width) //
width only once for a non colspan cell
+ {
+ $row_data[".$col"] .= "
WIDTH=\"$width\"";
+ $opts[$col] =
"0,$disable";
+ }
+ }
+ $row_data[".$col"] .=
$this->html->formatOptions($cell['align'],'ALIGN');
+ list(,$cl) = explode(',',$cell['span']);
+ $cl =
$this->expand_name(isset($this->class_conf[$cl]) ? $this->class_conf[$cl] : $cl,
+
$c,$r,$show_c,$show_row,$content);
+ $row_data[".$col"] .=
$this->html->formatOptions($cl,'CLASS');
+ }
+ $rows[$row] = $row_data;
+ }
+ if
(!$GLOBALS['phpgw_info']['etemplate']['styles_included'][$this->name])
+ {
+ $style = $this->html->style($this->style);
+
$GLOBALS['phpgw_info']['etemplate']['styles_included'][$this->name] = True;
+ }
+ $html =
$this->html->table($rows,$this->html->formatOptions($this->size,'WIDTH,HEIGHT,BORDER,CLASS,CELLSPACING,CELLPADDING'),$no_table_tr);
+
+ list($width,$height,,,,,$overflow) =
explode(',',$this->size);
+ if (!empty($overflow)) {
+ $div_style=' STYLE="'.($width?"width: $width;
":'').($height ? "height: $height; ":'')."overflow: $overflow\"";
+ $html = $this->html->div($html,$div_style);
+ }
+ return "\n\n<!-- BEGIN $this->name
-->\n$style\n".$html."<!-- END $this->name -->\n\n";
+ }
+
+ /**
+ * generates HTML for 1 input-field / cell
+ *
+ * calls show to generate included eTemplates. Again only an
INTERMAL function.
+ * @param $cell array with data of the cell: name, type, ...
+ * @param for rest see show
+ * @return the generated HTML
+ */
+ function
show_cell($cell,$content,$sel_options,$readonlys,$cname,$show_c,$show_row,&$span)
+ {
+ $options = '';
+ if (is_int($this->debug) && $this->debug >= 3 ||
$this->debug == $cell['type'])
+ {
+ echo
"<p>etemplate.show_cell($this->name,name='${cell['name']}',type='${cell['type']}',cname='$cname')</p>\n";
+ }
+
+ if(isset($cell['span']))
+ {
+ list($span) = explode(',',$cell['span']);
// evtl. overriten later for type template
+ }
+ else
+ {
+ $span = '';
+ }
+
+ $name = '';
+ if(isset($cell['name']))
+ {
+ if ($cell['name'][0] == '@' && $cell['type'] !=
'template')
+ {
+ $cell['name'] =
$this->get_array($content,substr($cell['name'],1));
+ }
+ $name =
$this->expand_name($cell['name'],$show_c,$show_row,$content['.c'],$content['.row'],$content);
+ }
+
+ $name_parts = explode('[',str_replace(']','',$name));
+ if (!empty($cname))
+ {
+ array_unshift($name_parts,$cname);
+ }
+ $form_name = array_shift($name_parts);
+ if (count($name_parts))
+ {
+ $form_name .= '['.implode('][',$name_parts).']';
+ }
+ $value = $this->get_array($content,$name);
+
+ if ( ( isset($cell['readonly']) && $readonly =
$cell['readonly'])
+ || (isset($readonlys[$name]) &&
$readonlys[$name] && !is_array($readonlys[$name]))
+ || isset($readonlys['__ALL__']) )
+ {
+ $options .= ' readonly';
+ }
+
+ if ( (isset($cell['disabled']) && $cell['disabled'])
+ || $readonlys && ( isset($cell['type']) &&
$cell['type'] == 'button') && ( isset($cell['size']) &&
!strstr($cell['size'],',') ) )
+ {
+ if ($this->rows == 1) {
+ return ''; // if only one row omit
cell
+ }
+ $cell = $this->empty_cell(); // show nothing
+ $value = '';
+ }
+ $extra_label = True;
+
+ $sub_type = '';
+ $cell_type = explode('-', $cell['type']);
+ $type = $cell_type[0];
+ if ( count($cell_type) == 2 )
+ {
+ $sub_type = $cell_type[1];
+ }
+ if ((!$this->types[$cell['type']] || !empty($sub_type))
&& $this->haveExtension($type,'pre_process'))
+ {
+ $ext_type = $type;
+ $extra_label =
$this->extensionPreProcess($ext_type,$form_name,$value,$cell,$readonlys[$name]);
+
+ $readonly = (isset($readonly) && $readonly) ||
(isset($cell['readonly']) && $cell['readonly']); // might be set be extension
+ $this->set_array($content,$name,$value);
+ }
+
+ $cell_options = '';
+ if ( isset($cell['size']) )
+ {
+ $cell_options = $cell['size'];
+ }
+ if ( strlen($cell_options) && $cell_options[0] == '@')
+ {
+ $cell_options =
$this->get_array($content,substr($cell_options,1));
+ }
+
+ if ( !isset($cell['label']) )
+ {
+ $cell['label'] = '';
+ }
+ $label =
$this->expand_name($cell['label'],$show_c,$show_row,$content['.c'],$content['.row'],$content);
+
+ $help = '';
+ if ( isset($cell['help']) )
+ {
+ $help = $cell['help'];
+ }
+ if ( isset($help[0]) && $help[0] == '@')
+ {
+ $help =
$this->get_array($content,substr($help,1));
+ }
+
+ $blur = '';
+ if ( isset($call['blur']) )
+ {
+ if ( $cell['blur'][0] == '@' )
+ {
+ $blur =
$this->get_array($content,substr($cell['blur'],1));
+ }
+ else if ( strlen($cell['blur']) <= 1 )
+ {
+ $blur = $cell['blur'];
+ }
+ $blur = lang($blur);
+ }
+
+ $onBlur = '';
+ $onFocus = '';
+ if ($this->java_script())
+ {
+ if ($blur)
+ {
+ if (empty($value))
+ {
+ $value = $blur;
+ }
+ $onFocus .=
"if(this.value=='".addslashes(htmlspecialchars($blur))."') this.value='';";
+ $onBlur .= "if(this.value=='')
this.value='".addslashes(htmlspecialchars($blur))."';";
+ }
+ if ($help)
+ {
+ if ( isset($cell['no_lang']) &&
$cell['no_lang'] < 2)
+ {
+ $help = lang($help);
+ }
+ $onFocus .=
"self.status='".addslashes(htmlspecialchars($help))."'; return true;";
+ $onBlur .= "self.status=''; return
true;";
+ if ($cell['type'] == 'button' ||
$cell['type'] == 'file') // for button additionally when mouse over button
+ {
+ $options .= "
onMouseOver=\"self.status='".addslashes(htmlspecialchars($help))."'; return
true;\"";
+ $options .= "
onMouseOut=\"self.status=''; return true;\"";
+ }
+ }
+ if ($onBlur)
+ {
+ $options .= " onFocus=\"$onFocus\"
onBlur=\"$onBlur\"";
+ }
+ if ( isset($cell['onchange']) &&
$cell['onchange'] && $cell['type'] != 'button') // values != '1' can only set
by a program (not in the editor so fa
+ {
+ $options .= '
onChange="'.($cell['onchange']=='1'?'this.form.submit();':$cell['onchange']).'"';
+ }
+ }
+ if ($form_name != '')
+ {
+ $options = "ID=\"$form_name\" $options";
+ }
+
+ $html = '';
+ switch ($type)
+ {
+ case 'label': // size:
[[b]old][[i]talic][,link]
+ if (is_array($value))
+ {
+ break;
+ }
+ $extra_link = '';
+ $tmp = explode(',', $cell_options);
+ $style = $tmp[0];
+ if ( count($tmp) == 2 )
+ {
+ $extra_link = $tmp[1];
+ }
+ unset($tmp);
+ $value = strlen($value) > 1 && (
!isset($cell['no_lang']) || !$cell['no_lang']) ? lang($value) : $value;
+ $value =
nl2br(htmlspecialchars($value));
+ if ($value != '' && strstr($style,'b'))
$value = $this->html->bold($value);
+ if ($value != '' && strstr($style,'i'))
$value = $this->html->italic($value);
+ $html .= $value;
+ break;
+ case 'html':
+ $extra_link = $cell_options;
+ $html .= $value;
+ break;
+ case 'int': // size:
[min][,[max][,len]]
+ case 'float':
+ $tmp = explode(',', $cell_options);
+ $min = $tmp[0];
+ $max = isset($tmp[1]) ? $tmp[1] : '';
+ $cell_options = isset($tmp[2]) ?
$tmp[2] : '';
+ unset($tmp);
+
+ if ($cell_options == '')
+ {
+ $cell_options = $cell['type']
== 'int' ? 5 : 8;
+ }
+ // fall-through
+ case 'text': // size:
[length][,maxLength]
+ if (isset($readonly) && $readonly)
+ {
+ $html .=
$this->html->bold(htmlspecialchars($value));
+ }
+ else
+ {
+ $html .=
$this->html->input($form_name,$value,'',
+
$options.$this->html->formatOptions($cell_options,'SIZE,MAXLENGTH'));
+
$GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name] = $cell['type'];
+ }
+ break;
+ case 'textarea': // Multiline Text
Input, size: [rows][,cols]
+ $html .=
$this->html->textarea($form_name,$value,
+
$options.$this->html->formatOptions($cell_options,'ROWS,COLS'));
+ if (!isset($readonly) || !$readonly)
+
$GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name] = $cell['type'];
+ break;
+ case 'checkbox':
+ if (!empty($cell_options))
+ {
+
list($true_val,$false_val,$ro_true,$ro_false) = explode(',',$cell_options);
+ $value = $value == $true_val;
+ }
+ else
+ {
+ $ro_true = 'x';
+ $ro_false = '';
+ }
+ if ($value)
+ {
+ $options .= ' checked';
+ }
+ if ( isset($readonly) && $readonly)
+ {
+ $html .= $value ?
$this->html->bold($ro_true) : $ro_false;
+ }
+ else
+ {
+ $html .=
$this->html->input($form_name,'1','CHECKBOX',$options);
+
$GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name] = array(
+ 'type' => $cell['type'],
+ 'values' =>
$cell_options
+ );
+ }
+ break;
+ case 'radio': // size: value if
checked
+ $set_val =
$this->expand_name($cell_options,$show_c,$show_row,$content['.c'],$content['.row'],$content);
+
+ if ($value == $set_val)
+ {
+ $options .= ' CHECKED';
+ }
+ if ($readonly)
+ {
+ $html .= $value == $set_val ?
$this->html->bold('x') : '';
+ }
+ else
+ {
+ $html .=
$this->html->input($form_name,$set_val,'RADIO',$options);
+
$GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name] = $cell['type'];
+ }
+ break;
+ case 'button':
+ list($app) = explode('.',$this->name);
+ if ($this->java_script() &&
isset($cell['onchange']) && $cell['onchange'] != '' && !$cell['needed']) // use
a link instead of a button
+ {
+ if ($cell['onchange'] == 1)
+ {
+ $html .=
$this->html->input_hidden($form_name,'',False) . "\n";
+ $html .= '<a href=""
onClick="set_element(document.eTemplate,\''.$form_name.'\',\'pressed\');
document.eTemplate.submit(); return false;" '.$options.'>' .
+ (strlen($label)
<= 1 || $cell['no_lang'] ? $label : lang($label)) . '</a>';
+ }
+ else // use custom javascript
+ {
+ $html .= '<a href=""
onClick="'.$cell['onchange'].'; return false;" '.$options.'>' .
+ (strlen($label)
<= 1 || $cell['no_lang'] ? $label : lang($label)) . '</a>';
+ }
+ }
+ else
+ {
+ $ro_img = '';
+ $tmp = explode(',',
$cell_options);
+ $img = $tmp[0];
+ if ( count($tmp) == 2 )
+ {
+ $ro_img = $tmp[1];
+ }
+ unset($tmp);
+
+ if (!empty($img))
+ {
+ $options .= '
title="'.(strlen($label)<=1||$cell['no_lang']?$label:lang($label)).'"';
+ }
+ $html .= ( !isset($readonly) ||
!$readonly )
+ ?
$this->html->submit_button($form_name,$label, isset($cell['onchange']) ?
$cell['onchange'] : '', strlen($label) <= 1 || isset($cell['no_lang'])
,$options, $img, $app)
+ :
$this->html->image($app,$ro_img);
+ }
+ $extra_label = False;
+ if (!isset($readonly) || !$readonly )
+ {
+
$GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name] = $cell['type'];
+ }
+ break;
+ case 'hrule':
+ $html .= $this->html->hr($cell_options);
+ break;
+ case 'template': // size: index in
content-array (if not full content is past further on)
+ if (is_object($cell['name']))
+ {
+ $cell['obj'] = &$cell['name'];
+ unset($cell['name']);
+ $cell['name'] = 'was Object';
+ echo "<p>Object in Name in tpl
'$this->name': "; _debug_array($this->data);
+ }
+ $obj_read = 'already loaded';
+ if ( !isset($cell['obj']) ||
!is_object($cell['obj']))
+ {
+ if ($cell['name'][0] == '@')
+ {
+ $cell['obj'] =
$this->get_array($content,substr($cell['name'],1));
+ $obj_read =
is_object($cell['obj']) ? 'obj from content' : 'obj read, obj-name from
content';
+ if
(!is_object($cell['obj']))
+ {
+ $cell['obj'] =
new etemplate($cell['obj'],$this->as_array());
+ }
+ }
+ else
+ { $obj_read = 'obj read';
+ $cell['obj'] = new
etemplate(/*** TESTWEISE ***$cell['name']*/$name,$this->as_array());
+ }
+ }
+ if (is_int($this->debug) &&
$this->debug >= 3 || $this->debug == $cell['type'])
+ {
+ echo
"<p>show_cell::template(tpl=$this->name,name=$cell[name]): $obj_read</p>\n";
+ }
+ if
($this->autorepeat_idx($cell,$show_c,$show_row,$idx,$idx_cname) ||
$cell_options != '')
+ {
+ if ($span == '' &&
isset($content[$idx]['span']))
+ { // this allows a
colspan in autorepeated cells like the editor
+ list($span) =
explode(',',$content[$idx]['span']);
+ if ($span == 'all')
+ {
+ $span = 1 +
$content['cols'] - $show_c;
+ }
+ }
+ $readonlys =
$this->get_array($readonlys,$idx); //$readonlys[$idx];
+ $content =
$this->get_array($content,$idx); // $content[$idx];
+ if ($idx_cname != '')
+ {
+ $cname .= $cname == ''
? $idx_cname : '['.str_replace('[','][',str_replace(']','',$idx_cname)).']';
+ }
+ //echo
"<p>show_cell-autorepeat($name,$show_c,$show_row,cname='$cname',idx='$idx',idx_cname='$idx_cname',span='$span'):
content ="; _debug_array($content);
+ }
+ if ( isset($readonly) && $readonly)
+ {
+ $readonlys['__ALL__'] = True;
+ }
+ if ( !isset($cell['onchange']) )
+ {
+ $cell['onchange'] = '';
+ }
+
+ if ( !isset($cell['tr_class']) )
+ {
+ $cell['tr_class'] = '';
+ }
+ $html =
$cell['obj']->show($content,$sel_options,$readonlys,$cname,$show_c,$show_row,$cell['onchange'],$cell['tr_class']);
+ break;
+ case 'select': // size:[linesOnMultiselect]
+ $sels = array();
+ list($multiple) =
explode(',',$cell_options);
+ if (!empty($multiple) && 0+$multiple <=
0)
+ {
+ $sels[''] = $multiple < 0 ?
'all' : $multiple;
+ if ($cell['no_lang'])
+ {
+ $sels[''] =
lang($sels['']);
+ }
+ $multiple = 0;
+ }
+ if (!empty($cell['sel_options']))
+ {
+ if
(!is_array($cell['sel_options']))
+ {
+ $opts =
explode(',',$cell['sel_options']);
+ while (list(,$opt) =
each($opts))
+ {
+ list($k,$v) =
explode('=',$opt);
+ $sels[$k] = $v;
+ }
+ }
+ else
+ {
+ $sels +=
$cell['sel_options'];
+ }
+ }
+ if (isset($sel_options[$name]) &&
is_array($sel_options[$name]))
+ {
+ $sels += $sel_options[$name];
+ }
+ elseif (count($name_parts))
+ {
+ $org_name =
$name_parts[count($name_parts)-1];
+ if
(isset($sel_options[$org_name]) && is_array($sel_options[$org_name]))
+ {
+ $sels +=
$sel_options[$org_name];
+ }
+ }
+ if (isset($content["options-$name"]))
+ {
+ $sels +=
$content["options-$name"];
+ }
+ if ( isset($readonly) && $readonly )
+ {
+ $html .= $cell['no_lang'] ?
$sels[$value] : lang($sels[$value]);
+ }
+ else
+ {
+ $html .=
$this->html->select($form_name.($multiple > 1 ? '[]' : ''),$value,$sels,
+ isset($cell['no_lang'])
? $cell['no_lang'] : '' ,$options,$multiple);
+
$GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name] = $cell['type'];
+ }
+ break;
+ case 'image':
+ $image = $value != '' ? $value : $name;
+ $image =
$this->html->image(substr($this->name,0,strpos($this->name,'.')),
+ $image,strlen($label) > 1 &&
!$cell['no_lang'] ? lang($label) : $label,'BORDER="0"');
+ $html .= $image;
+ $extra_link = $cell_options;
+ $extra_label = False;
+ break;
+ case 'file':
+ $html .=
$this->html->input_hidden($path =
str_replace($name,$name.'_path',$form_name),'.');
+ $html .=
$this->html->input($form_name,'','file',$options);
+
$GLOBALS['phpgw_info']['etemplate']['form_options'] =
+
"enctype=\"multipart/form-data\"
onSubmit=\"set_element2(this,'$path','$form_name')\"";
+
$GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name] = $cell['type'];
+ break;
+ case 'vbox':
+ case 'hbox':
+ $rows = array();
+ $box_row = 1;
+ $box_col = 'A';
+ $box_anz = 0;
+ for ($n = 1; $n <= $cell_options; ++$n)
+ {
+ $h =
$this->show_cell($cell[$n],$content,$sel_options,$readonlys,$cname,$show_c,$show_row,$nul);
+ if ($h != '' && $h != ' ')
+ {
+ if ($cell['type'] ==
'vbox')
+ {
+ $box_row = $n;
+ }
+ else
+ {
+ $box_col =
$this->num2chrs($n);
}
- if ($disabled != '' &&
$this->check_disabled($disabled,$content))
+
$rows[$box_row][$box_col] = $html = $h;
+ $box_anz++;
+ if (
isset($cell[$n]['align']) && $cell[$n]['align'] )
{
- continue; // row is disabled
+
$rows[$box_row]['.'.$box_col] =
$this->html->formatOptions($cell[$n]['align'],'ALIGN');
}
- $rows[".$row"] .=
$this->html->formatOptions($height,'HEIGHT');
- list($cl) = explode(',',$class);
- if ($cl == 'nmr' || $cl == 'row')
+ $cl = '';
+ if (
isset($cell[$n]['span']) )
{
- $cl = 'row_'.($nmr_alternate++ & 1 ?
'off' : 'on'); // alternate color
- }
- $cl = isset($this->class_conf[$cl]) ?
$this->class_conf[$cl] : $cl;
- $rows[".$row"] .=
$this->html->formatOptions($cl,'CLASS');
- $rows[".$row"] .=
$this->html->formatOptions($class,',VALIGN');
-
- reset ($cols);
- $row_data = array();
- for ($c = 0; True /*list($col,$cell) =
each($cols)*/; ++$c)
+ $tmp =
explode(',',$cell[$n]['span']);
+ if (
count($tmp) == 2 )
{
- $col = $this->num2chrs($c);
- if (!(list($c_key) = each($cols)))
// no further cols
+ $cl =
$tmp[1];
+ }
+ }
+ $cl =
$this->expand_name(isset($this->class_conf[$cl]) ? $this->class_conf[$cl] : $cl,
+
$show_c,$show_row,$content['.c'],$content['.row'],$content);
+ if (
!isset($rows[$box_row][".$box_col"]) )
{
- if
(!$this->autorepeat_idx($cell,$c,$r,$idx,$idx_cname,True) ||
-
!$this->isset_array($content,$idx))
+
$rows[$box_row][".$box_col"] = '';
+ }
+
$rows[$box_row][".$box_col"] .= $this->html->formatOptions($cl, 'CLASS');
+ }
+ }
+ if ($box_anz > 1) // a single
cell is NOT placed into a table
{
- break; // no
auto-col-repeat
+ $html = "\n\n<!-- BEGIN
{$cell['type']} -->\n\n".
+
$this->html->table($rows,$this->html->formatOptions($cell_options,',CELLPADDING,CELLSPACING').
+ (isset($cell['align'])
&& $cell['align'] && $type == 'vbox' ? ' width="100%"' : '')). // alignment
only works if table has full width - 100% tables break IE
+ "\n\n<!-- END
{$cell['type']} -->\n\n";
}
+ break;
+ case 'deck':
+ for ($n = 1; $n <= $cell_options &&
(empty($value) || $value != $cell[$n]['name']); ++$n) ;
+ if ($n > $cell_options)
+ {
+ $value = $cell[1]['name'];
}
- else
+ if ($s_width = $cell['width'])
{
- $cell = &$cols[$c_key];
- list($col_width,$col_disabled)
= explode(',',$opts[$col]);
-
- if (!$cell['height']) // if
not set, cell-height = height of row
+ $s_width = "width:
$s_width".(substr($s_width,-1) != '%' ? 'px' : '').';';
+ }
+ if ($s_height = $cell['height'])
{
- $cell['height'] =
$height;
+ $s_height = "height:
$s_height".(substr($s_height,-1) != '%' ? 'px' : '').';';
}
- if (!$cell['width']) // if
not set, cell-width = width of column or table
+ for ($n = 1; $n <= $cell_options; ++$n)
{
- list($col_span) =
explode(',',$cell['span']);
- if ($col_span == 'all'
&& !$c)
+ $h =
$this->show_cell($cell[$n],$content,$sel_options,$readonlys,$cname,$show_c,$show_row,$nul);
+ $vis = !empty($value) && $value
== $cell_options[$n]['name'] || $n == 1 && $first ? 'visible' : 'hidden';
+ list (,$cl) =
explode(',',$cell[$n]['span']);
+ $html .=
$this->html->div($h,$this->html->formatOptions(array(
+ $cl.($cl ? '
':'').'tab_body',
+ "$s_width $s_height
position: absolute; left: 0px; top: 0px; visibility: $vis; z-index: 50;",
+ $cell[$n]['name']
+ ),'CLASS,STYLE,ID'));
+ }
+ $html .=
$this->html->input_hidden($form_name,$value); // to store active plane
+
+ list (,$cl) =
explode(',',$cell['span']);
+ $html =
$this->html->input_hidden($form_name,$value)."\n". // to store active plane
+
$this->html->div($html,$this->html->formatOptions(array(
+ $cl,
+ "$s_width $s_height
position: relative; z-index: 100;"
+ ),'CLASS,STYLE'));
+ break;
+ default:
+ if ($ext_type &&
$this->haveExtension($ext_type,'render'))
{
-
list($cell['width']) = explode(',',$this->size);
+ $html .=
$this->extensionRender($ext_type,$form_name,$value,$cell,$readonly);
}
else
{
- $cell['width']
= $col_width;
+ $html .= "<i>unknown type
'$cell[type]'</i>";
}
+ break;
}
+ if ( isset($ext_type) && $ext_type && !$readonly &&
$this->haveExtension($ext_type,'post_process')) // extension-processing
need to be after all other and only with diff. name
+ { // unset it first, if it is already set, to be
after the other widgets of the ext.
+
unset($GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name]);
+
$GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name] =
'ext-'.$ext_type;
}
- if ($cell['type'] == 'template' &&
$cell['onchange'])
+ // save blur-value to strip it in process_exec
+ if (!empty($blur) &&
isset($GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name]))
{
- $cell['tr_class'] = $cl;
+
$GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name] =
is_array($GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name]) ?
$GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name] : array('type' =>
$GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name]);
+
$GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name]['blur'] = $blur;
}
- if ($col_disabled != '' &&
$this->check_disabled($col_disabled,$content))
+ if ($extra_label && ($label != '' || $html == ''))
{
- continue; // col is
disabled
- }
- $row_data[$col] =
$this->show_cell($cell,$content,$sel_options,$readonlys,$cname,
- $c,$r,$span);
- if ($row_data[$col] == '' &&
$this->rows == 1)
+ if (strlen($label) > 1 &&
!(isset($cell['no_lang']) && $cell['no_lang'] && $cell['label'] != $label ||
(isset($cell['no_lang']) && $cell['no_lang'] == 2)) )
{
- unset($row_data[$col]); // omit
empty/disabled cells if only one row
- continue;
+ $label = lang($label);
}
- if ($cell['onclick']) // can only be
set via source at the moment
- {
- $row_data[".$col"] .= '
onClick="'.$cell['onclick'].'"';
-
- if ($cell['id'])
+ if (($accesskey = strstr($label,'&')) &&
$accesskey[1] != ' ' && $form_name != '' &&
+ (($pos = strpos($accesskey,';')) ===
False || $pos > 5))
{
- $row_data[".$col"] .= '
ID="'.$cell['id'].'"';
- }
+ $label =
str_replace('&'.$accesskey[1],'<u>'.$accesskey[1].'</u>',$label);
+ $label =
$this->html->label($label,$form_name,$accesskey[1]);
}
- $colspan = $span == 'all' ?
$this->cols-$c : 0+$span;
- if ($colspan > 1)
+ if ($type == 'radio' || $type == 'checkbox' ||
strstr($label,'%s')) // default for radio is label after the button
{
- $row_data[".$col"] .= "
COLSPAN=\"$colspan\"";
- for ($i = 1; $i < $colspan;
++$i,++$c)
+ $html = strstr($label,'%s') ?
str_replace('%s',$html,$label) : $html.' '.$label;
+ }
+ elseif (($html = $label . ' ' . $html) == ' ')
{
- each($cols); // skip
next cell(s)
+ $html = ' ';
}
}
- else
+ if ( isset($extra_link) && $extra_link )
{
- list($width,$disable) =
explode(',',$opts[$col]);
- if ($width) //
width only once for a non colspan cell
+ $extra_link =
$this->expand_name($extra_link,$show_c,$show_row,$content['.c'],$content['.row'],$content);
+ if ($extra_link[0] == '@')
{
- $row_data[".$col"] .= "
WIDTH=\"$width\"";
- $opts[$col] =
"0,$disable";
- }
- }
- $row_data[".$col"] .=
$this->html->formatOptions($cell['align'],'ALIGN');
- list(,$cl) = explode(',',$cell['span']);
- $cl =
$this->expand_name(isset($this->class_conf[$cl]) ? $this->class_conf[$cl] : $cl,
-
$c,$r,$show_c,$show_row,$content);
- $row_data[".$col"] .=
$this->html->formatOptions($cl,'CLASS');
- }
- $rows[$row] = $row_data;
+ $extra_link =
$this->get_array($content,substr($extra_link,1));
}
- if
(!$GLOBALS['phpgw_info']['etemplate']['styles_included'][$this->name])
+ if ($extra_link)
{
- $style = $this->html->style($this->style);
-
$GLOBALS['phpgw_info']['etemplate']['styles_included'][$this->name] = True;
+ $options = "
onMouseOver=\"self.status='".addslashes(lang($help))."'; return true;\"";
+ $options .= "
onMouseOut=\"self.status=''; return true;\"";
+ return
$this->html->a_href($html,$extra_link,'',$help != '' ? $options : '');
}
- $html =
$this->html->table($rows,$this->html->formatOptions($this->size,'WIDTH,HEIGHT,BORDER,CLASS,CELLSPACING,CELLPADDING'),$no_table_tr);
-
- list($width,$height,,,,,$overflow) =
explode(',',$this->size);
- if (!empty($overflow)) {
- $div_style=' STYLE="'.($width?"width: $width;
":'').($height ? "height: $height; ":'')."overflow: $overflow\"";
- $html = $this->html->div($html,$div_style);
}
- return "\n\n<!-- BEGIN $this->name
-->\n$style\n".$html."<!-- END $this->name -->\n\n";
+ return $html;
}
/*!
@@ -467,8 +1411,9 @@
@param $cell array with data of the cell: name, type, ...
@param for rest see show
@result the generated HTML
+ @todo - consider delete this function (from .16)
*/
- function
show_cell($cell,$content,$sel_options,$readonlys,$cname,$show_c,$show_row,&$span)
+ function
show_cell_16($cell,$content,$sel_options,$readonlys,$cname,$show_c,$show_row,&$span)
{
if (is_int($this->debug) && $this->debug >= 3 ||
$this->debug == $cell['type'])
{
@@ -494,7 +1439,7 @@
}
$value = $this->get_array($content,$name);
- if ($readonly = $cell['readonly'] ||
(@$readonlys[$name] && !is_array($readonlys[$name])) || $readonlys['__ALL__'])
+ if ((isset($readonly) && $readonly = $cell['readonly'])
|| (@$readonlys[$name] && !is_array($readonlys[$name])) ||
(isset($readonlys['__ALL__']) && $readonlys['__ALL__']))
{
$options .= ' READONLY';
}
@@ -523,13 +1468,15 @@
$cell_options =
$this->get_array($content,substr($cell_options,1));
}
$label =
$this->expand_name($cell['label'],$show_c,$show_row,$content['.c'],$content['.row'],$content);
- $help = $cell['help'];
- if ($help[0] == '@')
+ $help = isset($cell['help']) ? $cell['help'] : array();
+ if (isset($help[0]) && $help[0] == '@')
{
$help =
$this->get_array($content,substr($help,1));
}
- $blur = $cell['blur'][0] == '@' ?
$this->get_array($content,substr($cell['blur'],1)) :
- (strlen($cell['blur']) <= 1 ? $cell['blur'] :
lang($cell['blur']));
+ $blur_temp = isset($cell['blur']) ? $cell['blur'] : '';
+ $blur = isset($cell['blur'][0]) && $cell['blur'][0] ==
'@' ? $this->get_array($content,substr($blur_temp,1)) :
+ (strlen($blur_temp) <= 1 ? $blur_temp :
lang($blur_temp));
+ unset($blur_temp);
if ($this->java_script())
{
@@ -959,6 +1906,7 @@
@param $cname basename of our returnt content (same as in call
to show)
@result the adjusted content (by using the var-param &$content)
*/
+
function process_show(&$content,$to_process,$cname='')
{
if (!isset($content) || !is_array($content) ||
!is_array($to_process))
@@ -990,6 +1938,112 @@
$value = ''; // blur-values is equal
to emtpy
}
//echo "<p>process_show($this->name) $type:
$form_name = '$value'</p>\n";
+ $sub = '';
+ $tmp = explode('-', $type);
+ $type = $tmp[0];
+ if ( count($tmp) == 2 )
+ {
+ $sub = $tmp[1];
+ }
+ unset($tmp);
+ switch ($type)
+ {
+ case 'ext':
+
$this->extensionPostProcess($sub,$form_name,$this->get_array($content,$form_name),$value);
+ break;
+ case 'text':
+ case 'textarea':
+ if (isset($value))
+ {
+ $value =
stripslashes($value);
+ }
+
$this->set_array($content,$form_name,$value);
+ break;
+ case 'button':
+ if ($value)
+ {
+
$this->set_array($content,$form_name,$value);
+ }
+ break;
+ case 'select':
+
$this->set_array($content,$form_name,is_array($value) ? implode(',',$value) :
$value);
+ break;
+ case 'checkbox':
+ if (!isset($value)) //
checkbox was not checked
+ {
+ $value = 0;
// need to be reported too
+ }
+ if (!empty($attr['values']))
+ {
+
list($true_val,$false_val) = explode(',',$attr['values']);
+ $value = $value ?
$true_val : $false_val;
+ }
+
$this->set_array($content,$form_name,$value);
+ break;
+ case 'file':
+ $parts =
explode('[',str_replace(']','',$form_name));
+ $name = array_shift($parts);
+ $index = count($parts) ?
'['.implode('][',$parts).']' : '';
+ $value = array();
+ $parts =
array('tmp_name','type','size','name');
+ while (list(,$part) =
each($parts))
+ {
+ $value[$part] =
$this->get_array($GLOBALS['HTTP_POST_FILES'][$name],$part.$index);
+ }
+ $value['path'] =
$this->get_array($content_in,substr($form_name,0,-1).'_path]');
+ $value['ip'] =
get_var('REMOTE_ADDR',Array('SERVER'));
+ if
(function_exists('is_uploaded_file') && !is_uploaded_file($value['tmp_name']))
+ {
+ $value = array();
// to be on the save side
+ }
+ //_debug_array($value);
+ // fall-throught
+ default:
+
$this->set_array($content,$form_name,$value);
+ break;
+ }
+ }
+ if ($cname)
+ {
+ $content = $content[$cname];
+ }
+ if (is_int($this->debug) && $this->debug >= 2 ||
$this->debug == $this->name && $this->name)
+ {
+ echo "<p>process_show($this->name) end: content
="; _debug_array($content);
+ }
+ }
+
+ function process_show_16(&$content,$to_process,$cname='')
+ {
+ if (!isset($content) || !is_array($content) ||
!is_array($to_process))
+ {
+ return;
+ }
+ if (is_int($this->debug) && $this->debug >= 1 ||
$this->debug == $this->name && $this->name)
+ {
+ echo "<p>process_show($this->name) start:
content ="; _debug_array($content);
+ }
+ $content_in = $cname ? array($cname => $content) :
$content;
+ $content = array();
+ reset($to_process);
+ while (list($form_name,$type) = each($to_process))
+ {
+ if (is_array($type))
+ {
+ $attr = $type;
+ $type = $attr['type'];
+ }
+ else
+ {
+ $attr = array();
+ }
+ $value =
$this->get_array($content_in,$form_name);
+
+ if (isset($attr['blur']) && $attr['blur'] ==
stripslashes($value))
+ {
+ $value = ''; // blur-values is equal
to emtpy
+ }
+ //echo "<p>process_show($this->name) $type:
$form_name = '$value'</p>\n";
list($type,$sub) = explode('-',$type);
switch ($type)
{
@@ -1068,7 +2122,7 @@
*/
function java_script($consider_not_tested_as_enabled = True)
{
- $ret =
!!$GLOBALS['phpgw_info']['etemplate']['java_script'] ||
+ $ret = (
isset($GLOBALS['phpgw_info']['etemplate']['java_script']) &&
$GLOBALS['phpgw_info']['etemplate']['java_script']) ||
$consider_not_tested_as_enabled &&
!isset($GLOBALS['phpgw_info']['etemplate']['java_script']);
//echo
"<p>java_script($consider_not_tested_as_enabled)='$ret',
java_script='".$GLOBALS['phpgw_info']['etemplate']['java_script']."',
isset(java_script)=".isset($GLOBALS['phpgw_info']['etemplate']['java_script'])."</p>\n";
@@ -1079,6 +2133,7 @@
$GLOBALS['phpgw_info']['etemplate']['java_script'].'' == '');
}
+
/*!
@function include_java_script
@syntax include_java_script( )
@@ -1089,6 +2144,7 @@
*/
function include_java_script($what = 3)
{
+ $js = '';
// this is to test if javascript is enabled
if ($what & 1 &&
!isset($GLOBALS['phpgw_info']['etemplate']['java_script']))
{
Index: setup/setup.inc.php
===================================================================
RCS file: /sources/phpgroupware/etemplate/setup/setup.inc.php,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- setup/setup.inc.php 10 Feb 2007 16:03:46 -0000 1.17
+++ setup/setup.inc.php 11 Feb 2007 21:58:04 -0000 1.18
@@ -10,7 +10,7 @@
* option) any later version.
*
\**************************************************************************/
- /* $Id: setup.inc.php,v 1.17 2007/02/10 16:03:46 sigurdne Exp $ */
+ /* $Id: setup.inc.php,v 1.18 2007/02/11 21:58:04 sigurdne Exp $ */
$setup_info['etemplate']['name'] = 'etemplate';
$setup_info['etemplate']['version'] = '0.9.15.002';
@@ -41,6 +41,6 @@
/* Dependencies for this app to work */
$setup_info['etemplate']['depends'][] = array(
'appname' => 'phpgwapi',
- 'versions' => Array('0.9.13','0.9.14','0.9.15','0.9.16')
+ 'versions' =>
Array('0.9.13','0.9.14','0.9.15','0.9.16','0.9.17')
);
?>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] etemplate index.php inc/class.boetemplate.inc.p...,
Sigurd Nes <=