mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-26 00:29:38 +01:00
Expand link_to custom fields and make available all placeholders from the app.
eg: {{#address}} gives the link title, but now you can use {{#address/n_fn}}, {{#address/email}}, etc.
This commit is contained in:
parent
74a79dfad9
commit
57602e41ca
@ -1103,6 +1103,43 @@ abstract class bo_merge
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Expand link_to custom fields with the merge replacements from the app
|
||||
* but only if the template uses them.
|
||||
*/
|
||||
public function cf_link_to_expand($values, $content, &$replacements, $app = null)
|
||||
{
|
||||
if($app == null)
|
||||
{
|
||||
$app = str_replace('_merge','',get_class($this));
|
||||
}
|
||||
$cfs = config::get_customfields($app);
|
||||
|
||||
// Cache, in case more than one sub-placeholder is used
|
||||
$app_replacements = array();
|
||||
|
||||
// Custom field placeholders look like {{#name}}
|
||||
// Placeholders that need expanded will look like {{#name/placeholder}}
|
||||
preg_match_all('/[${]{2}(([\w]+\/)*)#([\w]+)\/(.*)[$}]{2}/', $content, $matches);
|
||||
list($placeholders, $prefixes, $pre, $cf, $sub) = $matches;
|
||||
|
||||
foreach($cf as $index => $field)
|
||||
{
|
||||
if($cfs[$field])
|
||||
{
|
||||
// Get replacements for that application
|
||||
$field_app = $cfs[$field]['type'];
|
||||
if(!$app_replacements[$field_app])
|
||||
{
|
||||
$classname = "{$field_app}_merge";
|
||||
$class = new $classname();
|
||||
$app_replacements[$field_app] = $class->get_replacements($values['#'.$field], $placeholders[$index]);
|
||||
}
|
||||
$replacements[$placeholders[$index]] = $app_replacements[$field_app]['$$'.$sub[$index].'$$'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process special flags, such as IF or NELF
|
||||
*
|
||||
|
@ -58,7 +58,7 @@ class infolog_merge extends bo_merge
|
||||
*/
|
||||
protected function get_replacements($id,&$content=null)
|
||||
{
|
||||
if (!($replacements = $this->infolog_replacements($id)))
|
||||
if (!($replacements = $this->infolog_replacements($id, '', $content)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -81,7 +81,7 @@ class infolog_merge extends bo_merge
|
||||
* @param string $prefix='' prefix like eg. 'erole'
|
||||
* @return array|boolean
|
||||
*/
|
||||
public function infolog_replacements($id,$prefix='')
|
||||
public function infolog_replacements($id,$prefix='', &$content = '')
|
||||
{
|
||||
$record = new infolog_egw_record($id);
|
||||
$info = array();
|
||||
@ -94,6 +94,12 @@ class infolog_merge extends bo_merge
|
||||
$selects['info_'.$name] = $value;
|
||||
$types['select'][] = 'info_'.$name;
|
||||
}
|
||||
|
||||
if($content && strpos($content, '$$#') !== 0)
|
||||
{
|
||||
$this->cf_link_to_expand($record->get_record_array(), $content, $info);
|
||||
}
|
||||
|
||||
importexport_export_csv::convert($record, $types, 'infolog', $selects);
|
||||
if($record->info_contact)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user