mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-27 09:09:07 +01:00
added javascrpt values2url function to transmit selected runtime values via the url to a popup, which can use etemplate::process_values2url to retrieve the values from the url as content-array (incl. $preserv from exec())
This commit is contained in:
parent
fd13a74162
commit
215ab71516
@ -1003,21 +1003,21 @@
|
||||
$cell_content['onclick'] = $matches[1];
|
||||
$cell_content['onclick_type'] = 'confirm';
|
||||
}
|
||||
elseif (preg_match('/^window.open\(egw::link\(\'\/index.php\',\'([^\']+)\'\),\'([^\']+)\',\'dependent=yes,width=([0-9]+),height=([0-9]+),scrollbars=yes,status=yes\'\); return false;$/',$widget['onclick'],$matches))
|
||||
elseif (preg_match('/^window.open\(egw::link\(\'\/index.php\',\'([^\']+)\'\)(\+values2url\(.*\))?,\'([^\']+)\',\'dependent=yes,width=([0-9]+),height=([0-9]+),scrollbars=yes,status=yes\'\); return false;$/',$widget['onclick'],$matches))
|
||||
{
|
||||
$cell_content['onclick'] = $matches[1];
|
||||
if ($matches[2] != '_blank')
|
||||
$cell_content['onclick'] = $matches[1].($matches[2] ? str_replace('+values2url(this.form,','&values2url(',$matches[2]) : '');
|
||||
if ($matches[3] != '_blank')
|
||||
{
|
||||
$cell_content['onclick'] .= ','.$matches[2];
|
||||
$cell_content['onclick'] .= ','.$matches[3];
|
||||
}
|
||||
if ($matches[3] != '600')
|
||||
if ($matches[4] != '600')
|
||||
{
|
||||
$cell_content['onclick'] .= ($matches[2]=='_blank' ? ',':'').','.$matches[3];
|
||||
$cell_content['onclick'] .= ($matches[3]=='_blank' ? ',':'').','.$matches[4];
|
||||
}
|
||||
if ($matches[4] != '450')
|
||||
if ($matches[5] != '450')
|
||||
{
|
||||
$cell_content['onclick'] .= ($matches[2]=='_blank' ? ',':'').
|
||||
($matches[3]=='600' ? ',':'').','.$matches[4];
|
||||
$cell_content['onclick'] .= ($matches[3]=='_blank' ? ',':'').
|
||||
($matches[4]=='600' ? ',':'').','.$matches[5];
|
||||
}
|
||||
$cell_content['onclick_type'] = 'popup';
|
||||
}
|
||||
@ -1037,11 +1037,18 @@
|
||||
}
|
||||
elseif ($cell_content['onclick_type'] == 'popup' && $cell_content['onclick'])
|
||||
{
|
||||
list($get,$target,$width,$height) = explode(',',$cell_content['onclick']);
|
||||
// eg: menuaction=calendar.uiforms.freetimesearch&values2url('start,end,participants'),ft_search,700,500
|
||||
if (($values2url = preg_match('/&values2url\((\'[^\']+\')\)/',$cell_content['onclick'],$matches)))
|
||||
{
|
||||
$values2url = $matches[1];
|
||||
$onclick = str_replace('&values2url('.$values2url.')','',$cell_content['onclick']);
|
||||
}
|
||||
list($get,$target,$width,$height) = explode(',',$values2url ? $onclick : $cell_content['onclick']);
|
||||
if (!$target) $target = '_blank';
|
||||
if (!$width) $width = 600;
|
||||
if (!$height) $height = 450;
|
||||
$widget['onclick'] = "window.open(egw::link('/index.php','$get'),'$target','dependent=yes,width=$width,height=$height,scrollbars=yes,status=yes'); return false;";
|
||||
$widget['onclick'] = "window.open(egw::link('/index.php','$get')".($values2url ? "+values2url(this.form,$values2url)" : '').
|
||||
",'$target','dependent=yes,width=$width,height=$height,scrollbars=yes,status=yes'); return false;";
|
||||
}
|
||||
elseif ($cell_content['onclick'])
|
||||
{
|
||||
|
@ -348,6 +348,35 @@
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
$GLOBALS['phpgw_info']['etemplate']['extension_data'] = $session_data['extension_data'];
|
||||
|
||||
$content = $_GET['exec'];
|
||||
if (!is_array($content))
|
||||
{
|
||||
$content = array();
|
||||
}
|
||||
$this->process_show($content,$session_data['to_process'],'exec');
|
||||
|
||||
return $this->complete_array_merge($session_data['preserv'],$content);
|
||||
}
|
||||
|
||||
/**
|
||||
* creates HTML from an eTemplate
|
||||
*
|
||||
@ -744,6 +773,12 @@
|
||||
{
|
||||
$help = lang($help);
|
||||
}
|
||||
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
|
||||
{
|
||||
$onFocus .= "self.status='".addslashes($this->html->htmlspecialchars($help))."'; return true;";
|
||||
$onBlur .= "self.status=''; return true;";
|
||||
if ($cell['type'] == 'button' || $cell['type'] == 'file') // for button additionally when mouse over button
|
||||
@ -752,6 +787,7 @@
|
||||
$options .= " onMouseOut=\"self.status=''; return true;\"";
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($onBlur)
|
||||
{
|
||||
$options .= " onFocus=\"$onFocus\" onBlur=\"$onBlur\"";
|
||||
|
@ -112,3 +112,39 @@ function toggle_all(form,name)
|
||||
form.elements[name][i].checked = !all_set;
|
||||
}
|
||||
}
|
||||
|
||||
/* gets the values of the named widgets (use the etemplate-name, not the form-name) and creates an url from it */
|
||||
function values2url(form,names)
|
||||
{
|
||||
url = '';
|
||||
names = names.split(',');
|
||||
for(i=0; i < names.length; i++)
|
||||
{
|
||||
form_name = names[i];
|
||||
b = form_name.indexOf('[');
|
||||
if (b < 0) {
|
||||
form_name = 'exec['+form_name+']';
|
||||
} else {
|
||||
form_name = 'exec['+form_name.slice(0,b-1)+']'+form_name.slice(b,99);
|
||||
}
|
||||
//alert('Searching for '+form_name);
|
||||
for (f=0; f < form.elements.length; f++) {
|
||||
element = form.elements[f];
|
||||
//alert('checking '+element.name);
|
||||
if (element.name.slice(0,form_name.length) == form_name) {
|
||||
//alert('found '+element.name+', value='+element.value);
|
||||
if (element.type == 'checkbox' || element.type == 'radio') { // checkbox or radio
|
||||
if (element.checked) url += '&'+element.name+'='+element.value;
|
||||
} else if (element.value != null) {
|
||||
url += '&'+element.name+'='+element.value;
|
||||
} else if (element.options) { // selectbox
|
||||
for(opt=0; opt < element.options.length; opt++) {
|
||||
if (element.options[opt].selected) url += '&'+element.name+'[]='+element.options[opt].value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//alert('url='+url);
|
||||
return url+'&etemplate_exec_id='+form['etemplate_exec_id'].value;
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user