mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-27 09:09:04 +01:00
Add get_all_links() to get all link placeholders from content
This commit is contained in:
parent
d288fadaec
commit
03aeacf69d
@ -334,6 +334,48 @@ abstract class bo_merge
|
||||
return implode("\n",$link_titles);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all link placeholders
|
||||
*
|
||||
* Calls get_links() repeatedly to get all the combinations for the content.
|
||||
*
|
||||
* @param app String appname
|
||||
* @param id String ID of record
|
||||
* @param content String document content
|
||||
*/
|
||||
protected function get_all_links($app, $id, &$content)
|
||||
{
|
||||
$array = array();
|
||||
$pattern = '@\$(links|attachments|links_attachments)\/?(title|href|link)?\/?([a-z]*)\$@';
|
||||
static $link_cache;
|
||||
if(preg_match_all($pattern, $content, $matches))
|
||||
{
|
||||
foreach($matches[0] as $i => $placeholder)
|
||||
{
|
||||
$placeholder = substr($placeholder, 1, -1);
|
||||
if($link_cache[$id][$placeholder])
|
||||
{
|
||||
$array[$placeholder] = $link_cache[$id][$placeholder];
|
||||
continue;
|
||||
}
|
||||
switch($matches[1][$i])
|
||||
{
|
||||
case 'links':
|
||||
$array[$placeholder] = $this->get_links($app, $id, '!'.egw_link::VFS_APPNAME, array(),$matches[2][$i]);
|
||||
break;
|
||||
case 'attachments':
|
||||
$array[$placeholder] = $this->get_links($app, $id, egw_link::VFS_APPNAME,array(),$matches[2][$i]);
|
||||
break;
|
||||
default:
|
||||
$array[$placeholder] = $this->get_links($app, $id, $matches[3][$i], array(), $matches[2][$i]);
|
||||
break;
|
||||
}
|
||||
$link_cache[$id][$placeholder] = $array[$placeholder];
|
||||
}
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a datetime
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user