mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-23 00:13:35 +01:00
some new features for the infolog-widget to improve form printting: 1) fetching contact fields from linked infolog entries, 2) formatting content with preg_replace
This commit is contained in:
parent
cea9766cc4
commit
8e9f44c745
@ -99,7 +99,7 @@ class infolog_widget
|
||||
$value = '';
|
||||
break;
|
||||
}
|
||||
list($type,$compare,$alternatives) = explode(',',$cell['size']);
|
||||
list($type,$compare,$alternatives,$contactfield,$regex,$replace) = explode(',',$cell['size'],6);
|
||||
$value = $this->info[$type];
|
||||
$cell['size'] = '';
|
||||
$cell['no_lang'] = 1;
|
||||
@ -109,7 +109,7 @@ class infolog_widget
|
||||
{
|
||||
case '': // Sum of the alternatives
|
||||
$cell['type'] = 'float';
|
||||
$cell['size'] = ',,,2';
|
||||
$cell['size'] = ',,,%0.2lf';
|
||||
$value = 0.0;
|
||||
foreach(explode(':',$alternatives) as $name)
|
||||
{
|
||||
@ -174,6 +174,23 @@ class infolog_widget
|
||||
$value = $value == $compare ? 'X' : '';
|
||||
$cell['type'] = 'label';
|
||||
}
|
||||
// modify the value with a regular expression
|
||||
if (!empty($regex))
|
||||
{
|
||||
$parts = explode('/',$regex);
|
||||
if (strchr(array_pop($parts),'e') === false) // dont allow e modifier, which would execute arbitrary php code
|
||||
{
|
||||
$value = preg_replace($regex,$replace,$value);
|
||||
}
|
||||
$cell['type'] = 'label';
|
||||
$cell['size'] = '';
|
||||
}
|
||||
// use a contact widget to render the value, eg. to fetch contact data from an linked infolog
|
||||
if (!empty($contactfield))
|
||||
{
|
||||
$cell['type'] = 'contact-value';
|
||||
$cell['size'] = $contactfield;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return True; // extra label ok
|
||||
|
Loading…
Reference in New Issue
Block a user