mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-06-19 00:16:56 +02:00
* Mail, Filemanager: use now same handling, pdf, text or html are opened now in popup, fixes viewing of attachments using mobile theme
This commit is contained in:
parent
b061210386
commit
5887bc4313
@ -245,7 +245,7 @@ var et2_description = expose(et2_baseWidget.extend([et2_IDetachedDOM],
|
||||
}
|
||||
else
|
||||
{
|
||||
egw(window).open_link(self.options.mime_data || self.options.href, self.options.extra_link_title,self.options.extra_link_popup,null,null,self.options.mime);
|
||||
egw(window).open_link(self.options.mime_data || self.options.href, self.options.extra_link_target, self.options.extra_link_popup, null, null, self.options.mime);
|
||||
}
|
||||
e.preventDefault();
|
||||
return false;
|
||||
|
@ -93,6 +93,8 @@ class mail_hooks
|
||||
'message/rfc822' => array(
|
||||
'menuaction' => 'mail.mail_ui.importMessageFromVFS2DraftAndDisplay',
|
||||
'mime_url' => 'formData[file]',
|
||||
'mime_data' => 'formData[data]',
|
||||
'formData[type]' => 'message/rfc822',
|
||||
'mime_popup' => '870xavailHeight',
|
||||
),
|
||||
),
|
||||
|
@ -2186,6 +2186,11 @@ class mail_ui
|
||||
if (strtoupper($value['mimeType']=='APPLICATION/OCTET-STREAM')) $value['mimeType'] = mime_magic::filename2mime($attachmentHTML[$key]['filename']);
|
||||
$attachmentHTML[$key]['type']=$value['mimeType'];
|
||||
$attachmentHTML[$key]['mimetype']=mime_magic::mime2label($value['mimeType']);
|
||||
list(, $acc_id) = explode(self::$delimiter, $rowID);
|
||||
|
||||
$attachmentHTML[$key]['mime_data'] = egw_link::set_data($value['mimeType'], 'emailadmin_imapbase::getAttachmentAccount', array(
|
||||
$acc_id, $mailbox, $uid, $value['partID'], $value['is_winmail'], true
|
||||
));
|
||||
$attachmentHTML[$key]['size']=egw_vfs::hsize($value['size']);
|
||||
$attachmentHTML[$key]['attachment_number']=$key;
|
||||
$attachmentHTML[$key]['partID']=$value['partID'];
|
||||
@ -2266,7 +2271,12 @@ class mail_ui
|
||||
$linkView = "window.location.href = '".egw::link('/index.php',$linkData)."';";
|
||||
break;
|
||||
}
|
||||
$attachmentHTML[$key]['href_link'] = egw::link('/index.php',$linkData);
|
||||
// we either use mime_data for server-side supported mime-types or mime_url for client-side or download
|
||||
if (empty($attachmentHTML[$key]['mime_data']))
|
||||
{
|
||||
$attachmentHTML[$key]['mime_url'] = egw::link('/index.php',$linkData);
|
||||
unset($attachmentHTML[$key]['mime_data']);
|
||||
}
|
||||
$attachmentHTML[$key]['windowName'] = $windowName;
|
||||
|
||||
//error_log(__METHOD__.__LINE__.$linkView);
|
||||
@ -2549,8 +2559,7 @@ class mail_ui
|
||||
html::safe_content_header($attachment['attachment'], $filename, $attachment['type'], $size=0, True, $_GET['mode'] == "save");
|
||||
echo $attachment['attachment'];
|
||||
|
||||
$GLOBALS['egw']->common->egw_exit();
|
||||
exit;
|
||||
common::egw_exit();
|
||||
}
|
||||
|
||||
|
||||
@ -3303,8 +3312,6 @@ class mail_ui
|
||||
if ($importfailed === false)
|
||||
{
|
||||
$mailObject = new egw_mailer();
|
||||
$Header = '';
|
||||
$Body = '';
|
||||
try
|
||||
{
|
||||
$this->mail_bo->parseFileIntoMailObject($mailObject, $tmpFileName);
|
||||
@ -3389,15 +3396,20 @@ class mail_ui
|
||||
//error_log(__METHOD__.__LINE__.':'.array2string($formData).' Mode:'.$mode.'->'.function_backtrace());
|
||||
$draftFolder = $this->mail_bo->getDraftFolder(false);
|
||||
$importID = mail_bo::getRandomString();
|
||||
|
||||
// handling for mime-data hash
|
||||
if (!empty($formData['data']))
|
||||
{
|
||||
$formData['file'] = 'egw-data://'.$formData['data'];
|
||||
}
|
||||
// name should be set to meet the requirements of checkFileBasics
|
||||
if (in_array(parse_url($formData['file'],PHP_URL_SCHEME), array('vfs', 'http', 'https')) && (!isset($formData['name']) || empty($formData['name'])))
|
||||
if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && empty($formData['name']))
|
||||
{
|
||||
$buff = explode('/',$formData['file']);
|
||||
$suffix = '';
|
||||
if (is_array($buff)) $formData['name'] = array_pop($buff); // take the last part as name
|
||||
}
|
||||
// type should be set to meet the requirements of checkFileBasics
|
||||
if (in_array(parse_url($formData['file'],PHP_URL_SCHEME), array('vfs', 'http', 'https')) && (!isset($formData['type']) || empty($formData['type'])))
|
||||
if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && empty($formData['type']))
|
||||
{
|
||||
$buff = explode('.',$formData['file']);
|
||||
$suffix = '';
|
||||
@ -3405,7 +3417,7 @@ class mail_ui
|
||||
if (!empty($suffix)) $formData['type'] = mime_magic::ext2mime($suffix);
|
||||
}
|
||||
// size should be set to meet the requirements of checkFileBasics
|
||||
if (in_array(parse_url($formData['file'],PHP_URL_SCHEME), array('vfs', 'http', 'https')) && !isset($formData['size']))
|
||||
if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && !isset($formData['size']))
|
||||
{
|
||||
$formData['size'] = strlen($formData['file']); // set some size, to meet requirements of checkFileBasics
|
||||
}
|
||||
@ -3427,18 +3439,12 @@ class mail_ui
|
||||
{
|
||||
$linkData['mode']=$mode;
|
||||
}
|
||||
|
||||
egw::redirect_link('/index.php',$linkData);
|
||||
}
|
||||
catch (egw_exception_wrong_userinput $e)
|
||||
{
|
||||
$linkData = array
|
||||
(
|
||||
'menuaction' => 'mail.mail_ui.importMessage',
|
||||
'msg' => htmlspecialchars($e->getMessage()),
|
||||
);
|
||||
egw_framework::window_close($e->getMessage());
|
||||
}
|
||||
egw::redirect_link('/index.php',$linkData);
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -72,7 +72,7 @@
|
||||
<description id="${row}[partID]" />
|
||||
<description id="${row}[type]" />
|
||||
<description id="${row}[winmailFlag]" />
|
||||
<description class="useEllipsis et2_link" id="${row}[filename]" expose_view="true" mime="$row_cont[type]" no_lang="1" href="$row_cont[href_link]" extra_link_title="$row_cont[windowName]" />
|
||||
<description class="useEllipsis et2_link" id="${row}[filename]" expose_view="true" mime="$row_cont[type]" no_lang="1" mime_data="$row_cont[mime_data]" href="$row_cont[mime_url]"/>
|
||||
<description align="right" id="${row}[size]" />
|
||||
<buttononly id="${row}[save]" value="save" image="fileexport" onclick="app.mail.saveAttachment"/>
|
||||
<buttononly id="${row}[saveAsVFS]" value="save" image="filemanager/navbar" onclick="app.mail.saveAttachmentToVFS"/>
|
||||
|
@ -98,7 +98,7 @@
|
||||
<description id="${row}[partID]" />
|
||||
<description id="${row}[type]" />
|
||||
<description id="${row}[winmailFlag]" />
|
||||
<description class="et2_link useEllipsis" id="${row}[filename]" no_lang="1" expose_view="true" mime="$row_cont[type]" href="$row_cont[href_link]" extra_link_title="$row_cont[windowName]"/>
|
||||
<description class="et2_link useEllipsis" id="${row}[filename]" no_lang="1" expose_view="true" mime="$row_cont[type]" mime_data="$row_cont[mime_data]" href="$row_cont[mime_url]"/>
|
||||
<description align="right" id="${row}[size]"/>
|
||||
<buttononly id="${row}[save]" image="fileexport" onclick="app.mail.saveAttachment"/>
|
||||
<buttononly id="${row}[saveAsVFS]" image="filemanager/navbar" onclick="app.mail.saveAttachmentToVFS"/>
|
||||
|
@ -25,7 +25,7 @@
|
||||
* /**
|
||||
* * Hook called by link-class to include app in the appregistry of the linkage
|
||||
* *
|
||||
* * @param array/string $location location and other parameters (not used)
|
||||
* * @param array|string $location location and other parameters (not used)
|
||||
* * @return array with method-names
|
||||
* *%
|
||||
* function search_link($location)
|
||||
@ -73,7 +73,8 @@
|
||||
* 'entries' => 'Contacts', // Optional name for multiple entries of app, eg. "contacts" used instead of appname
|
||||
* 'mime' => array( // Optional register mime-types application can open
|
||||
* 'text/something' => array(
|
||||
* 'mime_url' => 'url', // required (!)
|
||||
* 'mime_url' => $attr, // either mime_url or mime_data is required for server-side processing!
|
||||
* 'mime_data' => $attr, // md5-hash returned from egw_link::set_data() to retrive content (only server-side)
|
||||
* 'menuaction' => 'app.class.method', // method to call
|
||||
* 'mime_popup' => '400x300', // optional size of popup
|
||||
* 'mime_target' => '_self', // optional target, default _blank
|
||||
@ -140,6 +141,19 @@ class egw_link extends solink
|
||||
'view' => array('menuaction'=>'addressbook.addressbook_ui.view'),
|
||||
'view_id' => 'account_id'
|
||||
),
|
||||
'home' => array(
|
||||
// handling of text or pdf files by browser in a popup window
|
||||
'mime' => array(
|
||||
'application/pdf' => array(
|
||||
'mime_popup' => '640x480',
|
||||
'mime_target' => '_blank',
|
||||
),
|
||||
'/^text\\//' => array( // text/* as preg, no modifier!
|
||||
'mime_popup' => '640x480',
|
||||
'mime_target' => '_blank',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
/**
|
||||
* Caches link titles for a better performance
|
||||
@ -169,6 +183,11 @@ class egw_link extends solink
|
||||
*/
|
||||
static function init_static( )
|
||||
{
|
||||
// FireFox 36 can not display pdf with it's internal viewer in an iframe used by mobile theme/template for popups
|
||||
if (html::$user_agent == 'firefox' && $GLOBALS['egw_info']['user']['preferences']['common']['theme'] == 'mobile')
|
||||
{
|
||||
unset(self::$app_register['home']['mime']['application/pdf']['mime_popup']);
|
||||
}
|
||||
// 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
|
||||
// for performance reasons, we do it only once / cache it in the session
|
||||
@ -280,10 +299,10 @@ class egw_link extends solink
|
||||
* File-attachments return a negative link-id !!!
|
||||
*
|
||||
* @param string $app1 app of $id1
|
||||
* @param string/array &$id1 id of item to linkto or 0 if item not yet created or array with links
|
||||
* @param string|array &$id1 id of item to linkto or 0 if item not yet created or array with links
|
||||
* of not created item or $file-array if $app1 == self::VFS_APPNAME (see below).
|
||||
* If $id==0 it will be set on return to an array with the links for the new item.
|
||||
* @param string/array $app2 app of 2.linkend or array with links ($id2 not used)
|
||||
* @param string|array $app2 app of 2.linkend or array with links ($id2 not used)
|
||||
* @param string $id2 ='' id of 2. item of $file-array if $app2 == self::VFS_APPNAME (see below)<br>
|
||||
* $file array with informations about the file in format of the etemplate file-type<br>
|
||||
* $file['name'] name of the file (no directory)<br>
|
||||
@ -535,8 +554,8 @@ class egw_link extends solink
|
||||
*
|
||||
* If $id is an array (links not yet created) only link_ids are allowed.
|
||||
*
|
||||
* @param int/string $app_link_id > 0 link_id of link or app-name of link
|
||||
* @param string/array $id='' id if $app_link_id is an appname or array with links, if 1. entry not yet created
|
||||
* @param int|string $app_link_id > 0 link_id of link or app-name of link
|
||||
* @param string|array $id ='' id if $app_link_id is an appname or array with links, if 1. entry not yet created
|
||||
* @param string $app2 ='' second app
|
||||
* @param string $id2 ='' id in $app2
|
||||
* @return array with link-data or False
|
||||
@ -580,7 +599,7 @@ class egw_link extends solink
|
||||
*
|
||||
* @param $link_id link-id to remove if > 0
|
||||
* @param string $app ='' appname of first endpoint
|
||||
* @param string/array $id='' id in $app or array with links, if 1. entry not yet created
|
||||
* @param string|array $id ='' id in $app or array with links, if 1. entry not yet created
|
||||
* @param int $owner =0 account_id to delete all links of a given owner, or 0
|
||||
* @param string $app2 ='' app of second endpoint
|
||||
* @param string $id2 ='' id in $app2
|
||||
@ -597,7 +616,7 @@ class egw_link extends solink
|
||||
*
|
||||
* @param $link_id link-id to remove if > 0
|
||||
* @param string $app ='' appname of first endpoint
|
||||
* @param string/array &$id='' id in $app or array with links, if 1. entry not yet created
|
||||
* @param string|array &$id='' id in $app or array with links, if 1. entry not yet created
|
||||
* @param int $owner =0 account_id to delete all links of a given owner, or 0
|
||||
* @param string $app2 ='' app of second endpoint, or !file (other !app are not yet supported!)
|
||||
* @param string $id2 ='' id in $app2
|
||||
@ -974,6 +993,8 @@ class egw_link extends solink
|
||||
*
|
||||
* Only return information from apps the user has access too (incl. registered sub-types of that apps).
|
||||
*
|
||||
* We prefer full matches over wildcards like "text/*" written as regexp "/^text\\//".
|
||||
*
|
||||
* @param string $type
|
||||
* @return array with values for keys 'menuaction', 'mime_id' (path) or 'mime_url' and options 'mime_popup' and other values to pass one
|
||||
*/
|
||||
@ -988,10 +1009,14 @@ class egw_link extends solink
|
||||
foreach($registry['mime'] as $mime => $data)
|
||||
{
|
||||
if ($mime == $type) return $data;
|
||||
if ($mime[0] == '/' && preg_match($mime.'i', $type))
|
||||
{
|
||||
$wildcard_mime = $data;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return isset($wildcard_mime) ? $wildcard_mime : null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1201,7 +1226,7 @@ class egw_link extends solink
|
||||
/**
|
||||
* deletes a single or all attached files of an entry (for all there's no acl check, as the entry probably not exists any more!)
|
||||
*
|
||||
* @param int/string $app > 0: file_id of an attchemnt or $app/$id entry which linked to
|
||||
* @param int|string $app > 0: file_id of an attchemnt or $app/$id entry which linked to
|
||||
* @param string $id ='' id in app
|
||||
* @param string $fname ='' filename
|
||||
* @return boolean|array false on error ($app or $id not found), array with path as key and boolean result of delete
|
||||
@ -1272,7 +1297,7 @@ class egw_link extends solink
|
||||
/**
|
||||
* converts a fileinfo (row in the vfs-db-table) in a link
|
||||
*
|
||||
* @param array/int $fileinfo a row from the vfs-db-table (eg. returned by the vfs ls static function) or a file_id of that table
|
||||
* @param array|int $fileinfo a row from the vfs-db-table (eg. returned by the vfs ls static function) or a file_id of that table
|
||||
* @return array a 'kind' of link-array
|
||||
*/
|
||||
static function fileinfo2link($fileinfo,$url=null)
|
||||
@ -1514,6 +1539,68 @@ class egw_link extends solink
|
||||
unset(self::$file_access_cache[$app.':'.$id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store function call and parameters in session and return id to retrieve it result
|
||||
*
|
||||
* @param string $mime_type
|
||||
* @param string $method
|
||||
* @param array $params
|
||||
* @return string|null md5 hash of stored data of server-side supported mime-type or null otherwise
|
||||
*/
|
||||
public static function set_data($mime_type, $method, array $params)
|
||||
{
|
||||
if (!($info = self::get_mime_info($mime_type)) || empty($info['mime_data']))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
array_unshift($params, $method);
|
||||
$id = md5(json_encode($params));
|
||||
egw_cache::setSession(__CLASS__, $id, $params);
|
||||
return $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call stored function with parameters and return result
|
||||
*
|
||||
* @param string $id
|
||||
* @param boolean $return_resource =false false: return string, true: return resource
|
||||
* @return mixed null if id is not found or invalid
|
||||
* @throws egw_exception_wrong_parameter
|
||||
*/
|
||||
public static function get_data($id, $return_resource=false)
|
||||
{
|
||||
$data = egw_cache::getSession(__CLASS__, $id);
|
||||
|
||||
if (!isset($data) || empty($data[0]))
|
||||
{
|
||||
throw new egw_exception_wrong_parameter(__METHOD__."('$id')");
|
||||
}
|
||||
$ret = call_user_func_array('ExecMethod2', $data);
|
||||
|
||||
if ($return_resource != is_resource($ret))
|
||||
{
|
||||
if ($return_resource && ($fp = fopen('php://temp', 'w')))
|
||||
{
|
||||
fwrite($fp, $ret);
|
||||
fseek($fp, 0);
|
||||
$ret = $fp;
|
||||
}
|
||||
if (!$return_resource)
|
||||
{
|
||||
$fp = $ret;
|
||||
$ret = '';
|
||||
fseek($fp, 0);
|
||||
while(!feof($fp))
|
||||
{
|
||||
$ret .= fread($fp, 8192);
|
||||
}
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
//error_log(__METHOD__."('$id') returning ".gettype($ret).'='.array2string($ret));
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the file access perms for $app/id and given user $user
|
||||
*
|
||||
|
@ -105,11 +105,14 @@ egw.extend('links', egw.MODULE_GLOBAL, function()
|
||||
/**
|
||||
* Get mime-type information from app-registry
|
||||
*
|
||||
* We prefer a full match over a wildcard like 'text/*' (written as regualr expr. "/^text\\//"
|
||||
*
|
||||
* @param {string} _type
|
||||
* @return {object} with values for keys 'menuaction', 'mime_id' (path) or 'mime_url' and options 'mime_popup' and other values to pass one
|
||||
*/
|
||||
get_mime_info: function(_type)
|
||||
{
|
||||
var wildcard_mime;
|
||||
for(var app in link_registry)
|
||||
{
|
||||
var reg = link_registry[app];
|
||||
@ -118,16 +121,20 @@ egw.extend('links', egw.MODULE_GLOBAL, function()
|
||||
for(var mime in reg.mime)
|
||||
{
|
||||
if (mime == _type) return reg.mime[_type];
|
||||
if (mime[0] == '/' && _type.match(new RegExp(mime.substring(1, mime.length-1), 'i')))
|
||||
{
|
||||
wildcard_mime = reg.mime[mime];
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return wildcard_mime ? wildcard_mime : null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Get handler (link-data) for given path and mime-type
|
||||
*
|
||||
* @param {string|object} _path vfs path or object with attr path or id, app2 and id2 (path=/apps/app2/id2/id)
|
||||
* @param {string|object} _path vfs path, egw_link::set_data() id or object with attr path or id, app2 and id2 (path=/apps/app2/id2/id)
|
||||
* @param {string} _type mime-type, if not given in _path object
|
||||
* @return {string|object} string with EGw relative link, array with get-parameters for '/index.php' or null (directory and not filemanager access)
|
||||
*/
|
||||
@ -148,6 +155,10 @@ egw.extend('links', egw.MODULE_GLOBAL, function()
|
||||
{
|
||||
_type = _path.type;
|
||||
}
|
||||
}
|
||||
else if(_path[0] != '/')
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -164,10 +175,20 @@ egw.extend('links', egw.MODULE_GLOBAL, function()
|
||||
case 'mime_url':
|
||||
data[mime_info.mime_url] = 'vfs://default' + path;
|
||||
break;
|
||||
case 'mime_data':
|
||||
break;
|
||||
case 'mime_type':
|
||||
data[mime_info.mime_type] = _type;
|
||||
break;
|
||||
default:
|
||||
data[attr] = mime_info[attr];
|
||||
}
|
||||
}
|
||||
// if mime_info did NOT define mime_url attribute, we use a WebDAV url drived from path
|
||||
if (typeof mime_info.mime_url == 'undefined')
|
||||
{
|
||||
data.url = '/webdav.php' + path;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -187,10 +187,17 @@ egw.extend('open', egw.MODULE_WND_LOCAL, function(_egw, _wnd)
|
||||
target = url.mime_target;
|
||||
delete url.mime_target;
|
||||
}
|
||||
if (typeof url.url == 'string')
|
||||
{
|
||||
url = url.url;
|
||||
}
|
||||
else
|
||||
{
|
||||
params = url;
|
||||
url = '/index.php';
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var app_registry = this.link_get_registry(app);
|
||||
@ -280,21 +287,39 @@ egw.extend('open', egw.MODULE_WND_LOCAL, function(_egw, _wnd)
|
||||
url = this.webserverUrl + url;
|
||||
}
|
||||
var mime_info = _mime_type ? this.get_mime_info(_mime_type) : undefined;
|
||||
if (mime_info && mime_info[mime_info.mime_url])
|
||||
if (mime_info && (mime_info.mime_url || mime_info.mime_data))
|
||||
{
|
||||
if (mime_info.mime_popup)
|
||||
var data = {};
|
||||
for(var attr in mime_info)
|
||||
{
|
||||
switch(attr)
|
||||
{
|
||||
case 'mime_popup':
|
||||
_popup = mime_info.mime_popup;
|
||||
delete mime_info.mime_popup;
|
||||
}
|
||||
if (mime_info.mime_target)
|
||||
{
|
||||
break;
|
||||
case 'mime_target':
|
||||
_target = mime_info.mime_target;
|
||||
delete mime_info.mime_target;
|
||||
break;
|
||||
case 'mime_type':
|
||||
data[mime_info.mime_type] = _mime_type;
|
||||
break;
|
||||
case 'mime_data':
|
||||
data[mime_info[attr]] = _link;
|
||||
break;
|
||||
case 'mime_url':
|
||||
data[mime_info[attr]] = url;
|
||||
break;
|
||||
default:
|
||||
data[attr] = mime_info[attr];
|
||||
break;
|
||||
}
|
||||
mime_info[mime_info.mime_url] = url;
|
||||
delete mime_info.mime_url;
|
||||
url = egw.link('/index.php', mime_info);
|
||||
}
|
||||
url = egw.link('/index.php', data);
|
||||
}
|
||||
else if (mime_info)
|
||||
{
|
||||
if (mime_info.mime_popup) _popup = mime_info.mime_popup;
|
||||
if (mime_info.mime_target) _target = mime_info.mime_target;
|
||||
}
|
||||
if (_popup)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user