From 8075cb9a9b15d339837cf0cf47e0223b5e81d510 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Tue, 26 Jun 2012 14:35:53 +0000 Subject: [PATCH] * For files inside /apps/appname/id, the application's merge print placeholders are also available --- .../inc/class.filemanager_merge.inc.php | 48 +++++++++++++++++++ filemanager/lang/egw_en.lang | 1 + 2 files changed, 49 insertions(+) diff --git a/filemanager/inc/class.filemanager_merge.inc.php b/filemanager/inc/class.filemanager_merge.inc.php index 0c39cf4592..1cbb020321 100644 --- a/filemanager/inc/class.filemanager_merge.inc.php +++ b/filemanager/inc/class.filemanager_merge.inc.php @@ -138,6 +138,47 @@ class filemanager_merge extends bo_merge $file["links/{$app}"] = $this->get_links('filemanager',$id, $app); } */ + + // If in apps folder, try for app-specific placeholders + if($dirlist[1] == 'apps' && count($dirlist) > 1) + { + // Try this first - a normal path /apps/appname/id/file + list($app, $id) = explode('/', substr($file['path'], strpos($file['path'], 'apps/')+5)); + + // Symlink? + if(!$app || !$id || !array_key_exists($app, $GLOBALS['egw_info']['user']['apps'])) { + // Try resolving just app + ID - /apps/App Name/Record Title/file + $resolved = egw_vfs::resolve_url_symlinks(implode('/',array_slice($dirlist,0,4))); + list($app, $id) = explode('/', substr($resolved, strpos($resolved, 'apps/')+5)); + + if(!$app || !$id || !array_key_exists($app, $GLOBALS['egw_info']['user']['apps'])) { + // Get rid of any virtual folders (eg: All$) and symlinks + $resolved = egw_vfs::resolve_url_symlinks($file['path']); + list($app, $id) = explode('/', substr($resolved, strpos($resolved, 'apps/')+5)); + } + } + if($app && $id) + { + if($app && $GLOBALS['egw_info']['user']['apps'][$app]) + { + $app_merge = null; + try + { + $classname = $app .'_merge'; + if(class_exists($classname)) + { + $app_merge = new $classname(); + if($app_merge && method_exists($app_merge, 'get_replacements')) + { + $app_placeholders = $app_merge->get_replacements($id, $content); + } + } + } + // Silently discard & continue + catch(Exception $e) {} + } + } + } $link = egw_link::mime_open($file['url'], $file['mime']); if(is_array($link)) { @@ -166,6 +207,10 @@ class filemanager_merge extends bo_merge if(!$value) $value = ''; $info['$$'.($prefix ? $prefix.'/':'').$key.'$$'] = $value; } + if($app_placeholders) + { + $info = array_merge($app_placeholders, $info); + } return $info; } @@ -212,6 +257,9 @@ class filemanager_merge extends bo_merge echo '{{#'.$name.'}}'.$field['label']."\n"; } + echo '

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

"; + echo ''.lang('For files linked to an application entry (inside /apps/appname/id/) the placeholders for that application are also available. See the specific application for a list of available placeholders.').''; + echo '

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

"; foreach(array( 'date' => lang('Date'), diff --git a/filemanager/lang/egw_en.lang b/filemanager/lang/egw_en.lang index 2b19f82537..b343eb54fb 100644 --- a/filemanager/lang/egw_en.lang +++ b/filemanager/lang/egw_en.lang @@ -105,6 +105,7 @@ files in this directory filemanager en Files in this directory filesystem check reported no problems. filemanager en Filesystem check reported no problems. fix reported problems filemanager en Fix reported problems folder up filemanager en Folder up +for files linked to an application entry (inside /apps/appname/id/) the placeholders for that application are also available. see the specific application for a list of placeholders filemanager en For files linked to an application entry (inside /apps/appname/id/) the placeholders for that application are also available. See the specific application for a list of placeholders general filemanager en General go home filemanager en Go home go to filemanager en Go to