From 88d5a016e0e7e26329cc42db62bdf8597d9102b9 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Wed, 4 Oct 2006 08:23:28 +0000 Subject: [PATCH] caching the link-titles in the session --- phpgwapi/inc/class.bolink.inc.php | 36 +++++++++++++++++++++++++++---- phpgwapi/inc/class.common.inc.php | 4 ++++ 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/phpgwapi/inc/class.bolink.inc.php b/phpgwapi/inc/class.bolink.inc.php index c27ffad9de..0499c3576c 100644 --- a/phpgwapi/inc/class.bolink.inc.php +++ b/phpgwapi/inc/class.bolink.inc.php @@ -34,7 +34,8 @@ class bolink extends solink /** * other apps can participate in the linking by implementing a 'search_link' hook, which * has to return an array in the format of an app_register entry below - * @var array $app_register + * + * @var array */ var $app_register = array( 'projects' => array( @@ -57,11 +58,22 @@ class bolink extends solink var $public_functions = array( // functions callable via menuaction 'get_file' => True ); + /** + * Instance of the vfs class + * + * @var vfs + */ var $vfs; var $vfs_basedir='/infolog'; var $vfs_appname='file'; // pseudo-appname for own file-attachments in vfs, this is NOT the vfs-app var $valid_pathes = array(); var $send_file_ips = array(); + /** + * Caches link titles for a better performance + * + * @var array + */ + var $title_cache = array(); /** * constructor @@ -93,6 +105,16 @@ class bolink extends solink } } } + if (!($this->title_cache = $GLOBALS['egw']->session->appsession('link_title_cache','phpgwapi'))) $this->title_cache = array(); + } + + /** + * Called by egw::egw_final to store the title-cache in the session + * + */ + function save_session_cache() + { + $GLOBALS['egw']->session->appsession('link_title_cache','phpgwapi',$this->title_cache); } /** @@ -346,6 +368,7 @@ class bolink extends solink if (!$link_id && !$app2 && !$id2) { $this->delete_attached($app,$id); // deleting all attachments + unset($this->title_cache[$app.':'.$id]); } $deleted =& solink::unlink($link_id,$app,$id,$owner,$app2,$id2); @@ -427,7 +450,11 @@ class bolink extends solink echo "

bolink::title('$app','$id')

\n"; } if (!$id) return ''; - + + if (isset($this->title_cache[$app.':'.$id])) + { + return $this->title_cache[$app.':'.$id]; + } if ($app == $this->vfs_appname) { if (is_array($id) && $link) @@ -451,7 +478,7 @@ class bolink extends solink } $extra = ': '.$link['type'] . ' '.$size; } - return $id.$extra; + return $this->title_cache[$app.':'.$id] = $id.$extra; } if ($app == '' || !is_array($reg = $this->app_register[$app]) || !isset($reg['title'])) { @@ -466,7 +493,7 @@ class bolink extends solink $this->unlink(0,$app,$id); return False; } - return $title; + return $this->title_cache[$app.':'.$id] = $title; } /** @@ -973,6 +1000,7 @@ class bolink extends solink { $this->notify('update',$link['app'],$link['id'],$app,$id,$link_id,$data); } + unset($this->title_cache[$app.':'.$id]); } /** diff --git a/phpgwapi/inc/class.common.inc.php b/phpgwapi/inc/class.common.inc.php index 185406fc4c..afd889c9f5 100644 --- a/phpgwapi/inc/class.common.inc.php +++ b/phpgwapi/inc/class.common.inc.php @@ -325,6 +325,10 @@ { $GLOBALS['egw']->accounts->save_session_cache(); } + if (is_object($GLOBALS['egw']->link)) + { + $GLOBALS['egw']->link->save_session_cache(); + } // call the asyncservice check_run function if it is not explicitly set to cron-only // if (!$GLOBALS['egw_info']['server']['asyncservice']) // is default