Add placeholder [links|attachments|links_attachments]/link to get a download url for attachments

This commit is contained in:
Nathan Gray 2012-02-28 00:23:41 +00:00
parent 058553b8d9
commit dc6da791f4

View File

@ -309,8 +309,17 @@ abstract class bo_merge
* Get links for the given record
*
* Uses egw_link system to get link titles
*
* @param app Name of current app
* @param id ID of current entry
* @param only_app Restrict links to only given application
* @param exclude Exclude links to these applications
* @param style String One of:
* 'title' - plain text, just the title of the link
* 'link' - URL to the entry
* 'href' - HREF tag wrapped around the title
*/
protected function get_links($app, $id, $only_app='', $exclude = array())
protected function get_links($app, $id, $only_app='', $exclude = array(), $style = 'title')
{
$links = egw_link::get_links($app, $id, $only_app);
$link_titles = array();
@ -331,6 +340,25 @@ abstract class bo_merge
{
$title = stylite_links_stream_wrapper::entry2name($link_info['app'], $link_info['id'], $title);
}
if($style == 'href' || $style == 'link')
{
$link = egw_link::view($link_info['app'], $link_info['id'], $link_info);
if($link_info['app'] != egw_link::VFS_APPNAME)
{
$link = str_replace(',','%2C',egw::link('/index.php',$link, $link_info['app']));
}
else
{
$link = egw::link($link);
}
// Prepend site
if ($link{0} == '/')
{
$link = ($_SERVER['HTTPS'] || $GLOBALS['egw_info']['server']['enforce_ssl'] ? 'https://' : 'http://').
($GLOBALS['egw_info']['server']['hostname'] ? $GLOBALS['egw_info']['server']['hostname'] : $_SERVER['HTTP_HOST']).$link;
}
$title = $style == 'href' ? html::a_href(html::htmlspecialchars($title), $link) : $link;
}
$link_titles[] = $title;
}
return implode("\n",$link_titles);
@ -830,7 +858,7 @@ abstract class bo_merge
case 'text/html':
$replace_tags = array(
'<b>','<strong>','<i>','<em>','<u>','<span>','<ol>','<ul>','<li>',
'<table>','<tr>','<td>',
'<table>','<tr>','<td>','<a>',
);
break;
case 'application/vnd.oasis.opendocument.text': // open office