Permalink
Browse files

Introducing preview pane and conditional skin tags

  • Loading branch information...
1 parent 740e9ec commit b19097058c02f203321599bf04a5d7da7c2dafe8 @thomascube thomascube committed Dec 1, 2006
View
@@ -195,6 +195,9 @@ $rcmail_config['mail_header_delimiter'] = NULL;
* 'fuzzy_search' => 0);
*/
+// don't allow these settings to be overriden by the user
+$rcmail_config['dont_override'] = array();
+
// list of configuration option names that need to be available in Javascript.
$rcmail_config['javascript_config'] = array('read_when_deleted', 'flag_for_deletion');
@@ -216,6 +219,9 @@ $rcmail_config['dst_active'] = TRUE;
// prefer displaying HTML messages
$rcmail_config['prefer_html'] = TRUE;
+// compose html formatted messages by default
+$rcmail_config['htmleditor'] = TRUE;
+
// show pretty dates as standard
$rcmail_config['prettydate'] = TRUE;
@@ -228,5 +234,8 @@ $rcmail_config['message_sort_order'] = 'DESC';
// save compose message every 300 seconds (5min)
$rcmail_config['draft_autosave'] = 300;
+// default setting if preview pane is enabled
+$rcmail_config['preview_pane'] = FALSE;
+
// end of config file
?>
View
@@ -2,7 +2,7 @@
/*
+-----------------------------------------------------------------------+
| RoundCube Webmail IMAP Client |
- | Version 0.1-20061122 |
+ | Version 0.1-20061201 |
| |
| Copyright (C) 2005-2006, RoundCube Dev. - Switzerland |
| Licensed under the GNU GPL |
@@ -40,7 +40,7 @@
*/
-define('RCMAIL_VERSION', '0.1-20061122');
+define('RCMAIL_VERSION', '0.1-20061201');
// define global vars
$CHARSET = 'UTF-8';
@@ -264,7 +264,7 @@
{
include_once('program/steps/mail/func.inc');
- if ($_action=='show' || $_action=='print')
+ if ($_action=='show' || $_action=='preview' || $_action=='print')
include('program/steps/mail/show.inc');
if ($_action=='get')
View
@@ -1142,8 +1142,12 @@ function parse_template($name='main', $exit=TRUE)
// parse for specialtags
- $output = parse_rcube_xml($templ);
+ $output = parse_rcube_xml(parse_rcube_conditions($templ));
+ // add debug console
+ if ($CONFIG['debug_level'] & 8)
+ $OUTPUT->footer = '<div style="position:absolute;top:5px;left:5px;width:400px;opacity:0.8;z-index:9000;"><form name="debugform"><textarea name="console" rows="15" cols="40" style="width:400px;border:none;font-size:x-small"></textarea></form>';
+
$OUTPUT->write(trim(parse_with_globals($output)), $skin_path);
if ($exit)
@@ -1161,6 +1165,55 @@ function parse_with_globals($input)
}
+// parse conditional code
+function parse_rcube_conditions($input)
+ {
+ if (($matches = preg_split('/<roundcube:(if|elseif|else|endif)\s+([^>]+)>/is', $input, 2, PREG_SPLIT_DELIM_CAPTURE)) && count($matches)==4)
+ {
+ if (preg_match('/^(else|endif)$/i', $matches[1]))
+ return $matches[0] . parse_rcube_conditions($matches[3]);
+ else
+ {
+ $attrib = parse_attrib_string($matches[2]);
+ if (isset($attrib['condition']))
+ {
+ $condmet = rcube_xml_condition($attrib['condition']);
+ $submatches = preg_split('/<roundcube:(elseif|else|endif)\s+([^>]+)>/is', $matches[3], 2, PREG_SPLIT_DELIM_CAPTURE);
+
+ if ($condmet)
+ $result = $submatches[0] . preg_replace('/.*<roundcube:endif\s+[^>]+>/is', '', $submatches[3]);
+ else
+ $result = "<roundcube:$submatches[1] $submatches[2]>" . $submatches[3];
+
+ return $matches[0] . parse_rcube_conditions($result);
+ }
+ else
+ {
+ raise_error(array('code' => 500, 'type' => 'php', 'line' => __LINE__, 'file' => __FILE__,
+ 'message' => "Unable to parse conditional tag " . $matches[2]), TRUE, FALSE);
+ }
+ }
+ }
+
+ return $input;
+ }
+
+
+/**
+ * Determines if a given condition is met
+ *
+ * @return True if condition is valid, False is not
+ */
+function rcube_xml_condition($condition)
+ {
+ $condition = preg_replace(
+ array('/session:([a-z0-9_]+)/i', '/config:([a-z0-9_]+)/i', '/request:([a-z0-9_]+)/ie'),
+ array("\$_SESSION['\\1']", "\$GLOBALS['CONFIG']['\\1']", "get_input_value('\\1', RCUBE_INPUT_GPC)"),
+ $condition);
+
+ return @eval("return (".$condition.");");
+ }
+
function parse_rcube_xml($input)
{
@@ -1169,12 +1222,19 @@ function parse_rcube_xml($input)
}
+/**
+ * Convert a xml command tag into real content
+ */
function rcube_xml_command($command, $str_attrib, $add_attrib=array())
{
global $IMAP, $CONFIG, $OUTPUT;
$command = strtolower($command);
$attrib = parse_attrib_string($str_attrib) + $add_attrib;
+
+ // empty output if required condition is not met
+ if (!empty($attrib['condition']) && !rcube_xml_condition($attrib['condition']))
+ return '';
// execute command
switch ($command)
@@ -169,6 +169,9 @@ class rcube_html_page
if (strlen($this->scripts['foot']))
$__page_footer .= sprintf($this->script_tag, $this->scripts['foot']);
+
+ if ($this->footer)
+ $__page_footer .= "\n" . $this->footer;
$__page_header .= $this->css->show();
View
@@ -32,7 +32,7 @@ function rcube_webmail()
this.ref = 'rcube_webmail_client';
// webmail client settings
- this.dblclick_time = 600;
+ this.dblclick_time = 500;
this.message_time = 5000;
this.mbox_expression = new RegExp('[^0-9a-z\-_]', 'gi');
@@ -137,7 +137,7 @@ function rcube_webmail()
// enable mail commands
this.enable_command('list', 'checkmail', 'compose', 'add-contact', 'search', 'reset-search', true);
- if (this.env.action=='show')
+ if (this.env.action=='show' || this.env.action=='preview')
{
this.enable_command('show', 'reply', 'reply-all', 'forward', 'moveto', 'delete', 'viewsource', 'print', 'load-attachment', true);
if (this.env.next_uid)
@@ -151,8 +151,15 @@ function rcube_webmail()
this.enable_command('firstmessage', true);
}
}
+
+ // make preview/message frame visible
+ if (this.env.action == 'preview' && this.env.framed && parent.rcmail)
+ {
+ this.enable_command('compose', 'add-contact', false);
+ parent.rcmail.show_messageframe(true);
+ }
- if (this.env.action=='show' && this.env.blockedobjects)
+ if ((this.env.action=='show' || this.env.action=='preview') && this.env.blockedobjects)
{
if (this.gui_objects.remoteobjectsmsg)
this.gui_objects.remoteobjectsmsg.style.display = 'block';
@@ -637,7 +644,7 @@ function rcube_webmail()
case 'load-images':
if (this.env.uid)
- this.show_message(this.env.uid, true);
+ this.show_message(this.env.uid, true, this.env.action=='preview');
break;
case 'load-attachment':
@@ -646,7 +653,7 @@ function rcube_webmail()
// open attachment in frame if it's of a supported mimetype
if (this.env.uid && props.mimetype && find_in_array(props.mimetype, this.mimetypes)>=0)
{
- this.attachment_win = window.open(this.env.comm_path+'&_action=get'+url+'&_frame=1', 'rcubemailattachment');
+ this.attachment_win = window.open(this.env.comm_path+'&_action=get&'+qstring+'&_frame=1', 'rcubemailattachment');
if (this.attachment_win)
{
setTimeout(this.ref+'.attachment_win.focus()', 10);
@@ -667,7 +674,7 @@ function rcube_webmail()
case 'nextmessage':
if (this.env.next_uid)
- this.show_message(this.env.next_uid);
+ this.show_message(this.env.next_uid, false, this.env.action=='preview');
break;
case 'lastmessage':
@@ -677,7 +684,7 @@ function rcube_webmail()
case 'previousmessage':
if (this.env.prev_uid)
- this.show_message(this.env.prev_uid);
+ this.show_message(this.env.prev_uid, false, this.env.action=='preview');
break;
case 'firstmessage':
@@ -1052,6 +1059,9 @@ function rcube_webmail()
this.msglist_select = function(list)
{
+ if (this.preview_timer)
+ clearTimeout(this.preview_timer);
+
var selected = list.selection.length==1;
if (this.env.mailbox == this.env.drafts_mailbox)
{
@@ -1062,17 +1072,26 @@ function rcube_webmail()
{
this.enable_command('show', 'reply', 'reply-all', 'forward', 'print', selected);
this.enable_command('delete', 'moveto', list.selection.length>0 ? true : false);
+
+ // start timer for message preview (wait for double click)
+ if (selected && this.env.contentframe)
+ this.preview_timer = setTimeout(this.ref+'.msglist_get_preview()', this.dblclick_time + 10);
+ else if (this.env.contentframe)
+ this.show_messageframe(false);
}
- };
+ };
this.msglist_dbl_click = function(list)
{
+ if (this.preview_timer)
+ clearTimeout(this.preview_timer);
+
var uid = list.get_single_selection();
if (uid && this.env.mailbox == this.env.drafts_mailbox)
this.goto_url('compose', '_draft_uid='+uid+'&_mbox='+urlencode(this.env.mailbox), true);
else if (uid)
- this.show_message(uid);
+ this.show_message(uid, false, false);
};
@@ -1085,18 +1104,28 @@ function rcube_webmail()
};
+ this.msglist_get_preview = function()
+ {
+ var uid = this.get_single_uid();
+ if (uid && this.env.contentframe)
+ this.show_message(uid, false, true);
+ else if (this.env.contentframe)
+ this.show_messageframe(false);
+ };
+
/*********************************************************/
/********* (message) list functionality *********/
/*********************************************************/
// when user doble-clicks on a row
- this.show_message = function(id, safe)
+ this.show_message = function(id, safe, preview)
{
var add_url = '';
+ var action = preview ? 'preview': 'show';
var target = window;
- if (this.env.contentframe && window.frames && window.frames[this.env.contentframe])
+ if (preview && this.env.contentframe && window.frames && window.frames[this.env.contentframe])
{
target = window.frames[this.env.contentframe];
add_url = '&_framed=1';
@@ -1107,12 +1136,32 @@ function rcube_webmail()
if (id)
{
- this.set_busy(true, 'loading');
- target.location.href = this.env.comm_path+'&_action=show&_uid='+id+'&_mbox='+urlencode(this.env.mailbox)+add_url;
+ var url = '&_action='+action+'&_uid='+id+'&_mbox='+urlencode(this.env.mailbox)+add_url;
+ if (action == 'preview' && String(target.location.href).indexOf(url) >= 0)
+ this.show_messageframe(true);
+ else
+ {
+ this.set_busy(true, 'loading');
+ target.location.href = this.env.comm_path+url;
+ }
}
};
+ this.show_messageframe = function(show)
+ {
+ var frm;
+ if (this.env.contentframe && (frm = rcube_find_object(this.env.contentframe)))
+ {
+ if (window.frames[this.env.contentframe] && !show)
+ window.frames[this.env.contentframe].location.href = 'program/blank.gif';
+ frm.style.display = show ? 'block' : 'none';
+ }
+
+ if (!show && this.busy)
+ this.set_busy(false);
+ };
+
// list a specific page
this.list_page = function(page)
@@ -1373,7 +1422,7 @@ function rcube_webmail()
this.mark_message = function(flag, uid)
{
var a_uids = new Array();
- var selection = this.message_list.get_selection();
+ var selection = this.message_list ? this.message_list.get_selection() : new Array();
if (uid)
a_uids[0] = uid;
@@ -3102,7 +3151,7 @@ function rcube_webmail()
this.http_request = function(action, querystring, lock)
{
var request_obj = this.get_request_obj();
- querystring += '&_remote=1';
+ querystring += (querystring ? '&' : '') + '_remote=1';
// add timestamp to request url to avoid cacheing problems in Safari
if (bw.safari)
@@ -3151,6 +3200,8 @@ function rcube_webmail()
case 'moveto':
if (this.env.action=='show')
this.command('list');
+ else if (this.message_list)
+ this.message_list.init();
break;
case 'list':
@@ -199,6 +199,9 @@ $labels['timezone'] = 'Zeitzone';
$labels['pagesize'] = 'Einträge pro Seite';
$labels['signature'] = 'Signatur';
$labels['dstactive'] = 'Sommerzeit';
+$labels['htmleditor'] = 'HTML-Nachrichten verfassen';
+$labels['htmlsignature'] = 'HTML-Signatur';
+$labels['previewpane'] = 'Nachrichtenvorschau anzeigen';
$labels['autosavedraft'] = 'Entwurf autom. speichern';
$labels['everynminutes'] = 'alle $n Minuten';
@@ -104,5 +104,10 @@ $messages['nospellerrors'] = 'Keine Rechtschreibfehler gefunden';
$messages['folderdeleted'] = 'Ordner erfolgreich gelöscht';
+$messages['deletedsuccessfully'] = "Erfolgreich gelöscht";
+
+$messages['converting'] = 'Entferne Formatierungen...';
+
+$messages['messageopenerror'] = 'Die Nachricht konnte nicht vom Server geladen werden';
?>
@@ -106,4 +106,6 @@ $messages['nospellerrors'] = 'Keine Rechtschreibfehler gefunden';
$messages['folderdeleted'] = 'Ordner erfolgreich gelöscht';
+$messages['messageopenerror'] = 'Die Nachricht konnte nicht vom Server geladen werden';
+
?>
@@ -211,6 +211,7 @@ $labels['signature'] = 'Signature';
$labels['dstactive'] = 'Daylight savings';
$labels['htmleditor'] = 'Compose HTML messages';
$labels['htmlsignature'] = 'HTML signature';
+$labels['previewpane'] = 'Show preview pane';
$labels['autosavedraft'] = 'Automatically save draft';
$labels['everynminutes'] = 'every $n minutes';
Oops, something went wrong.

0 comments on commit b190970

Please sign in to comment.