using mime-registry for link-widget "link-list" and "link-string" too

This commit is contained in:
Ralf Becker 2012-03-09 07:45:31 +00:00
parent f41d998e54
commit 6e6aacb5a0
2 changed files with 21 additions and 7 deletions

View File

@ -302,7 +302,7 @@ class link_widget
if (!is_array($link['id']))
{
$value[$row]['view'] = egw_link::view($link['app'],$link['id'],$link);
if (!($value[$row]['popup'] = egw_link::is_popup($link['app'],'view')) &&
if (!($value[$row]['popup'] = egw_link::is_popup($link['app'],'view',$link)) &&
etemplate::$request->output_mode == 2) // we are in a popup
{
$value[$row]['target'] = '_blank'; // we create a new window as the linked page is no popup
@ -481,7 +481,7 @@ class link_widget
*/
static function link2a_href(array $link,$help='')
{
if (($popup = egw_link::is_popup($link['app'],'view')))
if (($popup = egw_link::is_popup($link['app'], 'view', $link)))
{
list($w,$h) = explode('x',$popup);
$options = ' onclick="window.open(this,this.target,\'width='.(int)$w.',height='.(int)$h.',location=no,menubar=no,toolbar=no,scrollbars=yes,status=yes\'); return false;"';
@ -544,9 +544,9 @@ class link_widget
// this may fail, if $extension_data['default'][0] is set on purpose
foreach($extension_data['default'] as $k => $v)
{
if ($v)
if ($v)
{
$defaultData=true;
$defaultData=true;
if ($k==0 && !empty($value_in['id'])) // we have a valid incomming id, we intend to use that
{
$defaultData=false;

View File

@ -877,7 +877,8 @@ class egw_link extends solink
{
if ($app == self::VFS_APPNAME && !empty($id) && is_array($link))
{
return egw_vfs::download_url(self::vfs_path($link['app2'],$link['id2'],$link['id'],true));
//return egw_vfs::download_url(self::vfs_path($link['app2'],$link['id2'],$link['id'],true));
return self::mime_open(self::vfs_path($link['app2'],$link['id2'],$link['id'],true), $link['type']);
}
if ($app == '' || !is_array($reg = self::$app_register[$app]) || !isset($reg['view']) || !isset($reg['view_id']))
{
@ -988,11 +989,24 @@ class egw_link extends solink
*
* @param string $app app-name
* @param string $action='view' name of the action, atm. 'view' or 'add'
* @param array $link=null link-data for file-attachments
* @return boolean|string false if no popup is used or $app is not registered, otherwise string with the prefered popup size (eg. '640x400)
*/
static function is_popup($app,$action='view')
static function is_popup($app, $action='view', $link=null)
{
return self::get_registry($app,$action.'_popup');
$popup = self::get_registry($app,$action.'_popup');
// for files/attachments check mime-registry
if ($app == self::VFS_APPNAME && is_array($link) && !empty($link['type']))
{
$path = self::vfs_path($link['app2'], $link['id2'], $link['id'], true);
if (self::mime_open($path, $link['type'], $p))
{
$popup = $p;
}
}
//error_log(__METHOD__."('$app', '$action', ".array2string($link).') returning '.array2string($popup));
return $popup;
}
/**