forked from extern/egroupware
Basic egw.link_title(_app,_id,_callback,_context) method.
Plan is to run a clientside cache and own queue for link_titles, as server can query titles for N id's for a given app more effiently then N separeate queries.
This commit is contained in:
parent
cf53019c13
commit
5cadd29d58
@ -95,6 +95,20 @@ error_log("$app, $pattern, $options");
|
|||||||
$response->data($links);
|
$response->data($links);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return title for a given app/id pair
|
||||||
|
*
|
||||||
|
* @param string $app
|
||||||
|
* @param string|int $id
|
||||||
|
* @return string|boolean string with title, boolean false of permission denied or null if not found
|
||||||
|
*/
|
||||||
|
public static function ajax_link_title($app,$id)
|
||||||
|
{
|
||||||
|
$title = egw_link::title($app, $id);
|
||||||
|
error_log(__METHOD__."('$app', '$id') = ".array2string($title));
|
||||||
|
egw_json_response::get()->data($title);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create links
|
* Create links
|
||||||
*/
|
*/
|
||||||
@ -103,13 +117,13 @@ error_log("$app, $pattern, $options");
|
|||||||
foreach($links as &$link) {
|
foreach($links as &$link) {
|
||||||
if($link['app'] == egw_link::VFS_APPNAME) {
|
if($link['app'] == egw_link::VFS_APPNAME) {
|
||||||
if (is_dir($GLOBALS['egw_info']['server']['temp_dir']) && is_writable($GLOBALS['egw_info']['server']['temp_dir']))
|
if (is_dir($GLOBALS['egw_info']['server']['temp_dir']) && is_writable($GLOBALS['egw_info']['server']['temp_dir']))
|
||||||
{
|
{
|
||||||
$path = $GLOBALS['egw_info']['server']['temp_dir'] . '/' . $link['id'];
|
$path = $GLOBALS['egw_info']['server']['temp_dir'] . '/' . $link['id'];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$path = $link['id'].'+';
|
$path = $link['id'].'+';
|
||||||
}
|
}
|
||||||
$link['tmp_name'] = $path;
|
$link['tmp_name'] = $path;
|
||||||
$link['id'] = $link;
|
$link['id'] = $link;
|
||||||
}
|
}
|
||||||
|
@ -750,6 +750,24 @@ else
|
|||||||
|
|
||||||
delete this.jsonq_queue[uid];
|
delete this.jsonq_queue[uid];
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query a title of _app/_id
|
||||||
|
*
|
||||||
|
* @param string _app
|
||||||
|
* @param string|int _id
|
||||||
|
* @param function _callback optinal callback, required if for responses from the server
|
||||||
|
* @param object _context context for the callback
|
||||||
|
* @return string|boolean|null string with title if it exist in local cache or null if not
|
||||||
|
*/
|
||||||
|
link_title: function(_app, _id, _callback, _context)
|
||||||
|
{
|
||||||
|
if (typeof _callback == 'function')
|
||||||
|
{
|
||||||
|
this.jsonq(_app+'.etemplate_widget_link.ajax_link_title', [_app, _id], _callback, _context);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user