mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-23 08:23:12 +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 = '';
|
$value = '';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
list($type,$compare,$alternatives) = explode(',',$cell['size']);
|
list($type,$compare,$alternatives,$contactfield,$regex,$replace) = explode(',',$cell['size'],6);
|
||||||
$value = $this->info[$type];
|
$value = $this->info[$type];
|
||||||
$cell['size'] = '';
|
$cell['size'] = '';
|
||||||
$cell['no_lang'] = 1;
|
$cell['no_lang'] = 1;
|
||||||
@ -109,7 +109,7 @@ class infolog_widget
|
|||||||
{
|
{
|
||||||
case '': // Sum of the alternatives
|
case '': // Sum of the alternatives
|
||||||
$cell['type'] = 'float';
|
$cell['type'] = 'float';
|
||||||
$cell['size'] = ',,,2';
|
$cell['size'] = ',,,%0.2lf';
|
||||||
$value = 0.0;
|
$value = 0.0;
|
||||||
foreach(explode(':',$alternatives) as $name)
|
foreach(explode(':',$alternatives) as $name)
|
||||||
{
|
{
|
||||||
@ -174,6 +174,23 @@ class infolog_widget
|
|||||||
$value = $value == $compare ? 'X' : '';
|
$value = $value == $compare ? 'X' : '';
|
||||||
$cell['type'] = 'label';
|
$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;
|
break;
|
||||||
}
|
}
|
||||||
return True; // extra label ok
|
return True; // extra label ok
|
||||||
|
Loading…
Reference in New Issue
Block a user