From 81fbfc23cc717b9f03962eb4a796a2e64812c423 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Tue, 19 Mar 2013 20:56:58 +0000 Subject: [PATCH] Add general placeholder {{link}} is a link to current record --- etemplate/inc/class.bo_merge.inc.php | 29 ++++++++++++++++++++++++- etemplate/lang/egw_en.lang | 1 + infolog/inc/class.infolog_merge.inc.php | 1 + 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/etemplate/inc/class.bo_merge.inc.php b/etemplate/inc/class.bo_merge.inc.php index 5b0f8a8c63..4892116a7b 100644 --- a/etemplate/inc/class.bo_merge.inc.php +++ b/etemplate/inc/class.bo_merge.inc.php @@ -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; diff --git a/etemplate/lang/egw_en.lang b/etemplate/lang/egw_en.lang index a280418f7b..7fbc5d9042 100644 --- a/etemplate/lang/egw_en.lang +++ b/etemplate/lang/egw_en.lang @@ -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. diff --git a/infolog/inc/class.infolog_merge.inc.php b/infolog/inc/class.infolog_merge.inc.php index 5bbf7bea84..c33e8650cd 100644 --- a/infolog/inc/class.infolog_merge.inc.php +++ b/infolog/inc/class.infolog_merge.inc.php @@ -207,6 +207,7 @@ class infolog_merge extends bo_merge echo '

'.lang('General fields:')."

"; 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'),