2002-02-06 10:03:11 +01:00
|
|
|
<?php
|
|
|
|
/**************************************************************************\
|
2004-01-27 17:58:19 +01:00
|
|
|
* eGroupWare - EditableTemplates - HTML User Interface *
|
|
|
|
* http://www.egroupware.org *
|
2002-02-06 10:03:11 +01:00
|
|
|
* Written by Ralf Becker <RalfBecker@outdoor-training.de> *
|
|
|
|
* -------------------------------------------- *
|
|
|
|
* This program is free software; you can redistribute it and/or modify it *
|
|
|
|
* under the terms of the GNU General Public License as published by the *
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your *
|
|
|
|
* option) any later version. *
|
|
|
|
\**************************************************************************/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
2002-09-29 10:50:18 +02:00
|
|
|
include_once(PHPGW_INCLUDE_ROOT . '/etemplate/inc/class.boetemplate.inc.php');
|
2002-02-06 10:03:11 +01:00
|
|
|
|
|
|
|
/*!
|
|
|
|
@class etemplate
|
2002-09-02 13:14:30 +02:00
|
|
|
@author ralfbecker
|
2002-02-06 10:03:11 +01:00
|
|
|
@abstract creates dialogs / HTML-forms from eTemplate descriptions
|
|
|
|
@discussion etemplate or uietemplate extends boetemplate, all vars and public functions are inherited
|
|
|
|
@example $tmpl = CreateObject('etemplate.etemplate','app.template.name');
|
|
|
|
@example $tmpl->exec('app.class.callback',$content_to_show);
|
|
|
|
@example This creates a form from the eTemplate 'app.template.name' and takes care that
|
|
|
|
@example the method / public function 'callback' in (bo)class 'class' of 'app' gets called
|
|
|
|
@example if the user submitts the form. Vor the complete param's see the description of exec.
|
|
|
|
@param $debug enables debug messages: 0=no, 1=calls to show and process_show, 2=content of process_show
|
|
|
|
@param 3=calls to show_cell OR template- or cell-type name
|
2002-10-02 02:44:33 +02:00
|
|
|
@param $html instances of html class used to generate the html
|
2002-02-06 10:03:11 +01:00
|
|
|
*/
|
|
|
|
class etemplate extends boetemplate
|
|
|
|
{
|
2002-06-15 21:59:07 +02:00
|
|
|
var $debug; // 1=calls to show and process_show, 2=content after process_show,
|
2003-10-26 20:26:58 +01:00
|
|
|
// 3=calls to show_cell and process_show_cell, or template-name or cell-type
|
2002-10-02 02:44:33 +02:00
|
|
|
var $html; // instance of html-class
|
2002-09-28 02:09:47 +02:00
|
|
|
var $class_conf = array('nmh' => 'th','nmr0' => 'row_on','nmr1' => 'row_off');
|
2002-09-25 18:36:07 +02:00
|
|
|
|
2002-02-06 10:03:11 +01:00
|
|
|
/*!
|
|
|
|
@function etemplate
|
|
|
|
@abstract constructor of etemplate class, reads an eTemplate if $name is given
|
2002-09-25 18:36:07 +02:00
|
|
|
@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
|
2002-02-06 10:03:11 +01:00
|
|
|
*/
|
2002-09-25 18:36:07 +02:00
|
|
|
function etemplate($name='',$load_via='')
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
|
|
|
$this->public_functions += array(
|
2002-02-14 15:06:53 +01:00
|
|
|
'exec' => True,
|
|
|
|
'process_exec' => True,
|
|
|
|
'show' => True,
|
|
|
|
'process_show' => True,
|
2002-02-06 10:03:11 +01:00
|
|
|
);
|
2003-09-14 12:25:05 +02:00
|
|
|
if (!is_object($GLOBALS['phpgw']->html))
|
|
|
|
{
|
|
|
|
$GLOBALS['phpgw']->html = CreateObject('phpgwapi.html');
|
|
|
|
}
|
|
|
|
$this->html = &$GLOBALS['phpgw']->html;
|
2002-02-06 10:03:11 +01:00
|
|
|
|
2002-09-25 18:36:07 +02:00
|
|
|
$this->boetemplate($name,$load_via);
|
2002-09-28 02:30:01 +02:00
|
|
|
|
|
|
|
list($a,$b,$c,$d) = explode('.',$GLOBALS['phpgw_info']['server']['versions']['phpgwapi']);
|
|
|
|
//echo "Version: $a.$b.$c.$d\n";
|
2003-09-13 23:07:27 +02:00
|
|
|
$this->stable = $a <= 0 && $b <= 9 && ($c <= 14 || $c == 99) || !is_object($GLOBALS['phpgw']->xslttpl);
|
2002-02-06 10:03:11 +01:00
|
|
|
}
|
|
|
|
|
2002-10-14 02:39:47 +02:00
|
|
|
/*!
|
2002-10-16 02:19:36 +02:00
|
|
|
@function location
|
|
|
|
@abstract Abstracts a html-location-header call
|
2002-10-14 02:39:47 +02:00
|
|
|
@discussion In other UI's than html this needs to call the methode, defined by menuaction or
|
|
|
|
@discussion open a browser-window for any other links.
|
|
|
|
*/
|
2002-10-16 02:19:36 +02:00
|
|
|
function location($vars='')
|
2002-10-14 02:39:47 +02:00
|
|
|
{
|
2003-04-21 10:43:20 +02:00
|
|
|
$GLOBALS['phpgw']->redirect_link(is_array($vars) ? '/index.php' : $vars,
|
|
|
|
is_array($vars) ? $vars : '');
|
2002-10-14 02:39:47 +02:00
|
|
|
}
|
|
|
|
|
2002-02-06 10:03:11 +01:00
|
|
|
/*!
|
|
|
|
@function exec
|
|
|
|
@abstract Generats a Dialog from an eTemplate - abstract the UI-layer
|
|
|
|
@discussion This is the only function an application should use, all other are INTERNAL and
|
|
|
|
@discussion do NOT abstract the UI-layer, because they return HTML.
|
|
|
|
@discussion Generates a webpage with a form from the template and puts process_exec in the
|
|
|
|
@discussion form as submit-url to call process_show for the template before it
|
2003-08-28 16:31:11 +02:00
|
|
|
@discussion ExecuteMethod's the given $method of the caller.
|
|
|
|
@param $method Methode (e.g. 'etemplate.editor.edit') to be called if form is submitted
|
2002-02-06 10:03:11 +01:00
|
|
|
@param $content Array with content to fill the input-fields of template, eg. the text-field
|
|
|
|
@param with name 'name' gets its content from $content['name']
|
|
|
|
@param $sel_options Array or arrays with the options for each select-field, keys are the
|
|
|
|
@param field-names, eg. array('name' => array(1 => 'one',2 => 'two')) set the
|
|
|
|
@param options for field 'name'. ($content['options-name'] is possible too !!!)
|
|
|
|
@param $readonlys Array with field-names as keys for fields with should be readonly
|
|
|
|
@param (eg. to implement ACL grants on field-level or to remove buttons not applicable)
|
2003-08-28 16:31:11 +02:00
|
|
|
@param $preserv Array with vars which should be transported to the $method-call (eg. an id) array('id' => $id)
|
|
|
|
sets $_POST['id'] for the $method-call
|
2003-07-06 22:07:19 +02:00
|
|
|
@param $return_html if true, dont show the page, just return the html
|
2002-09-02 13:14:30 +02:00
|
|
|
@result nothing
|
2002-02-06 10:03:11 +01:00
|
|
|
*/
|
2003-07-06 22:07:19 +02:00
|
|
|
function exec($method,$content,$sel_options='',$readonlys='',$preserv='',$changes='',$return_html=False)
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
2002-06-15 21:59:07 +02:00
|
|
|
//echo "<br>globals[java_script] = '".$GLOBALS['phpgw_info']['etemplate']['java_script']."', this->java_script() = '".$this->java_script()."'\n";
|
2002-02-14 15:06:53 +01:00
|
|
|
if (!$sel_options)
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
|
|
|
$sel_options = array();
|
|
|
|
}
|
2002-02-14 15:06:53 +01:00
|
|
|
if (!$readonlys)
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
|
|
|
$readonlys = array();
|
|
|
|
}
|
2002-02-14 15:06:53 +01:00
|
|
|
if (!$preserv)
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
|
|
|
$preserv = array();
|
|
|
|
}
|
2002-06-09 23:40:06 +02:00
|
|
|
if (!$changes)
|
|
|
|
{
|
|
|
|
$changes = array();
|
|
|
|
}
|
2003-04-21 10:43:20 +02:00
|
|
|
if (isset($content['app_header']))
|
|
|
|
{
|
|
|
|
$GLOBALS['phpgw_info']['flags']['app_header'] = $content['app_header'];
|
|
|
|
}
|
2002-10-06 02:20:32 +02:00
|
|
|
if ($GLOBALS['phpgw_info']['flags']['currentapp'] != 'etemplate')
|
|
|
|
{
|
|
|
|
$GLOBALS['phpgw']->translation->add_app('etemplate'); // some extensions have own texts
|
|
|
|
}
|
2002-06-09 23:40:06 +02:00
|
|
|
$id = $this->appsession_id();
|
2002-09-24 23:57:15 +02:00
|
|
|
$GLOBALS['phpgw_info']['etemplate']['loop'] = False;
|
2002-09-12 10:40:57 +02:00
|
|
|
$GLOBALS['phpgw_info']['etemplate']['form_options'] = ''; // might be set in show
|
2002-10-01 20:26:30 +02:00
|
|
|
$GLOBALS['phpgw_info']['etemplate']['to_process'] = array();
|
2003-08-19 01:15:59 +02:00
|
|
|
$html = ($this->stable ? $this->html->themeStyles()."\n\n" : ''). // so they get included once
|
2003-04-21 10:43:20 +02:00
|
|
|
$this->html->form($this->include_java_script(1).
|
2004-02-14 19:48:53 +01:00
|
|
|
$this->html->input_hidden('submit_button','',False).
|
2002-10-01 20:26:30 +02:00
|
|
|
$this->show($this->complete_array_merge($content,$changes),$sel_options,$readonlys,'exec'),array(
|
2003-08-28 16:31:11 +02:00
|
|
|
'etemplate_exec_id' => $id
|
|
|
|
),'/etemplate/process_exec.php?menuaction='.$method,'','eTemplate',$GLOBALS['phpgw_info']['etemplate']['form_options']);
|
2002-10-01 20:26:30 +02:00
|
|
|
//_debug_array($GLOBALS['phpgw_info']['etemplate']['to_process']);
|
2003-08-19 01:15:59 +02:00
|
|
|
if ($this->stable)
|
|
|
|
{
|
|
|
|
$hooked = $GLOBALS['phpgw']->template->get_var('phpgw_body');
|
|
|
|
if (!@$GLOBALS['phpgw_info']['etemplate']['hooked'] && !$return_html)
|
|
|
|
{
|
|
|
|
$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)));
|
|
|
|
}
|
2003-12-09 01:03:41 +01:00
|
|
|
|
2002-06-09 23:40:06 +02:00
|
|
|
$id = $this->save_appsession($this->as_array(1) + array(
|
2002-02-17 20:09:15 +01:00
|
|
|
'readonlys' => $readonlys,
|
|
|
|
'content' => $content,
|
2002-06-09 23:40:06 +02:00
|
|
|
'changes' => $changes,
|
2002-02-17 20:09:15 +01:00
|
|
|
'sel_options' => $sel_options,
|
|
|
|
'preserv' => $preserv,
|
2002-06-09 23:40:06 +02:00
|
|
|
'extension_data' => $GLOBALS['phpgw_info']['etemplate']['extension_data'],
|
2002-10-01 20:26:30 +02:00
|
|
|
'to_process' => $GLOBALS['phpgw_info']['etemplate']['to_process'],
|
2002-06-15 21:59:07 +02:00
|
|
|
'java_script' => $GLOBALS['phpgw_info']['etemplate']['java_script'],
|
2003-04-13 21:14:50 +02:00
|
|
|
'dom_enabled' => $GLOBALS['phpgw_info']['etemplate']['dom_enabled'],
|
2004-02-05 14:31:54 +01:00
|
|
|
'hooked' => $hooked != '' ? $hooked : $GLOBALS['phpgw_info']['etemplate']['hook_content'],
|
|
|
|
'app_header' => $GLOBALS['phpgw_info']['flags']['app_header'],
|
2002-06-09 23:40:06 +02:00
|
|
|
),$id);
|
2002-06-07 23:26:05 +02:00
|
|
|
|
2003-07-06 22:07:19 +02:00
|
|
|
if ($return_html)
|
|
|
|
{
|
|
|
|
return $html;
|
|
|
|
}
|
2002-09-28 02:30:01 +02:00
|
|
|
if ($this->stable)
|
2002-06-07 23:26:05 +02:00
|
|
|
{
|
2002-10-18 01:34:28 +02:00
|
|
|
if (!@$GLOBALS['phpgw_info']['etemplate']['hooked'])
|
|
|
|
{
|
|
|
|
echo parse_navbar();
|
|
|
|
}
|
2003-08-28 16:31:11 +02:00
|
|
|
echo $GLOBALS['phpgw_info']['etemplate']['hook_content'].$html;
|
2003-04-28 01:21:27 +02:00
|
|
|
|
2003-08-28 16:31:11 +02:00
|
|
|
if (!@$GLOBALS['phpgw_info']['etemplate']['hooked'] &&
|
|
|
|
(!isset($_GET['menuaction']) || strstr($_SERVER['PHP_SELF'],'process_exec.php')))
|
2003-04-28 01:21:27 +02:00
|
|
|
{
|
|
|
|
$GLOBALS['phpgw']->common->phpgw_footer();
|
|
|
|
}
|
2002-06-07 23:26:05 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-10-26 20:45:37 +02:00
|
|
|
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('body_data' => $html));
|
2002-06-07 23:26:05 +02:00
|
|
|
}
|
2002-02-06 10:03:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
@function process_exec
|
2003-08-28 16:31:11 +02:00
|
|
|
@abstract Makes the necessary adjustments to _POST before it calls the app's method
|
2002-02-06 10:03:11 +01:00
|
|
|
@discussion This function is only to submit forms to, create with exec.
|
|
|
|
@discussion All eTemplates / forms executed with exec are submited to this function
|
|
|
|
@discussion (via the global index.php and menuaction). It then calls process_show
|
2003-08-28 16:31:11 +02:00
|
|
|
@discussion for the eTemplate (to adjust the content of the _POST) and
|
2002-02-17 20:09:15 +01:00
|
|
|
@discussion ExecMethod's the given callback from the app with the content of the form as first argument.
|
2002-02-06 10:03:11 +01:00
|
|
|
*/
|
|
|
|
function process_exec()
|
|
|
|
{
|
2003-08-28 16:31:11 +02:00
|
|
|
//echo "process_exec: _POST ="; _debug_array($_POST);
|
|
|
|
$session_data = $this->get_appsession($_POST['etemplate_exec_id']);
|
2002-06-15 21:59:07 +02:00
|
|
|
//echo "<p>process_exec: session_data ="; _debug_array($session_data);
|
2002-02-06 10:03:11 +01:00
|
|
|
|
2003-08-28 16:31:11 +02:00
|
|
|
if (!$_POST['etemplate_exec_id'] || !is_array($session_data) || count($session_data) < 10)
|
|
|
|
{
|
|
|
|
// this prevents an empty screen, if the sessiondata gets lost somehow
|
|
|
|
$this->location(array('menuaction' => $_GET['menuaction']));
|
|
|
|
}
|
2004-02-14 19:48:53 +01:00
|
|
|
if (isset($_POST['submit_button']) && !empty($_POST['submit_button']))
|
|
|
|
{
|
|
|
|
$this->set_array($_POST,$_POST['submit_button'],'pressed');
|
|
|
|
}
|
2003-08-28 16:31:11 +02:00
|
|
|
$content = $_POST['exec'];
|
2002-02-17 20:09:15 +01:00
|
|
|
if (!is_array($content))
|
|
|
|
{
|
|
|
|
$content = array();
|
|
|
|
}
|
2002-06-09 23:40:06 +02:00
|
|
|
$this->init($session_data);
|
|
|
|
$GLOBALS['phpgw_info']['etemplate']['extension_data'] = $session_data['extension_data'];
|
2003-08-28 16:31:11 +02:00
|
|
|
$GLOBALS['phpgw_info']['etemplate']['java_script'] = $session_data['java_script'] || $_POST['java_script'];
|
|
|
|
$GLOBALS['phpgw_info']['etemplate']['dom_enabled'] = $session_data['dom_enabled'] || $_POST['dom_enabled'];
|
|
|
|
//echo "globals[java_script] = '".$GLOBALS['phpgw_info']['etemplate']['java_script']."', session_data[java_script] = '".$session_data['java_script']."', _POST[java_script] = '".$_POST['java_script']."'\n";
|
2002-06-09 23:40:06 +02:00
|
|
|
//echo "process_exec($this->name) content ="; _debug_array($content);
|
2004-08-01 21:26:33 +02:00
|
|
|
if ($GLOBALS['phpgw_info']['flags']['currentapp'] != 'etemplate')
|
|
|
|
{
|
|
|
|
$GLOBALS['phpgw']->translation->add_app('etemplate'); // some extensions have own texts
|
|
|
|
}
|
2002-10-01 20:26:30 +02:00
|
|
|
$this->process_show($content,$session_data['to_process'],'exec');
|
2002-02-06 10:03:11 +01:00
|
|
|
|
2004-08-01 21:26:33 +02:00
|
|
|
$GLOBALS['phpgw_info']['etemplate']['loop'] |= !$this->canceled && $this->button_pressed &&
|
2004-04-05 03:33:23 +02:00
|
|
|
count($GLOBALS['phpgw_info']['etemplate']['validation_errors']) > 0; // set by process_show
|
|
|
|
|
2002-06-09 23:40:06 +02:00
|
|
|
//echo "process_exec($this->name) process_show(content) ="; _debug_array($content);
|
|
|
|
//echo "process_exec($this->name) session_data[changes] ="; _debug_array($session_data['changes']);
|
|
|
|
$content = $this->complete_array_merge($session_data['changes'],$content);
|
|
|
|
//echo "process_exec($this->name) merge(changes,content) ="; _debug_array($content);
|
2002-02-06 10:03:11 +01:00
|
|
|
|
2002-09-24 23:57:15 +02:00
|
|
|
if ($GLOBALS['phpgw_info']['etemplate']['loop'])
|
2002-06-09 23:40:06 +02:00
|
|
|
{
|
2002-10-16 02:19:36 +02:00
|
|
|
if ($session_data['hooked'] != '') // set previous phpgw_body if we are called as hook
|
|
|
|
{
|
2002-10-26 20:45:37 +02:00
|
|
|
if ($this->stable)
|
|
|
|
{
|
2003-08-28 16:31:11 +02:00
|
|
|
//echo "<p>process_exec: hook_content set</p>\n";
|
|
|
|
$GLOBALS['phpgw_info']['etemplate']['hook_content'] = $session_data['hooked'];
|
2002-10-26 20:45:37 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('body_data' => $session_data['hooked']));
|
|
|
|
}
|
2002-10-16 02:19:36 +02:00
|
|
|
}
|
2004-02-05 14:31:54 +01:00
|
|
|
if (!empty($session_data['app_header']))
|
|
|
|
{
|
|
|
|
$GLOBALS['phpgw_info']['flags']['app_header'] = $session_data['app_header'];
|
|
|
|
}
|
2002-06-09 23:40:06 +02:00
|
|
|
//echo "<p>process_exec($this->name): <font color=red>loop is set</font>, content=</p>\n"; _debug_array($content);
|
2003-08-28 16:31:11 +02:00
|
|
|
$this->exec($_GET['menuaction'],$session_data['content'],$session_data['sel_options'],
|
2002-06-09 23:40:06 +02:00
|
|
|
$session_data['readonlys'],$session_data['preserv'],$content);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-08-28 16:31:11 +02:00
|
|
|
ExecMethod($_GET['menuaction'],$this->complete_array_merge($session_data['preserv'],$content));
|
2002-06-09 23:40:06 +02:00
|
|
|
}
|
2002-02-06 10:03:11 +01:00
|
|
|
}
|
|
|
|
|
2002-10-10 13:29:36 +02:00
|
|
|
function check_disabled($disabled,$content)
|
|
|
|
{
|
|
|
|
//return False;
|
|
|
|
if ($not = $disabled[0] == '!')
|
|
|
|
{
|
|
|
|
$disabled = substr($disabled,1);
|
|
|
|
}
|
|
|
|
list($val,$check_val) = $vals = explode('=',$disabled);
|
|
|
|
|
|
|
|
if ($val[0] == '@')
|
|
|
|
{
|
|
|
|
$val = $this->get_array($content,substr($val,1));
|
|
|
|
}
|
|
|
|
if ($check_val[0] == '@')
|
|
|
|
{
|
|
|
|
$check_val = $this->get_array($content,substr($check_val,1));
|
|
|
|
}
|
|
|
|
$result = count($vals) == 1 ? $val != '' : $val == $check_val;
|
|
|
|
if ($not) $result = !$result;
|
2002-10-14 02:39:47 +02:00
|
|
|
//echo "<p>check_disabled: '".($not?'!':'')."$disabled' = '$val' ".(count($vals) == 1 ? '' : ($not?'!':'=')."= '$check_val'")." = ".($result?'True':'False')."</p>\n";
|
2002-10-10 13:29:36 +02:00
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
2002-02-06 10:03:11 +01:00
|
|
|
/*!
|
|
|
|
@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 !!!
|
2003-08-28 16:31:11 +02:00
|
|
|
@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']
|
2002-02-06 10:03:11 +01:00
|
|
|
@param $show_xxx row,col name/index for name expansion
|
2002-09-02 13:14:30 +02:00
|
|
|
@result the generated HTML
|
2002-02-06 10:03:11 +01:00
|
|
|
*/
|
2002-10-12 18:37:44 +02:00
|
|
|
function show($content,$sel_options='',$readonlys='',$cname='',$show_c=0,$show_row=0,
|
|
|
|
$no_table_tr=False,$tr_class='')
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
2002-02-14 15:06:53 +01:00
|
|
|
if (!$sel_options)
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
|
|
|
$sel_options = array();
|
|
|
|
}
|
2002-02-14 15:06:53 +01:00
|
|
|
if (!$readonlys)
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
|
|
|
$readonlys = array();
|
|
|
|
}
|
2003-02-22 13:29:04 +01:00
|
|
|
if (is_int($this->debug) && $this->debug >= 1 || $this->debug == $this->name && $this->name)
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
|
|
|
echo "<p>etemplate.show($this->name): $cname =\n"; _debug_array($content);
|
|
|
|
}
|
|
|
|
if (!is_array($content))
|
|
|
|
{
|
|
|
|
$content = array(); // happens if incl. template has no content
|
|
|
|
}
|
2002-02-14 15:06:53 +01:00
|
|
|
$content += array( // for var-expansion in names in show_cell
|
|
|
|
'.c' => $show_c,
|
2002-02-06 10:03:11 +01:00
|
|
|
'.col' => $this->num2chrs($show_c-1),
|
2002-02-14 15:06:53 +01:00
|
|
|
'.row' => $show_row
|
2002-02-06 10:03:11 +01:00
|
|
|
);
|
2002-06-09 23:40:06 +02:00
|
|
|
reset($this->data);
|
2002-02-06 10:03:11 +01:00
|
|
|
if (isset($this->data[0]))
|
|
|
|
{
|
2002-10-10 13:29:36 +02:00
|
|
|
list(,$opts) = each($this->data);
|
2002-02-06 10:03:11 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-10-10 13:29:36 +02:00
|
|
|
$opts = array();
|
2002-02-06 10:03:11 +01:00
|
|
|
}
|
|
|
|
for ($r = 0; $row = 1+$r /*list($row,$cols) = each($this->data)*/; ++$r)
|
|
|
|
{
|
2002-09-27 18:17:39 +02:00
|
|
|
if (!(list($r_key) = each($this->data))) // no further row
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
2003-10-26 20:26:58 +01:00
|
|
|
if (!(($this->autorepeat_idx($cols['A'],0,$r,$idx,$idx_cname) && $idx_cname) ||
|
2003-12-10 02:21:31 +01:00
|
|
|
(substr($cols['A']['type'],1) == 'box' && $this->autorepeat_idx($cols['A'][1],0,$r,$idx,$idx_cname) && $idx_cname) ||
|
2003-10-26 20:26:58 +01:00
|
|
|
($this->autorepeat_idx($cols['B'],1,$r,$idx,$idx_cname) && $idx_cname)) ||
|
|
|
|
!$this->isset_array($content,$idx_cname))
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
2002-02-14 15:06:53 +01:00
|
|
|
break; // no auto-row-repeat
|
2002-02-06 10:03:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-09-27 18:17:39 +02:00
|
|
|
$cols = &$this->data[$r_key];
|
2002-10-10 13:29:36 +02:00
|
|
|
list($height,$disabled) = explode(',',$opts["h$row"]);
|
2002-10-12 18:37:44 +02:00
|
|
|
$class = $no_table_tr ? $tr_class : $opts["c$row"];
|
2002-10-10 13:29:36 +02:00
|
|
|
}
|
|
|
|
if ($disabled != '' && $this->check_disabled($disabled,$content))
|
|
|
|
{
|
|
|
|
continue; // row is disabled
|
2002-02-06 10:03:11 +01:00
|
|
|
}
|
2002-10-12 18:37:44 +02:00
|
|
|
$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');
|
|
|
|
|
2002-09-27 18:17:39 +02:00
|
|
|
reset ($cols);
|
2002-02-06 10:03:11 +01:00
|
|
|
$row_data = array();
|
|
|
|
for ($c = 0; True /*list($col,$cell) = each($cols)*/; ++$c)
|
|
|
|
{
|
2002-10-10 13:29:36 +02:00
|
|
|
$col = $this->num2chrs($c);
|
2002-09-27 18:17:39 +02:00
|
|
|
if (!(list($c_key) = each($cols))) // no further cols
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
|
|
|
if (!$this->autorepeat_idx($cell,$c,$r,$idx,$idx_cname,True) ||
|
2002-06-15 11:21:55 +02:00
|
|
|
!$this->isset_array($content,$idx))
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
|
|
|
break; // no auto-col-repeat
|
|
|
|
}
|
|
|
|
}
|
2002-09-27 18:17:39 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
$cell = &$cols[$c_key];
|
2003-04-13 21:14:50 +02:00
|
|
|
list($col_width,$col_disabled) = explode(',',$opts[$col]);
|
2003-12-09 01:03:41 +01:00
|
|
|
|
2003-04-13 21:14:50 +02:00
|
|
|
if (!$cell['height']) // if not set, cell-height = height of row
|
|
|
|
{
|
|
|
|
$cell['height'] = $height;
|
|
|
|
}
|
|
|
|
if (!$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;
|
|
|
|
}
|
|
|
|
}
|
2002-10-10 13:29:36 +02:00
|
|
|
}
|
2002-10-12 18:37:44 +02:00
|
|
|
if ($cell['type'] == 'template' && $cell['onchange'])
|
|
|
|
{
|
|
|
|
$cell['tr_class'] = $cl;
|
|
|
|
}
|
2002-10-10 13:29:36 +02:00
|
|
|
if ($col_disabled != '' && $this->check_disabled($col_disabled,$content))
|
|
|
|
{
|
|
|
|
continue; // col is disabled
|
2002-09-27 18:17:39 +02:00
|
|
|
}
|
2002-02-06 10:03:11 +01:00
|
|
|
$row_data[$col] = $this->show_cell($cell,$content,$sel_options,$readonlys,$cname,
|
2003-12-09 01:03:41 +01:00
|
|
|
$c,$r,$span,$cl);
|
|
|
|
|
2002-02-06 10:03:11 +01:00
|
|
|
if ($row_data[$col] == '' && $this->rows == 1)
|
|
|
|
{
|
|
|
|
unset($row_data[$col]); // omit empty/disabled cells if only one row
|
|
|
|
continue;
|
|
|
|
}
|
2003-04-13 21:14:50 +02:00
|
|
|
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'].'"';
|
|
|
|
}
|
|
|
|
}
|
2002-02-06 10:03:11 +01:00
|
|
|
$colspan = $span == 'all' ? $this->cols-$c : 0+$span;
|
|
|
|
if ($colspan > 1)
|
|
|
|
{
|
2003-08-28 16:31:11 +02:00
|
|
|
$row_data[".$col"] .= " COLSPAN=\"$colspan\"";
|
2002-02-06 10:03:11 +01:00
|
|
|
for ($i = 1; $i < $colspan; ++$i,++$c)
|
|
|
|
{
|
|
|
|
each($cols); // skip next cell(s)
|
|
|
|
}
|
|
|
|
}
|
2002-10-18 22:20:35 +02:00
|
|
|
else
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
2002-10-18 22:20:35 +02:00
|
|
|
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";
|
|
|
|
}
|
2002-02-06 10:03:11 +01:00
|
|
|
}
|
2004-06-23 17:47:36 +02:00
|
|
|
$row_data[".$col"] .= $this->html->formatOptions($cell['align']?$cell['align']:'left','ALIGN');
|
2002-10-18 00:10:12 +02:00
|
|
|
$cl = $this->expand_name(isset($this->class_conf[$cl]) ? $this->class_conf[$cl] : $cl,
|
|
|
|
$c,$r,$show_c,$show_row,$content);
|
2002-09-28 02:09:47 +02:00
|
|
|
$row_data[".$col"] .= $this->html->formatOptions($cl,'CLASS');
|
2002-02-06 10:03:11 +01:00
|
|
|
}
|
|
|
|
$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;
|
|
|
|
}
|
2002-10-12 18:37:44 +02:00
|
|
|
$html = $this->html->table($rows,$this->html->formatOptions($this->size,'WIDTH,HEIGHT,BORDER,CLASS,CELLSPACING,CELLPADDING'),$no_table_tr);
|
2002-06-10 23:34:58 +02:00
|
|
|
|
2002-09-29 15:01:40 +02:00
|
|
|
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);
|
2003-08-28 16:31:11 +02:00
|
|
|
}
|
2002-09-29 15:01:40 +02:00
|
|
|
return "\n\n<!-- BEGIN $this->name -->\n$style\n".$html."<!-- END $this->name -->\n\n";
|
2002-02-06 10:03:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
@function show_cell
|
|
|
|
@abstract generates HTML for 1 input-field / cell
|
|
|
|
@discussion 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
|
2002-09-02 13:14:30 +02:00
|
|
|
@result the generated HTML
|
2002-02-06 10:03:11 +01:00
|
|
|
*/
|
2003-12-09 01:03:41 +01:00
|
|
|
function show_cell($cell,$content,$sel_options,$readonlys,$cname,$show_c,$show_row,&$span,&$class)
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
2003-02-22 13:29:04 +01:00
|
|
|
if (is_int($this->debug) && $this->debug >= 3 || $this->debug == $cell['type'])
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
|
|
|
echo "<p>etemplate.show_cell($this->name,name='${cell['name']}',type='${cell['type']}',cname='$cname')</p>\n";
|
|
|
|
}
|
|
|
|
list($span) = explode(',',$cell['span']); // evtl. overriten later for type template
|
|
|
|
|
2002-09-27 18:17:39 +02:00
|
|
|
if ($cell['name'][0] == '@' && $cell['type'] != 'template')
|
2002-06-15 11:21:55 +02:00
|
|
|
{
|
|
|
|
$cell['name'] = $this->get_array($content,substr($cell['name'],1));
|
|
|
|
}
|
2002-02-06 10:03:11 +01:00
|
|
|
$name = $this->expand_name($cell['name'],$show_c,$show_row,$content['.c'],$content['.row'],$content);
|
|
|
|
|
2002-10-04 01:47:14 +02:00
|
|
|
$name_parts = explode('[',str_replace(']','',$name));
|
|
|
|
if (!empty($cname))
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
2002-10-04 01:47:14 +02:00
|
|
|
array_unshift($name_parts,$cname);
|
2002-02-06 10:03:11 +01:00
|
|
|
}
|
2002-10-04 01:47:14 +02:00
|
|
|
$form_name = array_shift($name_parts);
|
|
|
|
if (count($name_parts))
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
2002-10-04 01:47:14 +02:00
|
|
|
$form_name .= '['.implode('][',$name_parts).']';
|
2002-02-06 10:03:11 +01:00
|
|
|
}
|
2002-10-04 01:47:14 +02:00
|
|
|
$value = $this->get_array($content,$name);
|
|
|
|
|
2003-08-28 16:31:11 +02:00
|
|
|
if ($readonly = $cell['readonly'] || (@$readonlys[$name] && !is_array($readonlys[$name])) || $readonlys['__ALL__'])
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
|
|
|
$options .= ' READONLY';
|
|
|
|
}
|
2002-09-17 14:29:01 +02:00
|
|
|
if ($cell['disabled'] || $readonly && $cell['type'] == 'button' && !strstr($cell['size'],','))
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
2002-02-14 15:06:53 +01:00
|
|
|
if ($this->rows == 1) {
|
2002-02-06 10:03:11 +01:00
|
|
|
return ''; // if only one row omit cell
|
|
|
|
}
|
|
|
|
$cell = $this->empty_cell(); // show nothing
|
|
|
|
$value = '';
|
|
|
|
}
|
2002-05-13 23:30:46 +02:00
|
|
|
$extra_label = True;
|
|
|
|
|
2002-10-02 02:44:33 +02:00
|
|
|
list($type,$sub_type) = explode('-',$cell['type']);
|
|
|
|
if ((!$this->types[$cell['type']] || !empty($sub_type)) && $this->haveExtension($type,'pre_process'))
|
2002-05-13 23:30:46 +02:00
|
|
|
{
|
2002-10-02 02:44:33 +02:00
|
|
|
$ext_type = $type;
|
2002-10-01 20:26:30 +02:00
|
|
|
$extra_label = $this->extensionPreProcess($ext_type,$form_name,$value,$cell,$readonlys[$name]);
|
|
|
|
|
2003-12-09 01:03:41 +01:00
|
|
|
$readonly = $readonly || $cell['readonly']; // might be set by extension
|
2002-10-04 01:47:14 +02:00
|
|
|
$this->set_array($content,$name,$value);
|
2002-06-10 23:34:58 +02:00
|
|
|
}
|
2003-12-09 01:03:41 +01:00
|
|
|
list(,$class) = explode(',',$cell['span']); // might be set by extension
|
|
|
|
|
2003-06-29 19:00:05 +02:00
|
|
|
$cell_options = $cell['size'];
|
2004-02-05 14:31:54 +01:00
|
|
|
if (strchr($cell_options,'$'))
|
|
|
|
{
|
|
|
|
$cell_options = $this->expand_name($cell_options,$show_c,$show_row,$content['.c'],$content['.row'],$content);
|
|
|
|
}
|
2003-06-29 19:00:05 +02:00
|
|
|
if ($cell_options[0] == '@')
|
|
|
|
{
|
|
|
|
$cell_options = $this->get_array($content,substr($cell_options,1));
|
|
|
|
}
|
2002-10-12 18:37:44 +02:00
|
|
|
$label = $this->expand_name($cell['label'],$show_c,$show_row,$content['.c'],$content['.row'],$content);
|
2002-06-10 23:34:58 +02:00
|
|
|
$help = $cell['help'];
|
|
|
|
if ($help[0] == '@')
|
|
|
|
{
|
|
|
|
$help = $this->get_array($content,substr($help,1));
|
2002-05-13 23:30:46 +02:00
|
|
|
}
|
2003-08-28 16:31:11 +02:00
|
|
|
$blur = $cell['blur'][0] == '@' ? $this->get_array($content,substr($cell['blur'],1)) :
|
|
|
|
(strlen($cell['blur']) <= 1 ? $cell['blur'] : lang($cell['blur']));
|
|
|
|
|
2002-06-15 21:59:07 +02:00
|
|
|
if ($this->java_script())
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
2003-08-28 16:31:11 +02:00
|
|
|
if ($blur)
|
|
|
|
{
|
|
|
|
if (empty($value))
|
|
|
|
{
|
|
|
|
$value = $blur;
|
|
|
|
}
|
2004-08-02 09:24:44 +02:00
|
|
|
$onFocus .= "if(this.value=='".addslashes($this->html->htmlspecialchars($blur))."') this.value='';";
|
|
|
|
$onBlur .= "if(this.value=='') this.value='".addslashes($this->html->htmlspecialchars($blur))."';";
|
2003-08-28 16:31:11 +02:00
|
|
|
}
|
2002-06-15 21:59:07 +02:00
|
|
|
if ($help)
|
|
|
|
{
|
2004-03-24 02:20:00 +01:00
|
|
|
if ((int)$cell['no_lang'] < 2)
|
2003-08-28 16:31:11 +02:00
|
|
|
{
|
|
|
|
$help = lang($help);
|
|
|
|
}
|
2004-08-02 09:24:44 +02:00
|
|
|
$onFocus .= "self.status='".addslashes($this->html->htmlspecialchars($help))."'; return true;";
|
2003-08-28 16:31:11 +02:00
|
|
|
$onBlur .= "self.status=''; return true;";
|
2002-10-20 17:06:52 +02:00
|
|
|
if ($cell['type'] == 'button' || $cell['type'] == 'file') // for button additionally when mouse over button
|
2002-06-15 21:59:07 +02:00
|
|
|
{
|
2004-08-02 09:24:44 +02:00
|
|
|
$options .= " onMouseOver=\"self.status='".addslashes($this->html->htmlspecialchars($help))."'; return true;\"";
|
2002-06-15 21:59:07 +02:00
|
|
|
$options .= " onMouseOut=\"self.status=''; return true;\"";
|
|
|
|
}
|
|
|
|
}
|
2003-08-28 16:31:11 +02:00
|
|
|
if ($onBlur)
|
|
|
|
{
|
|
|
|
$options .= " onFocus=\"$onFocus\" onBlur=\"$onBlur\"";
|
|
|
|
}
|
2003-04-13 21:14:50 +02:00
|
|
|
if ($cell['onchange'] && $cell['type'] != 'button') // values != '1' can only set by a program (not in the editor so fa
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
2002-06-15 21:59:07 +02:00
|
|
|
$options .= ' onChange="'.($cell['onchange']=='1'?'this.form.submit();':$cell['onchange']).'"';
|
2002-02-06 10:03:11 +01:00
|
|
|
}
|
|
|
|
}
|
2002-10-09 02:31:01 +02:00
|
|
|
if ($form_name != '')
|
|
|
|
{
|
|
|
|
$options = "ID=\"$form_name\" $options";
|
|
|
|
}
|
2002-10-02 02:44:33 +02:00
|
|
|
list($type,$sub_type) = explode('-',$cell['type']);
|
|
|
|
switch ($type)
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
2002-10-14 02:39:47 +02:00
|
|
|
case 'label': // size: [[b]old][[i]talic][,link]
|
2002-10-10 13:29:36 +02:00
|
|
|
if (is_array($value))
|
|
|
|
break;
|
2004-02-26 16:33:33 +01:00
|
|
|
list($style,$extra_link,$activate_links) = explode(',',$cell_options);
|
2002-02-06 10:03:11 +01:00
|
|
|
$value = strlen($value) > 1 && !$cell['no_lang'] ? lang($value) : $value;
|
2004-08-02 09:24:44 +02:00
|
|
|
$value = nl2br($this->html->htmlspecialchars($value));
|
2004-02-26 16:33:33 +01:00
|
|
|
if ($activate_links) $value = $this->html->activate_links($value);
|
2002-10-14 02:39:47 +02:00
|
|
|
if ($value != '' && strstr($style,'b')) $value = $this->html->bold($value);
|
|
|
|
if ($value != '' && strstr($style,'i')) $value = $this->html->italic($value);
|
2002-02-06 10:03:11 +01:00
|
|
|
$html .= $value;
|
|
|
|
break;
|
2002-10-09 02:31:01 +02:00
|
|
|
case 'html':
|
2003-06-29 19:00:05 +02:00
|
|
|
$extra_link = $cell_options;
|
2002-02-06 10:03:11 +01:00
|
|
|
$html .= $value;
|
|
|
|
break;
|
2002-02-14 15:06:53 +01:00
|
|
|
case 'int': // size: [min][,[max][,len]]
|
|
|
|
case 'float':
|
2003-06-29 19:00:05 +02:00
|
|
|
list($min,$max,$cell_options) = explode(',',$cell_options);
|
|
|
|
if ($cell_options == '')
|
2002-02-14 15:06:53 +01:00
|
|
|
{
|
2003-06-29 19:00:05 +02:00
|
|
|
$cell_options = $cell['type'] == 'int' ? 5 : 8;
|
2002-02-14 15:06:53 +01:00
|
|
|
}
|
2004-04-05 03:33:23 +02:00
|
|
|
$cell_options .= ',,'.($cell['type'] == 'int' ? '/^-?[0-9]*$/' : '/^-?[0-9]*[,.]?[0-9]*$/');
|
2002-02-14 15:06:53 +01:00
|
|
|
// fall-through
|
2004-04-05 03:33:23 +02:00
|
|
|
case 'text': // size: [length][,maxLength[,preg]]
|
2002-02-06 10:03:11 +01:00
|
|
|
if ($readonly)
|
|
|
|
{
|
2004-08-02 09:24:44 +02:00
|
|
|
$html .= $this->html->bold($this->html->htmlspecialchars($value));
|
2002-02-06 10:03:11 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$html .= $this->html->input($form_name,$value,'',
|
2003-06-29 19:00:05 +02:00
|
|
|
$options.$this->html->formatOptions($cell_options,'SIZE,MAXLENGTH'));
|
2004-04-05 03:33:23 +02:00
|
|
|
$cell_options = explode(',',$cell_options,3);
|
|
|
|
$GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name] = array(
|
|
|
|
'type' => $cell['type'],
|
|
|
|
'maxlength' => $cell_options[1],
|
|
|
|
'needed' => $cell['needed'],
|
|
|
|
'preg' => $cell_options[2],
|
|
|
|
'min' => $min, // int and float only
|
|
|
|
'max' => $max,
|
|
|
|
);
|
2002-02-06 10:03:11 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'textarea': // Multiline Text Input, size: [rows][,cols]
|
|
|
|
$html .= $this->html->textarea($form_name,$value,
|
2003-06-29 19:00:05 +02:00
|
|
|
$options.$this->html->formatOptions($cell_options,'ROWS,COLS'));
|
2002-10-01 20:26:30 +02:00
|
|
|
if (!$readonly)
|
2004-04-05 03:33:23 +02:00
|
|
|
{
|
|
|
|
$GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name] = array(
|
|
|
|
'type' => $cell['type'],
|
|
|
|
'needed' => $cell['needed'],
|
|
|
|
);
|
|
|
|
}
|
2002-02-06 10:03:11 +01:00
|
|
|
break;
|
2004-08-21 10:04:23 +02:00
|
|
|
case 'htmlarea': // Multiline formatted Text Input, size: [inline styles for the widget][,plugins (comma-sep.)]
|
2004-02-28 23:41:32 +01:00
|
|
|
if (!$readonly)
|
|
|
|
{
|
2004-08-21 10:04:23 +02:00
|
|
|
list($styles,$plugins) = explode(',',$cell_options,2);
|
|
|
|
$html .= $this->html->htmlarea($form_name,$value,$styles,'',$plugins);
|
2004-04-05 03:33:23 +02:00
|
|
|
$GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name] = array(
|
|
|
|
'type' => $cell['type'],
|
|
|
|
'needed' => $cell['needed'],
|
|
|
|
);
|
2004-02-28 23:41:32 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$html .= $this->html->div($this->html->activate_links($value),'style="overflow: auto; border: thin inset black;'.$cell_options.'"');
|
|
|
|
}
|
|
|
|
break;
|
2002-02-06 10:03:11 +01:00
|
|
|
case 'checkbox':
|
2003-06-29 19:00:05 +02:00
|
|
|
if (!empty($cell_options))
|
2002-10-02 02:44:33 +02:00
|
|
|
{
|
2003-06-29 19:00:05 +02:00
|
|
|
list($true_val,$false_val,$ro_true,$ro_false) = explode(',',$cell_options);
|
2002-10-02 02:44:33 +02:00
|
|
|
$value = $value == $true_val;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$ro_true = 'x';
|
|
|
|
$ro_false = '';
|
|
|
|
}
|
2002-02-06 10:03:11 +01:00
|
|
|
if ($value)
|
|
|
|
{
|
2004-02-14 19:48:53 +01:00
|
|
|
$options .= ' checked="1"';
|
2002-02-06 10:03:11 +01:00
|
|
|
}
|
2002-10-02 02:44:33 +02:00
|
|
|
if ($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'],
|
2003-06-29 19:00:05 +02:00
|
|
|
'values' => $cell_options
|
2002-10-02 02:44:33 +02:00
|
|
|
);
|
|
|
|
}
|
2002-02-06 10:03:11 +01:00
|
|
|
break;
|
|
|
|
case 'radio': // size: value if checked
|
2003-06-29 19:00:05 +02:00
|
|
|
$set_val = $this->expand_name($cell_options,$show_c,$show_row,$content['.c'],$content['.row'],$content);
|
2002-10-18 00:10:12 +02:00
|
|
|
|
|
|
|
if ($value == $set_val)
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
2004-02-14 19:48:53 +01:00
|
|
|
$options .= ' checked="1"';
|
2002-02-06 10:03:11 +01:00
|
|
|
}
|
2002-10-02 02:44:33 +02:00
|
|
|
if ($readonly)
|
|
|
|
{
|
2002-10-18 00:10:12 +02:00
|
|
|
$html .= $value == $set_val ? $this->html->bold('x') : '';
|
2002-10-02 02:44:33 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-10-18 00:10:12 +02:00
|
|
|
$html .= $this->html->input($form_name,$set_val,'RADIO',$options);
|
2002-10-01 20:26:30 +02:00
|
|
|
$GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name] = $cell['type'];
|
2002-10-02 02:44:33 +02:00
|
|
|
}
|
2002-02-06 10:03:11 +01:00
|
|
|
break;
|
|
|
|
case 'button':
|
2004-04-05 03:33:23 +02:00
|
|
|
case 'cancel': // cancel button
|
2002-10-08 02:08:40 +02:00
|
|
|
list($app) = explode('.',$this->name);
|
2004-02-14 19:48:53 +01:00
|
|
|
list($img,$ro_img) = explode(',',$cell_options);
|
|
|
|
$title = strlen($label) <= 1 || $cell['no_lang'] ? $label : lang($label);
|
|
|
|
if ($this->java_script() && ($cell['onchange'] != '' || $img && !$readonly) && !$cell['needed']) // use a link instead of a button
|
2002-06-15 21:59:07 +02:00
|
|
|
{
|
2004-02-14 19:48:53 +01:00
|
|
|
$onclick = ($cell['onchange'] == 1 || $img) ? "return submitit(document.eTemplate,'$form_name');" : $cell['onchange'].'; return false;';
|
2004-02-29 10:55:48 +01:00
|
|
|
if (!$this->html->netscape4 && substr($img,-1) == '%' && is_numeric($percent = substr($img,0,-1)))
|
|
|
|
{
|
|
|
|
$html .= $this->html->progressbar($percent,$title,'onclick="'.$onclick.'" '.$options);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$html .= '<a href="" onClick="'.$onclick.'" '.$options.'>' .
|
|
|
|
($img ? $this->html->image($app,$img,$title,'border="0"') : $title) . '</a>';
|
|
|
|
}
|
2002-06-15 21:59:07 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-04-13 21:14:50 +02:00
|
|
|
if (!empty($img))
|
2002-10-08 02:08:40 +02:00
|
|
|
{
|
2004-02-14 19:48:53 +01:00
|
|
|
$options .= ' title="'.$title.'"';
|
2002-10-08 02:08:40 +02:00
|
|
|
}
|
2003-04-13 21:14:50 +02:00
|
|
|
$html .= !$readonly ? $this->html->submit_button($form_name,$label,$cell['onchange'],
|
2002-10-08 02:08:40 +02:00
|
|
|
strlen($label) <= 1 || $cell['no_lang'],$options,$img,$app) :
|
|
|
|
$this->html->image($app,$ro_img);
|
2002-06-15 21:59:07 +02:00
|
|
|
}
|
2002-05-13 23:30:46 +02:00
|
|
|
$extra_label = False;
|
2002-10-01 20:26:30 +02:00
|
|
|
if (!$readonly)
|
2004-04-05 03:33:23 +02:00
|
|
|
{
|
2002-10-01 20:26:30 +02:00
|
|
|
$GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name] = $cell['type'];
|
2004-04-05 03:33:23 +02:00
|
|
|
if (strtolower($name) == 'cancel')
|
|
|
|
{
|
|
|
|
$GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name] = 'cancel';
|
|
|
|
}
|
|
|
|
}
|
2002-02-06 10:03:11 +01:00
|
|
|
break;
|
|
|
|
case 'hrule':
|
2003-06-29 19:00:05 +02:00
|
|
|
$html .= $this->html->hr($cell_options);
|
2002-02-06 10:03:11 +01:00
|
|
|
break;
|
|
|
|
case 'template': // size: index in content-array (if not full content is past further on)
|
2002-09-27 18:17:39 +02:00
|
|
|
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 (!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';
|
2002-10-12 18:37:44 +02:00
|
|
|
$cell['obj'] = new etemplate(/*** TESTWEISE ***$cell['name']*/$name,$this->as_array());
|
2002-09-27 18:17:39 +02:00
|
|
|
}
|
|
|
|
}
|
2003-02-22 13:29:04 +01:00
|
|
|
if (is_int($this->debug) && $this->debug >= 3 || $this->debug == $cell['type'])
|
2002-09-27 18:17:39 +02:00
|
|
|
{
|
|
|
|
echo "<p>show_cell::template(tpl=$this->name,name=$cell[name]): $obj_read</p>\n";
|
|
|
|
}
|
2003-06-29 19:00:05 +02:00
|
|
|
if ($this->autorepeat_idx($cell,$show_c,$show_row,$idx,$idx_cname) || $cell_options != '')
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
|
|
|
if ($span == '' && isset($content[$idx]['span']))
|
2002-02-14 15:06:53 +01:00
|
|
|
{ // this allows a colspan in autorepeated cells like the editor
|
2002-10-01 20:26:30 +02:00
|
|
|
list($span) = explode(',',$content[$idx]['span']);
|
2002-02-06 10:03:11 +01:00
|
|
|
if ($span == 'all')
|
|
|
|
{
|
|
|
|
$span = 1 + $content['cols'] - $show_c;
|
|
|
|
}
|
|
|
|
}
|
2002-06-10 23:34:58 +02:00
|
|
|
$readonlys = $this->get_array($readonlys,$idx); //$readonlys[$idx];
|
|
|
|
$content = $this->get_array($content,$idx); // $content[$idx];
|
2002-02-06 10:03:11 +01:00
|
|
|
if ($idx_cname != '')
|
|
|
|
{
|
2002-06-10 23:34:58 +02:00
|
|
|
$cname .= $cname == '' ? $idx_cname : '['.str_replace('[','][',str_replace(']','',$idx_cname)).']';
|
2002-02-06 10:03:11 +01:00
|
|
|
}
|
2002-06-10 23:34:58 +02:00
|
|
|
//echo "<p>show_cell-autorepeat($name,$show_c,$show_row,cname='$cname',idx='$idx',idx_cname='$idx_cname',span='$span'): content ="; _debug_array($content);
|
2002-02-06 10:03:11 +01:00
|
|
|
}
|
|
|
|
if ($readonly)
|
|
|
|
{
|
2004-02-05 14:31:54 +01:00
|
|
|
if (!is_array($readonlys)) $readonlys = array();
|
2002-02-06 10:03:11 +01:00
|
|
|
$readonlys['__ALL__'] = True;
|
|
|
|
}
|
2002-10-12 18:37:44 +02:00
|
|
|
$html = $cell['obj']->show($content,$sel_options,$readonlys,$cname,$show_c,$show_row,$cell['onchange'],$cell['tr_class']);
|
2002-02-06 10:03:11 +01:00
|
|
|
break;
|
|
|
|
case 'select': // size:[linesOnMultiselect]
|
2002-10-03 18:52:42 +02:00
|
|
|
$sels = array();
|
2003-06-29 19:00:05 +02:00
|
|
|
list($multiple) = explode(',',$cell_options);
|
2002-10-03 18:52:42 +02:00
|
|
|
if (!empty($multiple) && 0+$multiple <= 0)
|
|
|
|
{
|
2003-08-28 16:31:11 +02:00
|
|
|
$sels[''] = $multiple < 0 ? 'all' : $multiple;
|
2004-08-28 17:52:32 +02:00
|
|
|
// extra-option: no_lang=0 gets translated later and no_lang=1 gets translated too (now), only no_lang>1 gets not translated
|
|
|
|
if ((int)$cell['no_lang'] == 1)
|
2003-08-28 16:31:11 +02:00
|
|
|
{
|
|
|
|
$sels[''] = lang($sels['']);
|
|
|
|
}
|
2002-10-03 18:52:42 +02:00
|
|
|
$multiple = 0;
|
|
|
|
}
|
2002-10-02 02:44:33 +02:00
|
|
|
if (!empty($cell['sel_options']))
|
|
|
|
{
|
2002-10-03 18:52:42 +02:00
|
|
|
if (!is_array($cell['sel_options']))
|
2002-10-02 02:44:33 +02:00
|
|
|
{
|
|
|
|
$opts = explode(',',$cell['sel_options']);
|
|
|
|
while (list(,$opt) = each($opts))
|
|
|
|
{
|
|
|
|
list($k,$v) = explode('=',$opt);
|
2002-10-03 18:52:42 +02:00
|
|
|
$sels[$k] = $v;
|
2002-10-02 02:44:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-10-03 18:52:42 +02:00
|
|
|
$sels += $cell['sel_options'];
|
2002-10-02 02:44:33 +02:00
|
|
|
}
|
|
|
|
}
|
2002-10-06 02:20:32 +02:00
|
|
|
if (isset($sel_options[$name]) && is_array($sel_options[$name]))
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
2002-10-03 18:52:42 +02:00
|
|
|
$sels += $sel_options[$name];
|
2002-02-06 10:03:11 +01:00
|
|
|
}
|
2002-10-04 01:47:14 +02:00
|
|
|
elseif (count($name_parts))
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
2002-10-05 01:15:46 +02:00
|
|
|
$org_name = $name_parts[count($name_parts)-1];
|
2002-10-06 02:20:32 +02:00
|
|
|
if (isset($sel_options[$org_name]) && is_array($sel_options[$org_name]))
|
2002-10-04 01:47:14 +02:00
|
|
|
{
|
|
|
|
$sels += $sel_options[$org_name];
|
|
|
|
}
|
2003-10-26 20:26:58 +01:00
|
|
|
elseif (isset($sel_options[$name_parts[0]]) && is_array($sel_options[$name_parts[0]]))
|
|
|
|
{
|
|
|
|
$sels += $sel_options[$name_parts[0]];
|
|
|
|
}
|
2002-10-02 02:44:33 +02:00
|
|
|
}
|
2002-10-03 18:52:42 +02:00
|
|
|
if (isset($content["options-$name"]))
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
2002-10-03 18:52:42 +02:00
|
|
|
$sels += $content["options-$name"];
|
2002-02-06 10:03:11 +01:00
|
|
|
}
|
2002-10-02 02:44:33 +02:00
|
|
|
if ($readonly)
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
2002-10-03 18:52:42 +02:00
|
|
|
$html .= $cell['no_lang'] ? $sels[$value] : lang($sels[$value]);
|
2002-02-06 10:03:11 +01:00
|
|
|
}
|
2002-10-02 02:44:33 +02:00
|
|
|
else
|
|
|
|
{
|
2002-10-03 18:52:42 +02:00
|
|
|
$html .= $this->html->select($form_name.($multiple > 1 ? '[]' : ''),$value,$sels,
|
2002-10-02 02:44:33 +02:00
|
|
|
$cell['no_lang'],$options,$multiple);
|
2002-10-01 20:26:30 +02:00
|
|
|
$GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name] = $cell['type'];
|
2002-10-02 02:44:33 +02:00
|
|
|
}
|
2002-02-06 10:03:11 +01:00
|
|
|
break;
|
|
|
|
case 'image':
|
2002-10-12 18:37:44 +02:00
|
|
|
$image = $value != '' ? $value : $name;
|
2002-02-06 10:03:11 +01:00
|
|
|
$image = $this->html->image(substr($this->name,0,strpos($this->name,'.')),
|
2003-12-09 01:03:41 +01:00
|
|
|
$image,strlen($label) > 1 && !$cell['no_lang'] ? lang($label) : $label,'border="0"');
|
2002-10-14 02:39:47 +02:00
|
|
|
$html .= $image;
|
2003-06-29 19:00:05 +02:00
|
|
|
$extra_link = $cell_options;
|
2002-05-13 23:30:46 +02:00
|
|
|
$extra_label = False;
|
2002-02-06 10:03:11 +01:00
|
|
|
break;
|
2002-09-12 10:40:57 +02:00
|
|
|
case 'file':
|
|
|
|
$html .= $this->html->input_hidden($path = str_replace($name,$name.'_path',$form_name),'.');
|
2002-10-20 17:06:52 +02:00
|
|
|
$html .= $this->html->input($form_name,'','file',$options);
|
2002-09-12 10:40:57 +02:00
|
|
|
$GLOBALS['phpgw_info']['etemplate']['form_options'] =
|
|
|
|
"enctype=\"multipart/form-data\" onSubmit=\"set_element2(this,'$path','$form_name')\"";
|
2002-10-01 20:26:30 +02:00
|
|
|
$GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name] = $cell['type'];
|
2002-09-12 10:40:57 +02:00
|
|
|
break;
|
2002-10-12 18:37:44 +02:00
|
|
|
case 'vbox':
|
|
|
|
case 'hbox':
|
|
|
|
$rows = array();
|
|
|
|
$box_row = 1;
|
|
|
|
$box_col = 'A';
|
|
|
|
$box_anz = 0;
|
2003-12-10 02:21:31 +01:00
|
|
|
for ($n = 1; $n <= intval($cell_options); ++$n)
|
2002-10-12 18:37:44 +02:00
|
|
|
{
|
2003-12-09 01:03:41 +01:00
|
|
|
$h = $this->show_cell($cell[$n],$content,$sel_options,$readonlys,$cname,$show_c,$show_row,$nul,$cl);
|
2002-10-12 18:37:44 +02:00
|
|
|
if ($h != '' && $h != ' ')
|
|
|
|
{
|
|
|
|
if ($cell['type'] == 'vbox')
|
|
|
|
{
|
|
|
|
$box_row = $n;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$box_col = $this->num2chrs($n);
|
|
|
|
}
|
|
|
|
$rows[$box_row][$box_col] = $html = $h;
|
|
|
|
$box_anz++;
|
|
|
|
if ($cell[$n]['align'])
|
|
|
|
{
|
|
|
|
$rows[$box_row]['.'.$box_col] = $this->html->formatOptions($cell[$n]['align'],'ALIGN');
|
|
|
|
}
|
2002-10-18 00:10:12 +02:00
|
|
|
$cl = $this->expand_name(isset($this->class_conf[$cl]) ? $this->class_conf[$cl] : $cl,
|
|
|
|
$show_c,$show_row,$content['.c'],$content['.row'],$content);
|
|
|
|
$rows[$box_row]['.'.$box_col] .= $this->html->formatOptions($cl,'CLASS');
|
2002-10-12 18:37:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($box_anz > 1) // a single cell is NOT placed into a table
|
|
|
|
{
|
2002-10-14 02:39:47 +02:00
|
|
|
$html = "\n\n<!-- BEGIN $cell[type] -->\n\n".
|
2003-06-29 19:00:05 +02:00
|
|
|
$this->html->table($rows,$this->html->formatOptions($cell_options,',CELLPADDING,CELLSPACING').
|
|
|
|
($cell['align'] && $type == 'vbox' ? ' WIDTH="100%"' : '')). // alignment only works if table has full width
|
2002-10-14 02:39:47 +02:00
|
|
|
"\n\n<!-- END $cell[type] -->\n\n";
|
2002-10-12 18:37:44 +02:00
|
|
|
}
|
|
|
|
break;
|
2003-04-13 21:14:50 +02:00
|
|
|
case 'deck':
|
2003-06-29 19:00:05 +02:00
|
|
|
for ($n = 1; $n <= $cell_options && (empty($value) || $value != $cell[$n]['name']); ++$n) ;
|
|
|
|
if ($n > $cell_options)
|
2003-04-13 21:14:50 +02:00
|
|
|
{
|
|
|
|
$value = $cell[1]['name'];
|
|
|
|
}
|
|
|
|
if ($s_width = $cell['width'])
|
|
|
|
{
|
|
|
|
$s_width = "width: $s_width".(substr($s_width,-1) != '%' ? 'px' : '').';';
|
|
|
|
}
|
|
|
|
if ($s_height = $cell['height'])
|
|
|
|
{
|
|
|
|
$s_height = "height: $s_height".(substr($s_height,-1) != '%' ? 'px' : '').';';
|
|
|
|
}
|
2003-06-29 19:00:05 +02:00
|
|
|
for ($n = 1; $n <= $cell_options; ++$n)
|
2003-04-13 21:14:50 +02:00
|
|
|
{
|
2003-12-09 01:03:41 +01:00
|
|
|
$h = $this->show_cell($cell[$n],$content,$sel_options,$readonlys,$cname,$show_c,$show_row,$nul,$nul);
|
2003-06-29 19:00:05 +02:00
|
|
|
$vis = !empty($value) && $value == $cell_options[$n]['name'] || $n == 1 && $first ? 'visible' : 'hidden';
|
2003-04-13 21:14:50 +02:00
|
|
|
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;
|
2002-02-06 10:03:11 +01:00
|
|
|
default:
|
2002-10-01 20:26:30 +02:00
|
|
|
if ($ext_type && $this->haveExtension($ext_type,'render'))
|
2002-05-13 23:30:46 +02:00
|
|
|
{
|
2002-10-01 20:26:30 +02:00
|
|
|
$html .= $this->extensionRender($ext_type,$form_name,$value,$cell,$readonly);
|
2002-05-13 23:30:46 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-09-27 18:17:39 +02:00
|
|
|
$html .= "<i>unknown type '$cell[type]'</i>";
|
2002-05-13 23:30:46 +02:00
|
|
|
}
|
2002-02-06 10:03:11 +01:00
|
|
|
break;
|
|
|
|
}
|
2002-10-13 00:37:29 +02:00
|
|
|
if ($ext_type && !$readonly && $this->haveExtension($ext_type,'post_process')) // extension-processing need to be after all other and only with diff. name
|
2002-10-09 02:31:01 +02:00
|
|
|
{ // 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]);
|
2002-10-01 20:26:30 +02:00
|
|
|
$GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name] = 'ext-'.$ext_type;
|
|
|
|
}
|
2003-08-28 16:31:11 +02:00
|
|
|
// save blur-value to strip it in process_exec
|
|
|
|
if (!empty($blur) && isset($GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name]))
|
|
|
|
{
|
|
|
|
$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;
|
|
|
|
}
|
2002-06-10 23:34:58 +02:00
|
|
|
if ($extra_label && ($label != '' || $html == ''))
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
2004-03-24 02:20:00 +01:00
|
|
|
if (strlen($label) > 1 && !($cell['no_lang'] && $cell['label'] != $label || (int)$cell['no_lang'] == 2))
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
|
|
|
$label = lang($label);
|
|
|
|
}
|
2002-10-18 23:33:39 +02:00
|
|
|
if (($accesskey = strstr($label,'&')) && $accesskey[1] != ' ' && $form_name != '' &&
|
|
|
|
(($pos = strpos($accesskey,';')) === False || $pos > 5))
|
2002-10-09 02:31:01 +02:00
|
|
|
{
|
|
|
|
$label = str_replace('&'.$accesskey[1],'<u>'.$accesskey[1].'</u>',$label);
|
|
|
|
$label = $this->html->label($label,$form_name,$accesskey[1]);
|
|
|
|
}
|
2003-04-13 23:47:03 +02:00
|
|
|
if ($type == 'radio' || $type == 'checkbox' || strstr($label,'%s')) // default for radio is label after the button
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
2003-04-13 21:14:50 +02:00
|
|
|
$html = strstr($label,'%s') ? str_replace('%s',$html,$label) : $html.' '.$label;
|
2002-02-06 10:03:11 +01:00
|
|
|
}
|
|
|
|
elseif (($html = $label . ' ' . $html) == ' ')
|
|
|
|
{
|
|
|
|
$html = ' ';
|
|
|
|
}
|
|
|
|
}
|
2002-10-14 02:39:47 +02:00
|
|
|
if ($extra_link)
|
|
|
|
{
|
2002-10-18 00:10:12 +02:00
|
|
|
$extra_link = $this->expand_name($extra_link,$show_c,$show_row,$content['.c'],$content['.row'],$content);
|
2002-10-14 02:39:47 +02:00
|
|
|
if ($extra_link[0] == '@')
|
|
|
|
{
|
|
|
|
$extra_link = $this->get_array($content,substr($extra_link,1));
|
|
|
|
}
|
2002-10-18 00:10:12 +02:00
|
|
|
if ($extra_link)
|
|
|
|
{
|
|
|
|
$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 : '');
|
|
|
|
}
|
2002-10-14 02:39:47 +02:00
|
|
|
}
|
2004-04-05 03:33:23 +02:00
|
|
|
// if necessary show validation-error behind field
|
|
|
|
if (isset($GLOBALS['phpgw_info']['etemplate']['validation_errors'][$form_name]))
|
|
|
|
{
|
|
|
|
$html .= ' <font color="red">'.$GLOBALS['phpgw_info']['etemplate']['validation_errors'][$form_name].'</font>';
|
|
|
|
}
|
2002-02-06 10:03:11 +01:00
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
|
2002-10-01 20:26:30 +02:00
|
|
|
|
2002-02-06 10:03:11 +01:00
|
|
|
/*!
|
|
|
|
@function process_show
|
2003-08-28 16:31:11 +02:00
|
|
|
@abstract makes necessary adjustments on _POST after a eTemplate / form gots submitted
|
2002-02-06 10:03:11 +01:00
|
|
|
@discussion This is only an internal function, dont call it direct use only exec
|
2002-10-01 20:26:30 +02:00
|
|
|
@discussion Process_show uses a list of input-fields/widgets generated by show.
|
2003-02-22 13:29:04 +01:00
|
|
|
@syntax process_show(&$content,$to_process,$cname='')
|
2003-08-28 16:31:11 +02:00
|
|
|
@param $content _POST[$cname]
|
2002-10-01 20:26:30 +02:00
|
|
|
@param $to_process list of widgets/form-fields to process
|
2002-02-06 10:03:11 +01:00
|
|
|
@param $cname basename of our returnt content (same as in call to show)
|
2002-09-02 13:14:30 +02:00
|
|
|
@result the adjusted content (by using the var-param &$content)
|
2002-02-06 10:03:11 +01:00
|
|
|
*/
|
2002-10-01 20:26:30 +02:00
|
|
|
function process_show(&$content,$to_process,$cname='')
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
2002-10-09 02:31:01 +02:00
|
|
|
if (!isset($content) || !is_array($content) || !is_array($to_process))
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2003-02-22 13:29:04 +01:00
|
|
|
if (is_int($this->debug) && $this->debug >= 1 || $this->debug == $this->name && $this->name)
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
2004-02-14 19:48:53 +01:00
|
|
|
echo "<p>process_show($this->name) cname='$cname' start: content ="; _debug_array($content);
|
2002-02-06 10:03:11 +01:00
|
|
|
}
|
2002-10-01 20:26:30 +02:00
|
|
|
$content_in = $cname ? array($cname => $content) : $content;
|
|
|
|
$content = array();
|
2004-04-05 03:33:23 +02:00
|
|
|
$GLOBALS['phpgw_info']['etemplate']['validation_errors'] = array();
|
2004-08-01 21:26:33 +02:00
|
|
|
$this->canceled = $this->button_pressed = False;
|
2003-12-09 01:03:41 +01:00
|
|
|
|
|
|
|
foreach($to_process as $form_name => $type)
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
2002-10-02 02:44:33 +02:00
|
|
|
if (is_array($type))
|
|
|
|
{
|
|
|
|
$attr = $type;
|
|
|
|
$type = $attr['type'];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$attr = array();
|
|
|
|
}
|
2003-12-10 02:21:31 +01:00
|
|
|
$value = $this->get_array($content_in,$form_name,True);
|
2003-08-28 16:31:11 +02:00
|
|
|
|
|
|
|
if (isset($attr['blur']) && $attr['blur'] == stripslashes($value))
|
|
|
|
{
|
|
|
|
$value = ''; // blur-values is equal to emtpy
|
|
|
|
}
|
2003-12-09 01:03:41 +01:00
|
|
|
// echo "<p>process_show($this->name) $type: $form_name = '$value'</p>\n";
|
2002-10-01 20:26:30 +02:00
|
|
|
list($type,$sub) = explode('-',$type);
|
|
|
|
switch ($type)
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
2002-10-01 20:26:30 +02:00
|
|
|
case 'ext':
|
2004-09-20 20:51:31 +02:00
|
|
|
$_cont = &$this->get_array($content,$form_name,True);
|
|
|
|
if (!$this->extensionPostProcess($sub,$form_name,$_cont,$value))
|
2003-12-09 01:03:41 +01:00
|
|
|
{
|
|
|
|
$this->unset_array($content,$form_name);
|
|
|
|
}
|
2004-09-20 20:51:31 +02:00
|
|
|
// this else should NOT be unnecessary as $_cont is a reference to the index
|
|
|
|
// $form_name of $content, but under some circumstances a set/changed $_cont
|
|
|
|
// does not result in a change in $content -- RalfBecker 2004/09/18
|
|
|
|
elseif ($_cont && !$this->isset_array($content,$form_name))
|
|
|
|
{
|
|
|
|
$this->set_array($content,$form_name,$_cont);
|
|
|
|
}
|
2002-10-01 20:26:30 +02:00
|
|
|
break;
|
2004-02-28 23:41:32 +01:00
|
|
|
case 'htmlarea':
|
|
|
|
if (isset($value))
|
|
|
|
{
|
|
|
|
$value = stripslashes($value);
|
|
|
|
}
|
|
|
|
$this->set_array($content,$form_name,$value);
|
|
|
|
break;
|
2004-04-05 03:33:23 +02:00
|
|
|
case 'int':
|
|
|
|
case 'float':
|
2002-10-01 20:26:30 +02:00
|
|
|
case 'text':
|
|
|
|
case 'textarea':
|
|
|
|
if (isset($value))
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
2002-10-01 20:26:30 +02:00
|
|
|
$value = stripslashes($value);
|
2002-02-17 20:09:15 +01:00
|
|
|
}
|
2004-04-05 03:33:23 +02:00
|
|
|
if ($value === '' && $attr['needed'])
|
|
|
|
{
|
|
|
|
$GLOBALS['phpgw_info']['etemplate']['validation_errors'][$form_name] = lang('Field must not be empty !!!',$value);
|
|
|
|
}
|
|
|
|
if ((int) $attr['maxlength'] > 0 && strlen($value) > (int) $attr['maxlength'])
|
|
|
|
{
|
|
|
|
$value = substr($value,0,(int) $attr['maxlength']);
|
|
|
|
}
|
|
|
|
if ($attr['preg'] && !preg_match($attr['preg'],$value))
|
|
|
|
{
|
|
|
|
switch($type)
|
|
|
|
{
|
|
|
|
case 'int':
|
|
|
|
$GLOBALS['phpgw_info']['etemplate']['validation_errors'][$form_name] = lang("'%1' is not a valid integer !!!",$value);
|
|
|
|
break;
|
|
|
|
case 'float':
|
|
|
|
$GLOBALS['phpgw_info']['etemplate']['validation_errors'][$form_name] = lang("'%1' is not a valid floatingpoint number !!!",$value);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$GLOBALS['phpgw_info']['etemplate']['validation_errors'][$form_name] = lang("'%1' has an invalid format !!!",$value);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elseif ($type == 'int' || $type == 'float') // cast int and float and check range
|
|
|
|
{
|
|
|
|
if ($value !== '' || $attr['needed']) // empty values are Ok if needed is not set
|
|
|
|
{
|
|
|
|
$value = $type == 'int' ? (int) $value : (float) str_replace(',','.',$value); // allow for german (and maybe other) format
|
|
|
|
|
|
|
|
if (!empty($attr['min']) && $value < $attr['min'])
|
|
|
|
{
|
|
|
|
$GLOBALS['phpgw_info']['etemplate']['validation_errors'][$form_name] = lang("Value has to be at least '%1' !!!",$attr['min']);
|
|
|
|
$value = $type == 'int' ? (int) $attr['min'] : (float) $attr['min'];
|
|
|
|
}
|
|
|
|
if (!empty($attr['max']) && $value > $attr['max'])
|
|
|
|
{
|
|
|
|
$GLOBALS['phpgw_info']['etemplate']['validation_errors'][$form_name] = lang("Value has to be at maximum '%1' !!!",$attr['max']);
|
|
|
|
$value = $type == 'int' ? (int) $attr['max'] : (float) $attr['max'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-10-01 20:26:30 +02:00
|
|
|
$this->set_array($content,$form_name,$value);
|
|
|
|
break;
|
2004-04-05 03:33:23 +02:00
|
|
|
case 'cancel': // cancel button ==> dont care for validation errors
|
|
|
|
if ($value)
|
|
|
|
{
|
|
|
|
$this->canceled = True;
|
2004-08-01 21:26:33 +02:00
|
|
|
$this->set_array($content,$form_name,$value);
|
2004-04-05 03:33:23 +02:00
|
|
|
}
|
2004-08-01 21:26:33 +02:00
|
|
|
break;
|
2002-10-01 20:26:30 +02:00
|
|
|
case 'button':
|
|
|
|
if ($value)
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
2004-08-01 21:26:33 +02:00
|
|
|
$this->button_pressed = True;
|
2002-10-01 20:26:30 +02:00
|
|
|
$this->set_array($content,$form_name,$value);
|
2002-02-06 10:03:11 +01:00
|
|
|
}
|
2002-10-01 20:26:30 +02:00
|
|
|
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
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
2002-10-01 20:26:30 +02:00
|
|
|
$value = 0; // need to be reported too
|
2002-02-06 10:03:11 +01:00
|
|
|
}
|
2002-10-02 02:44:33 +02:00
|
|
|
if (!empty($attr['values']))
|
|
|
|
{
|
|
|
|
list($true_val,$false_val) = explode(',',$attr['values']);
|
|
|
|
$value = $value ? $true_val : $false_val;
|
|
|
|
}
|
2002-10-01 20:26:30 +02:00
|
|
|
$this->set_array($content,$form_name,$value);
|
|
|
|
break;
|
2002-10-20 17:06:52 +02:00
|
|
|
case 'file':
|
|
|
|
$parts = explode('[',str_replace(']','',$form_name));
|
|
|
|
$name = array_shift($parts);
|
|
|
|
$index = count($parts) ? '['.implode('][',$parts).']' : '';
|
|
|
|
$value = array();
|
2004-04-05 03:33:23 +02:00
|
|
|
foreach(array('tmp_name','type','size','name') as $part)
|
2002-10-20 17:06:52 +02:00
|
|
|
{
|
2003-12-02 09:02:31 +01:00
|
|
|
$value[$part] = is_array($_FILES[$name]) ? $this->get_array($_FILES[$name],$part.$index) : False;
|
2002-10-20 17:06:52 +02:00
|
|
|
}
|
|
|
|
$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
|
2002-10-01 20:26:30 +02:00
|
|
|
default:
|
|
|
|
$this->set_array($content,$form_name,$value);
|
|
|
|
break;
|
2002-02-06 10:03:11 +01:00
|
|
|
}
|
|
|
|
}
|
2002-10-01 20:26:30 +02:00
|
|
|
if ($cname)
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
2002-10-01 20:26:30 +02:00
|
|
|
$content = $content[$cname];
|
2002-02-06 10:03:11 +01:00
|
|
|
}
|
2003-02-22 13:29:04 +01:00
|
|
|
if (is_int($this->debug) && $this->debug >= 2 || $this->debug == $this->name && $this->name)
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
2002-10-01 20:26:30 +02:00
|
|
|
echo "<p>process_show($this->name) end: content ="; _debug_array($content);
|
2004-04-05 03:33:23 +02:00
|
|
|
if (count($GLOBALS['phpgw_info']['etemplate']['validation_errors']))
|
|
|
|
{
|
|
|
|
echo "<p>validation_errors = "; _debug_array($GLOBALS['phpgw_info']['etemplate']['validation_errors']);
|
|
|
|
}
|
2002-02-06 10:03:11 +01:00
|
|
|
}
|
2004-04-05 03:33:23 +02:00
|
|
|
return count($GLOBALS['phpgw_info']['etemplate']['validation_errors']);
|
2002-02-06 10:03:11 +01:00
|
|
|
}
|
2002-06-15 21:59:07 +02:00
|
|
|
|
|
|
|
/*!
|
2002-09-02 13:14:30 +02:00
|
|
|
@function java_script
|
|
|
|
@syntax java_script( $consider_not_tested_as_enabled = True )
|
|
|
|
@author ralfbecker
|
2002-06-15 21:59:07 +02:00
|
|
|
@abstract is javascript enabled?
|
|
|
|
@discussion this should be tested by the api at login
|
2003-04-13 21:14:50 +02:00
|
|
|
@result true if javascript is enabled or not yet tested and $consider_not_tested_as_enabled
|
2002-06-15 21:59:07 +02:00
|
|
|
*/
|
|
|
|
function java_script($consider_not_tested_as_enabled = True)
|
|
|
|
{
|
2003-04-13 23:47:03 +02:00
|
|
|
$ret = !!$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";
|
|
|
|
|
|
|
|
return $ret;
|
2002-06-15 21:59:07 +02:00
|
|
|
return !!$GLOBALS['phpgw_info']['etemplate']['java_script'] ||
|
|
|
|
$consider_not_tested_as_enabled &&
|
|
|
|
(!isset($GLOBALS['phpgw_info']['etemplate']['java_script']) ||
|
|
|
|
$GLOBALS['phpgw_info']['etemplate']['java_script'].'' == '');
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
2002-09-02 13:14:30 +02:00
|
|
|
@function include_java_script
|
|
|
|
@syntax include_java_script( )
|
|
|
|
@author ralfbecker
|
2002-06-15 21:59:07 +02:00
|
|
|
@abstract returns the javascript to be included by exec
|
2003-04-21 10:43:20 +02:00
|
|
|
@param $what &1 = returns the test, note: has to be included in the body, not the header\
|
|
|
|
&2 = returns the common functions, best to be included in the header
|
2002-06-15 21:59:07 +02:00
|
|
|
*/
|
2003-04-21 10:43:20 +02:00
|
|
|
function include_java_script($what = 3)
|
2002-06-15 21:59:07 +02:00
|
|
|
{
|
|
|
|
// this is to test if javascript is enabled
|
2003-04-21 10:43:20 +02:00
|
|
|
if ($what & 1 && !isset($GLOBALS['phpgw_info']['etemplate']['java_script']))
|
2002-06-15 21:59:07 +02:00
|
|
|
{
|
|
|
|
$js = '<script language="javascript">
|
|
|
|
document.write(\''.str_replace("\n",'',$this->html->input_hidden('java_script','1')).'\');
|
2003-04-13 21:14:50 +02:00
|
|
|
if (document.getElementById) {
|
|
|
|
document.write(\''.str_replace("\n",'',$this->html->input_hidden('dom_enabled','1')).'\');
|
|
|
|
}
|
2002-06-15 21:59:07 +02:00
|
|
|
</script>
|
|
|
|
';
|
|
|
|
}
|
|
|
|
|
2002-09-25 00:34:21 +02:00
|
|
|
// here are going all the necesarry functions if javascript is enabled
|
2003-04-21 10:43:20 +02:00
|
|
|
if ($what & 2 && $this->java_script(True))
|
2002-06-15 21:59:07 +02:00
|
|
|
{
|
2003-08-28 16:31:11 +02:00
|
|
|
$js .= '<script type="text/javascript" src="'.
|
|
|
|
$GLOBALS['phpgw_info']['server']['webserver_url'].'/etemplate/js/etemplate.js"></script>';
|
2002-06-15 21:59:07 +02:00
|
|
|
}
|
|
|
|
return $js;
|
|
|
|
}
|
2002-10-08 02:08:40 +02:00
|
|
|
};
|