* 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:
Ralf Becker 2015-03-25 17:48:24 +00:00
parent b061210386
commit 5887bc4313
8 changed files with 237 additions and 96 deletions

View File

@ -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;

View File

@ -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',
),
),

View File

@ -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;
}
/**

View File

@ -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"/>

View File

@ -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"/>

View File

@ -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,21 +299,21 @@ 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 $id2='' id of 2. item of $file-array if $app2 == self::VFS_APPNAME (see below)<br>
* @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>
* $file['type'] mine-type of the file<br>
* $file['tmp_name'] name of the uploaded file (incl. directory)<br>
* $file['path'] path of the file on the client computer<br>
* $file['ip'] of the client (path and ip in $file are only needed if u want a symlink (if possible))
* @param string $remark='' Remark to be saved with the link (defaults to '')
* @param int $owner=0 Owner of the link (defaults to user)
* @param int $lastmod=0 timestamp of last modification (defaults to now=time())
* @param int $no_notify=0 &1 dont notify $app1, &2 dont notify $app2
* @param string $remark ='' Remark to be saved with the link (defaults to '')
* @param int $owner =0 Owner of the link (defaults to user)
* @param int $lastmod =0 timestamp of last modification (defaults to now=time())
* @param int $no_notify =0 &1 dont notify $app1, &2 dont notify $app2
* @return int/boolean False (for db or param-error) or on success link_id (Please not the return-value of $id1)
*/
static function link( $app1,&$id1,$app2,$id2='',$remark='',$owner=0,$lastmod=0,$no_notify=0 )
@ -406,12 +425,12 @@ class egw_link extends solink
*
* @param string $app appname
* @param string|array $id id(s) in $app
* @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!)
* @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!)
* This option also removes links not viewable by current user from the result!
* @param boolean $deleted=false Include links that have been flagged as deleted, waiting for purge of linked record.
* @param int $limit=null number of entries to return, only affects links, attachments are allways reported!
* @param boolean $deleted =false Include links that have been flagged as deleted, waiting for purge of linked record.
* @param int $limit =null number of entries to return, only affects links, attachments are allways reported!
* @return array id => links pairs if $id is an array or just the links (only_app: ids) or empty array if no matching links found
*/
static function get_links($app, $id, $only_app='', $order='link_lastmod DESC',$cache_titles=false, $deleted=false, $limit=null)
@ -479,10 +498,10 @@ class egw_link extends solink
* @ToDo also query the attachments in a single query, eg. via a directory listing of /apps/$app
* @param string $app
* @param array $ids
* @param boolean $cache_titles=true should all titles be queryed and cached (allows to query each link app only once!)
* @param boolean $cache_titles =true should all titles be queryed and cached (allows to query each link app only once!)
* @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 $deleted=false Include links that have been flagged as deleted, waiting for purge of linked record.
* @param string $order ='link_lastmod DESC' defaults to newest links first
* @param boolean $deleted =false Include links that have been flagged as deleted, waiting for purge of linked record.
* @return array of $id => array($links) pairs
*/
static function get_links_multiple($app,array $ids,$cache_titles=true,$only_app='',$order='link_lastmod DESC', $deleted=false )
@ -535,10 +554,10 @@ 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 string $app2='' second app
* @param string $id2='' id in $app2
* @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
*/
static function get_link($app_link_id,$id='',$app2='',$id2='')
@ -579,11 +598,11 @@ class egw_link extends solink
* unlink has to be called with &$id to see the result (depricated) or unlink2 has to be used !!!
*
* @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 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
* @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 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
* @param boolean $hold_for_purge Don't really delete the link, just mark it as deleted and wait for final delete
* @return the number of links deleted
*/
@ -596,11 +615,11 @@ class egw_link extends solink
* Remove link with $link_id or all links matching given $app,$id
*
* @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 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
* @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 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
* @param boolean $hold_for_purge Don't really delete the link, just mark it as deleted and wait for final delete
* @return the number of links deleted
*/
@ -768,7 +787,7 @@ class egw_link extends solink
*
* @param string $app appname
* @param string $id id in $app
* @param array $link=null link-data for file-attachments
* @param array $link =null link-data for file-attachments
* @return string/boolean string with title, null if $id does not exist in $app or false if no perms to view it
*/
static function title($app,$id,$link=null)
@ -883,7 +902,7 @@ class egw_link extends solink
* Add new entry to $app, evtl. already linked to $to_app, $to_id
*
* @param string $app appname of entry to create
* @param string $to_app='' appname to link the new entry to
* @param string $to_app ='' appname to link the new entry to
* @param string $to_id =''id in $to_app
* @return array/boolean with name-value pairs for link to add-methode of $app or false if add not supported
*/
@ -937,7 +956,7 @@ class egw_link extends solink
*
* @param string $app appname
* @param string $id id in $app
* @param array $link=null link-data for file-attachments
* @param array $link =null link-data for file-attachments
* @return array with name-value pairs for link to view-methode of $app to view $id
*/
static function view($app,$id,$link=null)
@ -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,17 +1009,21 @@ 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;
}
/**
* Get handler (link-data) for given path and mime-type
*
* @param string $path vfs path
* @param string $type=null default to egw_vfs::mime_content_type($path)
* @param string $type =null default to egw_vfs::mime_content_type($path)
* @param string &$popup=null on return popup size or null
* @return string|array string with EGw relative link, array with get-parameters for '/index.php' or null (directory and not filemanager access)
*/
@ -1036,8 +1061,8 @@ class egw_link extends solink
* Check if $app uses a popup for $action
*
* @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
* @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', $link=null)
@ -1101,9 +1126,9 @@ class egw_link extends solink
* All link-files are based in the vfs-subdir '/apps/'.$app
*
* @param string $app appname
* @param string $id='' id in $app
* @param string $file='' filename
* @param boolean $just_the_path=false return url or just the vfs path
* @param string $id ='' id in $app
* @param string $file ='' filename
* @param boolean $just_the_path =false return url or just the vfs path
* @return string/array path or array with path and relatives, depending on $relatives
*/
static function vfs_path($app,$id='',$file='',$just_the_path=false)
@ -1149,7 +1174,7 @@ class egw_link extends solink
* $file['tmp_name'] name of the uploaded file (incl. directory)
* $file['path'] path of the file on the client computer
* $file['ip'] of the client (path and ip are only needed if u want a symlink (if possible))
* @param string $comment='' comment to add to the link
* @param string $comment ='' comment to add to the link
* @return int negative id of egw_sqlfs table as negative link-id's are for vfs attachments
*/
static function attach_file($app,$id,$file,$comment='')
@ -1177,7 +1202,7 @@ class egw_link extends solink
* @param string $app appname to link the file to
* @param string $id id in $app
* @param string $file VFS path to link to
* @param string $comment='' comment to add to the link
* @param string $comment ='' comment to add to the link
*/
static function link_file($app,$id,$file)//,$comment='')
{
@ -1201,9 +1226,9 @@ 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 string $id='' id in app
* @param string $fname='' filename
* @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
*/
static function delete_attached($app,$id='',$fname='')
@ -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)
@ -1366,7 +1391,7 @@ class egw_link extends solink
*
* @param string $app name of app in which the updated happend
* @param string $id id in $app of the updated entry
* @param array $data=null updated data of changed entry, as the read-method of the BO-layer would supply it
* @param array $data =null updated data of changed entry, as the read-method of the BO-layer would supply it
*/
static function notify_update($app,$id,$data=null)
{
@ -1401,7 +1426,7 @@ class egw_link extends solink
* @param string $notify_id id in $notify_app
* @param string $target_app name of app whos entry changed, linked or deleted
* @param string $target_id id in $target_app
* @param array $data=null data of entry in app2 (optional)
* @param array $data =null data of entry in app2 (optional)
*/
static private function notify($type,$notify_app,$notify_id,$target_app,$target_id,$link_id,$data=null)
{
@ -1461,7 +1486,7 @@ class egw_link extends solink
*
* @param string $app
* @param string|int $id
* @param string $type='title' 'title' or 'file_access'
* @param string $type ='title' 'title' or 'file_access'
* @return int|string can be null, if cache not yet set
*/
private static function &get_cache($app,$id,$type = 'title')
@ -1487,7 +1512,7 @@ class egw_link extends solink
* @param string $app
* @param int|string $id
* @param string $title title string or null
* @param int $file_access=null EGW_ACL_READ, EGW_ACL_EDIT or both or'ed together
* @param int $file_access =null EGW_ACL_READ, EGW_ACL_EDIT or both or'ed together
*/
public static function set_cache($app,$id,$title,$file_access=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
*
@ -1523,9 +1610,9 @@ class egw_link extends solink
* @ToDo $rel_path is not yet implemented, as no app use it currently
* @param string $app
* @param string|int $id id of entry
* @param int $required=EGW_ACL_READ EGW_ACL_{READ|EDIT}
* @param string $rel_path=null
* @param int $user=null default null = current user
* @param int $required =EGW_ACL_READ EGW_ACL_{READ|EDIT}
* @param string $rel_path =null
* @param int $user =null default null = current user
* @return boolean true if access granted, false otherwise
*/
static function file_access($app,$id,$required=EGW_ACL_READ,$rel_path=null,$user=null)

View File

@ -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
{

View File

@ -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)
{