Add general placeholder {{link}} is a link to current record

This commit is contained in:
Nathan Gray 2013-03-19 20:56:58 +00:00
parent 95846e595b
commit 81fbfc23cc
3 changed files with 30 additions and 1 deletions

View File

@ -346,7 +346,7 @@ abstract class bo_merge
protected function get_all_links($app, $id, $prefix, &$content)
{
$array = array();
$pattern = '@\$(links|attachments|links_attachments)\/?(title|href|link)?\/?([a-z]*)\$@';
$pattern = '@\$(link|links|attachments|links_attachments)\/?(title|href|link)?\/?([a-z]*)\$@';
static $link_cache;
if(preg_match_all($pattern, $content, $matches))
{
@ -360,6 +360,33 @@ abstract class bo_merge
}
switch($matches[1][$i])
{
case 'link':
// Link to current record
$title = egw_link::title($app, $id);
if(class_exists('stylite_links_stream_wrapper') && $app != egw_link::VFS_APPNAME)
{
$title = stylite_links_stream_wrapper::entry2name($app, $id, $title);
}
$link = egw_link::view($app, $id);
if($app != egw_link::VFS_APPNAME)
{
// Set app to false so we always get an external link
$link = str_replace(',','%2C',egw::link('/index.php',$link, false));
}
else
{
$link = egw::link($link, array());
}
// 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 = html::a_href(html::htmlspecialchars($title), $link);
$array[($prefix?$prefix.'/':'').$placeholder] = $title;
break;
case 'links':
$array[($prefix?$prefix.'/':'').$placeholder] = $this->get_links($app, $id, '!'.egw_link::VFS_APPNAME, array(),$matches[2][$i]);
break;

View File

@ -218,6 +218,7 @@ hour etemplate en Hour
hours etemplate en Hours
how many entries should the list show etemplate en How many entries should the list show
html etemplate en HTML
html link to the current record etemplate en HTML link to the current record
if field is disabled an empty table-cell is displayed, for (temporal) removement of a field/cell etemplate en If field is disabled an empty table cell is displayed
if you specify a directory (full vfs path) here, %1 displays an action for each document. that action allows to download the specified document with the data inserted. preferences en If you specify a directory, full vfs path, %1 displays an action for each document. That action allows to download the specified document with the data inserted.
if you specify a document (full vfs path) here, %1 displays an extra document icon for each entry. that icon allows to download the specified document with the data inserted. preferences en If you specify a document, full vfs path, %1 displays an extra document icon for each entry. That icon allows to download the specified document with the data inserted.

View File

@ -207,6 +207,7 @@ class infolog_merge extends bo_merge
echo '<tr><td colspan="4"><h3>'.lang('General fields:')."</h3></td></tr>";
foreach(array(
'link' => lang('HTML link to the current record'),
'links' => lang('Titles of any entries linked to the current record, excluding attached files'),
'attachments' => lang('List of files linked to the current record'),
'links_attachments' => lang('Links and attached files'),