mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-02-22 21:30:54 +01:00
backport of reworked solution from trunk
This commit is contained in:
parent
8b7e8d4b59
commit
08806fe9e5
@ -478,16 +478,10 @@
|
||||
// --> use it to send the mail as data uri
|
||||
if (!isset($_GET['printable']))
|
||||
{
|
||||
/*
|
||||
$bodyParts = $this->bofelamimail->getMessageBody($this->uid,'',$partID);
|
||||
$mailData = $this->get_load_email_data($this->uid, $partID);
|
||||
|
||||
$frameHtml = base64_encode(
|
||||
$this->get_email_header().
|
||||
$this->showBody($this->getdisplayableBody($bodyParts), false));
|
||||
$iframe_url = egw::link('/phpgwapi/js/egw_instant_load.html').'" onload="if (this.contentWindow && typeof this.contentWindow.egw_instant_load != \'undefined\') this.contentWindow.egw_instant_load(\''.$frameHtml.'\', true);';
|
||||
|
||||
$this->t->set_var('url_displayBody', $iframe_url);
|
||||
*/
|
||||
$this->t->set_var('url_displayBody', $mailData['src']."\" onload=\"".$mailData['onload']);
|
||||
$this->t->set_var('mail_dataScript', $mailData['script']);
|
||||
}
|
||||
|
||||
// attachments
|
||||
@ -989,6 +983,48 @@
|
||||
';
|
||||
}
|
||||
|
||||
function get_load_email_data($uid, $partID)
|
||||
{
|
||||
$bodyParts = $this->bofelamimail->getMessageBody($uid, '', $partID);
|
||||
|
||||
// Compose the content of the frame
|
||||
$frameHtml =
|
||||
$this->get_email_header().
|
||||
$this->showBody($this->getdisplayableBody($bodyParts), false);
|
||||
|
||||
// Calculate the hash of that E-Mail for function identification
|
||||
$hash = md5($frameHtml);
|
||||
|
||||
// The JS function name consists of a prefix and the hash suffix
|
||||
$funcname = "load_email_$hash";
|
||||
|
||||
// Compose the script code
|
||||
$script =
|
||||
"<script>
|
||||
var email_content_$hash = ".json_encode($frameHtml).";
|
||||
function $funcname(_tar)
|
||||
{
|
||||
if (_tar && typeof _tar.contentWindow != \"undefined\" &&
|
||||
typeof _tar.contentWindow.egw_instant_load != \"undefined\")
|
||||
{
|
||||
_tar.setAttribute(\"scrolling\", \"no\"); // Workaround for FF 3.5
|
||||
_tar.contentWindow.egw_instant_load(email_content_$hash);
|
||||
_tar.setAttribute(\"scrolling\", \"auto\");
|
||||
}
|
||||
}
|
||||
</script>";
|
||||
|
||||
// Compose the code for the onload event
|
||||
$onload = "if (typeof $funcname != 'undefined'){ $funcname(this); this.onload = function() {return false;}}";
|
||||
|
||||
// Return all the stuff
|
||||
return array(
|
||||
"script" => $script,
|
||||
"onload" => $onload,
|
||||
"src" => egw::link("/phpgwapi/js/egw_instant_load.html")
|
||||
);
|
||||
}
|
||||
|
||||
static function emailAddressToHTML($_emailAddress, $_organisation='', $allwaysShowMailAddress=false, $showAddToAdrdessbookLink=true, $decode=true) {
|
||||
//_debug_array($_emailAddress);
|
||||
// create some nice formated HTML for senderaddress
|
||||
|
@ -610,7 +610,7 @@ class uiwidgets
|
||||
} else $sent_not = "";
|
||||
if ( $sent_not != "" && strpos( array2string($flags),'Seen')===false)
|
||||
{
|
||||
$jscall= " onload='javascript:sendNotifyMS(".$headerData['uid'].")'";
|
||||
$jscall= "sendNotifyMS(".$headerData['uid']."); ";
|
||||
}
|
||||
}
|
||||
//if (strpos( array2string($flags),'Seen')===false) $this->bofelamimail->flagMessages('read', $headerData['uid']);
|
||||
@ -722,19 +722,19 @@ class uiwidgets
|
||||
);
|
||||
|
||||
$iframe_url = $GLOBALS['egw']->link('/index.php',$linkData);
|
||||
$script = "";
|
||||
// if browser supports data uri: ie<8 does NOT and ie>=8 does NOT support html as content :-(
|
||||
// --> use it to send the mail as data uri
|
||||
if (!isset($_GET['printable']))
|
||||
{
|
||||
/*
|
||||
$bodyParts = $this->bofelamimail->getMessageBody($headerData['uid'],'',$partID);
|
||||
$uidisplay = CreateObject('felamimail.uidisplay');
|
||||
$uidisplay->uid = $headerData['uid'];
|
||||
$uidisplay->mailbox = $_folderName;
|
||||
$mailData = $uidisplay->get_load_email_data($headerData['uid'], $partID);
|
||||
|
||||
$frameHtml = base64_encode(
|
||||
$uidisplay->get_email_header().
|
||||
$uidisplay->showBody($uidisplay->getdisplayableBody($bodyParts), false));
|
||||
$iframe_url = egw::link('/phpgwapi/js/egw_instant_load.html').'" onload="if (this.contentWindow && typeof this.contentWindow.egw_instant_load != \'undefined\') this.contentWindow.egw_instant_load(\''.$frameHtml.'\', true);';
|
||||
*/
|
||||
$iframe_url = $mailData['src'];
|
||||
$jscall .= $mailData['onload'];
|
||||
$script = $mailData['script'];
|
||||
}
|
||||
|
||||
//_debug_array($GLOBALS['egw']->link('/index.php',$linkData));
|
||||
@ -757,7 +757,8 @@ class uiwidgets
|
||||
</TR>
|
||||
<TR>
|
||||
<TD nowrap id=\"tdmessageIFRAME\" valign=\"top\" colspan=\"3\" height=\"".$IFrameHeight."\">
|
||||
<iframe ".(!empty($jscall) ? $jscall:"")." id=\"messageIFRAME\" frameborder=\"1\" height=\"".$IFrameHeight."\" scrolling=\"auto\" src=\"".$iframe_url."\">
|
||||
$script
|
||||
<iframe ".(!empty($jscall) ? "onload=\"$jscall\"" :"")." id=\"messageIFRAME\" frameborder=\"1\" height=\"".$IFrameHeight."\" scrolling=\"auto\" src=\"".$iframe_url."\">
|
||||
</iframe>
|
||||
</TD>
|
||||
</TR>
|
||||
|
@ -14,6 +14,7 @@ self.focus();
|
||||
{header}
|
||||
</div>
|
||||
<div class="bodyDIV" id="bodyDIV" style="border: 0px solid green; margin:0px; padding:0px; left:0px;">
|
||||
{mail_dataScript}
|
||||
<iframe id="messageIFRAME" frameborder="no" scrolling="auto" src="{url_displayBody}">
|
||||
</iframe>
|
||||
</div>
|
||||
@ -37,6 +38,7 @@ self.focus();
|
||||
{header}
|
||||
</div>
|
||||
<div class="bodyDIV bodyDIVAttachment" id="bodyDIV" style="border: 0px solid green; margin:0px; padding:0px; left:0px;">
|
||||
{mail_dataScript}
|
||||
<iframe frameborder="no" scrolling="auto" style="width:100%; height:100%;" src="{url_displayBody}">
|
||||
</iframe>
|
||||
</div>
|
||||
|
@ -1,9 +1,5 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
|
||||
<!--
|
||||
Open this file from inside egroupware in a popup/iframe and call the egw_instant_load
|
||||
function in its "onload" event.
|
||||
-->
|
||||
<head>
|
||||
<title>EGroupware [Loading Data]</title>
|
||||
<meta http-equiv="Cache-control" content="public" />
|
||||
@ -11,57 +7,8 @@ function in its "onload" event.
|
||||
</head>
|
||||
<body style="background-color: #F0F0F0">
|
||||
<script type="text/javascript">
|
||||
/*
|
||||
* base64.js - Base64 encoding and decoding functions
|
||||
*
|
||||
* See: http://developer.mozilla.org/en/docs/DOM:window.btoa
|
||||
* http://developer.mozilla.org/en/docs/DOM:window.atob
|
||||
*
|
||||
* Copyright (c) 2007, David Lindquist <david.lindquist@gmail.com>
|
||||
* Released under the MIT license
|
||||
*/
|
||||
|
||||
if (typeof atob == 'undefined') {
|
||||
function atob(str) {
|
||||
var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
||||
var invalid = {
|
||||
strlen: (str.length % 4 != 0),
|
||||
chars: new RegExp('[^' + chars + ']').test(str),
|
||||
equals: (/=/.test(str) && (/=[^=]/.test(str) || /={3}/.test(str)))
|
||||
};
|
||||
if (invalid.strlen || invalid.chars || invalid.equals)
|
||||
throw new Error('Invalid base64 data');
|
||||
var decoded = [];
|
||||
var c = 0;
|
||||
while (c < str.length) {
|
||||
var i0 = chars.indexOf(str.charAt(c++));
|
||||
var i1 = chars.indexOf(str.charAt(c++));
|
||||
var i2 = chars.indexOf(str.charAt(c++));
|
||||
var i3 = chars.indexOf(str.charAt(c++));
|
||||
var buf = (i0 << 18) + (i1 << 12) + ((i2 & 63) << 6) + (i3 & 63);
|
||||
var b0 = (buf & (255 << 16)) >> 16;
|
||||
var b1 = (i2 == 64) ? -1 : (buf & (255 << 8)) >> 8;
|
||||
var b2 = (i3 == 64) ? -1 : (buf & 255);
|
||||
decoded[decoded.length] = String.fromCharCode(b0);
|
||||
if (b1 >= 0) decoded[decoded.length] = String.fromCharCode(b1);
|
||||
if (b2 >= 0) decoded[decoded.length] = String.fromCharCode(b2);
|
||||
}
|
||||
return decoded.join('');
|
||||
}
|
||||
}
|
||||
|
||||
window.egw_instant_load = function(_data, _base64Encoded)
|
||||
window.egw_instant_load = function(_data)
|
||||
{
|
||||
if (typeof _base64Encoded == "undefined")
|
||||
{
|
||||
_base64Encoded = false;
|
||||
}
|
||||
|
||||
if (_base64Encoded)
|
||||
{
|
||||
_data = atob(_data);
|
||||
}
|
||||
|
||||
// Empty the document tree
|
||||
while (document.childNodes.length > 0)
|
||||
{
|
||||
|
@ -260,6 +260,12 @@ egw_json_request.prototype.handleResponse = function(data, textStatus, XMLHttpRe
|
||||
if (obj)
|
||||
{
|
||||
obj[res.data.key] = res.data.value;
|
||||
|
||||
if (res.data.key == "innerHTML")
|
||||
{
|
||||
egw_insertJS(res.data.value);
|
||||
}
|
||||
|
||||
hasResponse = true;
|
||||
}
|
||||
} else
|
||||
|
@ -69,6 +69,57 @@ egw_seperateJavaScript = function(_html)
|
||||
_html.html = html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts the script tags inside the given html into the dom tree
|
||||
*/
|
||||
function egw_insertJS(_html)
|
||||
{
|
||||
// Insert each script element seperately
|
||||
if (_html)
|
||||
{
|
||||
|
||||
var in_pos = -1;
|
||||
var out_pos = -1;
|
||||
|
||||
do {
|
||||
|
||||
// Search in and out position
|
||||
var in_pos = _html.search(/<script/im);
|
||||
var out_pos = _html.search(/<\/script>/im);
|
||||
|
||||
// Copy the text inside the script tags...
|
||||
if (in_pos > -1 && out_pos > -1)
|
||||
{
|
||||
if (out_pos > in_pos)
|
||||
{
|
||||
var scriptStart = _html.indexOf("\>", in_pos);
|
||||
if (scriptStart > in_pos)
|
||||
{
|
||||
var script = _html.substring(scriptStart + 1,
|
||||
out_pos);
|
||||
try
|
||||
{
|
||||
// And insert them as real script tags
|
||||
var tag = document.createElement("script");
|
||||
tag.setAttribute("type", "text/javascript");
|
||||
tag.text = script;
|
||||
document.getElementsByTagName("head")[0].appendChild(tag);
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
if (typeof console != "undefined" && typeof console.log != "undefined")
|
||||
{
|
||||
console.log('Error while inserting JS code:', _e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_html = _html.substr(out_pos + 9);
|
||||
}
|
||||
|
||||
} while (in_pos > -1 && out_pos > -1)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the top window which contains the current egw_instance, even for popup windows
|
||||
|
Loading…
Reference in New Issue
Block a user