added ability to insert attached images in HTML editor

release-0.6
svncommit 17 years ago
parent deb30262a7
commit 4315b0086b

@ -4,6 +4,7 @@ CHANGELOG RoundCube Webmail
2007/12/10 (estadtherr) 2007/12/10 (estadtherr)
---------- ----------
- Upgrade to TinyMCE 2.1.3 - Upgrade to TinyMCE 2.1.3
- Allow inserting image attachments into HTML messages while composing
2007/12/10 (thomasb) 2007/12/10 (thomasb)
---------- ----------

@ -283,7 +283,7 @@ if ($_task=='mail')
if ($_action=='upload') if ($_action=='upload')
include('program/steps/mail/upload.inc'); include('program/steps/mail/upload.inc');
if ($_action=='compose' || $_action=='remove-attachment') if ($_action=='compose' || $_action=='remove-attachment' || $_action=='display-attachment')
include('program/steps/mail/compose.inc'); include('program/steps/mail/compose.inc');
if ($_action=='addcontact') if ($_action=='addcontact')

@ -1884,7 +1884,6 @@ function rcube_webmail()
// upload attachment file // upload attachment file
this.upload_file = function(form) this.upload_file = function(form)
{ {
if (!form) if (!form)
return false; return false;

@ -29,8 +29,8 @@ function rcmail_editor_init(skin_path)
theme_advanced_toolbar_align : 'left', theme_advanced_toolbar_align : 'left',
extended_valid_elements : 'font[face|size|color|style],span[id|class|align|style]', extended_valid_elements : 'font[face|size|color|style],span[id|class|align|style]',
content_css : skin_path + '/editor_content.css', content_css : skin_path + '/editor_content.css',
popups_css : skin_path + '/editor_popup.css', editor_css : skin_path + '/editor_ui.css',
editor_css : skin_path + '/editor_ui.css' external_image_list_url : 'program/js/editor_images.js'
}); });
} }

@ -0,0 +1,20 @@
var rc_client = tinyMCEPopup.windowOpener.rcube_webmail_client;
if (rc_client.gui_objects.attachmentlist)
{
var tinyMCEImageList = new Array();
var attachElems = rc_client.gui_objects.attachmentlist.getElementsByTagName("li");
for (i = 0; i < attachElems.length; i++)
{
var liElem = attachElems[i];
var fname = attachElems[i].id;
for (j = 0; j < liElem.childNodes.length; j++)
{
if (liElem.childNodes[j].nodeName == "#text")
{
fname = liElem.childNodes[j].nodeValue;
}
}
tinyMCEImageList.push([fname, rc_client.env.comm_path+'&_action=display-attachment&_file='+attachElems[i].id]);
}
};

@ -1420,7 +1420,7 @@ var TinyMCE_AdvancedTheme = {
_insertImage : function(src, alt, border, hspace, vspace, width, height, align, title, onmouseover, onmouseout) { _insertImage : function(src, alt, border, hspace, vspace, width, height, align, title, onmouseover, onmouseout) {
tinyMCE.execCommand("mceInsertContent", false, tinyMCE.createTagHTML('img', { tinyMCE.execCommand("mceInsertContent", false, tinyMCE.createTagHTML('img', {
src : tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], src), // Force absolute src : tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings.base_href, src), // Force absolute
mce_src : src, mce_src : src,
alt : alt, alt : alt,
border : border, border : border,

@ -42,6 +42,18 @@ if ($_action=='remove-attachment' && preg_match('/^rcmfile([0-9]+)$/', $_POST['_
} }
} }
if ($_action=='display-attachment' && preg_match('/^rcmfile([0-9]+)$/', $_GET['_file'], $regs))
{
$id = $regs[1];
if (is_array($_SESSION['compose']['attachments'][$id]))
{
$apath = $_SESSION['compose']['attachments'][$id]['path'];
header('Content-Type: ' . $_SESSION['compose']['attachments'][$id]['mimetype']);
header('Content-Length: ' . filesize($apath));
readfile($apath);
}
exit;
}
$MESSAGE_FORM = NULL; $MESSAGE_FORM = NULL;
$MESSAGE = NULL; $MESSAGE = NULL;
@ -99,7 +111,6 @@ if (!empty($msg_uid))
{ {
$_SESSION['compose']['draft_uid'] = $msg_uid; $_SESSION['compose']['draft_uid'] = $msg_uid;
} }
} }
/****** compose mode functions ********/ /****** compose mode functions ********/
@ -153,7 +164,6 @@ function rcmail_compose_headers($attrib)
$allow_attrib = array('id', 'class', 'style', 'size', 'tabindex'); $allow_attrib = array('id', 'class', 'style', 'size', 'tabindex');
$field_type = 'textfield'; $field_type = 'textfield';
break; break;
} }
if ($fname && !empty($_POST[$fname])) if ($fname && !empty($_POST[$fname]))
@ -324,7 +334,6 @@ function rcmail_compose_header_from($attrib)
} }
function rcmail_compose_body($attrib) function rcmail_compose_body($attrib)
{ {
global $CONFIG, $OUTPUT, $MESSAGE, $compose_mode; global $CONFIG, $OUTPUT, $MESSAGE, $compose_mode;
@ -683,7 +692,6 @@ function rcmail_compose_attachment_list($attrib)
} }
function rcmail_compose_attachment_form($attrib) function rcmail_compose_attachment_form($attrib)
{ {
global $OUTPUT, $SESS_HIDDEN_FIELD; global $OUTPUT, $SESS_HIDDEN_FIELD;
@ -859,7 +867,6 @@ $OUTPUT->add_handlers(array(
'receiptcheckbox' => 'rcmail_receipt_checkbox', 'receiptcheckbox' => 'rcmail_receipt_checkbox',
)); ));
/****** get contacts for this user and add them to client scripts ********/ /****** get contacts for this user and add them to client scripts ********/
require_once('include/rcube_contacts.inc'); require_once('include/rcube_contacts.inc');
@ -877,6 +884,5 @@ if ($result = $CONTACTS->list_records())
$OUTPUT->set_env('contacts', $a_contacts); $OUTPUT->set_env('contacts', $a_contacts);
} }
parse_template('compose'); parse_template('compose');
?> ?>

@ -248,8 +248,21 @@ else
// add stored attachments, if any // add stored attachments, if any
if (is_array($_SESSION['compose']['attachments'])) if (is_array($_SESSION['compose']['attachments']))
foreach ($_SESSION['compose']['attachments'] as $attachment) foreach ($_SESSION['compose']['attachments'] as $id => $attachment)
{
$dispurl = '/\ssrc\s*=\s*[\'"]?\S+display-attachment\S+file=rcmfile' . $id . '[\'"]?/';
$match = preg_match($dispurl, $message_body);
if ($isHtml && ($match > 0))
{
$message_body = preg_replace($dispurl, ' src="'.$attachment['name'].'"', $message_body);
$MAIL_MIME->setHTMLBody($message_body);
$MAIL_MIME->addHTMLImage($attachment['path'], $attachment['mimetype'], $attachment['name']);
}
else
{
$MAIL_MIME->addAttachment($attachment['path'], $attachment['mimetype'], $attachment['name'], true, 'base64', 'attachment', $message_charset); $MAIL_MIME->addAttachment($attachment['path'], $attachment['mimetype'], $attachment['name'], true, 'base64', 'attachment', $message_charset);
}
}
// add submitted attachments // add submitted attachments
if (is_array($_FILES['_attachments']['tmp_name'])) if (is_array($_FILES['_attachments']['tmp_name']))
@ -382,5 +395,4 @@ else
$OUTPUT->send('iframe'); $OUTPUT->send('iframe');
} }
?> ?>

@ -43,7 +43,6 @@ function rcube_identity_form($attrib)
$OUTPUT->add_script("tinyMCE.init({ mode : 'specific_textareas'," . $OUTPUT->add_script("tinyMCE.init({ mode : 'specific_textareas'," .
"apply_source_formatting : true," . "apply_source_formatting : true," .
"content_css : '\$__skin_path' + '/editor_content.css'," . "content_css : '\$__skin_path' + '/editor_content.css'," .
"popups_css : '\$__skin_path' + '/editor_popups.css'," .
"editor_css : '\$__skin_path' + '/editor_ui.css'," . "editor_css : '\$__skin_path' + '/editor_ui.css'," .
"theme : 'advanced'," . "theme : 'advanced'," .
"theme_advanced_toolbar_location : 'top'," . "theme_advanced_toolbar_location : 'top'," .

Loading…
Cancel
Save