* 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:
Hadi Nategh 2015-03-30 11:03:46 +00:00
parent 586bce9c4d
commit 2ef3d4f048
20 changed files with 518 additions and 179 deletions

View File

@ -45,8 +45,10 @@ class calendar_hooks
'mime' => array( 'mime' => array(
'text/calendar' => array( 'text/calendar' => array(
'menuaction' => 'calendar.calendar_uiforms.edit', 'menuaction' => 'calendar.calendar_uiforms.edit',
'mime_id' => 'ical_vfs', 'mime_data' => 'ical_data',
'mime_url' => 'ical_url',
'mime_popup' => '750x400', 'mime_popup' => '750x400',
'mime_target' => '_blank'
), ),
), ),
'merge' => true, 'merge' => true,

View File

@ -1213,11 +1213,30 @@ class calendar_uiforms extends calendar_ui
unset($event['participants']); unset($event['participants']);
return $this->process_edit($event); return $this->process_edit($event);
} }
if (!empty($_GET['ical']) || !empty($_GET['ical_vfs']) && egw_vfs::file_exists($_GET['ical_vfs'])) // vfs url
if (!empty($_GET['ical_url']) && parse_url($_GET['ical_url'], PHP_URL_SCHEME) == 'vfs')
{
$_GET['ical_vfs'] = parse_url($_GET['ical_url'], PHP_URL_PATH);
}
// vfs path
if (!empty($_GET['ical_vfs']) &&
(!egw_vfs::file_exists($_GET['ical_vfs']) || !($_GET['ical'] = file_get_contents(egw_vfs::PREFIX.$_GET['ical_vfs']))))
{
//error_log(__METHOD__."() Error: importing the iCal: vfs file not found '$_GET[ical_vfs]'!");
$msg = lang('Error: importing the iCal').': '.lang('VFS file not found').': '.$_GET['ical_vfs'];
$event =& $this->default_add_event();
}
if (!empty($_GET['ical_data']) &&
!($_GET['ical'] = egw_link::get_data($_GET['ical_data'])))
{
//error_log(__METHOD__."() Error: importing the iCal: data not found '$_GET[ical_data]'!");
$msg = lang('Error: importing the iCal').': '.lang('Data not found').': '.$_GET['ical_data'];
$event =& $this->default_add_event();
}
if (!empty($_GET['ical']))
{ {
$ical = new calendar_ical(); $ical = new calendar_ical();
$ical_string = !empty($_GET['ical']) ? $_GET['ical'] : file_get_contents(egw_vfs::PREFIX.$_GET['ical_vfs']); if (!($events = $ical->icaltoegw($_GET['ical'], '', 'utf-8')) || count($events) != 1)
if (!($events = $ical->icaltoegw($ical_string, '', 'utf-8')) || count($events) != 1)
{ {
error_log(__METHOD__."('$_GET[ical]') error parsing iCal!"); error_log(__METHOD__."('$_GET[ical]') error parsing iCal!");
$msg = lang('Error: importing the iCal'); $msg = lang('Error: importing the iCal');
@ -1245,7 +1264,6 @@ class calendar_uiforms extends calendar_ui
//error_log(__METHOD__."(...) parsed as ".array2string($event)); //error_log(__METHOD__."(...) parsed as ".array2string($event));
} }
unset($ical); unset($ical);
unset($ical_string);
} }
elseif (!$cal_id || $cal_id && !($event = $this->bo->read($cal_id))) elseif (!$cal_id || $cal_id && !($event = $this->bo->read($cal_id)))
{ {

View File

@ -5124,20 +5124,40 @@ class emailadmin_imapbase
} }
/** /**
* retrieve a attachment * Get attachment data as string, to be used with egw_link::(get|set)_data()
* *
* @param int _uid the uid of the message * @param int $acc_id
* @param string _partID the id of the part, which holds the attachment * @param string $_mailbox
* @param int _winmail_nr winmail.dat attachment nr. * @param int $_uid
* @param boolean _returnPart flag to indicate if the attachment is to be returned as horde mime part object * @param string $_partID
* @param boolean _stream flag to indicate if the attachment is to be fetched or returned as filepointer * @param int $_winmail_nr
* @return resource stream with attachment content
*/
public static function getAttachmentAccount($acc_id, $_mailbox, $_uid, $_partID, $_winmail_nr)
{
$bo = self::getInstance(false, $acc_id);
$attachment = $bo->getAttachment($_uid, $_partID, $_winmail_nr, false, true, $_mailbox);
return $attachment['attachment'];
}
/**
* Retrieve a attachment
*
* @param int $_uid the uid of the message
* @param string $_partID the id of the part, which holds the attachment
* @param int $_winmail_nr = 0 winmail.dat attachment nr.
* @param boolean $_returnPart =true flag to indicate if the attachment is to be returned as horde mime part object
* @param boolean $_stream =false flag to indicate if the attachment is to be fetched or returned as filepointer
* @param string $_folder =null folder to use if not current folder
* *
* @return array * @return array
*/ */
function getAttachment($_uid, $_partID, $_winmail_nr=0, $_returnPart=true, $_stream=false) function getAttachment($_uid, $_partID, $_winmail_nr=0, $_returnPart=true, $_stream=false, $_folder=null)
{ {
//error_log(__METHOD__.__LINE__."Uid:$_uid, PartId:$_partID, WinMailNr:$_winmail_nr, ReturnPart:$_returnPart, Stream:$_stream"); //error_log(__METHOD__.__LINE__."Uid:$_uid, PartId:$_partID, WinMailNr:$_winmail_nr, ReturnPart:$_returnPart, Stream:$_stream");
$_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); if (!isset($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox());
$uidsToFetch = new Horde_Imap_Client_Ids(); $uidsToFetch = new Horde_Imap_Client_Ids();
if (!(is_object($_uid) || is_array($_uid))) $_uid = (array)$_uid; if (!(is_object($_uid) || is_array($_uid))) $_uid = (array)$_uid;
@ -5733,6 +5753,8 @@ class emailadmin_imapbase
*/ */
static function checkFileBasics(&$_formData, $IDtoAddToFileName='', $reqMimeType='message/rfc822') static function checkFileBasics(&$_formData, $IDtoAddToFileName='', $reqMimeType='message/rfc822')
{ {
if (parse_url($_formData['file'],PHP_URL_SCHEME) == 'egw-data') return $_formData['file'];
//error_log(__METHOD__.__FILE__.array2string($_formData).' Id:'.$IDtoAddToFileName.' ReqMimeType:'.$reqMimeType); //error_log(__METHOD__.__FILE__.array2string($_formData).' Id:'.$IDtoAddToFileName.' ReqMimeType:'.$reqMimeType);
$importfailed = $tmpFileName = false; $importfailed = $tmpFileName = false;
// ignore empty files, but allow to share vfs directories (which can have 0 size) // ignore empty files, but allow to share vfs directories (which can have 0 size)
@ -6162,11 +6184,20 @@ class emailadmin_imapbase
*/ */
function parseFileIntoMailObject(egw_mailer $mailer, $tmpFileName) function parseFileIntoMailObject(egw_mailer $mailer, $tmpFileName)
{ {
if (parse_url($tmpFileName, PHP_URL_SCHEME) != 'vfs') switch (parse_url($tmpFileName, PHP_URL_SCHEME))
{ {
$tmpFileName = $GLOBALS['egw_info']['server']['temp_dir'].SEP.basename($tmpFileName); case 'vfs':
break;
case 'egw-data':
$message = egw_link::get_data(parse_url($tmpFileName, PHP_URL_HOST), true);
break;
default:
$tmpFileName = $GLOBALS['egw_info']['server']['temp_dir'].SEP.basename($tmpFileName);
break;
} }
if (!($message = fopen($tmpFileName, 'r'))) if (!isset($message)) $message = fopen($tmpFileName, 'r');
if (!$message)
{ {
throw new egw_exception_not_found("File '$tmpFileName' not found!"); throw new egw_exception_not_found("File '$tmpFileName' not found!");
} }

View File

@ -15,6 +15,7 @@
/*egw:uses /*egw:uses
jquery.jquery; jquery.jquery;
et2_core_baseWidget; et2_core_baseWidget;
/etemplate/js/expose.js;
*/ */
/** /**
@ -22,9 +23,16 @@
* *
* @augments et2_baseWidget * @augments et2_baseWidget
*/ */
var et2_description = et2_baseWidget.extend([et2_IDetachedDOM], var et2_description = expose(et2_baseWidget.extend([et2_IDetachedDOM],
{ {
attributes: { attributes: {
"label": {
"name": "Label",
"default": "",
"type": "string",
"description": "The label is displayed by default in front (for radiobuttons behind) each widget (if not empty). If you want to specify a different position, use a '%s' in the label, which gets replaced by the widget itself. Eg. '%s Name' to have the label Name behind a checkbox. The label can contain variables, as descript for name. If the label starts with a '@' it is replaced by the value of the content-array at this index (with the '@'-removed and after expanding the variables).",
"translate": true
},
"value": { "value": {
"name": "Value", "name": "Value",
"type": "string", "type": "string",
@ -62,7 +70,7 @@ var et2_description = et2_baseWidget.extend([et2_IDetachedDOM],
"extra_link_target": { "extra_link_target": {
"name": "Link target", "name": "Link target",
"type": "string", "type": "string",
"default": "_self", "default": "_browser",
"description": "Link target for href attribute" "description": "Link target for href attribute"
}, },
"extra_link_popup": { "extra_link_popup": {
@ -75,6 +83,24 @@ var et2_description = et2_baseWidget.extend([et2_IDetachedDOM],
"type": "string", "type": "string",
"description": "Link title which is displayed on mouse over.", "description": "Link title which is displayed on mouse over.",
"translate": true "translate": true
},
"expose_view":{
name: "Expose view",
type: "boolean",
default: false,
description: "Clicking on description with href value would popup an expose view, and will show content referenced by href."
},
mime:{
name: "Mime type",
type: "string",
default: '',
description: "Mime type of the registered link"
},
mime_data:{
name: "Mime data",
type: "string",
default: '',
description: "hash for data stored on service-side with egw_link::(get|set)_data()"
} }
}, },
@ -119,6 +145,82 @@ var et2_description = et2_baseWidget.extend([et2_IDetachedDOM],
} }
}, },
set_label: function(_value) {
// Abort if ther was no change in the label
if (_value == this.label)
{
return;
}
if (_value)
{
// Create the label container if it didn't exist yet
if (this._labelContainer == null)
{
this._labelContainer = $j(document.createElement("label"))
.addClass("et2_label");
this.getSurroundings().insertDOMNode(this._labelContainer[0]);
}
// Clear the label container.
this._labelContainer.empty();
// Create the placeholder element and set it
var ph = document.createElement("span");
this.getSurroundings().setWidgetPlaceholder(ph);
// Split the label at the "%s"
var parts = et2_csvSplit(_value, 2, "%s");
// Update the content of the label container
for (var i = 0; i < parts.length; i++)
{
if (parts[i])
{
this._labelContainer.append(document.createTextNode(parts[i]));
}
if (i == 0)
{
this._labelContainer.append(ph);
}
}
}
else
{
// Delete the labelContainer from the surroundings object
if (this._labelContainer)
{
this.getSurroundings().removeDOMNode(this._labelContainer[0]);
}
this._labelContainer = null;
}
// Update the surroundings in order to reflect the change in the label
this.getSurroundings().update();
// Copy the given value
this.label = _value;
},
/**
* Function to get media content to feed the expose
* @param {type} _value
* @returns {Array|Array.getMedia.mediaContent}
*/
getMedia: function (_value)
{
var base_url = egw.webserverUrl.match(/^\//,'ig')?egw(window).window.location.origin :'';
var mediaContent = [];
if (_value)
{
mediaContent = [{
title: this.options.label,
href: base_url + _value,
type: this.options.type + "/*",
thumbnail: base_url + _value
}];
}
return mediaContent;
},
set_value: function(_value) { set_value: function(_value) {
if (!_value) _value = ""; if (!_value) _value = "";
if (!this.options.no_lang) _value = this.egw().lang(_value); if (!this.options.no_lang) _value = this.egw().lang(_value);
@ -130,17 +232,24 @@ var et2_description = et2_baseWidget.extend([et2_IDetachedDOM],
this.span[0], this.span[0],
this.options.href ? this.options.extra_link_target : '_blank' this.options.href ? this.options.extra_link_target : '_blank'
); );
if(this.options.extra_link_popup) if(this.options.extra_link_popup || this.options.mime)
{ {
var href = this.options.href; var self= this;
var title = this.options.extra_link_title; var $span = this.options.mime_data? jQuery(this.span): jQuery('a',this.span);
var popup = this.options.extra_link_popup; $span.click(function(e) {
jQuery('a',this.span) if (self.options.expose_view && typeof self.options.mime !='undefined' && self.options.mime.match(/video\/|image\/|audio\//,'ig'))
.click(function(e) { {
egw.open_link(href, title,popup); // Do not show thumbnail indicator for single expose view
e.preventDefault(); self.expose_options.thumbnailIndicators = false;
return false; self._init_blueimp_gallery(e,self.options.href);
}); }
else
{
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;
});
} }
}, },
@ -216,6 +325,6 @@ var et2_description = et2_baseWidget.extend([et2_IDetachedDOM],
_nodes[0].setAttribute("class", _values["class"]); _nodes[0].setAttribute("class", _values["class"]);
} }
} }
}); }));
et2_register_widget(et2_description, ["description", "label"]); et2_register_widget(et2_description, ["description", "label"]);

View File

@ -373,6 +373,9 @@ function expose (widget)
set_value:function (_value) set_value:function (_value)
{ {
if (typeof this._super == 'undefined') return;
this._super.apply(this,arguments);
// Do not run set value of expose if expose_view is not set // Do not run set value of expose if expose_view is not set
// it causes a wired error on nested image widgets which // it causes a wired error on nested image widgets which
// seems the expose is not its child widget // seems the expose is not its child widget
@ -380,7 +383,7 @@ function expose (widget)
{ {
return; return;
} }
this._super.apply(this,arguments);
var self=this; var self=this;
// If the media type is not supported do not bind the click handler // If the media type is not supported do not bind the click handler
@ -488,6 +491,7 @@ function expose (widget)
* @param {DOMNode} slide * @param {DOMNode} slide
*/ */
expose_onslide: function (gallery, index, slide){ expose_onslide: function (gallery, index, slide){
if (typeof this._super == 'undefined') return;
// First let parent try // First let parent try
this._super.apply(this, arguments); this._super.apply(this, arguments);
var nm = find_nextmatch(this); var nm = find_nextmatch(this);

View File

@ -745,7 +745,7 @@ app.classes.filemanager = AppJS.extend(
} }
else else
{ {
egw.open({path: path, type: data.data.mime}, 'file'); egw.open({path: path, type: data.data.mime}, 'file','view',null,'_browser');
} }
return false; return false;
}, },

View File

@ -139,11 +139,19 @@
*/ */
init:function(_wnd) init:function(_wnd)
{ {
var self = this;
this.$container = $j(document.createElement('div')).addClass('egw_fw_mobile_popup_container egw_fw_mobile_popup_loader'); this.$container = $j(document.createElement('div')).addClass('egw_fw_mobile_popup_container egw_fw_mobile_popup_loader');
this.$iFrame = $j(document.createElement('iframe')) this.$iFrame = $j(document.createElement('iframe'))
.addClass('egw_fw_mobile_popupFrame') .addClass('egw_fw_mobile_popupFrame')
.appendTo(this.$container); .appendTo(this.$container);
this.$container.appendTo('body'); this.$container.appendTo('body');
// Create close button for popups
var $closeBtn = $j(document.createElement('span'))
.addClass('egw_fw_mobile_popup_close')
.click(function (){self.close(framework.popup_idx(self.$iFrame[0].contentWindow));});
if (framework.getUserAgent() === 'iOS' && !framework.isNotFullScreen()) $closeBtn.css({top:"15px"});
this.$container.prepend($closeBtn);
this.windowOpener = _wnd; this.windowOpener = _wnd;
}, },
@ -168,20 +176,8 @@
this.$iFrame.on('onpopupload', function (){ this.$iFrame.on('onpopupload', function (){
var popupWindow = this.contentWindow; var popupWindow = this.contentWindow;
var $appHeader = $j(popupWindow.document).find('#divAppboxHeader'); var $appHeader = $j(popupWindow.document).find('#divAppboxHeader');
var $closeBtn = $appHeader.find('.egw_fw_mobile_popup_close'); $appHeader.addClass('egw_fw_mobile_popup_appHeader');
if ($closeBtn.length == 0)
{
$closeBtn = $j(document.createElement('span'))
.addClass('egw_fw_mobile_popup_close')
.click(function (){self.close(framework.popup_idx(self.$iFrame[0].contentWindow));});
if ($appHeader.length > 0)
{
$appHeader.addClass('egw_fw_mobile_popup_appHeader');
// Add close button only after everything is loaded
setTimeout(function(){$appHeader.prepend($closeBtn);},0);
}
}
//Remove the loading class //Remove the loading class
self.$container.removeClass('egw_fw_mobile_popup_loader'); self.$container.removeClass('egw_fw_mobile_popup_loader');
self.$iFrame.css({visibility:'visible'}); self.$iFrame.css({visibility:'visible'});
@ -204,24 +200,6 @@
// If the popup is not an et2_popup // If the popup is not an et2_popup
else if ($et2_container.length == 0) else if ($et2_container.length == 0)
{ {
// Since the popup is not et2, there's no css loaded
// therefore we need to add the style
var close_btn_styles = {width: "32px",
height: "32px",
float:"right",
"background-image": 'url(' +egw.webserverUrl+ '/pixelegg/images/cancelled.png)',
"-webkit-filter": "contrast(2)",
"background-repeat": "no-repeat",
"z-index": 999,
"padding-right": "5px"};
var $closeBtn = $j(document.createElement('span'))
.addClass('egw_fw_mobile_popup_close')
.click(function (){self.close(framework.popup_idx(self.$iFrame[0].contentWindow));})
.css(close_btn_styles);
setTimeout(function(){
$j('body',popupWindow.document).prepend($closeBtn);
},0);
self.$container.removeClass('egw_fw_mobile_popup_loader'); self.$container.removeClass('egw_fw_mobile_popup_loader');
self.$iFrame.css({visibility:'visible'}); self.$iFrame.css({visibility:'visible'});
} }
@ -401,6 +379,7 @@
*/ */
orientation: function () orientation: function ()
{ {
if (!this.isLandscape()) this.toggleMenu('on');
this.arrangeToolbar(this.isLandscape()?'landscape':'portrait'); this.arrangeToolbar(this.isLandscape()?'landscape':'portrait');
}, },

View File

@ -93,7 +93,10 @@ class mail_hooks
'message/rfc822' => array( 'message/rfc822' => array(
'menuaction' => 'mail.mail_ui.importMessageFromVFS2DraftAndDisplay', 'menuaction' => 'mail.mail_ui.importMessageFromVFS2DraftAndDisplay',
'mime_url' => 'formData[file]', 'mime_url' => 'formData[file]',
'mime_data' => 'formData[data]',
'formData[type]' => 'message/rfc822',
'mime_popup' => '870xavailHeight', 'mime_popup' => '870xavailHeight',
'mime_target' => '_blank'
), ),
), ),
'entry' => 'Mail', 'entry' => 'Mail',

View File

@ -2168,14 +2168,20 @@ class mail_ui
$attachmentHTML[$key]['filename'] = $x; $attachmentHTML[$key]['filename'] = $x;
} }
} }
//error_log(array2string($value)); //error_log(array2string($value));
//error_log(strtoupper($value['mimeType']) .'<->'. mime_magic::filename2mime($attachmentHTML[$key]['filename'])); //error_log(strtoupper($value['mimeType']) .'<->'. mime_magic::filename2mime($attachmentHTML[$key]['filename']));
if (strtoupper($value['mimeType']=='APPLICATION/OCTET-STREAM')) $value['mimeType'] = mime_magic::filename2mime($attachmentHTML[$key]['filename']); if (strtoupper($value['mimeType']=='APPLICATION/OCTET-STREAM')) $value['mimeType'] = mime_magic::filename2mime($attachmentHTML[$key]['filename']);
$attachmentHTML[$key]['type']=$value['mimeType']; $attachmentHTML[$key]['type']=$value['mimeType'];
$attachmentHTML[$key]['mimetype']=mime_magic::mime2label($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]['size']=egw_vfs::hsize($value['size']);
$attachmentHTML[$key]['attachment_number']=$key; $attachmentHTML[$key]['attachment_number']=$key;
$attachmentHTML[$key]['partID']=$value['partID']; $attachmentHTML[$key]['partID']=$value['partID'];
$attachmentHTML[$key]['mail_id'] = $rowID;
$attachmentHTML[$key]['winmailFlag']=$value['is_winmail']; $attachmentHTML[$key]['winmailFlag']=$value['is_winmail'];
$attachmentHTML[$key]['classSaveAllPossiblyDisabled'] = "mail_DisplayNone"; $attachmentHTML[$key]['classSaveAllPossiblyDisabled'] = "mail_DisplayNone";
@ -2185,7 +2191,7 @@ class mail_ui
$linkData = array $linkData = array
( (
'menuaction' => 'mail.mail_ui.displayMessage', 'menuaction' => 'mail.mail_ui.displayMessage',
//'mode' => 'display', //message/rfc822 attachments should be opened in display mode 'mode' => 'display', //message/rfc822 attachments should be opened in display mode
'id' => $rowID, 'id' => $rowID,
'part' => $value['partID'], 'part' => $value['partID'],
'is_winmail' => $value['is_winmail'] 'is_winmail' => $value['is_winmail']
@ -2252,6 +2258,14 @@ class mail_ui
$linkView = "window.location.href = '".egw::link('/index.php',$linkData)."';"; $linkView = "window.location.href = '".egw::link('/index.php',$linkData)."';";
break; break;
} }
// 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); //error_log(__METHOD__.__LINE__.$linkView);
$attachmentHTML[$key]['link_view'] = '<a href="#" ." title="'.$attachmentHTML[$key]['filename'].'" onclick="'.$linkView.' return false;"><b>'. $attachmentHTML[$key]['link_view'] = '<a href="#" ." title="'.$attachmentHTML[$key]['filename'].'" onclick="'.$linkView.' return false;"><b>'.
($value['name'] ? ( $filename ? $filename : $value['name'] ) : lang('(no subject)')). ($value['name'] ? ( $filename ? $filename : $value['name'] ) : lang('(no subject)')).
@ -2532,8 +2546,7 @@ class mail_ui
html::safe_content_header($attachment['attachment'], $filename, $attachment['type'], $size=0, True, $_GET['mode'] == "save"); html::safe_content_header($attachment['attachment'], $filename, $attachment['type'], $size=0, True, $_GET['mode'] == "save");
echo $attachment['attachment']; echo $attachment['attachment'];
$GLOBALS['egw']->common->egw_exit(); common::egw_exit();
exit;
} }
@ -3295,8 +3308,6 @@ class mail_ui
if ($importfailed === false) if ($importfailed === false)
{ {
$mailObject = new egw_mailer(); $mailObject = new egw_mailer();
$Header = '';
$Body = '';
try try
{ {
$this->mail_bo->parseFileIntoMailObject($mailObject, $tmpFileName); $this->mail_bo->parseFileIntoMailObject($mailObject, $tmpFileName);
@ -3381,15 +3392,20 @@ class mail_ui
//error_log(__METHOD__.__LINE__.':'.array2string($formData).' Mode:'.$mode.'->'.function_backtrace()); //error_log(__METHOD__.__LINE__.':'.array2string($formData).' Mode:'.$mode.'->'.function_backtrace());
$draftFolder = $this->mail_bo->getDraftFolder(false); $draftFolder = $this->mail_bo->getDraftFolder(false);
$importID = mail_bo::getRandomString(); $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 // name should be set to meet the requirements of checkFileBasics
if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && (!isset($formData['name']) || empty($formData['name']))) if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && empty($formData['name']))
{ {
$buff = explode('/',$formData['file']); $buff = explode('/',$formData['file']);
$suffix = '';
if (is_array($buff)) $formData['name'] = array_pop($buff); // take the last part as name 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 // type should be set to meet the requirements of checkFileBasics
if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && (!isset($formData['type']) || empty($formData['type']))) if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && empty($formData['type']))
{ {
$buff = explode('.',$formData['file']); $buff = explode('.',$formData['file']);
$suffix = ''; $suffix = '';
@ -3419,18 +3435,12 @@ class mail_ui
{ {
$linkData['mode']=$mode; $linkData['mode']=$mode;
} }
egw::redirect_link('/index.php',$linkData);
} }
catch (egw_exception_wrong_userinput $e) catch (egw_exception_wrong_userinput $e)
{ {
$linkData = array egw_framework::window_close($e->getMessage());
(
'menuaction' => 'mail.mail_ui.importMessage',
'msg' => htmlspecialchars($e->getMessage()),
);
} }
egw::redirect_link('/index.php',$linkData);
exit;
} }
/** /**

View File

@ -3682,6 +3682,13 @@ app.classes.mail = AppJS.extend(
*/ */
compose_resizeHandler: function() compose_resizeHandler: function()
{ {
// Do not resize compose dialog if it's running on mobile device
// in this case user would be able to edit mail body by scrolling down,
// which is more convenient on small devices. Also resize mailbody with
// ckeditor may causes performance regression, especially on devices with
// very limited resources and slow proccessor.
if (egwIsMobile()) return;
var bodyH = egw_getWindowInnerHeight(); var bodyH = egw_getWindowInnerHeight();
var textArea = this.et2.getWidgetById('mail_plaintext'); var textArea = this.et2.getWidgetById('mail_plaintext');
var $headerSec = jQuery('.mailComposeHeaderSection'); var $headerSec = jQuery('.mailComposeHeaderSection');

View File

@ -813,7 +813,7 @@ blockquote blockquote blockquote blockquote blockquote blockquote{
height: auto; height: auto;
} }
div#mail-display.et2_container { #mail-display.et2_container {
min-height: initial; min-height: initial;
} }

View File

@ -19,7 +19,7 @@
<date-time id="mail_displaydate" readonly="true"/> <date-time id="mail_displaydate" readonly="true"/>
</hbox> </hbox>
</hbox> </hbox>
<hbox class="mailDisplayHeaders" id="mailDisplayHeadersSender" disabled="!@SENDER" width="100%"> <hbox class="mailDisplayHeaders" id="mailDisplayHeadersSender" disabled="!@SENDER" width="100%">
<description value="on behalf of"/> <description value="on behalf of"/>
<url-email id="SENDER" readonly="true"/> <url-email id="SENDER" readonly="true"/>
@ -51,7 +51,7 @@
<box class="$cont[mailDisplayContainerClass]"> <box class="$cont[mailDisplayContainerClass]">
<iframe frameborder="1" class="mail_displaybody" id="mailDisplayBodySrc" name="mailDisplayBodySrc" scrolling="auto" width="100%"/> <iframe frameborder="1" class="mail_displaybody" id="mailDisplayBodySrc" name="mailDisplayBodySrc" scrolling="auto" width="100%"/>
</box> </box>
<box class="$cont[mailDisplayAttachmentsClass]"> <box class="$cont[mailDisplayAttachmentsClass]">
<grid disabled="@no_griddata" id="mail_displayattachments" class="egwGridView_grid" width="100%"> <grid disabled="@no_griddata" id="mail_displayattachments" class="egwGridView_grid" width="100%">
<columns> <columns>
@ -72,7 +72,7 @@
<description id="${row}[partID]" /> <description id="${row}[partID]" />
<description id="${row}[type]" /> <description id="${row}[type]" />
<description id="${row}[winmailFlag]" /> <description id="${row}[winmailFlag]" />
<description class="useEllipsis et2_link" id="${row}[filename]" no_lang="1" onclick="app.mail.displayAttachment"/> <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]" /> <description align="right" id="${row}[size]" />
<buttononly id="${row}[save]" value="save" image="fileexport" onclick="app.mail.saveAttachment"/> <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"/> <buttononly id="${row}[saveAsVFS]" value="save" image="filemanager/navbar" onclick="app.mail.saveAttachmentToVFS"/>

View File

@ -98,8 +98,8 @@
<description id="${row}[partID]" /> <description id="${row}[partID]" />
<description id="${row}[type]" /> <description id="${row}[type]" />
<description id="${row}[winmailFlag]" /> <description id="${row}[winmailFlag]" />
<description class="et2_link useEllipsis" id="${row}[filename]" no_lang="1" onclick="app.mail.displayAttachment"/> <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]" /> <description align="right" id="${row}[size]"/>
<buttononly id="${row}[save]" image="fileexport" onclick="app.mail.saveAttachment"/> <buttononly id="${row}[save]" image="fileexport" onclick="app.mail.saveAttachment"/>
<buttononly id="${row}[saveAsVFS]" image="filemanager/navbar" onclick="app.mail.saveAttachmentToVFS"/> <buttononly id="${row}[saveAsVFS]" image="filemanager/navbar" onclick="app.mail.saveAttachmentToVFS"/>
<buttononly class="$row_cont[classSaveAllPossiblyDisabled]" id="${row}[save_all]" image="mail/save_all" onclick="app.mail.saveAllAttachmentsToVFS"/> <buttononly class="$row_cont[classSaveAllPossiblyDisabled]" id="${row}[save_all]" image="mail/save_all" onclick="app.mail.saveAllAttachmentsToVFS"/>

View File

@ -807,7 +807,7 @@ blockquote blockquote blockquote blockquote blockquote blockquote {
margin-left: 0; margin-left: 0;
height: auto; height: auto;
} }
div#mail-display.et2_container { #mail-display.et2_container {
min-height: initial; min-height: initial;
} }
table.egwGridView_grid tbody td { table.egwGridView_grid tbody td {

View File

@ -25,7 +25,7 @@
* /** * /**
* * Hook called by link-class to include app in the appregistry of the linkage * * 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 * * @return array with method-names
* *% * *%
* function search_link($location) * function search_link($location)
@ -73,8 +73,8 @@
* 'entries' => 'Contacts', // Optional name for multiple entries of app, eg. "contacts" used instead of appname * 'entries' => 'Contacts', // Optional name for multiple entries of app, eg. "contacts" used instead of appname
* 'mime' => array( // Optional register mime-types application can open * 'mime' => array( // Optional register mime-types application can open
* 'text/something' => array( * 'text/something' => array(
* 'mime_id' => 'path', // one of id (path) or url is required! * 'mime_url' => $attr, // either mime_url or mime_data is required for server-side processing!
* 'mime_url' => 'url', * 'mime_data' => $attr, // md5-hash returned from egw_link::set_data() to retrive content (only server-side)
* 'menuaction' => 'app.class.method', // method to call * 'menuaction' => 'app.class.method', // method to call
* 'mime_popup' => '400x300', // optional size of popup * 'mime_popup' => '400x300', // optional size of popup
* 'mime_target' => '_self', // optional target, default _blank * 'mime_target' => '_self', // optional target, default _blank
@ -141,6 +141,19 @@ class egw_link extends solink
'view' => array('menuaction'=>'addressbook.addressbook_ui.view'), 'view' => array('menuaction'=>'addressbook.addressbook_ui.view'),
'view_id' => 'account_id' '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\\/(plain|html|diff)/' => array( // text/(mimetypes which can be opened as recognised popups)
'mime_popup' => '640x480',
'mime_target' => '_blank',
),
),
),
); );
/** /**
* Caches link titles for a better performance * Caches link titles for a better performance
@ -170,6 +183,11 @@ class egw_link extends solink
*/ */
static function init_static( ) 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 // 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 // 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 // for performance reasons, we do it only once / cache it in the session
@ -281,21 +299,21 @@ class egw_link extends solink
* File-attachments return a negative link-id !!! * File-attachments return a negative link-id !!!
* *
* @param string $app1 app of $id1 * @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). * 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. * 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> * @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 array with informations about the file in format of the etemplate file-type<br>
* $file['name'] name of the file (no directory)<br> * $file['name'] name of the file (no directory)<br>
* $file['type'] mine-type of the file<br> * $file['type'] mine-type of the file<br>
* $file['tmp_name'] name of the uploaded file (incl. directory)<br> * $file['tmp_name'] name of the uploaded file (incl. directory)<br>
* $file['path'] path of the file on the client computer<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)) * $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 string $remark ='' Remark to be saved with the link (defaults to '')
* @param int $owner=0 Owner of the link (defaults to user) * @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 $lastmod =0 timestamp of last modification (defaults to now=time())
* @param int $no_notify=0 &1 dont notify $app1, &2 dont notify $app2 * @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) * @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 ) static function link( $app1,&$id1,$app2,$id2='',$remark='',$owner=0,$lastmod=0,$no_notify=0 )
@ -407,12 +425,12 @@ class egw_link extends solink
* *
* @param string $app appname * @param string $app appname
* @param string|array $id id(s) in $app * @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 $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 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 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! * 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 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 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 * @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) static function get_links($app, $id, $only_app='', $order='link_lastmod DESC',$cache_titles=false, $deleted=false, $limit=null)
@ -480,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 * @ToDo also query the attachments in a single query, eg. via a directory listing of /apps/$app
* @param string $app * @param string $app
* @param array $ids * @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 $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 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 boolean $deleted =false Include links that have been flagged as deleted, waiting for purge of linked record.
* @return array of $id => array($links) pairs * @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 ) static function get_links_multiple($app,array $ids,$cache_titles=true,$only_app='',$order='link_lastmod DESC', $deleted=false )
@ -536,10 +554,10 @@ class egw_link extends solink
* *
* If $id is an array (links not yet created) only link_ids are allowed. * 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 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|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 $app2 ='' second app
* @param string $id2='' id in $app2 * @param string $id2 ='' id in $app2
* @return array with link-data or False * @return array with link-data or False
*/ */
static function get_link($app_link_id,$id='',$app2='',$id2='') static function get_link($app_link_id,$id='',$app2='',$id2='')
@ -580,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 !!! * 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 $link_id link-id to remove if > 0
* @param string $app='' appname of first endpoint * @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 int $owner =0 account_id to delete all links of a given owner, or 0
* @param string $app2='' app of second endpoint * @param string $app2 ='' app of second endpoint
* @param string $id2='' id in $app2 * @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 * @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 * @return the number of links deleted
*/ */
@ -597,11 +615,11 @@ class egw_link extends solink
* Remove link with $link_id or all links matching given $app,$id * Remove link with $link_id or all links matching given $app,$id
* *
* @param $link_id link-id to remove if > 0 * @param $link_id link-id to remove if > 0
* @param string $app='' appname of first endpoint * @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 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 $app2 ='' app of second endpoint, or !file (other !app are not yet supported!)
* @param string $id2='' id in $app2 * @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 * @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 * @return the number of links deleted
*/ */
@ -769,7 +787,7 @@ class egw_link extends solink
* *
* @param string $app appname * @param string $app appname
* @param string $id id in $app * @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 * @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) static function title($app,$id,$link=null)
@ -884,7 +902,7 @@ class egw_link extends solink
* Add new entry to $app, evtl. already linked to $to_app, $to_id * Add new entry to $app, evtl. already linked to $to_app, $to_id
* *
* @param string $app appname of entry to create * @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 * @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 * @return array/boolean with name-value pairs for link to add-methode of $app or false if add not supported
*/ */
@ -938,7 +956,7 @@ class egw_link extends solink
* *
* @param string $app appname * @param string $app appname
* @param string $id id in $app * @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 * @return array with name-value pairs for link to view-methode of $app to view $id
*/ */
static function view($app,$id,$link=null) static function view($app,$id,$link=null)
@ -975,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). * 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 * @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 * @return array with values for keys 'menuaction', 'mime_id' (path) or 'mime_url' and options 'mime_popup' and other values to pass one
*/ */
@ -989,17 +1009,21 @@ class egw_link extends solink
foreach($registry['mime'] as $mime => $data) foreach($registry['mime'] as $mime => $data)
{ {
if ($mime == $type) return $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 * Get handler (link-data) for given path and mime-type
* *
* @param string $path vfs path * @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 * @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) * @return string|array string with EGw relative link, array with get-parameters for '/index.php' or null (directory and not filemanager access)
*/ */
@ -1037,8 +1061,8 @@ class egw_link extends solink
* Check if $app uses a popup for $action * Check if $app uses a popup for $action
* *
* @param string $app app-name * @param string $app app-name
* @param string $action='view' name of the action, atm. 'view' or 'add' * @param string $action ='view' name of the action, atm. 'view' or 'add'
* @param array $link=null link-data for file-attachments * @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) * @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) static function is_popup($app, $action='view', $link=null)
@ -1102,9 +1126,9 @@ class egw_link extends solink
* All link-files are based in the vfs-subdir '/apps/'.$app * All link-files are based in the vfs-subdir '/apps/'.$app
* *
* @param string $app appname * @param string $app appname
* @param string $id='' id in $app * @param string $id ='' id in $app
* @param string $file='' filename * @param string $file ='' filename
* @param boolean $just_the_path=false return url or just the vfs path * @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 * @return string/array path or array with path and relatives, depending on $relatives
*/ */
static function vfs_path($app,$id='',$file='',$just_the_path=false) static function vfs_path($app,$id='',$file='',$just_the_path=false)
@ -1150,7 +1174,7 @@ class egw_link extends solink
* $file['tmp_name'] name of the uploaded file (incl. directory) * $file['tmp_name'] name of the uploaded file (incl. directory)
* $file['path'] path of the file on the client computer * $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)) * $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 * @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='') static function attach_file($app,$id,$file,$comment='')
@ -1178,7 +1202,7 @@ class egw_link extends solink
* @param string $app appname to link the file to * @param string $app appname to link the file to
* @param string $id id in $app * @param string $id id in $app
* @param string $file VFS path to link to * @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='') static function link_file($app,$id,$file)//,$comment='')
{ {
@ -1202,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!) * 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 $id ='' id in app
* @param string $fname='' filename * @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 * @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='') static function delete_attached($app,$id='',$fname='')
@ -1273,7 +1297,7 @@ class egw_link extends solink
/** /**
* converts a fileinfo (row in the vfs-db-table) in a link * 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 * @return array a 'kind' of link-array
*/ */
static function fileinfo2link($fileinfo,$url=null) static function fileinfo2link($fileinfo,$url=null)
@ -1367,7 +1391,7 @@ class egw_link extends solink
* *
* @param string $app name of app in which the updated happend * @param string $app name of app in which the updated happend
* @param string $id id in $app of the updated entry * @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) static function notify_update($app,$id,$data=null)
{ {
@ -1402,7 +1426,7 @@ class egw_link extends solink
* @param string $notify_id id in $notify_app * @param string $notify_id id in $notify_app
* @param string $target_app name of app whos entry changed, linked or deleted * @param string $target_app name of app whos entry changed, linked or deleted
* @param string $target_id id in $target_app * @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) static private function notify($type,$notify_app,$notify_id,$target_app,$target_id,$link_id,$data=null)
{ {
@ -1462,7 +1486,7 @@ class egw_link extends solink
* *
* @param string $app * @param string $app
* @param string|int $id * @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 * @return int|string can be null, if cache not yet set
*/ */
private static function &get_cache($app,$id,$type = 'title') private static function &get_cache($app,$id,$type = 'title')
@ -1488,7 +1512,7 @@ class egw_link extends solink
* @param string $app * @param string $app
* @param int|string $id * @param int|string $id
* @param string $title title string or null * @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) public static function set_cache($app,$id,$title,$file_access=null)
{ {
@ -1515,6 +1539,68 @@ class egw_link extends solink
unset(self::$file_access_cache[$app.':'.$id]); 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 * Check the file access perms for $app/id and given user $user
* *
@ -1524,9 +1610,9 @@ class egw_link extends solink
* @ToDo $rel_path is not yet implemented, as no app use it currently * @ToDo $rel_path is not yet implemented, as no app use it currently
* @param string $app * @param string $app
* @param string|int $id id of entry * @param string|int $id id of entry
* @param int $required=EGW_ACL_READ EGW_ACL_{READ|EDIT} * @param int $required =EGW_ACL_READ EGW_ACL_{READ|EDIT}
* @param string $rel_path=null * @param string $rel_path =null
* @param int $user=null default null = current user * @param int $user =null default null = current user
* @return boolean true if access granted, false otherwise * @return boolean true if access granted, false otherwise
*/ */
static function file_access($app,$id,$required=EGW_ACL_READ,$rel_path=null,$user=null) 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 * 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 * @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 * @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) get_mime_info: function(_type)
{ {
var wildcard_mime;
for(var app in link_registry) for(var app in link_registry)
{ {
var reg = link_registry[app]; var reg = link_registry[app];
@ -118,16 +121,20 @@ egw.extend('links', egw.MODULE_GLOBAL, function()
for(var mime in reg.mime) for(var mime in reg.mime)
{ {
if (mime == _type) return reg.mime[_type]; 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 * 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 * @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) * @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; _type = _path.type;
} }
}
else if(_path[0] != '/')
{
} }
else else
{ {
@ -164,13 +175,20 @@ egw.extend('links', egw.MODULE_GLOBAL, function()
case 'mime_url': case 'mime_url':
data[mime_info.mime_url] = 'vfs://default' + path; data[mime_info.mime_url] = 'vfs://default' + path;
break; break;
case 'mime_id': case 'mime_data':
data[mime_info.mime_id] = path; break;
case 'mime_type':
data[mime_info.mime_type] = _type;
break; break;
default: default:
data[attr] = mime_info[attr]; 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 else
{ {

View File

@ -187,8 +187,15 @@ egw.extend('open', egw.MODULE_WND_LOCAL, function(_egw, _wnd)
target = url.mime_target; target = url.mime_target;
delete url.mime_target; delete url.mime_target;
} }
params = url; if (typeof url.url == 'string')
url = '/index.php'; {
url = url.url;
}
else
{
params = url;
url = '/index.php';
}
} }
} }
else else
@ -243,8 +250,9 @@ egw.extend('open', egw.MODULE_WND_LOCAL, function(_egw, _wnd)
* @param {string} _target_app app-name for opener * @param {string} _target_app app-name for opener
* @param {boolean} _check_popup_blocker TRUE check if browser pop-up blocker is on/off, FALSE no check * @param {boolean} _check_popup_blocker TRUE check if browser pop-up blocker is on/off, FALSE no check
* - This option only makes sense to be enabled when the open_link requested without user interaction * - This option only makes sense to be enabled when the open_link requested without user interaction
* @param {string} _mime_type if given, we check if any app has registered a mime-handler for that type and use it
*/ */
open_link: function(_link, _target, _popup, _target_app, _check_popup_blocker) open_link: function(_link, _target, _popup, _target_app, _check_popup_blocker, _mime_type)
{ {
// Log for debugging purposes - don't use navigation here to avoid // Log for debugging purposes - don't use navigation here to avoid
// flooding log with details already captured by egw.open() // flooding log with details already captured by egw.open()
@ -278,6 +286,42 @@ egw.extend('open', egw.MODULE_WND_LOCAL, function(_egw, _wnd)
{ {
url = this.webserverUrl + url; url = this.webserverUrl + url;
} }
var mime_info = _mime_type ? this.get_mime_info(_mime_type) : undefined;
if (mime_info && (mime_info.mime_url || mime_info.mime_data))
{
var data = {};
for(var attr in mime_info)
{
switch(attr)
{
case 'mime_popup':
_popup = mime_info.mime_popup;
break;
case 'mime_target':
_target = 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;
}
}
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) if (_popup)
{ {
var w_h = _popup.split('x'); var w_h = _popup.split('x');
@ -300,6 +344,11 @@ egw.extend('open', egw.MODULE_WND_LOCAL, function(_egw, _wnd)
} }
else else
{ {
// No mime type registered, set target properly based on browsing environment
if (_target == '_browser')
{
_target = egwIsMobile()?'_self':'_blank';
}
return _wnd.open(url, _target); return _wnd.open(url, _target);
} }
}, },

View File

@ -6284,17 +6284,6 @@ a.textSidebox {
width: 100%; width: 100%;
line-height: 32px !important; line-height: 32px !important;
} }
body div.egw_fw_mobile_popup_appHeader .egw_fw_mobile_popup_close {
width: 32px;
height: 32px;
float: right;
background-image: url('../images/cancelled.png');
/*url(../images/topmenu_items/mobile/menu_active.png);*/
-webkit-filter: contrast(2);
background-repeat: no-repeat;
z-index: 999;
padding-right: 5px;
}
body div.dhtmlxMenu_egw_SubLevelArea_Polygon { body div.dhtmlxMenu_egw_SubLevelArea_Polygon {
font-size: medium; font-size: medium;
margin-top: 15px; margin-top: 15px;
@ -6979,7 +6968,6 @@ a.textSidebox {
display: none; display: none;
z-index: 999; z-index: 999;
-webkit-overflow-scrolling: touch; -webkit-overflow-scrolling: touch;
overflow-y: scroll;
background: white; background: white;
} }
.egw_fw_mobile_popup_container .egw_fw_mobile_popupFrame { .egw_fw_mobile_popup_container .egw_fw_mobile_popupFrame {
@ -6987,11 +6975,31 @@ a.textSidebox {
height: 100%; height: 100%;
visibility: hidden; visibility: hidden;
} }
.egw_fw_mobile_popup_container span.egw_fw_mobile_popup_close {
width: 32px;
height: 32px;
float: right;
background-image: url('../images/cancelled.png');
/*url(../images/topmenu_items/mobile/menu_active.png);*/
-webkit-filter: contrast(2);
background-repeat: no-repeat;
z-index: 1000;
padding-right: 5px;
top: 0;
right: 2px;
position: absolute;
}
.egw_fw_mobile_popup_loader { .egw_fw_mobile_popup_loader {
background: url(../images/loading.gif) center no-repeat; background: url(../images/loading.gif) center no-repeat;
background-size: 120px 120px; background-size: 120px 120px;
background-position: center; background-position: center;
} }
#mail-display {
min-height: initial !important;
}
#mail-display .mailDisplayContainer {
top: 140px;
}
} }
@media only screen and (max-device-width : 1024px) { @media only screen and (max-device-width : 1024px) {
#egw_fw_print { #egw_fw_print {

View File

@ -50,16 +50,7 @@
border-top: none !important; border-top: none !important;
width: 100%; width: 100%;
line-height: 32px !important; line-height: 32px !important;
.egw_fw_mobile_popup_close {
width: 32px;
height: 32px;
float:right;
background-image: url('../images/cancelled.png');/*url(../images/topmenu_items/mobile/menu_active.png);*/
-webkit-filter: contrast(2);
background-repeat: no-repeat;
z-index: 999;
padding-right: 5px;
}
} }
//################### //###################
//# # //# #
@ -753,19 +744,43 @@
display: none; display: none;
z-index: 999; z-index: 999;
-webkit-overflow-scrolling: touch; -webkit-overflow-scrolling: touch;
overflow-y:scroll;
background: white; background: white;
.egw_fw_mobile_popupFrame { .egw_fw_mobile_popupFrame {
width: 100%; width: 100%;
height: 100%; height: 100%;
visibility: hidden; visibility: hidden;
} }
span.egw_fw_mobile_popup_close {
width: 32px;
height: 32px;
float:right;
background-image: url('../images/cancelled.png');/*url(../images/topmenu_items/mobile/menu_active.png);*/
-webkit-filter: contrast(2);
background-repeat: no-repeat;
z-index: 1000;
padding-right: 5px;
top:0;
right:2px;
position: absolute;
}
} }
.egw_fw_mobile_popup_loader { .egw_fw_mobile_popup_loader {
background: url(../images/loading.gif) center no-repeat; background: url(../images/loading.gif) center no-repeat;
background-size: 120px 120px; background-size: 120px 120px;
background-position: center; background-position: center;
} }
//###################################
//# #
//# Mail App specific style #
//# #
//###################################
#mail-display {
min-height: initial !important;
.mailDisplayContainer {
top:140px;
}
}
} }
@media @handheld @media @handheld
{ {

View File

@ -3397,16 +3397,16 @@ div#popupMainDiv {
div#popupMainDiv > * { div#popupMainDiv > * {
margin: 0px; margin: 0px;
} }
div.et2_container { form.et2_container {
padding: 0; padding: 0;
} }
div.et2_container div table.et2_grid tbody tr .row td .et2_box_widget select { form.et2_container div table.et2_grid tbody tr .row td .et2_box_widget select {
height: 20px; height: 20px;
padding: 0; padding: 0;
margin: 0px; margin: 0px;
font-size: 0.95em; font-size: 0.95em;
} }
div.et2_container div table.et2_grid tbody tr .row td .et2_box_widget input { form.et2_container div table.et2_grid tbody tr .row td .et2_box_widget input {
height: 20px; height: 20px;
padding: 0; padding: 0;
margin: 4px 4px 4px 5px; margin: 4px 4px 4px 5px;
@ -3425,13 +3425,13 @@ div.et2_container div table.et2_grid tbody tr .row td .et2_box_widget input {
border-top-left-radius: 3px; border-top-left-radius: 3px;
/*.background-clip(padding-box);*/ /*.background-clip(padding-box);*/
} }
div.et2_container div table.et2_grid tbody tr .row td .et2_box_widget input.hasDatepicker { form.et2_container div table.et2_grid tbody tr .row td .et2_box_widget input.hasDatepicker {
background-image: url("../images/datepopup.png"); background-image: url("../images/datepopup.png");
} }
div.et2_container div table.et2_grid tbody tr .row td .et2_box_widget input.hasDatepicker:hover { form.et2_container div table.et2_grid tbody tr .row td .et2_box_widget input.hasDatepicker:hover {
cursor: pointer; cursor: pointer;
} }
div.et2_container div table.et2_grid tbody tr td .et2_tabbox .et2_tabs table.et2_grid { form.et2_container div table.et2_grid tbody tr td .et2_tabbox .et2_tabs table.et2_grid {
background-color: #ffffff; background-color: #ffffff;
} }
.high { .high {