mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-25 16:19:00 +01:00
Preseed link title-cache for link-list and link-string widget
(Performance improvment, as all titles of an application get queried in a single query and NOT once for every link)
This commit is contained in:
parent
50ae17055f
commit
0f2eceefb8
@ -195,7 +195,7 @@ class link_widget
|
||||
}
|
||||
if ($value['to_id'] && $value['to_app'])
|
||||
{
|
||||
$value = egw_link::get_links($value['to_app'],$value['to_id'],$only_app = $value['only_app']);
|
||||
$value = egw_link::get_links($value['to_app'],$value['to_id'],$only_app = $value['only_app'],'link_lastmod DESC',true);
|
||||
if ($only_app)
|
||||
{
|
||||
foreach($value as $key => $id)
|
||||
@ -287,7 +287,7 @@ class link_widget
|
||||
{
|
||||
$value['title'] = egw_link::title($app,$id);
|
||||
}
|
||||
$links = egw_link::get_links($app,$id);
|
||||
$links = egw_link::get_links($app,$id,'','link_lastmod DESC',true);
|
||||
$value['anz_links'] = count($links);
|
||||
$extension_data = $value;
|
||||
|
||||
|
@ -56,6 +56,11 @@
|
||||
* 'file_access' => 'app.class.method', // method to be called to check file access rights, see links_stream_wrapper class
|
||||
* // boolean file_access(string $id,int $check,string $rel_path)
|
||||
* 'find_extra' => array('name_preg' => '/^(?!.picture.jpg)$/') // extra options to egw_vfs::find, to eg. remove some files from the list of attachments
|
||||
* 'edit' => array(
|
||||
* 'menuaction' => 'app.class.method',
|
||||
* ),
|
||||
* 'edit_id' => 'app_id',
|
||||
* 'edit_popup' => '400x300',
|
||||
* }
|
||||
* All entries are optional, thought you only get conected functionality, if you implement them ...
|
||||
*
|
||||
@ -283,9 +288,10 @@ class egw_link extends solink
|
||||
* @param string/array $id id of entry in $app or array of links if entry not yet created
|
||||
* @param string $only_app if set return only links from $only_app (eg. only addressbook-entries) or NOT from if $only_app[0]=='!'
|
||||
* @param string $order='link_lastmod DESC' defaults to newest links first
|
||||
* @param boolean $cache_titles=false should all titles be queryed and cached (allows to query each link app only once!)
|
||||
* @return array of links or empty array if no matching links found
|
||||
*/
|
||||
static function get_links( $app,$id,$only_app='',$order='link_lastmod DESC' )
|
||||
static function get_links( $app,$id,$only_app='',$order='link_lastmod DESC',$cache_titles=false )
|
||||
{
|
||||
if (self::DEBUG) echo "<p>egw_link::get_links(app='$app',id='$id',only_app='$only_app',order='$order')</p>\n";
|
||||
|
||||
@ -319,7 +325,21 @@ class egw_link extends solink
|
||||
}
|
||||
}
|
||||
//echo "ids=<pre>"; print_r($ids); echo "</pre>\n";
|
||||
if ($cache_titles)
|
||||
{
|
||||
// agregate links by app
|
||||
$app_ids = array();
|
||||
foreach($ids as $link)
|
||||
{
|
||||
$app_ids[$link['app']][] = $link['id'];
|
||||
}
|
||||
reset($ids);
|
||||
|
||||
foreach($app_ids as $appname => $a_ids)
|
||||
{
|
||||
self::titles($appname,array_unique($a_ids));
|
||||
}
|
||||
}
|
||||
return $ids;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user