2002-02-06 10:03:11 +01:00
|
|
|
<?php
|
2006-04-20 19:12:30 +02:00
|
|
|
/**
|
|
|
|
* eGroupWare - EditableTemplates - HTML User Interface
|
|
|
|
*
|
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
|
|
|
* @package etemplate
|
|
|
|
* @link http://www.egroupware.org
|
|
|
|
* @author Ralf Becker <RalfBecker@outdoor-training.de>
|
|
|
|
* @version $Id$
|
|
|
|
*/
|
2002-02-06 10:03:11 +01:00
|
|
|
|
2005-11-09 21:50:45 +01:00
|
|
|
include_once(EGW_INCLUDE_ROOT . '/etemplate/inc/class.boetemplate.inc.php');
|
2002-02-06 10:03:11 +01:00
|
|
|
|
2004-10-07 23:53:41 +02:00
|
|
|
/**
|
|
|
|
* creates dialogs / HTML-forms from eTemplate descriptions
|
|
|
|
*
|
2005-11-10 15:51:12 +01:00
|
|
|
* Usage example:
|
|
|
|
*<code>
|
2005-11-05 18:07:29 +01:00
|
|
|
* $tmpl =& CreateObject('etemplate.etemplate','app.template.name');
|
2004-10-07 23:53:41 +02:00
|
|
|
* $tmpl->exec('app.class.callback',$content_to_show);
|
2005-11-10 15:51:12 +01:00
|
|
|
*</code>
|
2004-10-07 23:53:41 +02:00
|
|
|
* This creates a form from the eTemplate 'app.template.name' and takes care that
|
2005-11-05 18:07:29 +01:00
|
|
|
* the method / public function 'callback' in class 'class' of 'app' gets called
|
2005-11-10 15:51:12 +01:00
|
|
|
* if the user submits the form. For the complete param's see the description of exec.
|
|
|
|
*
|
|
|
|
* etemplate or uietemplate extends boetemplate, all vars and public functions are inherited
|
2004-10-07 23:53:41 +02:00
|
|
|
*
|
|
|
|
* @package etemplate
|
2005-02-18 23:44:42 +01:00
|
|
|
* @subpackage api
|
2005-11-10 15:51:12 +01:00
|
|
|
* @author Ralf Becker <RalfBecker@outdoor-training.de>
|
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
2004-10-07 23:53:41 +02:00
|
|
|
*/
|
2002-02-06 10:03:11 +01:00
|
|
|
class etemplate extends boetemplate
|
|
|
|
{
|
2005-02-12 14:59:08 +01:00
|
|
|
/**
|
2006-09-29 21:47:29 +02:00
|
|
|
* integer debug-level or template-name or cell-type or '' = off
|
2005-02-12 14:59:08 +01:00
|
|
|
* 1=calls to show and process_show, 2=content after process_show,
|
|
|
|
* 3=calls to show_cell and process_show_cell
|
2006-09-29 21:47:29 +02:00
|
|
|
*
|
|
|
|
* @var int/string
|
2005-02-12 14:59:08 +01:00
|
|
|
*/
|
|
|
|
var $debug;
|
2006-09-29 21:47:29 +02:00
|
|
|
/**
|
|
|
|
* Instance of the html class
|
|
|
|
*
|
|
|
|
* @var html
|
|
|
|
*/
|
2007-03-13 14:46:50 +01:00
|
|
|
var $html;
|
2005-02-16 00:22:10 +01:00
|
|
|
var $xslt = false; /* do we run in the xslt framework (true) or the regular eGW one (false) */
|
2002-09-28 02:09:47 +02:00
|
|
|
var $class_conf = array('nmh' => 'th','nmr0' => 'row_on','nmr1' => 'row_off');
|
2004-10-07 23:53:41 +02:00
|
|
|
var $public_functions = array('process_exec' => True);
|
2005-05-07 16:00:06 +02:00
|
|
|
/**
|
2007-03-13 14:46:50 +01:00
|
|
|
* Inner width of browser window
|
|
|
|
*
|
|
|
|
* @var int
|
2005-05-07 16:00:06 +02:00
|
|
|
*/
|
|
|
|
var $innerWidth;
|
2006-01-11 06:25:49 +01:00
|
|
|
/**
|
2007-03-13 14:46:50 +01:00
|
|
|
* Reference to the content-param of the last call to show, for extensions to use
|
|
|
|
*
|
|
|
|
* @var array
|
2006-01-11 06:25:49 +01:00
|
|
|
*/
|
|
|
|
var $content;
|
|
|
|
/**
|
2007-03-13 14:46:50 +01:00
|
|
|
* Reference to the sel_options-param of the last call to show, for extensions to use
|
|
|
|
*
|
|
|
|
* @var array
|
2006-01-11 06:25:49 +01:00
|
|
|
*/
|
|
|
|
var $sel_options;
|
2006-03-16 15:20:57 +01:00
|
|
|
/**
|
2007-03-13 14:46:50 +01:00
|
|
|
* Name of the currently processed etemplate, reference to $GLOBALS['egw_info']['etemplate']['name_form']
|
|
|
|
*
|
|
|
|
* @var string
|
2006-03-16 15:20:57 +01:00
|
|
|
*/
|
|
|
|
var $name_form;
|
|
|
|
/**
|
2007-03-13 14:46:50 +01:00
|
|
|
* Used form-names in this request, reference to $GLOBALS['egw_info']['etemplate']['name_forms']
|
|
|
|
*
|
|
|
|
* @var array
|
2006-03-16 15:20:57 +01:00
|
|
|
*/
|
|
|
|
var $name_forms;
|
2007-03-13 14:46:50 +01:00
|
|
|
/**
|
|
|
|
* Basename of the variables (content) in $_POST and id's, usually 'exec',
|
|
|
|
* if there's not more then one eTemplate on the page (then it will be exec, exec2, exec3, ...
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
var $name_vars='exec';
|
2002-09-25 18:36:07 +02:00
|
|
|
|
2004-10-07 23:53:41 +02:00
|
|
|
/**
|
|
|
|
* constructor of etemplate class, reads an eTemplate if $name is given
|
|
|
|
*
|
2005-02-13 14:03:36 +01:00
|
|
|
* @param string $name of etemplate or array with name and other keys
|
|
|
|
* @param string/array $load_via with keys of other etemplate to load in order to get $name
|
2004-10-07 23:53:41 +02:00
|
|
|
*/
|
2002-09-25 18:36:07 +02:00
|
|
|
function etemplate($name='',$load_via='')
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
2005-11-09 21:50:45 +01:00
|
|
|
if (!is_object($GLOBALS['egw']->html))
|
2003-09-14 12:25:05 +02:00
|
|
|
{
|
2005-11-09 21:50:45 +01:00
|
|
|
$GLOBALS['egw']->html =& CreateObject('phpgwapi.html');
|
2003-09-14 12:25:05 +02:00
|
|
|
}
|
2006-04-06 20:39:34 +02:00
|
|
|
$this->html = &$GLOBALS['egw']->html;
|
|
|
|
|
2006-03-29 21:25:00 +02:00
|
|
|
if (!is_object($GLOBALS['egw']->template))
|
|
|
|
{
|
2006-04-06 20:39:34 +02:00
|
|
|
$GLOBALS['egw']->template =& CreateObject('phpgwapi.Template');
|
2006-03-29 21:25:00 +02:00
|
|
|
}
|
2002-09-25 18:36:07 +02:00
|
|
|
$this->boetemplate($name,$load_via);
|
2002-09-28 02:30:01 +02:00
|
|
|
|
2005-11-09 21:50:45 +01:00
|
|
|
$this->xslt = is_object($GLOBALS['egw']->xslttpl);
|
2005-05-02 17:07:37 +02:00
|
|
|
|
|
|
|
$this->sitemgr = is_object($GLOBALS['Common_BO']);
|
2005-05-07 16:00:06 +02:00
|
|
|
|
|
|
|
if (($this->innerWidth = (int) $_POST['innerWidth']))
|
|
|
|
{
|
2005-11-09 21:50:45 +01:00
|
|
|
$GLOBALS['egw']->session->appsession('innerWidth','etemplate',$this->innerWidth);
|
2005-05-07 16:00:06 +02:00
|
|
|
}
|
2005-11-09 21:50:45 +01:00
|
|
|
elseif (!($this->innerWidth = (int) $GLOBALS['egw']->session->appsession('innerWidth','etemplate')))
|
2005-05-07 16:00:06 +02:00
|
|
|
{
|
|
|
|
$this->innerWidth = 1018; // default width for an assumed screen-resolution of 1024x768
|
|
|
|
}
|
|
|
|
//echo "<p>_POST[innerWidth]='$_POST[innerWidth]', innerWidth=$this->innerWidth</p>\n";
|
2006-03-16 15:20:57 +01:00
|
|
|
$this->name_form =& $GLOBALS['egw_info']['etemplate']['name_form'];
|
|
|
|
$this->name_forms =& $GLOBALS['egw_info']['etemplate']['name_forms'];
|
|
|
|
if (!is_array($this->name_forms)) $this->name_forms = array();
|
2002-02-06 10:03:11 +01:00
|
|
|
}
|
|
|
|
|
2004-10-07 23:53:41 +02:00
|
|
|
/**
|
|
|
|
* Abstracts a html-location-header call
|
|
|
|
*
|
|
|
|
* In other UI's than html this needs to call the methode, defined by menuaction or
|
|
|
|
* open a browser-window for any other links.
|
|
|
|
*
|
2005-02-12 14:59:08 +01:00
|
|
|
* @param string/array $params url or array with get-params incl. menuaction
|
2004-10-07 23:53:41 +02:00
|
|
|
*/
|
|
|
|
function location($params='')
|
2002-10-14 02:39:47 +02:00
|
|
|
{
|
2005-11-09 21:50:45 +01:00
|
|
|
$GLOBALS['egw']->redirect_link(is_array($params) ? '/index.php' : $params,
|
2004-10-07 23:53:41 +02:00
|
|
|
is_array($params) ? $params : '');
|
2002-10-14 02:39:47 +02:00
|
|
|
}
|
|
|
|
|
2004-10-07 23:53:41 +02:00
|
|
|
/**
|
|
|
|
* Generats a Dialog from an eTemplate - abstract the UI-layer
|
|
|
|
*
|
|
|
|
* This is the only function an application should use, all other are INTERNAL and
|
|
|
|
* do NOT abstract the UI-layer, because they return HTML.
|
|
|
|
* Generates a webpage with a form from the template and puts process_exec in the
|
|
|
|
* form as submit-url to call process_show for the template before it
|
|
|
|
* ExecuteMethod's the given $method of the caller.
|
|
|
|
*
|
2005-02-13 14:03:36 +01:00
|
|
|
* @param string $method Methode (e.g. 'etemplate.editor.edit') to be called if form is submitted
|
|
|
|
* @param array $content with content to fill the input-fields of template, eg. the text-field
|
|
|
|
* with name 'name' gets its content from $content['name']
|
2004-10-07 23:53:41 +02:00
|
|
|
* @param $sel_options array or arrays with the options for each select-field, keys are the
|
2005-02-13 14:03:36 +01:00
|
|
|
* field-names, eg. array('name' => array(1 => 'one',2 => 'two')) set the
|
|
|
|
* options for field 'name'. ($content['options-name'] is possible too !!!)
|
|
|
|
* @param array $readonlys with field-names as keys for fields with should be readonly
|
|
|
|
* (eg. to implement ACL grants on field-level or to remove buttons not applicable)
|
|
|
|
* @param array $preserv with vars which should be transported to the $method-call (eg. an id) array('id' => $id) sets $_POST['id'] for the $method-call
|
|
|
|
* @param int $output_mode 0 = echo incl. navbar, 1 = return html, 2 = echo without navbar (eg. for popups)
|
2005-07-17 23:40:31 +02:00
|
|
|
* -1 = first time return html, after use 0 (echo html incl. navbar), eg. for home
|
2005-03-05 15:59:33 +01:00
|
|
|
* @param string $ignore_validation if not empty regular expression for validation-errors to ignore
|
2005-02-13 14:03:36 +01:00
|
|
|
* @param array $changes change made in the last call if looping, only used internaly by process_exec
|
2004-10-07 23:53:41 +02:00
|
|
|
* @return string html for $output_mode == 1, else nothing
|
|
|
|
*/
|
2005-03-05 15:59:33 +01:00
|
|
|
function exec($method,$content,$sel_options='',$readonlys='',$preserv='',$output_mode=0,$ignore_validation='',$changes='')
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
2005-11-09 21:50:45 +01:00
|
|
|
//echo "<br>globals[java_script] = '".$GLOBALS['egw_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']))
|
|
|
|
{
|
2005-11-09 21:50:45 +01:00
|
|
|
$GLOBALS['egw_info']['flags']['app_header'] = $content['app_header'];
|
2003-04-21 10:43:20 +02:00
|
|
|
}
|
2005-11-09 21:50:45 +01:00
|
|
|
if ($GLOBALS['egw_info']['flags']['currentapp'] != 'etemplate')
|
2002-10-06 02:20:32 +02:00
|
|
|
{
|
2005-11-09 21:50:45 +01:00
|
|
|
$GLOBALS['egw']->translation->add_app('etemplate'); // some extensions have own texts
|
2002-10-06 02:20:32 +02:00
|
|
|
}
|
2002-06-09 23:40:06 +02:00
|
|
|
$id = $this->appsession_id();
|
2006-03-16 15:20:57 +01:00
|
|
|
|
2007-03-13 14:46:50 +01:00
|
|
|
// initialise $GLOBALS['egw_info']['etemplate'], in case there are multiple eTemplates on a page
|
|
|
|
$GLOBALS['egw_info']['etemplate'] = array(
|
|
|
|
'name_forms' => $GLOBALS['egw_info']['etemplate']['name_forms'],
|
|
|
|
'validation_errors' => $GLOBALS['egw_info']['etemplate']['validation_errors'],
|
2007-04-05 09:27:41 +02:00
|
|
|
'hooked' => $GLOBALS['egw_info']['etemplate']['hooked'],
|
2007-03-13 14:46:50 +01:00
|
|
|
);
|
|
|
|
$this->name_form =& $GLOBALS['egw_info']['etemplate']['name_form'];
|
|
|
|
$this->name_forms =& $GLOBALS['egw_info']['etemplate']['name_forms'];
|
|
|
|
if (!is_array($this->name_forms)) $this->name_forms = array();
|
|
|
|
|
2006-03-16 15:20:57 +01:00
|
|
|
// use different form-names to allows multiple eTemplates in one page, eg. addressbook-view
|
|
|
|
$this->name_form = 'eTemplate';
|
|
|
|
if (in_array($this->name_form,$this->name_forms))
|
|
|
|
{
|
2007-03-13 14:46:50 +01:00
|
|
|
$this->name_form .= 1+count($this->name_forms);
|
|
|
|
$this->name_vars .= 1+count($this->name_forms);
|
2006-03-16 15:20:57 +01:00
|
|
|
}
|
|
|
|
$this->name_forms[] = $this->name_form;
|
2007-03-13 14:46:50 +01:00
|
|
|
|
2005-11-10 15:51:12 +01:00
|
|
|
$GLOBALS['egw_info']['etemplate']['output_mode'] = $output_mode; // let extensions "know" they are run eg. in a popup
|
2005-11-09 21:50:45 +01:00
|
|
|
$GLOBALS['egw_info']['etemplate']['form_options'] = ''; // might be set in show
|
|
|
|
$GLOBALS['egw_info']['etemplate']['to_process'] = array();
|
2007-03-13 14:46:50 +01:00
|
|
|
|
2005-04-15 00:35:24 +02:00
|
|
|
$html = $this->html->form($this->include_java_script(1).
|
2005-05-07 16:00:06 +02:00
|
|
|
$this->html->input_hidden(array(
|
|
|
|
'submit_button' => '',
|
|
|
|
'innerWidth' => '',
|
|
|
|
),'',False).
|
2007-03-13 14:46:50 +01:00
|
|
|
$this->show($this->complete_array_merge($content,$changes),$sel_options,$readonlys,$this->name_vars),array(
|
2003-08-28 16:31:11 +02:00
|
|
|
'etemplate_exec_id' => $id
|
2005-05-02 17:07:37 +02:00
|
|
|
),$this->sitemgr ? '' : '/etemplate/process_exec.php?menuaction='.$method,
|
2006-03-16 15:20:57 +01:00
|
|
|
'',$this->name_form,$GLOBALS['egw_info']['etemplate']['form_options'].
|
2005-05-07 16:00:06 +02:00
|
|
|
// dont set the width of popups!
|
2005-07-17 23:40:31 +02:00
|
|
|
($output_mode != 0 ? '' : ' onsubmit="this.innerWidth.value=window.innerWidth ? window.innerWidth : document.body.clientWidth;"'));
|
2005-11-09 21:50:45 +01:00
|
|
|
//echo "to_process="; _debug_array($GLOBALS['egw_info']['etemplate']['to_process']);
|
2005-11-10 15:51:12 +01:00
|
|
|
|
2005-05-02 17:07:37 +02:00
|
|
|
if ($this->sitemgr)
|
|
|
|
{
|
2006-08-13 20:06:10 +02:00
|
|
|
$GLOBALS['egw_info']['flags']['java_script'] .= $this->include_java_script(2);
|
2005-05-02 17:07:37 +02:00
|
|
|
}
|
|
|
|
elseif (!$this->xslt)
|
2003-08-19 01:15:59 +02:00
|
|
|
{
|
2006-04-05 17:24:46 +02:00
|
|
|
$hooked = isset($GLOBALS['egw_info']['etemplate']['content']) ? $GLOBALS['egw_info']['etemplate']['content'] :
|
|
|
|
$GLOBALS['egw']->template->get_var('phpgw_body');
|
|
|
|
|
2005-11-09 21:50:45 +01:00
|
|
|
if (!@$GLOBALS['egw_info']['etemplate']['hooked'] && (int) $output_mode != 1 && (int) $output_mode != -1) // not just returning the html
|
2003-08-19 01:15:59 +02:00
|
|
|
{
|
2005-11-09 21:50:45 +01:00
|
|
|
$GLOBALS['egw_info']['flags']['java_script'] .= $this->include_java_script(2);
|
2007-03-09 12:25:08 +01:00
|
|
|
|
2007-03-07 13:30:17 +01:00
|
|
|
if ($GLOBALS['egw_info']['flags']['currentapp'] != 'etemplate')
|
|
|
|
{
|
|
|
|
$css_file = '/etemplate/templates/'.$GLOBALS['egw_info']['server']['template_set'].'/app.css';
|
|
|
|
if (!file_exists(EGW_SERVER_ROOT.$css_file))
|
|
|
|
{
|
|
|
|
$css_file = '/etemplate/templates/default/app.css';
|
|
|
|
}
|
2007-03-09 12:25:08 +01:00
|
|
|
$GLOBALS['egw_info']['flags']['css'] .= "\n\t\t</style>\n\t\t".'<link href="'.$GLOBALS['egw_info']['server']['webserver_url'].
|
|
|
|
$css_file.'?'.filemtime(EGW_SERVER_ROOT.$css_file).'" type="text/css" rel="StyleSheet" />'."\n\t\t<style>\n\t\t\t";
|
2007-03-07 13:30:17 +01:00
|
|
|
}
|
2007-03-09 12:25:08 +01:00
|
|
|
|
2005-11-09 21:50:45 +01:00
|
|
|
$GLOBALS['egw']->common->egw_header();
|
2003-08-19 01:15:59 +02:00
|
|
|
}
|
2006-04-05 17:24:46 +02:00
|
|
|
elseif (!isset($GLOBALS['egw_info']['etemplate']['content']))
|
2003-08-19 01:15:59 +02:00
|
|
|
{
|
|
|
|
$html = $this->include_java_script(2).$html; // better than nothing
|
|
|
|
}
|
2006-04-05 17:24:46 +02:00
|
|
|
// saving the etemplate content for other hooked etemplate apps (atm. infolog hooked into addressbook)
|
|
|
|
$GLOBALS['egw_info']['etemplate']['content'] =& $html;
|
2003-08-19 01:15:59 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-11-09 21:50:45 +01:00
|
|
|
$hooked = $GLOBALS['egw']->xslttpl->get_var('phpgw');
|
2003-08-19 01:15:59 +02:00
|
|
|
$hooked = $hooked['body_data'];
|
2005-11-09 21:50:45 +01:00
|
|
|
$GLOBALS['egw']->xslttpl->set_var('phpgw',array('java_script' => $GLOBALS['egw_info']['flags']['java_script'].$this->include_java_script(2)));
|
2003-08-19 01:15:59 +02:00
|
|
|
}
|
2005-07-17 23:40:31 +02:00
|
|
|
//echo "<p>uietemplate::exec($method,...) after show: sitemgr=$this->sitemgr, xslt=$this->xslt, hooked=$hooked, output_mode=$output_mode</p>\n";
|
2003-12-09 01:03:41 +01:00
|
|
|
|
2005-07-17 23:40:31 +02:00
|
|
|
if (!$this->sitemgr && (int) $output_mode != 1 && (int) $output_mode != -1) // NOT returning html
|
2005-02-23 15:33:00 +01:00
|
|
|
{
|
|
|
|
if (!$this->xslt)
|
|
|
|
{
|
2005-11-09 21:50:45 +01:00
|
|
|
if (!@$GLOBALS['egw_info']['etemplate']['hooked'])
|
2005-02-23 15:33:00 +01:00
|
|
|
{
|
|
|
|
if((int) $output_mode != 2)
|
|
|
|
{
|
|
|
|
echo parse_navbar();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
echo '<div id="divMain">'."\n";
|
2005-11-12 14:20:20 +01:00
|
|
|
if ($GLOBALS['egw_info']['user']['apps']['manual']) // adding a manual icon to every popup
|
2005-11-09 17:56:23 +01:00
|
|
|
{
|
|
|
|
$manual =& new etemplate('etemplate.popup.manual');
|
|
|
|
echo $manual->show(array());
|
|
|
|
unset($manual);
|
2006-10-09 19:36:40 +02:00
|
|
|
echo '<style type="text/css">.ajax-loader { position: absolute; right: 27px; top: 24px; display: none; }</style>'."\n";
|
|
|
|
echo '<div class="ajax-loader">'.$this->html->image('phpgwapi','ajax-loader') . '</div>';
|
2005-11-09 17:56:23 +01:00
|
|
|
}
|
2005-02-23 15:33:00 +01:00
|
|
|
}
|
|
|
|
}
|
2005-11-09 21:50:45 +01:00
|
|
|
echo $GLOBALS['egw_info']['etemplate']['hook_content'].$html;
|
2005-02-24 22:02:24 +01:00
|
|
|
|
2006-12-07 13:46:46 +01:00
|
|
|
if (!$GLOBALS['egw_info']['etemplate']['hooked'] &&
|
|
|
|
(!isset($_GET['menuaction']) ||
|
|
|
|
strpos($_SERVER['PHP_SELF'],'process_exec.php')!==false))
|
2005-02-23 15:33:00 +01:00
|
|
|
{
|
|
|
|
if((int) $output_mode == 2)
|
|
|
|
{
|
|
|
|
echo "</div>\n";
|
|
|
|
}
|
2005-11-09 21:50:45 +01:00
|
|
|
$GLOBALS['egw']->common->egw_footer();
|
2005-02-23 15:33:00 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// need to add some logic here to support popups (output_mode==2) for xslt, but who cares ...
|
2005-11-09 21:50:45 +01:00
|
|
|
$GLOBALS['egw']->xslttpl->set_var('phpgw',array('body_data' => $html));
|
2005-02-23 15:33:00 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
$this->save_appsession($this->as_array(2) + 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,
|
2005-11-09 21:50:45 +01:00
|
|
|
'extension_data' => $GLOBALS['egw_info']['etemplate']['extension_data'],
|
|
|
|
'to_process' => $GLOBALS['egw_info']['etemplate']['to_process'],
|
|
|
|
'java_script' => $GLOBALS['egw_info']['etemplate']['java_script'],
|
2006-05-18 18:19:50 +02:00
|
|
|
'java_script_from_flags' => $GLOBALS['egw_info']['flags']['java_script'],
|
|
|
|
'java_script_body_tags' => $GLOBALS['egw']->js->body,
|
2005-11-09 21:50:45 +01:00
|
|
|
'dom_enabled' => $GLOBALS['egw_info']['etemplate']['dom_enabled'],
|
|
|
|
'hooked' => $hooked != '' ? $hooked : $GLOBALS['egw_info']['etemplate']['hook_content'],
|
2006-04-05 17:24:46 +02:00
|
|
|
'hook_app' => $hooked ? $GLOBALS['egw_info']['flags']['currentapp'] : $GLOBALS['egw_info']['etemplate']['hook_app'],
|
2005-11-09 21:50:45 +01:00
|
|
|
'app_header' => $GLOBALS['egw_info']['flags']['app_header'],
|
2005-07-17 23:40:31 +02:00
|
|
|
'output_mode' => $output_mode != -1 ? $output_mode : 0,
|
2005-02-18 23:44:42 +01:00
|
|
|
'session_used' => 0,
|
2005-03-05 15:59:33 +01:00
|
|
|
'ignore_validation' => $ignore_validation,
|
2005-05-02 17:07:37 +02:00
|
|
|
'method' => $method,
|
2007-03-13 14:46:50 +01:00
|
|
|
'name_vars' => $this->name_vars,
|
2002-06-09 23:40:06 +02:00
|
|
|
),$id);
|
2002-06-07 23:26:05 +02:00
|
|
|
|
2005-07-17 23:40:31 +02:00
|
|
|
if ($this->sitemgr || (int) $output_mode == 1 || (int) $output_mode == -1) // return html
|
2003-07-06 22:07:19 +02:00
|
|
|
{
|
2006-04-05 17:24:46 +02:00
|
|
|
return $html;
|
2003-07-06 22:07:19 +02:00
|
|
|
}
|
2002-02-06 10:03:11 +01:00
|
|
|
}
|
|
|
|
|
2005-03-05 15:59:33 +01:00
|
|
|
/**
|
|
|
|
* Check if we have not ignored validation errors
|
|
|
|
*
|
2006-09-12 17:12:39 +02:00
|
|
|
* @param string $ignore_validation='' if not empty regular expression for validation-errors to ignore
|
2007-03-13 14:46:50 +01:00
|
|
|
* @param string $cname=null name-prefix, which need to be ignored, default $this->name_vars
|
2005-03-05 15:59:33 +01:00
|
|
|
* @return boolean true if there are not ignored validation errors, false otherwise
|
|
|
|
*/
|
2007-03-13 14:46:50 +01:00
|
|
|
function validation_errors($ignore_validation='',$cname=null)
|
2005-03-05 15:59:33 +01:00
|
|
|
{
|
2007-03-13 14:46:50 +01:00
|
|
|
if (is_null($cname)) $cname = $this->name_vars;
|
2005-11-09 21:50:45 +01:00
|
|
|
//echo "<p>uietemplate::validation_errors('$ignore_validation','$cname') validation_error="; _debug_array($GLOBALS['egw_info']['etemplate']['validation_errors']);
|
|
|
|
if (!$ignore_validation) return count($GLOBALS['egw_info']['etemplate']['validation_errors']) > 0;
|
2005-03-05 15:59:33 +01:00
|
|
|
|
2005-11-09 21:50:45 +01:00
|
|
|
foreach($GLOBALS['egw_info']['etemplate']['validation_errors'] as $name => $error)
|
2005-03-05 15:59:33 +01:00
|
|
|
{
|
|
|
|
if ($cname) $name = preg_replace('/^'.$cname.'\[([^\]]+)\](.*)$/','\\1\\2',$name);
|
|
|
|
|
2007-01-27 05:02:21 +01:00
|
|
|
// treat $ignoare_validation only as regular expression, if it starts with a slash
|
2007-02-19 06:29:17 +01:00
|
|
|
if ($ignore_validation[0] == '/' && !preg_match($ignore_validation,$name) ||
|
|
|
|
$ignore_validation[0] != '/' && $ignore_validation != $name)
|
2005-03-05 15:59:33 +01:00
|
|
|
{
|
|
|
|
//echo "<p>uietemplate::validation_errors('$ignore_validation','$cname') name='$name' ($error) not ignored!!!</p>\n";
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
//echo "<p>uietemplate::validation_errors('$ignore_validation','$cname') name='$name' ($error) ignored</p>\n";
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2004-10-07 23:53:41 +02:00
|
|
|
/**
|
|
|
|
* Makes the necessary adjustments to _POST before it calls the app's method
|
|
|
|
*
|
|
|
|
* This function is only to submit forms to, create with exec.
|
|
|
|
* All eTemplates / forms executed with exec are submited to this function
|
2005-02-08 13:29:06 +01:00
|
|
|
* via /etemplate/process_exec.php?menuaction=<callback>. We cant use the global index.php as
|
|
|
|
* it would set some constants to etemplate instead of the calling app.
|
|
|
|
* process_exec then calls process_show for the eTemplate (to adjust the content of the _POST) and
|
2004-10-07 23:53:41 +02:00
|
|
|
* ExecMethod's the given callback from the app with the content of the form as first argument.
|
2005-05-02 17:07:37 +02:00
|
|
|
*
|
|
|
|
* @return mixed false if no sessiondata and $this->sitemgr, else the returnvalue of exec of the method-calls
|
2004-10-07 23:53:41 +02:00
|
|
|
*/
|
2006-12-17 15:15:10 +01:00
|
|
|
function process_exec($etemplate_exec_id = null, $submit_button = null, $exec = null, $type = 'regular' )
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
2006-03-29 21:25:00 +02:00
|
|
|
if(!$etemplate_exec_id) $etemplate_exec_id = $_POST['etemplate_exec_id'];
|
|
|
|
if(!$submit_button) $submit_button = $_POST['submit_button'];
|
|
|
|
if(!$exec) $exec = $_POST;
|
|
|
|
|
2003-08-28 16:31:11 +02:00
|
|
|
//echo "process_exec: _POST ="; _debug_array($_POST);
|
2006-03-29 21:25:00 +02:00
|
|
|
$session_data = $this->get_appsession($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
|
|
|
|
2006-03-29 21:25:00 +02:00
|
|
|
if (!$etemplate_exec_id || !is_array($session_data) || count($session_data) < 10)
|
2003-08-28 16:31:11 +02:00
|
|
|
{
|
2005-05-02 17:07:37 +02:00
|
|
|
if ($this->sitemgr) return false;
|
2005-02-24 22:02:24 +01:00
|
|
|
//echo "uitemplate::process_exec() id='$_POST[etemplate_exec_id]' invalid session-data !!!"; _debug_array($_SESSION);
|
2003-08-28 16:31:11 +02:00
|
|
|
// this prevents an empty screen, if the sessiondata gets lost somehow
|
|
|
|
$this->location(array('menuaction' => $_GET['menuaction']));
|
|
|
|
}
|
2007-03-13 14:46:50 +01:00
|
|
|
$this->name_vars = $session_data['name_vars'];
|
2006-03-29 21:25:00 +02:00
|
|
|
if (isset($submit_button) && !empty($submit_button))
|
2004-02-14 19:48:53 +01:00
|
|
|
{
|
2006-03-29 21:25:00 +02:00
|
|
|
$this->set_array($exec,$submit_button,'pressed');
|
2004-02-14 19:48:53 +01:00
|
|
|
}
|
2007-03-13 14:46:50 +01:00
|
|
|
$content = $exec[$this->name_vars];
|
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);
|
2005-11-09 21:50:45 +01:00
|
|
|
$GLOBALS['egw_info']['etemplate']['extension_data'] = $session_data['extension_data'];
|
|
|
|
$GLOBALS['egw_info']['etemplate']['java_script'] = $session_data['java_script'] || $_POST['java_script'];
|
|
|
|
$GLOBALS['egw_info']['etemplate']['dom_enabled'] = $session_data['dom_enabled'] || $_POST['dom_enabled'];
|
|
|
|
//echo "globals[java_script] = '".$GLOBALS['egw_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);
|
2005-11-09 21:50:45 +01:00
|
|
|
if ($GLOBALS['egw_info']['flags']['currentapp'] != 'etemplate')
|
2004-08-01 21:26:33 +02:00
|
|
|
{
|
2005-11-09 21:50:45 +01:00
|
|
|
$GLOBALS['egw']->translation->add_app('etemplate'); // some extensions have own texts
|
2004-08-01 21:26:33 +02:00
|
|
|
}
|
2007-03-13 14:46:50 +01:00
|
|
|
$this->process_show($content,$session_data['to_process'],$this->name_vars,$type);
|
2002-02-06 10:03:11 +01:00
|
|
|
|
2005-11-09 21:50:45 +01:00
|
|
|
$GLOBALS['egw_info']['etemplate']['loop'] |= !$this->canceled && $this->button_pressed &&
|
2005-03-05 15:59:33 +01:00
|
|
|
$this->validation_errors($session_data['ignore_validation']); // set by process_show
|
2004-04-05 03:33:23 +02:00
|
|
|
|
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
|
|
|
|
2005-11-09 21:50:45 +01:00
|
|
|
if ($GLOBALS['egw_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
|
|
|
|
{
|
2004-10-07 23:53:41 +02:00
|
|
|
if (!$this->xslt)
|
2002-10-26 20:45:37 +02:00
|
|
|
{
|
2005-11-09 21:50:45 +01:00
|
|
|
$GLOBALS['egw_info']['etemplate']['hook_content'] = $session_data['hooked'];
|
2006-04-05 17:24:46 +02:00
|
|
|
$GLOBALS['egw_info']['flags']['currentapp'] = $GLOBALS['egw_info']['etemplate']['hook_app'] = $session_data['hook_app'];
|
2002-10-26 20:45:37 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-11-09 21:50:45 +01:00
|
|
|
$GLOBALS['egw']->xslttpl->set_var('phpgw',array('body_data' => $session_data['hooked']));
|
2002-10-26 20:45:37 +02:00
|
|
|
}
|
2002-10-16 02:19:36 +02:00
|
|
|
}
|
2004-02-05 14:31:54 +01:00
|
|
|
if (!empty($session_data['app_header']))
|
|
|
|
{
|
2005-11-09 21:50:45 +01:00
|
|
|
$GLOBALS['egw_info']['flags']['app_header'] = $session_data['app_header'];
|
2004-02-05 14:31:54 +01:00
|
|
|
}
|
2006-05-18 18:19:50 +02:00
|
|
|
|
|
|
|
$GLOBALS['egw_info']['flags']['java_script'] .= $session_data['java_script_from_flags'];
|
|
|
|
if (!empty($session_data['java_script_body_tags']))
|
|
|
|
{
|
2006-10-22 13:37:38 +02:00
|
|
|
if( !is_object($GLOBALS['egw']->js))
|
2006-05-18 18:19:50 +02:00
|
|
|
{
|
2006-10-22 13:37:38 +02:00
|
|
|
$GLOBALS['egw']->js =& CreateObject('phpgwapi.javascript');
|
2006-05-18 18:19:50 +02:00
|
|
|
}
|
|
|
|
foreach ($session_data['java_script_body_tags'] as $tag => $code)
|
|
|
|
{
|
2006-10-22 13:37:38 +02:00
|
|
|
//error_log($GLOBALS['egw']->js->body[$tag]);
|
2006-05-18 18:19:50 +02:00
|
|
|
$GLOBALS['egw']->js->body[$tag] .= $code;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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);
|
2005-05-02 17:07:37 +02:00
|
|
|
return $this->exec($session_data['method'],$session_data['content'],$session_data['sel_options'],
|
2005-03-05 15:59:33 +01:00
|
|
|
$session_data['readonlys'],$session_data['preserv'],$session_data['output_mode'],
|
|
|
|
$session_data['ignore_validation'],$content);
|
2002-06-09 23:40:06 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-09-27 15:09:28 +02:00
|
|
|
//echo "<p>process_exec($this->name): calling $session_data[method]</p>\n";
|
2005-05-02 17:07:37 +02:00
|
|
|
return ExecMethod($session_data['method'],$this->complete_array_merge($session_data['preserv'],$content));
|
2002-06-09 23:40:06 +02:00
|
|
|
}
|
2002-02-06 10:03:11 +01:00
|
|
|
}
|
|
|
|
|
2005-06-16 23:44:51 +02:00
|
|
|
/**
|
|
|
|
* process the values transfered with the javascript function values2url
|
|
|
|
*
|
|
|
|
* The returned array contains the preserved values overwritten (only!) with the variables named in values2url
|
|
|
|
*
|
|
|
|
* @return array/boolean content array or false on error
|
|
|
|
*/
|
|
|
|
function process_values2url()
|
|
|
|
{
|
|
|
|
//echo "process_exec: _GET ="; _debug_array($_GET);
|
|
|
|
$session_data = $this->get_appsession($_GET['etemplate_exec_id']);
|
|
|
|
//echo "<p>process_exec: session_data ="; _debug_array($session_data);
|
|
|
|
|
|
|
|
if (!$_GET['etemplate_exec_id'] || !is_array($session_data) || count($session_data) < 10)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2007-03-13 14:46:50 +01:00
|
|
|
$this->name_vars = $session_data['name_vars'];
|
2005-11-09 21:50:45 +01:00
|
|
|
$GLOBALS['egw_info']['etemplate']['extension_data'] = $session_data['extension_data'];
|
2005-06-16 23:44:51 +02:00
|
|
|
|
2007-03-13 14:46:50 +01:00
|
|
|
$content = $_GET[$this->name_vars];
|
2005-06-16 23:44:51 +02:00
|
|
|
if (!is_array($content))
|
|
|
|
{
|
|
|
|
$content = array();
|
|
|
|
}
|
2007-03-13 14:46:50 +01:00
|
|
|
$this->process_show($content,$session_data['to_process'],$this->name_vars);
|
2005-06-16 23:44:51 +02:00
|
|
|
|
|
|
|
return $this->complete_array_merge($session_data['preserv'],$content);
|
|
|
|
}
|
|
|
|
|
2005-02-08 13:29:06 +01:00
|
|
|
/**
|
|
|
|
* 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 could 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.
|
|
|
|
*
|
|
|
|
* @internal
|
2005-02-13 14:03:36 +01:00
|
|
|
* @param array $content with content for the cells, keys are the names given in the cells/form elements
|
|
|
|
* @param array $sel_options with options for the selectboxes, keys are the name of the selectbox
|
|
|
|
* @param array $readonlys with names of cells/form-elements to be not allowed to change
|
|
|
|
* This is to facilitate complex ACL's which denies access on field-level !!!
|
|
|
|
* @param string $cname basename of names for form-elements, means index in $_POST
|
|
|
|
* eg. $cname='cont', element-name = 'name' returned content in $_POST['cont']['name']
|
|
|
|
* @param string $show_c name/index for name expansion
|
|
|
|
* @param string $show_row name/index for name expansion
|
2005-02-08 13:29:06 +01:00
|
|
|
* @return string the generated HTML
|
|
|
|
*/
|
2005-02-16 00:22:10 +01:00
|
|
|
function show($content,$sel_options='',$readonlys='',$cname='',$show_c=0,$show_row=0)
|
2002-10-10 13:29:36 +02:00
|
|
|
{
|
2005-02-08 13:29:06 +01:00
|
|
|
if (!$sel_options)
|
2002-10-10 13:29:36 +02:00
|
|
|
{
|
2005-02-08 13:29:06 +01:00
|
|
|
$sel_options = array();
|
2002-10-10 13:29:36 +02:00
|
|
|
}
|
2006-01-11 06:25:49 +01:00
|
|
|
// make it globaly availible for show_cell and show_grid, or extensions
|
2005-03-14 00:38:37 +01:00
|
|
|
$this->sel_options =& $sel_options;
|
|
|
|
|
2005-02-08 13:29:06 +01:00
|
|
|
if (!$readonlys)
|
2002-10-10 13:29:36 +02:00
|
|
|
{
|
2005-02-08 13:29:06 +01:00
|
|
|
$readonlys = array();
|
2002-10-10 13:29:36 +02:00
|
|
|
}
|
2005-02-20 22:45:24 +01:00
|
|
|
if (++$this->already_showed > 1) return ''; // prefens infinit self-inclusion
|
|
|
|
|
2005-02-08 13:29:06 +01:00
|
|
|
if (is_int($this->debug) && $this->debug >= 1 || $this->name && $this->debug == $this->name)
|
2002-10-10 13:29:36 +02:00
|
|
|
{
|
2005-02-08 13:29:06 +01:00
|
|
|
echo "<p>etemplate.show($this->name): $cname =\n"; _debug_array($content);
|
2005-03-07 22:56:30 +01:00
|
|
|
echo "readonlys="; _debug_array($readonlys);
|
2002-10-10 13:29:36 +02:00
|
|
|
}
|
2005-02-08 13:29:06 +01:00
|
|
|
if (!is_array($content))
|
|
|
|
{
|
|
|
|
$content = array(); // happens if incl. template has no content
|
|
|
|
}
|
2006-01-11 06:25:49 +01:00
|
|
|
// make the content availible as class-var for extensions
|
|
|
|
$this->content =& $content;
|
|
|
|
|
2005-02-08 13:29:06 +01:00
|
|
|
$html = "\n\n<!-- BEGIN eTemplate $this->name -->\n\n";
|
2005-11-09 21:50:45 +01:00
|
|
|
if (!$GLOBALS['egw_info']['etemplate']['styles_included'][$this->name])
|
2005-02-08 13:29:06 +01:00
|
|
|
{
|
2005-11-09 21:50:45 +01:00
|
|
|
$GLOBALS['egw_info']['etemplate']['styles_included'][$this->name] = True;
|
2005-02-08 13:29:06 +01:00
|
|
|
$html .= $this->html->style($this->style)."\n\n";
|
|
|
|
}
|
2005-02-16 00:22:10 +01:00
|
|
|
$path = '/';
|
|
|
|
foreach ($this->children as $n => $child)
|
2005-02-08 13:29:06 +01:00
|
|
|
{
|
2005-06-19 10:31:11 +02:00
|
|
|
$h = $this->show_cell($child,$content,$readonlys,$cname,$show_c,$show_row,$nul,$class,$path.$n);
|
|
|
|
$html .= $class || $child['align'] ? $this->html->div($h,$this->html->formatOptions(array(
|
|
|
|
$class,
|
|
|
|
$child['align'],
|
|
|
|
),'class,align')) : $h;
|
2005-02-08 13:29:06 +01:00
|
|
|
}
|
|
|
|
return $html."<!-- END eTemplate $this->name -->\n\n";
|
2002-10-10 13:29:36 +02:00
|
|
|
}
|
2005-02-08 13:29:06 +01:00
|
|
|
|
2004-10-07 23:53:41 +02:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*
|
2005-02-08 13:29:06 +01:00
|
|
|
* @internal
|
2005-02-13 14:03:36 +01:00
|
|
|
* @param array $grid representing a grid
|
|
|
|
* @param array $content with content for the cells, keys are the names given in the cells/form elements
|
|
|
|
* @param array $readonlys with names of cells/form-elements to be not allowed to change
|
|
|
|
* This is to facilitate complex ACL's which denies access on field-level !!!
|
|
|
|
* @param string $cname basename of names for form-elements, means index in $_POST
|
|
|
|
* eg. $cname='cont', element-name = 'name' returned content in $_POST['cont']['name']
|
|
|
|
* @param string $show_c name/index for name expansion
|
|
|
|
* @param string $show_row name/index for name expansion
|
2005-02-16 00:22:10 +01:00
|
|
|
* @param string $path path in the widget tree
|
2004-10-07 23:53:41 +02:00
|
|
|
* @return string the generated HTML
|
|
|
|
*/
|
2005-03-14 00:38:37 +01:00
|
|
|
function show_grid(&$grid,$content,$readonlys='',$cname='',$show_c=0,$show_row=0,$path='')
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
2002-02-14 15:06:53 +01:00
|
|
|
if (!$readonlys)
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
|
|
|
$readonlys = array();
|
|
|
|
}
|
2005-02-18 23:44:42 +01:00
|
|
|
if (is_int($this->debug) && $this->debug >= 2 || $grid['name'] && $this->debug == $grid['name'] ||
|
|
|
|
$this->name && $this->debug == $this->name)
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
2005-02-08 13:29:06 +01:00
|
|
|
echo "<p>etemplate.show_grid($grid[name]): $cname =\n"; _debug_array($content);
|
2002-02-06 10:03:11 +01:00
|
|
|
}
|
|
|
|
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
|
|
|
);
|
2005-06-11 22:13:38 +02:00
|
|
|
$rows = array();
|
|
|
|
|
2005-02-08 13:29:06 +01:00
|
|
|
$data = &$grid['data'];
|
|
|
|
reset($data);
|
|
|
|
if (isset($data[0]))
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
2005-02-08 13:29:06 +01:00
|
|
|
list(,$opts) = each($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
|
|
|
}
|
2005-04-22 15:51:59 +02:00
|
|
|
$max_cols = $grid['cols'];
|
2005-02-08 13:29:06 +01:00
|
|
|
for ($r = 0; $row = 1+$r /*list($row,$cols) = each($data)*/; ++$r)
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
2005-02-08 13:29:06 +01:00
|
|
|
if (!(list($r_key) = each($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) ||
|
2005-11-09 21:50:45 +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
|
|
|
|
{
|
2005-02-08 13:29:06 +01:00
|
|
|
$cols = &$data[$r_key];
|
2002-10-10 13:29:36 +02:00
|
|
|
list($height,$disabled) = explode(',',$opts["h$row"]);
|
2005-02-08 13:29:06 +01:00
|
|
|
$class = /*TEST-RB$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
|
|
|
}
|
2005-05-19 15:16:52 +02:00
|
|
|
$rows[".$row"] .= $this->html->formatOptions($height,'height');
|
2002-10-12 18:37:44 +02:00
|
|
|
list($cl) = explode(',',$class);
|
2006-12-07 13:46:46 +01:00
|
|
|
if ($cl == '@' || $cl && strpos($cl,'$') !== false)
|
2006-03-27 00:17:55 +02:00
|
|
|
{
|
|
|
|
$cl = $this->expand_name($cl,0,$r,$content['.c'],$content['.row'],$content);
|
|
|
|
}
|
2007-01-08 16:53:27 +01:00
|
|
|
if ($cl == 'nmr' || substr($cl,0,3) == 'row') // allow to have further classes behind row
|
2002-10-12 18:37:44 +02:00
|
|
|
{
|
2007-01-08 16:53:27 +01:00
|
|
|
$cl = 'row_'.($nmr_alternate++ & 1 ? 'off' : 'on').substr($cl,3); // alternate color
|
2002-10-12 18:37:44 +02:00
|
|
|
}
|
|
|
|
$cl = isset($this->class_conf[$cl]) ? $this->class_conf[$cl] : $cl;
|
2005-05-19 15:16:52 +02:00
|
|
|
$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
|
|
|
{
|
2005-04-22 15:51:59 +02:00
|
|
|
// only check if the max. column-number reached so far is exeeded
|
|
|
|
// otherwise the rows have a differen number of cells and it saved a lot checks
|
|
|
|
if ($c >= $max_cols)
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
2005-04-22 15:51:59 +02:00
|
|
|
if (!$this->autorepeat_idx($cell,$c,$r,$idx,$idx_cname,True) ||
|
|
|
|
!$this->isset_array($content,$idx))
|
|
|
|
{
|
|
|
|
break; // no auto-col-repeat
|
|
|
|
}
|
|
|
|
$max_cols = $c+1;
|
2002-02-06 10:03:11 +01:00
|
|
|
}
|
|
|
|
}
|
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
|
|
|
}
|
2005-02-08 13:29:06 +01:00
|
|
|
/*TEST-RB
|
2002-10-12 18:37:44 +02:00
|
|
|
if ($cell['type'] == 'template' && $cell['onchange'])
|
|
|
|
{
|
|
|
|
$cell['tr_class'] = $cl;
|
2005-02-08 13:29:06 +01:00
|
|
|
}*/
|
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
|
|
|
}
|
2005-03-14 00:38:37 +01:00
|
|
|
$row_data[$col] = $this->show_cell($cell,$content,$readonlys,$cname,$c,$r,$span,$cl,$path.'/'.$r_key.$c_key);
|
2003-12-09 01:03:41 +01:00
|
|
|
|
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;
|
|
|
|
}
|
2005-05-19 15:16:52 +02:00
|
|
|
// can only be set via source at the moment
|
|
|
|
if (strlen($cell['onclick']) > 1 && $cell['type'] != 'button')
|
2003-04-13 21:14:50 +02:00
|
|
|
{
|
2006-12-19 14:36:54 +01:00
|
|
|
$row_data[".$col"] .= ' onclick="'.$this->js_pseudo_funcs($cell['onclick'],$cname).'"' .
|
2005-05-19 15:16:52 +02:00
|
|
|
($cell['id'] ? ' id="'.$cell['id'].'"' : '');
|
|
|
|
}
|
2002-02-06 10:03:11 +01:00
|
|
|
$colspan = $span == 'all' ? $this->cols-$c : 0+$span;
|
|
|
|
if ($colspan > 1)
|
|
|
|
{
|
2005-05-19 15:16:52 +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
|
|
|
|
{
|
2005-05-19 15:16:52 +02:00
|
|
|
$row_data[".$col"] .= " width=\"$width\"";
|
2002-10-18 22:20:35 +02:00
|
|
|
$opts[$col] = "0,$disable";
|
|
|
|
}
|
2002-02-06 10:03:11 +01:00
|
|
|
}
|
2005-05-19 15:16:52 +02:00
|
|
|
$row_data[".$col"] .= $this->html->formatOptions($cell['align']?$cell['align']:'left','align');
|
2005-06-02 16:44:49 +02:00
|
|
|
// allow to set further attributes in the tablecell, beside the class
|
|
|
|
if (is_array($cl))
|
|
|
|
{
|
|
|
|
foreach($cl as $attr => $val)
|
|
|
|
{
|
|
|
|
if ($attr != 'class' && $val)
|
|
|
|
{
|
|
|
|
$row_data['.'.$col] .= ' '.$attr.'="'.$val.'"';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$cl = $cl['class'];
|
|
|
|
}
|
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);
|
2005-05-25 17:09:47 +02:00
|
|
|
// else the class is set twice, in the table and the table-cell, which is not good for borders
|
|
|
|
if ($cl && $cell['type'] != 'template' && $cell['type'] != 'grid')
|
|
|
|
{
|
|
|
|
$row_data[".$col"] .= $this->html->formatOptions($cl,'class');
|
|
|
|
}
|
2002-02-06 10:03:11 +01:00
|
|
|
}
|
|
|
|
$rows[$row] = $row_data;
|
|
|
|
}
|
2006-09-29 21:47:29 +02:00
|
|
|
if (!$rows) return '';
|
2005-02-18 23:44:42 +01:00
|
|
|
|
2005-05-19 15:16:52 +02:00
|
|
|
list($width,$height,,,,,$overflow) = $options = explode(',',$grid['size']);
|
|
|
|
if ($overflow && $height)
|
|
|
|
{
|
|
|
|
$options[1] = ''; // set height in div only
|
|
|
|
}
|
2005-05-21 09:41:09 +02:00
|
|
|
$html = $this->html->table($rows,$this->html->formatOptions($options,'width,height,border,class,cellspacing,cellpadding').
|
2006-09-29 21:47:29 +02:00
|
|
|
$this->html->formatOptions($grid['span'],',class').
|
|
|
|
$this->html->formatOptions($grid['name']?$this->form_name($cname,$grid['name']):'','id'));
|
2002-06-10 23:34:58 +02:00
|
|
|
|
2002-09-29 15:01:40 +02:00
|
|
|
if (!empty($overflow)) {
|
2005-05-20 18:49:54 +02:00
|
|
|
if (is_numeric($height)) $height .= 'px';
|
|
|
|
if (is_numeric($width)) $width .= 'px';
|
2005-05-19 15:16:52 +02:00
|
|
|
$div_style=' style="'.($width?"width: $width; ":'').($height ? "height: $height; ":'')."overflow: $overflow;\"";
|
2002-09-29 15:01:40 +02:00
|
|
|
$html = $this->html->div($html,$div_style);
|
2003-08-28 16:31:11 +02:00
|
|
|
}
|
2005-02-08 13:29:06 +01:00
|
|
|
return "\n\n<!-- BEGIN grid $grid[name] -->\n$html<!-- END grid $grid[name] -->\n\n";
|
2002-02-06 10:03:11 +01:00
|
|
|
}
|
2005-02-16 00:22:10 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* build the name of a form-element from a basename and name
|
|
|
|
*
|
|
|
|
* name and basename can contain sub-indices in square bracets, eg. basename="base[basesub1][basesub2]"
|
|
|
|
* and name = "name[sub]" gives "base[basesub1][basesub2][name][sub]"
|
|
|
|
*
|
|
|
|
* @param string $cname basename
|
|
|
|
* @param string $name name
|
|
|
|
* @return string complete form-name
|
|
|
|
*/
|
|
|
|
function form_name($cname,$name)
|
|
|
|
{
|
2006-04-06 07:10:32 +02:00
|
|
|
if(is_object($name)) return '';
|
|
|
|
|
2005-02-16 00:22:10 +01:00
|
|
|
$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).']';
|
|
|
|
}
|
|
|
|
return $form_name;
|
|
|
|
}
|
2002-02-06 10:03:11 +01:00
|
|
|
|
2004-10-07 23:53:41 +02:00
|
|
|
/**
|
2005-11-10 15:51:12 +01:00
|
|
|
* generates HTML for one widget (input-field / cell)
|
2004-10-07 23:53:41 +02:00
|
|
|
*
|
|
|
|
* calls show to generate included eTemplates. Again only an INTERMAL function.
|
|
|
|
*
|
|
|
|
* @internal
|
2005-02-13 14:03:36 +01:00
|
|
|
* @param array $cell with data of the cell: name, type, ...
|
|
|
|
* @param array $content with content for the cells, keys are the names given in the cells/form elements
|
|
|
|
* @param array $readonlys with names of cells/form-elements to be not allowed to change
|
|
|
|
* This is to facilitate complex ACL's which denies access on field-level !!!
|
|
|
|
* @param string $cname basename of names for form-elements, means index in $_POST
|
|
|
|
* eg. $cname='cont', element-name = 'name' returned content in $_POST['cont']['name']
|
|
|
|
* @param string $show_c name/index for name expansion
|
|
|
|
* @param string $show_row name/index for name expansion
|
|
|
|
* @param string &$span on return number of cells to span or 'all' for the rest (only used for grids)
|
|
|
|
* @param string &$class on return the css class of the cell, to be set in the <td> tag
|
2005-02-16 00:22:10 +01:00
|
|
|
* @param string $path path in the widget tree
|
2005-02-13 14:03:36 +01:00
|
|
|
* @return string the generated HTML
|
2002-02-06 10:03:11 +01:00
|
|
|
*/
|
2005-03-14 00:38:37 +01:00
|
|
|
function show_cell($cell,$content,$readonlys,$cname,$show_c,$show_row,&$span,&$class,$path='')
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
2005-02-20 22:45:24 +01:00
|
|
|
if ($this->debug && (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
|
|
|
|
|
2005-11-10 15:51:12 +01:00
|
|
|
if ($cell['name']{0} == '@' && $cell['type'] != 'template')
|
2002-06-15 11:21:55 +02:00
|
|
|
{
|
2005-04-27 22:53:17 +02:00
|
|
|
$cell['name'] = $this->get_array($content,$this->expand_name(substr($cell['name'],1),
|
|
|
|
$show_c,$show_row,$content['.c'],$content['.row'],$content));
|
2002-06-15 11:21:55 +02:00
|
|
|
}
|
2002-02-06 10:03:11 +01:00
|
|
|
$name = $this->expand_name($cell['name'],$show_c,$show_row,$content['.c'],$content['.row'],$content);
|
|
|
|
|
2005-02-16 00:22:10 +01:00
|
|
|
$form_name = $this->form_name($cname,$name);
|
|
|
|
|
2002-10-04 01:47:14 +02:00
|
|
|
$value = $this->get_array($content,$name);
|
|
|
|
|
2005-11-05 18:07:29 +01:00
|
|
|
$options = '';
|
2005-02-24 22:02:24 +01:00
|
|
|
if ($readonly = $cell['readonly'] || @$readonlys[$name] && !is_array($readonlys[$name]) || $readonlys['__ALL__'])
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
2005-11-05 18:07:29 +01:00
|
|
|
$options .= ' readonly="readonly"';
|
2002-02-06 10:03:11 +01:00
|
|
|
}
|
2005-11-05 18:07:29 +01:00
|
|
|
if ((int) $cell['tabindex']) $options .= ' tabindex="'.(int)$cell['tabindex'].'"';
|
|
|
|
if ($cell['accesskey']) $options .= ' accesskey="'.$this->html->htmlspecialchars($cell['accesskey']).'"';
|
|
|
|
|
2006-09-27 15:09:28 +02:00
|
|
|
if (strchr($cell['size'],'$') || $cell['size']{0} == '@') // expand cell['size'] for the button-disabled-check now
|
|
|
|
{
|
|
|
|
$cell['size'] = $this->expand_name($cell['size'],$show_c,$show_row,$content['.c'],$content['.row'],$content);
|
|
|
|
}
|
2007-01-20 09:55:26 +01:00
|
|
|
if ($cell['disabled'] && $readonlys[$name] !== false || $readonly && ($cell['type'] == 'button' || $cell['type'] == 'buttononly') && strpos($cell['size'],',')===false)
|
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;
|
|
|
|
|
2005-07-14 08:42:39 +02:00
|
|
|
// the while loop allows to build extensions from other extensions
|
|
|
|
// please note: only the first extension's post_process function is called !!!
|
2002-10-02 02:44:33 +02:00
|
|
|
list($type,$sub_type) = explode('-',$cell['type']);
|
2005-07-14 08:42:39 +02:00
|
|
|
while ((!$this->types[$cell['type']] || !empty($sub_type)) && $this->haveExtension($type,'pre_process'))
|
2002-05-13 23:30:46 +02:00
|
|
|
{
|
2005-07-14 08:42:39 +02:00
|
|
|
//echo "<p>pre_process($cell[name]/$cell[type])</p>\n";
|
2005-11-10 15:51:12 +01:00
|
|
|
if (strchr($cell['size'],'$') || $cell['size']{0} == '@')
|
2005-06-03 00:26:41 +02:00
|
|
|
{
|
|
|
|
$cell['size'] = $this->expand_name($cell['size'],$show_c,$show_row,$content['.c'],$content['.row'],$content);
|
|
|
|
}
|
2005-07-14 08:42:39 +02:00
|
|
|
if (!$ext_type) $ext_type = $type;
|
|
|
|
$extra_label = $this->extensionPreProcess($type,$form_name,$value,$cell,$readonlys[$name]);
|
2002-10-01 20:26:30 +02:00
|
|
|
|
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);
|
2005-07-14 08:42:39 +02:00
|
|
|
|
|
|
|
if ($cell['type'] == $type.'-'.$sub_type) break; // stop if no further type-change
|
|
|
|
|
|
|
|
list($type,$sub_type) = explode('-',$cell['type']);
|
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
|
2005-11-10 15:51:12 +01:00
|
|
|
if (strchr($class,'$') || $class{0} == '@')
|
2005-04-27 22:53:17 +02:00
|
|
|
{
|
|
|
|
$class = $this->expand_name($class,$show_c,$show_row,$content['.c'],$content['.row'],$content);
|
|
|
|
}
|
2003-06-29 19:00:05 +02:00
|
|
|
$cell_options = $cell['size'];
|
2005-11-10 15:51:12 +01:00
|
|
|
if (strchr($cell_options,'$') || $cell_options{0} == '@')
|
2004-02-05 14:31:54 +01:00
|
|
|
{
|
|
|
|
$cell_options = $this->expand_name($cell_options,$show_c,$show_row,$content['.c'],$content['.row'],$content);
|
|
|
|
}
|
2005-06-03 00:26:41 +02:00
|
|
|
$label = $cell['label'];
|
2005-11-10 15:51:12 +01:00
|
|
|
if (strchr($label,'$') || $label{0} == '@')
|
2003-06-29 19:00:05 +02:00
|
|
|
{
|
2005-06-03 00:26:41 +02:00
|
|
|
$label = $this->expand_name($label,$show_c,$show_row,$content['.c'],$content['.row'],$content);
|
2003-06-29 19:00:05 +02:00
|
|
|
}
|
2002-06-10 23:34:58 +02:00
|
|
|
$help = $cell['help'];
|
2005-11-10 15:51:12 +01:00
|
|
|
if (strchr($help,'$') || $help{0} == '@')
|
2005-06-01 10:09:33 +02:00
|
|
|
{
|
|
|
|
$no_lang_on_help = true;
|
|
|
|
$help = $this->expand_name($help,$show_c,$show_row,$content['.c'],$content['.row'],$content);
|
|
|
|
}
|
2005-11-10 15:51:12 +01:00
|
|
|
$blur = $cell['blur']{0} == '@' ? $this->get_array($content,substr($cell['blur'],1)) :
|
2003-08-28 16:31:11 +02:00
|
|
|
(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)
|
|
|
|
{
|
2005-06-01 10:09:33 +02:00
|
|
|
if ((int)$cell['no_lang'] < 2 && !$no_lang_on_help)
|
2003-08-28 16:31:11 +02:00
|
|
|
{
|
|
|
|
$help = lang($help);
|
|
|
|
}
|
2005-06-16 23:44:51 +02:00
|
|
|
if (($use_tooltip_for_help = strstr($help,'<') && strip_tags($help) != $help)) // helptext is html => use a tooltip
|
|
|
|
{
|
|
|
|
$options .= $this->html->tooltip($help);
|
|
|
|
}
|
|
|
|
else // "regular" help-text in the statusline
|
2002-06-15 21:59:07 +02:00
|
|
|
{
|
2005-06-16 23:44:51 +02:00
|
|
|
$onFocus .= "self.status='".addslashes($this->html->htmlspecialchars($help))."'; return true;";
|
|
|
|
$onBlur .= "self.status=''; return true;";
|
2007-01-20 09:55:26 +01:00
|
|
|
if ($cell['type'] == 'button' || $cell['type'] == 'buttononly' || $cell['type'] == 'file') // for button additionally when mouse over button
|
2005-06-16 23:44:51 +02:00
|
|
|
{
|
|
|
|
$options .= " onMouseOver=\"self.status='".addslashes($this->html->htmlspecialchars($help))."'; return true;\"";
|
|
|
|
$options .= " onMouseOut=\"self.status=''; return true;\"";
|
|
|
|
}
|
2002-06-15 21:59:07 +02:00
|
|
|
}
|
|
|
|
}
|
2003-08-28 16:31:11 +02:00
|
|
|
if ($onBlur)
|
|
|
|
{
|
|
|
|
$options .= " onFocus=\"$onFocus\" onBlur=\"$onBlur\"";
|
|
|
|
}
|
2007-01-20 09:55:26 +01:00
|
|
|
if ($cell['onchange'] && !($cell['type'] == 'button' || $cell['type'] == 'buttononly'))
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
2006-03-21 23:13:46 +01:00
|
|
|
if (strchr($cell['onchange'],'$') || $cell['onchange']{0} == '@')
|
|
|
|
{
|
|
|
|
$cell['onchange'] = $this->expand_name($cell['onchange'],$show_c,$show_row,$content['.c'],$content['.row'],$content);
|
|
|
|
}
|
2006-09-29 21:47:29 +02:00
|
|
|
$options .= ' onChange="'.($cell['onchange'] == '1' ? 'this.form.submit();' : $this->js_pseudo_funcs($cell['onchange'],$cname)).'"';
|
2002-02-06 10:03:11 +01:00
|
|
|
}
|
|
|
|
}
|
2002-10-09 02:31:01 +02:00
|
|
|
if ($form_name != '')
|
|
|
|
{
|
2005-06-12 14:31:05 +02:00
|
|
|
$options = 'id="'.($cell['id'] ? $cell['id'] : $form_name).'" '.$options;
|
2002-10-09 02:31:01 +02:00
|
|
|
}
|
2007-01-25 15:48:54 +01:00
|
|
|
|
2002-10-02 02:44:33 +02:00
|
|
|
switch ($type)
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
2006-06-15 23:57:21 +02:00
|
|
|
case 'label': // size: [b[old]][i[talic]],[link],[activate_links],[label_for],[link_target],[link_popup_size],[link_title]
|
2002-10-10 13:29:36 +02:00
|
|
|
if (is_array($value))
|
|
|
|
break;
|
2006-06-15 23:57:21 +02:00
|
|
|
list($style,$extra_link,$activate_links,$label_for,$extra_link_target,$extra_link_popup,$extra_link_title) = 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);
|
2006-12-07 13:46:46 +01:00
|
|
|
if ($value != '' && $style && strpos($style,'b')!==false) $value = $this->html->bold($value);
|
|
|
|
if ($value != '' && $style && strpos($style,'i')!==false) $value = $this->html->italic($value);
|
2002-02-06 10:03:11 +01:00
|
|
|
$html .= $value;
|
2005-06-02 16:44:49 +02:00
|
|
|
if ($help)
|
|
|
|
{
|
|
|
|
$class = array(
|
|
|
|
'class' => $class,
|
|
|
|
'onmouseover' => "self.status='".addslashes($this->html->htmlspecialchars($help))."'; return true;",
|
|
|
|
'onmouseout' => "self.status=''; return true;",
|
|
|
|
);
|
|
|
|
}
|
2002-02-06 10:03:11 +01:00
|
|
|
break;
|
2006-06-15 23:57:21 +02:00
|
|
|
case 'html': // size: [link],[link_target],[link_popup_size],[link_title]
|
|
|
|
list($extra_link,$extra_link_target,$extra_link_popup,$extra_link_title) = explode(',',$cell_options);
|
2002-02-06 10:03:11 +01:00
|
|
|
$html .= $value;
|
|
|
|
break;
|
2007-01-08 16:53:27 +01:00
|
|
|
case 'int': // size: [min],[max],[len],[precission/sprint format]
|
2002-02-14 15:06:53 +01:00
|
|
|
case 'float':
|
2006-03-27 14:21:29 +02:00
|
|
|
list($min,$max,$cell_options,$pre) = explode(',',$cell_options);
|
2006-12-07 19:59:53 +01:00
|
|
|
if ($cell_options == '' && !$readonly)
|
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
|
|
|
}
|
2007-01-08 16:53:27 +01:00
|
|
|
if (($type == 'float' || !is_numeric($pre)) && $value && $pre)
|
2006-03-27 14:21:29 +02:00
|
|
|
{
|
2007-01-08 16:53:27 +01:00
|
|
|
$value = is_numeric($pre) ? round($value,$pre) : sprintf($pre,$value);
|
2006-03-27 14:21:29 +02: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
|
2006-12-06 21:09:22 +01:00
|
|
|
case 'passwd' :
|
2004-04-05 03:33:23 +02:00
|
|
|
case 'text': // size: [length][,maxLength[,preg]]
|
2006-12-07 19:59:53 +01:00
|
|
|
$cell_opts = explode(',',$cell_options,3);
|
2006-12-25 18:43:59 +01:00
|
|
|
if ($readonly && (int)$cell_opts[0] >= 0)
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
2006-03-21 18:11:57 +01:00
|
|
|
$html .= strlen($value) ? $this->html->bold($this->html->htmlspecialchars($value)) : '';
|
2002-02-06 10:03:11 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-12-25 18:43:59 +01:00
|
|
|
if ($cell_opts[0] < 0) $cell_opts[0] = abs($cell_opts[0]);
|
2006-12-06 21:09:22 +01:00
|
|
|
$html .= $this->html->input($form_name,$value,$type == 'passwd' ? 'password' : '',
|
2006-12-25 18:43:59 +01:00
|
|
|
$options.$this->html->formatOptions($cell_opts,'SIZE,MAXLENGTH'));
|
2006-12-07 19:59:53 +01:00
|
|
|
|
|
|
|
if (!$readonly)
|
|
|
|
{
|
|
|
|
$GLOBALS['egw_info']['etemplate']['to_process'][$form_name] = array(
|
|
|
|
'type' => $cell['type'],
|
|
|
|
'maxlength' => $cell_opts[1],
|
|
|
|
'needed' => $cell['needed'],
|
|
|
|
'preg' => $cell_opts[2],
|
|
|
|
'min' => $min, // int and float only
|
|
|
|
'max' => $max,
|
|
|
|
);
|
|
|
|
}
|
2002-02-06 10:03:11 +01:00
|
|
|
}
|
2006-12-07 19:59:53 +01:00
|
|
|
unset($cell_opts);
|
2002-02-06 10:03:11 +01:00
|
|
|
break;
|
|
|
|
case 'textarea': // Multiline Text Input, size: [rows][,cols]
|
2006-08-12 08:14:28 +02:00
|
|
|
if ($readonly && !$cell_options)
|
|
|
|
{
|
2006-12-26 08:21:54 +01:00
|
|
|
$html .= '<div>'.nl2br($this->html->htmlspecialchars($value))."</div>\n";
|
2006-08-12 08:14:28 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$html .= $this->html->textarea($form_name,$value,
|
|
|
|
$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
|
|
|
{
|
2005-11-09 21:50:45 +01:00
|
|
|
$GLOBALS['egw_info']['etemplate']['to_process'][$form_name] = array(
|
2004-04-05 03:33:23 +02:00
|
|
|
'type' => $cell['type'],
|
|
|
|
'needed' => $cell['needed'],
|
|
|
|
);
|
|
|
|
}
|
2002-02-06 10:03:11 +01:00
|
|
|
break;
|
2007-04-14 18:44:37 +02:00
|
|
|
case 'htmlarea': // Multiline formatted Text Input, size: {simple|extended|advanced},height,width,toolbar-expanded,upload-path
|
2007-01-18 20:19:01 +01:00
|
|
|
list($mode,$height,$width,$toolbar,$baseref) = explode(',',$cell_options);
|
2004-02-28 23:41:32 +01:00
|
|
|
if (!$readonly)
|
|
|
|
{
|
2007-01-18 20:19:01 +01:00
|
|
|
$mode = $mode ? $mode : 'simple';
|
|
|
|
$height = $height ? $height : '400px';
|
|
|
|
$width = $width ? $width : '100%';
|
|
|
|
$fckoptions = array(
|
|
|
|
'toolbar_expanded' => $toolbar,
|
|
|
|
);
|
|
|
|
$html .= $this->html->fckEditor($form_name,$value,$mode,$fckoptions,$height,$width,$baseref);
|
2005-10-10 17:43:45 +02:00
|
|
|
|
2005-11-09 21:50:45 +01:00
|
|
|
$GLOBALS['egw_info']['etemplate']['to_process'][$form_name] = array(
|
2004-04-05 03:33:23 +02:00
|
|
|
'type' => $cell['type'],
|
|
|
|
'needed' => $cell['needed'],
|
|
|
|
);
|
2004-02-28 23:41:32 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-01-18 20:19:01 +01:00
|
|
|
$html .= $this->html->div($this->html->activate_links($value),'style="overflow: auto; border: thin inset black; width='. $width. '; height='. $height. '"');
|
2004-02-28 23:41:32 +01:00
|
|
|
}
|
|
|
|
break;
|
2002-02-06 10:03:11 +01:00
|
|
|
case 'checkbox':
|
2005-06-12 17:58:22 +02:00
|
|
|
$set_val = 1; $unset_val = 0;
|
2003-06-29 19:00:05 +02:00
|
|
|
if (!empty($cell_options))
|
2002-10-02 02:44:33 +02:00
|
|
|
{
|
2005-06-12 17:58:22 +02:00
|
|
|
list($set_val,$unset_val,$ro_true,$ro_false) = explode(',',$cell_options);
|
2005-06-14 23:38:49 +02:00
|
|
|
if (!$set_val && !$unset_val) $set_val = 1;
|
2005-06-12 17:58:22 +02:00
|
|
|
$value = $value == $set_val;
|
2002-10-02 02:44:33 +02:00
|
|
|
}
|
|
|
|
if ($readonly)
|
|
|
|
{
|
2005-06-14 23:38:49 +02:00
|
|
|
if (count(explode(',',$cell_options)) < 3)
|
|
|
|
{
|
|
|
|
$ro_true = 'x';
|
|
|
|
$ro_false = '';
|
|
|
|
}
|
|
|
|
if (!$value && $ro_false == 'disable') return '';
|
|
|
|
|
2002-10-02 02:44:33 +02:00
|
|
|
$html .= $value ? $this->html->bold($ro_true) : $ro_false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-11-05 18:07:29 +01:00
|
|
|
if ($value) $options .= ' checked="checked"';
|
2005-06-14 23:38:49 +02:00
|
|
|
|
2005-06-12 17:58:22 +02:00
|
|
|
if (($multiple = substr($cell['name'],-2) == '[]'))
|
|
|
|
{
|
|
|
|
// add the set_val to the id to make it unique
|
|
|
|
$options = str_replace('id="'.$form_name,'id="'.substr($form_name,0,-2)."[$set_val]",$options);
|
|
|
|
}
|
|
|
|
$html .= $this->html->input($form_name,$set_val,'checkbox',$options);
|
|
|
|
|
|
|
|
if ($multiple) $form_name = $this->form_name($cname,substr($cell['name'],0,-2));
|
|
|
|
|
2005-11-09 21:50:45 +01:00
|
|
|
if (!isset($GLOBALS['egw_info']['etemplate']['to_process'][$form_name]))
|
2005-06-12 17:58:22 +02:00
|
|
|
{
|
2005-11-09 21:50:45 +01:00
|
|
|
$GLOBALS['egw_info']['etemplate']['to_process'][$form_name] = array(
|
2005-06-12 17:58:22 +02:00
|
|
|
'type' => $cell['type'],
|
|
|
|
'unset_value' => $unset_val,
|
|
|
|
'multiple' => $multiple,
|
|
|
|
);
|
|
|
|
}
|
2005-11-09 21:50:45 +01:00
|
|
|
$GLOBALS['egw_info']['etemplate']['to_process'][$form_name]['values'][] = $set_val;
|
2005-06-14 10:40:39 +02:00
|
|
|
if (!$multiple) unset($set_val); // otherwise it will be added to the label
|
2002-10-02 02:44:33 +02:00
|
|
|
}
|
2002-02-06 10:03:11 +01:00
|
|
|
break;
|
2006-04-30 09:20:12 +02:00
|
|
|
case 'radio': // size: value if checked, readonly set, readonly unset
|
|
|
|
list($set_val,$ro_true,$ro_false) = explode(',',$cell_options);
|
|
|
|
$set_val = $this->expand_name($set_val,$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
|
|
|
{
|
2005-11-05 18:07:29 +01:00
|
|
|
$options .= ' checked="checked"';
|
2002-02-06 10:03:11 +01:00
|
|
|
}
|
2005-02-18 23:44:42 +01:00
|
|
|
// add the set_val to the id to make it unique
|
|
|
|
$options = str_replace('id="'.$form_name,'id="'.$form_name."[$set_val]",$options);
|
|
|
|
|
2002-10-02 02:44:33 +02:00
|
|
|
if ($readonly)
|
|
|
|
{
|
2006-04-30 09:20:12 +02:00
|
|
|
if (!$ro_true && !$ro_false) $ro_true = 'x';
|
|
|
|
$html .= $value == $set_val ? $this->html->bold($ro_true) : $ro_false;
|
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);
|
2005-11-09 21:50:45 +01:00
|
|
|
$GLOBALS['egw_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':
|
2007-01-20 09:55:26 +01:00
|
|
|
case 'buttononly':
|
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);
|
2005-02-24 22:02:24 +01:00
|
|
|
if ($cell['onclick'] &&
|
|
|
|
($onclick = $this->expand_name($cell['onclick'],$show_c,$show_row,$content['.c'],$content['.row'],$content)))
|
2005-02-20 22:45:24 +01:00
|
|
|
{
|
2006-09-29 21:47:29 +02:00
|
|
|
$onclick = $this->js_pseudo_funcs($onclick,$cname);
|
2005-02-20 22:45:24 +01:00
|
|
|
}
|
2004-02-14 19:48:53 +01:00
|
|
|
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
|
|
|
{
|
2005-02-24 22:02:24 +01:00
|
|
|
$onclick = ($onclick ? preg_replace('/^return(.*);$/','if (\\1) ',$onclick) : '').
|
2006-03-16 15:20:57 +01:00
|
|
|
(($cell['onchange'] == 1 || $img) ? "return submitit($this->name_form,'$form_name');" : $cell['onchange']).'; return false;';
|
2005-02-24 22:02:24 +01:00
|
|
|
|
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
|
|
|
}
|
2005-02-20 22:45:24 +01:00
|
|
|
if ($cell['onchange'] && $cell['onchange'] != 1)
|
2005-03-05 15:59:33 +01:00
|
|
|
{
|
2005-02-24 22:02:24 +01:00
|
|
|
$onclick = ($onclick ? preg_replace('/^return(.*);$/','if (\\1) ',$onclick) : '').$cell['onchange'];
|
2005-03-05 15:59:33 +01:00
|
|
|
}
|
2005-02-20 22:45:24 +01:00
|
|
|
$html .= !$readonly ? $this->html->submit_button($form_name,$label,$onclick,
|
2007-01-20 09:55:26 +01:00
|
|
|
strlen($label) <= 1 || $cell['no_lang'],$options,$img,$app,(($type=='buttononly') ? 'button' : 'submit')) :
|
2002-10-08 02:08:40 +02:00
|
|
|
$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
|
|
|
{
|
2005-11-09 21:50:45 +01:00
|
|
|
$GLOBALS['egw_info']['etemplate']['to_process'][$form_name] = $cell['type'];
|
2004-04-05 03:33:23 +02:00
|
|
|
if (strtolower($name) == 'cancel')
|
|
|
|
{
|
2005-11-09 21:50:45 +01:00
|
|
|
$GLOBALS['egw_info']['etemplate']['to_process'][$form_name] = 'cancel';
|
2004-04-05 03:33:23 +02:00
|
|
|
}
|
|
|
|
}
|
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;
|
2005-02-08 13:29:06 +01:00
|
|
|
case 'grid':
|
2005-07-14 08:42:39 +02:00
|
|
|
if ($readonly && !$readonlys['__ALL__'])
|
2005-02-08 13:29:06 +01:00
|
|
|
{
|
|
|
|
if (!is_array($readonlys)) $readonlys = array();
|
2005-07-14 08:42:39 +02:00
|
|
|
$set_readonlys_all = $readonlys['__ALL__'] = True;
|
2005-02-08 13:29:06 +01:00
|
|
|
}
|
|
|
|
if ($name != '')
|
|
|
|
{
|
|
|
|
$cname .= $cname == '' ? $name : '['.str_replace('[','][',str_replace(']','',$name)).']';
|
|
|
|
}
|
2005-03-14 00:38:37 +01:00
|
|
|
$html .= $this->show_grid($cell,$name ? $value : $content,$readonlys,$cname,$show_c,$show_row,$path);
|
2005-07-14 08:42:39 +02:00
|
|
|
if ($set_readonlys_all) unset($readonlys['__ALL__']);
|
2005-02-08 13:29:06 +01:00
|
|
|
break;
|
2002-02-06 10:03:11 +01:00
|
|
|
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';
|
2005-02-08 13:29:06 +01:00
|
|
|
echo "<p>Object in Name in tpl '$this->name': "; _debug_array($grid);
|
2002-09-27 18:17:39 +02:00
|
|
|
}
|
|
|
|
$obj_read = 'already loaded';
|
2005-02-23 15:33:00 +01:00
|
|
|
if (is_array($cell['obj']))
|
|
|
|
{
|
|
|
|
$obj =& new etemplate();
|
|
|
|
$obj->init($cell['obj']);
|
|
|
|
$cell['obj'] =& $obj;
|
|
|
|
unset($obj);
|
|
|
|
}
|
2002-09-27 18:17:39 +02:00
|
|
|
if (!is_object($cell['obj']))
|
|
|
|
{
|
2005-11-10 15:51:12 +01:00
|
|
|
if ($cell['name']{0} == '@')
|
2002-09-27 18:17:39 +02:00
|
|
|
{
|
|
|
|
$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']))
|
|
|
|
{
|
2005-11-09 21:50:45 +01:00
|
|
|
$cell['obj'] =& new etemplate($cell['obj'],$this->as_array());
|
2002-09-27 18:17:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ $obj_read = 'obj read';
|
2005-11-09 21:50:45 +01:00
|
|
|
$cell['obj'] =& new etemplate($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
|
|
|
{
|
2006-12-07 19:59:53 +01:00
|
|
|
echo "<p>show_cell::template(tpl=$this->name,name=$cell[name]): $obj_read, readonly=$readonly</p>\n";
|
2002-09-27 18:17:39 +02:00
|
|
|
}
|
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;
|
|
|
|
}
|
|
|
|
}
|
2005-06-12 17:58:22 +02:00
|
|
|
$readonlys = $this->get_array($readonlys,$idx);
|
|
|
|
$content = $this->get_array($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
|
|
|
}
|
2005-07-14 08:42:39 +02:00
|
|
|
if ($readonly && !$readonlys['__ALL__'])
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
2004-02-05 14:31:54 +01:00
|
|
|
if (!is_array($readonlys)) $readonlys = array();
|
2005-07-14 08:42:39 +02:00
|
|
|
$set_readonlys_all = $readonlys['__ALL__'] = True;
|
2002-02-06 10:03:11 +01:00
|
|
|
}
|
2005-02-16 00:22:10 +01:00
|
|
|
// propagate our onclick handler to embeded templates, if they dont have their own
|
|
|
|
if (!isset($cell['obj']->onclick_handler)) $cell['obj']->onclick_handler = $this->onclick_handler;
|
|
|
|
if ($cell['obj']->no_onclick)
|
|
|
|
{
|
2005-03-29 16:16:42 +02:00
|
|
|
$cell['obj']->onclick_proxy = $this->onclick_proxy ? $this->onclick_proxy : $this->name.':'.$this->version.':'.$path;
|
2005-02-16 00:22:10 +01:00
|
|
|
}
|
2005-05-21 09:41:09 +02:00
|
|
|
// propagate the CSS class to the template
|
|
|
|
if ($class)
|
|
|
|
{
|
|
|
|
$grid_size = array_pad(explode(',',$cell['obj']->size),4,'');
|
|
|
|
$grid_size[3] = ($grid_size[3] ? $grid_size[3].' ' : '') . $class;
|
|
|
|
$cell['obj']->size = implode(',',$grid_size);
|
|
|
|
}
|
2005-03-14 00:38:37 +01:00
|
|
|
$html = $cell['obj']->show($content,$this->sel_options,$readonlys,$cname,$show_c,$show_row);
|
2005-07-14 08:42:39 +02:00
|
|
|
|
|
|
|
if ($set_readonlys_all) unset($readonlys['__ALL__']);
|
2002-02-06 10:03:11 +01:00
|
|
|
break;
|
2006-03-20 22:51:55 +01:00
|
|
|
case 'select': // size:[linesOnMultiselect|emptyLabel,extraStyleMulitselect]
|
2002-10-03 18:52:42 +02:00
|
|
|
$sels = array();
|
2006-03-20 22:51:55 +01:00
|
|
|
list($multiple,$extraStyleMultiselect) = explode(',',$cell_options,2);
|
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
|
|
|
{
|
2005-03-14 00:38:37 +01:00
|
|
|
$sels[''] = substr($sels[''],-3) == '...' ? lang(substr($sels[''],0,-3)).'...' : lang($sels['']);
|
2003-08-28 16:31:11 +02:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
}
|
2005-03-14 00:38:37 +01:00
|
|
|
if (isset($this->sel_options[$name]) && is_array($this->sel_options[$name]))
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
2005-03-14 00:38:37 +01:00
|
|
|
$sels += $this->sel_options[$name];
|
2002-02-06 10:03:11 +01:00
|
|
|
}
|
2005-02-23 15:33:00 +01:00
|
|
|
else
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
2005-02-23 15:33:00 +01:00
|
|
|
$name_parts = explode('[',str_replace(']','',$name));
|
|
|
|
if (count($name_parts))
|
2002-10-04 01:47:14 +02:00
|
|
|
{
|
2005-02-23 15:33:00 +01:00
|
|
|
$org_name = $name_parts[count($name_parts)-1];
|
2005-03-14 00:38:37 +01:00
|
|
|
if (isset($this->sel_options[$org_name]) && is_array($this->sel_options[$org_name]))
|
2005-02-23 15:33:00 +01:00
|
|
|
{
|
2005-03-14 00:38:37 +01:00
|
|
|
$sels += $this->sel_options[$org_name];
|
2005-02-23 15:33:00 +01:00
|
|
|
}
|
2005-03-14 00:38:37 +01:00
|
|
|
elseif (isset($this->sel_options[$name_parts[0]]) && is_array($this->sel_options[$name_parts[0]]))
|
2005-02-23 15:33:00 +01:00
|
|
|
{
|
2005-03-14 00:38:37 +01:00
|
|
|
$sels += $this->sel_options[$name_parts[0]];
|
2005-02-23 15:33:00 +01:00
|
|
|
}
|
2003-10-26 20:26:58 +01:00
|
|
|
}
|
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
|
|
|
}
|
2005-02-24 22:02:24 +01:00
|
|
|
if ($multiple && !is_array($value)) $value = explode(',',$value);
|
2006-03-27 00:17:55 +02:00
|
|
|
if ($readonly || $cell['noprint'])
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
2007-03-07 13:30:17 +01:00
|
|
|
foreach($multiple || is_array($value) ? $value : array($value) as $val)
|
2005-02-24 22:02:24 +01:00
|
|
|
{
|
2005-05-21 20:21:55 +02:00
|
|
|
if (is_array($sels[$val]))
|
2005-02-24 22:02:24 +01:00
|
|
|
{
|
2005-05-21 20:21:55 +02:00
|
|
|
$option_label = $sels[$val]['label'];
|
|
|
|
$option_title = $sels[$val]['title'];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$option_label = $sels[$val];
|
|
|
|
$option_title = '';
|
|
|
|
}
|
|
|
|
if (!$cell['no_lang']) $option_label = lang($option_label);
|
|
|
|
|
|
|
|
if ($html) $html .= "<br>\n";
|
|
|
|
|
|
|
|
if ($option_title)
|
|
|
|
{
|
|
|
|
$html .= '<span title="'.$this->html->htmlspecialchars($option_title).'">'.$this->html->htmlspecialchars($option_label).'</span>';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$html .= $this->html->htmlspecialchars($option_label);
|
2005-02-24 22:02:24 +01:00
|
|
|
}
|
|
|
|
}
|
2002-02-06 10:03:11 +01:00
|
|
|
}
|
2006-03-27 00:17:55 +02:00
|
|
|
if (!$readonly)
|
2002-10-02 02:44:33 +02:00
|
|
|
{
|
2006-03-27 00:17:55 +02:00
|
|
|
if ($cell['noprint'])
|
|
|
|
{
|
|
|
|
$html = '<span class="onlyPrint">'.$html.'</span>';
|
|
|
|
$options .= ' class="noPrint"';
|
|
|
|
}
|
2005-02-24 22:02:24 +01:00
|
|
|
if ($multiple && is_numeric($multiple)) // eg. "3+" would give a regular multiselectbox
|
|
|
|
{
|
|
|
|
$html .= $this->html->checkbox_multiselect($form_name.($multiple > 1 ? '[]' : ''),$value,$sels,
|
2007-03-07 13:30:17 +01:00
|
|
|
$cell['no_lang'],$options,$multiple,$multiple{0}!=='0',$extraStyleMultiselect);
|
2005-02-24 22:02:24 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$html .= $this->html->select($form_name.($multiple > 1 ? '[]' : ''),$value,$sels,
|
|
|
|
$cell['no_lang'],$options,$multiple);
|
|
|
|
}
|
2005-11-09 21:50:45 +01:00
|
|
|
if (!isset($GLOBALS['egw_info']['etemplate']['to_process'][$form_name]))
|
2004-10-07 23:53:41 +02:00
|
|
|
{
|
2006-08-15 14:14:05 +02:00
|
|
|
$GLOBALS['egw_info']['etemplate']['to_process'][$form_name] = array(
|
|
|
|
'type' => $cell['type'],
|
|
|
|
'needed' => $cell['needed'],
|
2006-09-12 17:12:39 +02:00
|
|
|
'allowed' => array_keys($sels),
|
|
|
|
'multiple'=> $multiple,
|
2006-08-15 14:14:05 +02:00
|
|
|
);
|
2004-10-07 23:53:41 +02:00
|
|
|
}
|
2002-10-02 02:44:33 +02:00
|
|
|
}
|
2002-02-06 10:03:11 +01:00
|
|
|
break;
|
2005-11-10 15:51:12 +01:00
|
|
|
case 'image': // size: [link],[link_target],[imagemap],[link_popup]
|
2002-10-12 18:37:44 +02:00
|
|
|
$image = $value != '' ? $value : $name;
|
2005-04-08 20:31:55 +02:00
|
|
|
list($app,$img) = explode('/',$image,2);
|
2006-12-07 13:46:46 +01:00
|
|
|
if (!$app || !$img || !is_dir(EGW_SERVER_ROOT.'/'.$app) || strpos($img,'/')!==false)
|
2005-04-08 20:31:55 +02:00
|
|
|
{
|
|
|
|
$img = $image;
|
|
|
|
list($app) = explode('.',$this->name);
|
|
|
|
}
|
2005-05-19 15:16:52 +02:00
|
|
|
if (!$readonly)
|
|
|
|
{
|
2005-11-10 15:51:12 +01:00
|
|
|
list($extra_link,$extra_link_target,$imagemap,$extra_link_popup) = explode(',',$cell['size']);
|
2005-05-19 15:16:52 +02:00
|
|
|
}
|
2005-05-07 16:00:06 +02:00
|
|
|
$html .= $this->html->image($app,$img,strlen($label) > 1 && !$cell['no_lang'] ? lang($label) : $label,
|
|
|
|
'border="0"'.($imagemap?' usemap="'.$this->html->htmlspecialchars($imagemap).'"':''));
|
2002-05-13 23:30:46 +02:00
|
|
|
$extra_label = False;
|
2002-02-06 10:03:11 +01:00
|
|
|
break;
|
2005-11-10 15:51:12 +01:00
|
|
|
case 'file': // size: size of the filename field
|
2005-03-05 15:59:33 +01:00
|
|
|
if (!$readonly)
|
|
|
|
{
|
2005-11-10 15:51:12 +01:00
|
|
|
if ((int) $cell_options) $options .= ' size="'.(int)$cell_options.'"';
|
2005-03-05 15:59:33 +01:00
|
|
|
$html .= $this->html->input_hidden($path_name = str_replace($name,$name.'_path',$form_name),'.');
|
|
|
|
$html .= $this->html->input($form_name,'','file',$options);
|
2005-11-09 21:50:45 +01:00
|
|
|
$GLOBALS['egw_info']['etemplate']['form_options'] =
|
2005-05-19 15:16:52 +02:00
|
|
|
"enctype=\"multipart/form-data\" onsubmit=\"set_element2(this,'$path_name','$form_name')\"";
|
2005-11-09 21:50:45 +01:00
|
|
|
$GLOBALS['egw_info']['etemplate']['to_process'][$form_name] = $cell['type'];
|
2005-03-05 15:59:33 +01:00
|
|
|
}
|
2002-09-12 10:40:57 +02:00
|
|
|
break;
|
2002-10-12 18:37:44 +02:00
|
|
|
case 'vbox':
|
|
|
|
case 'hbox':
|
2005-02-06 16:49:50 +01:00
|
|
|
case 'groupbox':
|
2005-02-08 13:29:06 +01:00
|
|
|
case 'box':
|
2002-10-12 18:37:44 +02:00
|
|
|
$rows = array();
|
|
|
|
$box_row = 1;
|
|
|
|
$box_col = 'A';
|
|
|
|
$box_anz = 0;
|
2006-09-27 15:09:28 +02:00
|
|
|
list($num,$orient,,,$keep_empty) = explode(',',$cell_options);
|
2005-02-18 23:44:42 +01:00
|
|
|
if (!$orient) $orient = $type == 'hbox' ? 'horizontal' : ($type == 'box' ? false : 'vertical');
|
|
|
|
for ($n = 1; $n <= (int) $num; ++$n)
|
2002-10-12 18:37:44 +02:00
|
|
|
{
|
2005-03-14 00:38:37 +01:00
|
|
|
$h = $this->show_cell($cell[$n],$content,$readonlys,$cname,$show_c,$show_row,$nul,$cl,$path.'/'.$n);
|
2006-09-27 15:09:28 +02:00
|
|
|
if ($h != '' && $h != ' ' || $keep_empty)
|
2002-10-12 18:37:44 +02:00
|
|
|
{
|
2005-02-18 23:44:42 +01:00
|
|
|
if ($orient != 'horizontal')
|
2002-10-12 18:37:44 +02:00
|
|
|
{
|
|
|
|
$box_row = $n;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$box_col = $this->num2chrs($n);
|
|
|
|
}
|
2005-02-18 23:44:42 +01:00
|
|
|
if (!$orient)
|
2005-02-08 13:29:06 +01:00
|
|
|
{
|
2005-06-19 10:31:11 +02:00
|
|
|
$html .= $cl ? $this->html->div($h," class=\"$cl\"") : $h;
|
2005-02-08 13:29:06 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$rows[$box_row][$box_col] = $html = $h;
|
|
|
|
}
|
2002-10-12 18:37:44 +02:00
|
|
|
$box_anz++;
|
|
|
|
if ($cell[$n]['align'])
|
|
|
|
{
|
2005-05-19 15:16:52 +02:00
|
|
|
$rows[$box_row]['.'.$box_col] = $this->html->formatOptions($cell[$n]['align'],'align');
|
2005-04-27 22:53:17 +02:00
|
|
|
$sub_cell_has_align = true;
|
2002-10-12 18:37:44 +02:00
|
|
|
}
|
2005-05-19 15:16:52 +02:00
|
|
|
// can only be set via source at the moment
|
2007-01-20 09:55:26 +01:00
|
|
|
if (strlen($cell[$n]['onclick']) > 1 && !($cell[$n]['type'] == 'button' || $cell[$n]['type'] == 'buttononly'))
|
2005-05-19 15:16:52 +02:00
|
|
|
{
|
2006-12-19 14:36:54 +01:00
|
|
|
$rows[$box_row]['.'.$box_col] .= ' onclick="'.$this->js_pseudo_funcs($cell[$n]['onclick'],$cname).'"'.
|
2005-05-19 15:16:52 +02:00
|
|
|
($cell[$n]['id'] ? ' id="'.$cell[$n]['id'].'"' : '');
|
|
|
|
}
|
2005-06-02 16:44:49 +02:00
|
|
|
// allow to set further attributes in the tablecell, beside the class
|
|
|
|
if (is_array($cl))
|
|
|
|
{
|
|
|
|
foreach($cl as $attr => $val)
|
|
|
|
{
|
|
|
|
if ($attr != 'class' && $val)
|
|
|
|
{
|
|
|
|
$rows[$box_row]['.'.$box_col] .= ' '.$attr.'="'.$val.'"';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$cl = $cl['class'];
|
|
|
|
}
|
2005-05-19 15:16:52 +02:00
|
|
|
$box_item_class = $this->expand_name(isset($this->class_conf[$cl]) ? $this->class_conf[$cl] : $cl,
|
2002-10-18 00:10:12 +02:00
|
|
|
$show_c,$show_row,$content['.c'],$content['.row'],$content);
|
2005-05-19 15:16:52 +02:00
|
|
|
$rows[$box_row]['.'.$box_col] .= $this->html->formatOptions($box_item_class,'class');
|
2002-10-12 18:37:44 +02:00
|
|
|
}
|
|
|
|
}
|
2005-02-18 23:44:42 +01:00
|
|
|
if ($box_anz > 1 && $orient) // a single cell is NOT placed into a table
|
2002-10-12 18:37:44 +02:00
|
|
|
{
|
2005-05-19 15:16:52 +02:00
|
|
|
$html = $this->html->table($rows,$this->html->formatOptions($cell_options,',,cellpadding,cellspacing').
|
2007-03-07 13:30:17 +01:00
|
|
|
($type != 'groupbox' ? $this->html->formatOptions($class,'class').
|
|
|
|
($cell['name'] ? ' id="'.$form_name.'"' : '') : '').
|
2005-05-19 15:16:52 +02:00
|
|
|
($cell['align'] && $orient != 'horizontal' || $sub_cell_has_align ? ' width="100%"' : '')); // alignment only works if table has full width
|
2007-03-07 13:30:17 +01:00
|
|
|
if ($type != 'groupbox') $class = ''; // otherwise we create an extra div
|
2002-10-12 18:37:44 +02:00
|
|
|
}
|
2005-05-31 23:29:49 +02:00
|
|
|
// put the class of the box-cell, into the the class of this cell
|
2006-09-29 21:47:29 +02:00
|
|
|
elseif ($box_item_class && $box_anz == 1)
|
2005-04-15 00:35:24 +02:00
|
|
|
{
|
2005-05-31 23:29:49 +02:00
|
|
|
$class = ($class ? $class . ' ' : '') . $box_item_class;
|
2005-04-15 00:35:24 +02:00
|
|
|
}
|
2005-02-18 23:44:42 +01:00
|
|
|
if ($type == 'groupbox')
|
2005-02-06 16:49:50 +01:00
|
|
|
{
|
2005-02-06 19:12:26 +01:00
|
|
|
if (strlen($label) > 1 && $cell['label'] == $label)
|
2005-02-06 18:52:43 +01:00
|
|
|
{
|
|
|
|
$label = lang($label);
|
|
|
|
}
|
2007-03-07 13:30:17 +01:00
|
|
|
$html = $this->html->fieldset($html,$label,($cell['name'] ? ' id="'.$form_name.'"' : '').
|
|
|
|
($class ? ' class="'.$class.'"' : ''));
|
|
|
|
$class = ''; // otherwise we create an extra div
|
2005-02-06 16:49:50 +01:00
|
|
|
}
|
2005-02-18 23:44:42 +01:00
|
|
|
elseif (!$orient)
|
2005-02-08 13:29:06 +01:00
|
|
|
{
|
|
|
|
$html = $this->html->div($html,$this->html->formatOptions(array(
|
|
|
|
$cell['height'],
|
|
|
|
$cell['width'],
|
2006-09-29 21:47:29 +02:00
|
|
|
$class,
|
|
|
|
$cell['name'] ? $form_name : '',
|
2006-03-22 14:04:17 +01:00
|
|
|
),'height,widht,class,id')). ($html ? '' : '</div>');
|
2006-09-29 21:47:29 +02:00
|
|
|
$class = ''; // otherwise we create an extra div
|
2005-02-08 13:29:06 +01:00
|
|
|
}
|
|
|
|
if ($box_anz > 1) // small docu in the html-source
|
2005-02-06 16:49:50 +01:00
|
|
|
{
|
|
|
|
$html = "\n\n<!-- BEGIN $cell[type] -->\n\n".$html."\n\n<!-- END $cell[type] -->\n\n";
|
|
|
|
}
|
|
|
|
$extra_label = False;
|
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' : '').';';
|
|
|
|
}
|
2005-05-19 15:16:52 +02:00
|
|
|
$html = $this->html->input_hidden($form_name,$value);
|
2005-11-09 21:50:45 +01:00
|
|
|
$GLOBALS['egw_info']['etemplate']['to_process'][$form_name] = $cell['type'];
|
2005-05-19 15:16:52 +02:00
|
|
|
|
2003-06-29 19:00:05 +02:00
|
|
|
for ($n = 1; $n <= $cell_options; ++$n)
|
2003-04-13 21:14:50 +02:00
|
|
|
{
|
2005-05-19 15:16:52 +02:00
|
|
|
$html .= $this->html->div($this->show_cell($cell[$n],$content,$readonlys,$cname,$show_c,
|
|
|
|
$show_row,$nul,$cl,$path.'/'.$n),$this->html->formatOptions(array(
|
|
|
|
'display: '.($value == $cell[$n]['name'] ? 'inline' : 'none').';',
|
2003-04-13 21:14:50 +02:00
|
|
|
$cell[$n]['name']
|
2005-05-19 15:16:52 +02:00
|
|
|
),'style,id'));
|
|
|
|
}
|
2003-04-13 21:14:50 +02:00
|
|
|
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;
|
|
|
|
}
|
2004-10-07 23:53:41 +02:00
|
|
|
// extension-processing need to be after all other and only with diff. name
|
|
|
|
if ($ext_type && !$readonly && $this->haveExtension($ext_type,'post_process'))
|
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.
|
2005-03-05 15:59:33 +01:00
|
|
|
$to_process = 'ext-'.$ext_type;
|
2005-11-09 21:50:45 +01:00
|
|
|
if (is_array($GLOBALS['egw_info']['etemplate']['to_process'][$form_name]))
|
2005-03-05 15:59:33 +01:00
|
|
|
{
|
2005-11-09 21:50:45 +01:00
|
|
|
$to_process = $GLOBALS['egw_info']['etemplate']['to_process'][$form_name];
|
2005-03-05 15:59:33 +01:00
|
|
|
$to_process['type'] = 'ext-'.$ext_type;
|
|
|
|
}
|
2005-11-09 21:50:45 +01:00
|
|
|
unset($GLOBALS['egw_info']['etemplate']['to_process'][$form_name]);
|
|
|
|
$GLOBALS['egw_info']['etemplate']['to_process'][$form_name] = $to_process;
|
2002-10-01 20:26:30 +02:00
|
|
|
}
|
2003-08-28 16:31:11 +02:00
|
|
|
// save blur-value to strip it in process_exec
|
2005-11-09 21:50:45 +01:00
|
|
|
if (!empty($blur) && isset($GLOBALS['egw_info']['etemplate']['to_process'][$form_name]))
|
2003-08-28 16:31:11 +02:00
|
|
|
{
|
2005-11-09 21:50:45 +01:00
|
|
|
if (!is_array($GLOBALS['egw_info']['etemplate']['to_process'][$form_name]))
|
2004-10-07 23:53:41 +02:00
|
|
|
{
|
2005-11-09 21:50:45 +01:00
|
|
|
$GLOBALS['egw_info']['etemplate']['to_process'][$form_name] = array(
|
|
|
|
'type' => $GLOBALS['egw_info']['etemplate']['to_process'][$form_name]
|
2004-10-07 23:53:41 +02:00
|
|
|
);
|
|
|
|
}
|
2005-11-09 21:50:45 +01:00
|
|
|
$GLOBALS['egw_info']['etemplate']['to_process'][$form_name]['blur'] = $blur;
|
2003-08-28 16:31:11 +02:00
|
|
|
}
|
2002-06-10 23:34:58 +02:00
|
|
|
if ($extra_label && ($label != '' || $html == ''))
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
2006-04-06 20:39:34 +02: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);
|
|
|
|
}
|
2005-02-16 00:22:10 +01:00
|
|
|
$accesskey = false;
|
2006-12-07 13:46:46 +01:00
|
|
|
if (($accesskey = $label && strpos($label,'&')!==false) && $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);
|
2005-02-16 00:22:10 +01:00
|
|
|
$accesskey = $accesskey[1];
|
|
|
|
}
|
2005-05-07 16:00:06 +02:00
|
|
|
if ($label && !$readonly && ($accesskey || $label_for || $type != 'label' && $cell['name']))
|
2005-02-16 00:22:10 +01:00
|
|
|
{
|
|
|
|
$label = $this->html->label($label,$label_for ? $this->form_name($cname,$label_for) :
|
2005-02-18 23:44:42 +01:00
|
|
|
$form_name.($set_val?"[$set_val]":''),$accesskey);
|
2002-10-09 02:31:01 +02:00
|
|
|
}
|
2006-12-07 13:46:46 +01:00
|
|
|
if ($type == 'radio' || $type == 'checkbox' || $label && strpos($label,'%s')!==false) // default for radio is label after the button
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
2006-12-07 13:46:46 +01:00
|
|
|
$html = strpos($label,'%s')!==false ? str_replace('%s',$html,$label) : $html.' '.$label;
|
2002-02-06 10:03:11 +01:00
|
|
|
}
|
|
|
|
elseif (($html = $label . ' ' . $html) == ' ')
|
|
|
|
{
|
|
|
|
$html = ' ';
|
|
|
|
}
|
|
|
|
}
|
2005-11-10 15:51:12 +01:00
|
|
|
if ($extra_link && (($extra_link = $this->expand_name($extra_link,$show_c,$show_row,$content['.c'],$content['.row'],$content))))
|
2002-10-14 02:39:47 +02:00
|
|
|
{
|
2005-11-10 15:51:12 +01:00
|
|
|
$options = $help ? ' onmouseover="self.status=\''.addslashes($this->html->htmlspecialchars($help)).'\'; return true;"' .
|
|
|
|
' onmouseout="self.status=\'\'; return true;"' : '';
|
|
|
|
|
|
|
|
if ($extra_link_target && (($extra_link_target = $this->expand_name($extra_link_target,$show_c,$show_row,$content['.c'],$content['.row'],$content))))
|
2002-10-14 02:39:47 +02:00
|
|
|
{
|
2005-11-10 15:51:12 +01:00
|
|
|
$options .= ' target="'.addslashes($extra_link_target).'"';
|
2002-10-14 02:39:47 +02:00
|
|
|
}
|
2005-11-10 15:51:12 +01:00
|
|
|
if ($extra_link_popup && (($extra_link_popup = $this->expand_name($extra_link_popup,$show_c,$show_row,$content['.c'],$content['.row'],$content))))
|
2002-10-18 00:10:12 +02:00
|
|
|
{
|
2005-11-10 15:51:12 +01:00
|
|
|
list($w,$h) = explode('x',$extra_link_popup);
|
|
|
|
$options .= ' onclick="window.open(this,this.target,\'width='.(int)$w.',height='.(int)$h.',location=no,menubar=no,toolbar=no,scrollbars=yes,status=yes\'); return false;"';
|
2002-10-18 00:10:12 +02:00
|
|
|
}
|
2006-06-15 23:57:21 +02:00
|
|
|
if ($extra_link_title)
|
|
|
|
{
|
|
|
|
$options .= ' title="'.addslashes($extra_link_title).'"';
|
|
|
|
}
|
2005-11-10 15:51:12 +01:00
|
|
|
return $this->html->a_href($html,$extra_link,'',$options);
|
2002-10-14 02:39:47 +02:00
|
|
|
}
|
2004-04-05 03:33:23 +02:00
|
|
|
// if necessary show validation-error behind field
|
2005-11-09 21:50:45 +01:00
|
|
|
if (isset($GLOBALS['egw_info']['etemplate']['validation_errors'][$form_name]))
|
2004-04-05 03:33:23 +02:00
|
|
|
{
|
2006-08-12 08:14:28 +02:00
|
|
|
$html .= ' <span style="color: red; white-space: nowrap;">'.$GLOBALS['egw_info']['etemplate']['validation_errors'][$form_name].'</span>';
|
2004-04-05 03:33:23 +02:00
|
|
|
}
|
2005-02-16 00:22:10 +01:00
|
|
|
// generate an extra div, if we have an onclick handler and NO children or it's an extension
|
|
|
|
//echo "<p>$this->name($this->onclick_handler:$this->no_onclick:$this->onclick_proxy): $cell[type]/$cell[name]</p>\n";
|
|
|
|
if ($this->onclick_handler && !isset($this->widgets_with_children[$cell['type']]))
|
|
|
|
{
|
2005-03-29 16:16:42 +02:00
|
|
|
$handler = str_replace('%p',$this->no_onclick ? $this->onclick_proxy : $this->name.':'.$this->version.':'.$path,
|
2005-02-16 00:22:10 +01:00
|
|
|
$this->onclick_handler);
|
2007-01-20 09:55:26 +01:00
|
|
|
if ($type == 'button' || $type == 'buttononly' || !$label) // add something to click on
|
2005-02-22 22:02:26 +01:00
|
|
|
{
|
|
|
|
$html = (substr($html,-1) == "\n" ? substr($html,0,-1) : $html).' ';
|
|
|
|
}
|
2005-02-16 00:22:10 +01:00
|
|
|
return $this->html->div($html,' ondblclick="'.$handler.'"','clickWidgetToEdit');
|
|
|
|
}
|
2002-02-06 10:03:11 +01:00
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
|
2006-09-29 21:47:29 +02:00
|
|
|
/**
|
|
|
|
* Resolve javascript pseudo functions:
|
|
|
|
* - egw::link('$l','$p') calls $egw->link($l,$p)
|
|
|
|
* - form::name('name') returns expanded name/id taking into account the name at that point of the template hierashy
|
|
|
|
* - confirm('message') translates 'message' and adds a '?' if not present
|
|
|
|
*
|
|
|
|
* @param string $on onclick, onchange, ... action
|
|
|
|
* @param string $cname name-prefix / name-space
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
function js_pseudo_funcs($on,$cname)
|
|
|
|
{
|
|
|
|
if (preg_match("/egw::link\\('([^']+)','([^']+)'\\)/",$on,$matches))
|
|
|
|
{
|
|
|
|
$url = $GLOBALS['egw']->link($matches[1],$matches[2]);
|
|
|
|
$on = str_replace($matches[0],'\''.$url.'\'',$on);
|
|
|
|
//$on = preg_replace('/egw::link\(\'([^\']+)\',\'([^\']+)\'\)/','\''.$url.'\'',$on);
|
|
|
|
}
|
|
|
|
if (preg_match_all("/form::name\\('([^']+)'\\)/",$on,$matches))
|
|
|
|
{
|
|
|
|
foreach($matches[1] as $n => $matche_name)
|
|
|
|
{
|
|
|
|
$matches[1][$n] = '\''.$this->form_name($cname,$matche_name).'\'';
|
|
|
|
}
|
|
|
|
$on = str_replace($matches[0],$matches[1],$on);
|
|
|
|
}
|
|
|
|
if (preg_match('/confirm\(["\']{1}(.*)["\']{1}\)/',$on,$matches))
|
|
|
|
{
|
|
|
|
$question = lang($matches[1]).(substr($matches[1],-1) != '?' ? '?' : ''); // add ? if not there, saves extra phrase
|
|
|
|
$on = str_replace($matches[0],'confirm(\''.addslashes($question).'\')',$on);
|
|
|
|
//$on = preg_replace('/confirm\(["\']{1}(.*)["\']{1}\)/','confirm(\''.addslashes($question).'\')',$on);
|
|
|
|
}
|
2006-04-06 07:10:32 +02:00
|
|
|
// replace xajax calls to code in widgets, with the "etemplate" handler,
|
|
|
|
// this allows to call widgets with the current app, otherwise everyone would need etemplate run rights
|
2006-12-07 13:46:46 +01:00
|
|
|
if (strpos($on,"xajax_doXMLHTTP('etemplate.")!==false)
|
2006-04-06 07:10:32 +02:00
|
|
|
{
|
|
|
|
$on = preg_replace("/^xajax_doXMLHTTP\('etemplate\.([a-z]+_widget\.[a-zA-Z0-9_]+)\'/",'xajax_doXMLHTTP(\''.$GLOBALS['egw_info']['flags']['currentapp'].'.\\1.etemplate\'',$on);
|
|
|
|
}
|
2006-09-29 21:47:29 +02:00
|
|
|
return $on;
|
|
|
|
}
|
|
|
|
|
2005-02-12 14:59:08 +01:00
|
|
|
/**
|
|
|
|
* applies stripslashes recursivly on each element of an array
|
|
|
|
*
|
|
|
|
* @param array &$var
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
function array_stripslashes($var)
|
|
|
|
{
|
|
|
|
if (!is_array($var))
|
|
|
|
{
|
|
|
|
return stripslashes($var);
|
|
|
|
}
|
|
|
|
foreach($var as $key => $val)
|
|
|
|
{
|
|
|
|
$var[$key] = is_array($val) ? $this->array_stripslashes($val) : stripslashes($val);
|
|
|
|
}
|
|
|
|
return $var;
|
|
|
|
}
|
2002-10-01 20:26:30 +02:00
|
|
|
|
2004-10-07 23:53:41 +02:00
|
|
|
/**
|
|
|
|
* makes necessary adjustments on $_POST after a eTemplate / form gots submitted
|
|
|
|
*
|
|
|
|
* This is only an internal function, dont call it direct use only exec
|
|
|
|
* Process_show uses a list of input-fields/widgets generated by show.
|
|
|
|
*
|
2005-02-08 13:29:06 +01:00
|
|
|
* @internal
|
2005-02-12 14:59:08 +01:00
|
|
|
* @param array $content $_POST[$cname], on return the adjusted content
|
|
|
|
* @param array $to_process list of widgets/form-fields to process
|
|
|
|
* @param string $cname basename of our returnt content (same as in call to show)
|
2006-12-17 15:15:10 +01:00
|
|
|
* @param string $type type of request
|
2004-10-07 23:53:41 +02:00
|
|
|
* @return int number of validation errors (the adjusted content is returned by the var-param &$content !)
|
2006-10-16 22:01:31 +02:00
|
|
|
*/
|
2006-12-17 15:15:10 +01:00
|
|
|
function process_show(&$content,$to_process,$cname='', $type = 'regular')
|
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();
|
2005-02-12 14:59:08 +01:00
|
|
|
if (get_magic_quotes_gpc())
|
|
|
|
{
|
|
|
|
$content_in = $this->array_stripslashes($content_in);
|
|
|
|
}
|
2005-11-09 21:50:45 +01:00
|
|
|
$GLOBALS['egw_info']['etemplate']['validation_errors'] = array();
|
2004-08-01 21:26:33 +02:00
|
|
|
$this->canceled = $this->button_pressed = False;
|
2006-10-16 22:01:31 +02:00
|
|
|
|
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();
|
|
|
|
}
|
2006-10-10 20:03:27 +02:00
|
|
|
$value = $this->get_array($content_in,$form_name,True,$GLOBALS['egw_info']['flags']['currentapp'] == 'etemplate' ? false : true );
|
2006-12-17 15:15:10 +01:00
|
|
|
// The comment below does only aplay to normal posts, not for xajax. Files are not supported anyway by xajax atm.
|
2006-10-24 16:15:28 +02:00
|
|
|
// not checked checboxes are not returned in HTML and file is in $_FILES and not in $content_in
|
2006-12-17 15:15:10 +01:00
|
|
|
if($value === false && $type == 'xajaxResponse' /*!in_array($type,array('checkbox','file'))*/) continue;
|
2006-10-10 17:10:07 +02:00
|
|
|
|
2005-02-04 14:40:56 +01:00
|
|
|
if (isset($attr['blur']) && $attr['blur'] == $value)
|
2003-08-28 16:31:11 +02:00
|
|
|
{
|
|
|
|
$value = ''; // blur-values is equal to emtpy
|
|
|
|
}
|
2006-09-27 15:09:28 +02:00
|
|
|
//echo "<p>process_show($this->name) loop was {$GLOBALS['egw_info']['etemplate']['loop']}, $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
|
|
|
{
|
2005-04-06 08:31:27 +02:00
|
|
|
//echo "\n<p><b>unsetting content[$form_name] !!!</b></p>\n";
|
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
|
2005-04-06 08:31:27 +02:00
|
|
|
// seems to depend on the number of (not existing) dimensions of the array -- -- RalfBecker 2005/04/06
|
|
|
|
elseif (!$this->isset_array($content,$form_name))
|
2004-09-20 20:51:31 +02:00
|
|
|
{
|
2005-04-06 08:31:27 +02:00
|
|
|
//echo "<p>setting content[$form_name]='$_cont' because is was unset !!!</p>\n";
|
2004-09-20 20:51:31 +02:00
|
|
|
$this->set_array($content,$form_name,$_cont);
|
|
|
|
}
|
2006-03-21 15:00:50 +01:00
|
|
|
if ($_cont === '' && $attr['needed'] && !$attr['blur'])
|
2005-03-05 15:59:33 +01:00
|
|
|
{
|
2006-09-12 17:12:39 +02:00
|
|
|
$this->set_validation_error($form_name,lang('Field must not be empty !!!'),'');
|
2005-03-05 15:59:33 +01:00
|
|
|
}
|
2002-10-01 20:26:30 +02:00
|
|
|
break;
|
2004-02-28 23:41:32 +01:00
|
|
|
case 'htmlarea':
|
|
|
|
$this->set_array($content,$form_name,$value);
|
|
|
|
break;
|
2004-04-05 03:33:23 +02:00
|
|
|
case 'int':
|
|
|
|
case 'float':
|
2006-12-06 21:09:22 +01:00
|
|
|
case 'passwd':
|
2002-10-01 20:26:30 +02:00
|
|
|
case 'text':
|
|
|
|
case 'textarea':
|
2006-03-21 15:00:50 +01:00
|
|
|
if ($value === '' && $attr['needed'] && !$attr['blur'])
|
2004-04-05 03:33:23 +02:00
|
|
|
{
|
2006-09-12 17:12:39 +02:00
|
|
|
$this->set_validation_error($form_name,lang('Field must not be empty !!!'),'');
|
2004-04-05 03:33:23 +02:00
|
|
|
}
|
|
|
|
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':
|
2006-09-12 17:12:39 +02:00
|
|
|
$this->set_validation_error($form_name,lang("'%1' is not a valid integer !!!",$value),'');
|
2004-04-05 03:33:23 +02:00
|
|
|
break;
|
|
|
|
case 'float':
|
2006-09-12 17:12:39 +02:00
|
|
|
$this->set_validation_error($form_name,lang("'%1' is not a valid floatingpoint number !!!",$value),'');
|
2004-04-05 03:33:23 +02:00
|
|
|
break;
|
|
|
|
default:
|
2006-09-12 17:12:39 +02:00
|
|
|
$this->set_validation_error($form_name,lang("'%1' has an invalid format !!!",$value),'');
|
2004-04-05 03:33:23 +02:00
|
|
|
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'])
|
|
|
|
{
|
2006-09-12 17:12:39 +02:00
|
|
|
$this->set_validation_error($form_name,lang("Value has to be at least '%1' !!!",$attr['min']),'');
|
2004-04-05 03:33:23 +02:00
|
|
|
$value = $type == 'int' ? (int) $attr['min'] : (float) $attr['min'];
|
|
|
|
}
|
|
|
|
if (!empty($attr['max']) && $value > $attr['max'])
|
|
|
|
{
|
2006-09-12 17:12:39 +02:00
|
|
|
$this->set_validation_error($form_name,lang("Value has to be at maximum '%1' !!!",$attr['max']),'');
|
2004-04-05 03:33:23 +02:00
|
|
|
$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':
|
2006-08-15 14:14:05 +02:00
|
|
|
if ($attr['allowed']) // only check for $value is allowed, if allowed values are set
|
|
|
|
{
|
|
|
|
foreach(is_array($value) ? $value : array($value) as $val)
|
|
|
|
{
|
2007-03-13 14:46:50 +01:00
|
|
|
if (!($attr['multiple'] && !$val) && !in_array($val,$attr['allowed']))
|
2006-08-15 14:14:05 +02:00
|
|
|
{
|
2007-03-13 14:46:50 +01:00
|
|
|
$this->set_validation_error($form_name,lang("'%1' is NOT allowed ('%2')!",$val,implode("','",$attr['allowed'])),'');
|
2006-08-15 14:14:05 +02:00
|
|
|
$value = '';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (is_array($value)) $value = implode(',',$value);
|
|
|
|
if ($value === '' && $attr['needed'])
|
|
|
|
{
|
2006-09-12 17:12:39 +02:00
|
|
|
$this->set_validation_error($form_name,lang('Field must not be empty !!!',$value),'');
|
2006-08-15 14:14:05 +02:00
|
|
|
}
|
|
|
|
$this->set_array($content,$form_name,$value);
|
2002-10-01 20:26:30 +02:00
|
|
|
break;
|
|
|
|
case 'checkbox':
|
2006-10-24 16:15:28 +02:00
|
|
|
if ($value === false) // get_array() returns false for not set
|
2002-02-06 10:03:11 +01:00
|
|
|
{
|
2005-06-12 17:58:22 +02:00
|
|
|
$this->set_array($content,$form_name,$attr['multiple'] ? array() : $attr['unset_value']); // need to be reported too
|
2002-02-06 10:03:11 +01:00
|
|
|
}
|
2005-06-12 17:58:22 +02:00
|
|
|
else
|
2002-10-02 02:44:33 +02:00
|
|
|
{
|
2005-06-12 17:58:22 +02:00
|
|
|
$value = array_intersect(is_array($value) ? $value : array($value),$attr['values']); // return only allowed values
|
|
|
|
$this->set_array($content,$form_name,$attr['multiple'] ? $value : $value[0]);
|
2002-10-02 02:44:33 +02:00
|
|
|
}
|
2002-10-01 20:26:30 +02:00
|
|
|
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);
|
2005-11-09 21:50:45 +01:00
|
|
|
if (count($GLOBALS['egw_info']['etemplate']['validation_errors']))
|
2004-04-05 03:33:23 +02:00
|
|
|
{
|
2005-11-09 21:50:45 +01:00
|
|
|
echo "<p>validation_errors = "; _debug_array($GLOBALS['egw_info']['etemplate']['validation_errors']);
|
2004-04-05 03:33:23 +02:00
|
|
|
}
|
2002-02-06 10:03:11 +01:00
|
|
|
}
|
2005-11-09 21:50:45 +01:00
|
|
|
return count($GLOBALS['egw_info']['etemplate']['validation_errors']);
|
2002-02-06 10:03:11 +01:00
|
|
|
}
|
2006-09-12 17:12:39 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets a validation error, to be displayed in the next exec
|
|
|
|
*
|
|
|
|
* @param string $name (complete) name of the widget causing the error
|
|
|
|
* @param string $error error-message already translated
|
2007-03-13 14:46:50 +01:00
|
|
|
* @param string $cname=null set it to '', if the name is already a form-name, defaults to $this->name_vars
|
2006-09-12 17:12:39 +02:00
|
|
|
*/
|
2007-03-13 14:46:50 +01:00
|
|
|
function set_validation_error($name,$error,$cname=null)
|
2006-09-12 17:12:39 +02:00
|
|
|
{
|
2007-03-13 14:46:50 +01:00
|
|
|
if (is_null($cname)) $cname = $this->name_vars;
|
|
|
|
//echo "<p>etemplate::set_validation_error('$name','$error','$cname');</p>\n";
|
2006-09-12 17:12:39 +02:00
|
|
|
if ($cname) $name = $this->form_name($cname,$name);
|
|
|
|
|
|
|
|
if ($GLOBALS['egw_info']['etemplate']['validation_errors'][$name])
|
|
|
|
{
|
|
|
|
$GLOBALS['egw_info']['etemplate']['validation_errors'][$name] .= ', ';
|
|
|
|
}
|
|
|
|
$GLOBALS['egw_info']['etemplate']['validation_errors'][$name] .= $error;
|
|
|
|
}
|
2002-06-15 21:59:07 +02:00
|
|
|
|
2004-10-07 23:53:41 +02:00
|
|
|
/**
|
|
|
|
* is javascript enabled?
|
|
|
|
*
|
|
|
|
* this should be tested by the api at login
|
|
|
|
*
|
|
|
|
* @return boolean 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)
|
|
|
|
{
|
2005-11-09 21:50:45 +01:00
|
|
|
$ret = !!$GLOBALS['egw_info']['etemplate']['java_script'] ||
|
|
|
|
$consider_not_tested_as_enabled && !isset($GLOBALS['egw_info']['etemplate']['java_script']);
|
|
|
|
//echo "<p>java_script($consider_not_tested_as_enabled)='$ret', java_script='".$GLOBALS['egw_info']['etemplate']['java_script']."', isset(java_script)=".isset($GLOBALS['egw_info']['etemplate']['java_script'])."</p>\n";
|
2003-04-13 23:47:03 +02:00
|
|
|
|
|
|
|
return $ret;
|
2005-11-09 21:50:45 +01:00
|
|
|
return !!$GLOBALS['egw_info']['etemplate']['java_script'] ||
|
2002-06-15 21:59:07 +02:00
|
|
|
$consider_not_tested_as_enabled &&
|
2005-11-09 21:50:45 +01:00
|
|
|
(!isset($GLOBALS['egw_info']['etemplate']['java_script']) ||
|
|
|
|
$GLOBALS['egw_info']['etemplate']['java_script'].'' == '');
|
2002-06-15 21:59:07 +02:00
|
|
|
}
|
|
|
|
|
2004-10-07 23:53:41 +02:00
|
|
|
/**
|
|
|
|
* returns the javascript to be included by exec
|
|
|
|
*
|
2005-02-13 14:03:36 +01:00
|
|
|
* @param int $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
|
2004-10-07 23:53:41 +02:00
|
|
|
* @return string javascript
|
|
|
|
*/
|
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
|
2005-11-09 21:50:45 +01:00
|
|
|
if ($what & 1 && !isset($GLOBALS['egw_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
|
|
|
{
|
2006-10-09 19:36:40 +02:00
|
|
|
$lastmod = filectime(EGW_INCLUDE_ROOT. '/etemplate/js/etemplate.js');
|
2003-08-28 16:31:11 +02:00
|
|
|
$js .= '<script type="text/javascript" src="'.
|
2006-10-09 19:36:40 +02:00
|
|
|
$GLOBALS['egw_info']['server']['webserver_url'].'/etemplate/js/etemplate.js?'. $lastmod.'"></script>'."\n";
|
2002-06-15 21:59:07 +02:00
|
|
|
}
|
|
|
|
return $js;
|
|
|
|
}
|
2002-10-08 02:08:40 +02:00
|
|
|
};
|