From 5eee009671d773cb3ebef5beca6ad47c919ac4c7 Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Wed, 19 Sep 2007 02:29:28 -0400
Subject: [PATCH] Allow vars and PHP code in templates; improved page title; fixed #1484395
---
CHANGELOG | 8 ++
program/steps/mail/list.inc | 3
program/include/rcmail_template.inc | 66 ++++++++++++++++++++-
program/steps/mail/check_recent.inc | 2
program/steps/mail/func.inc | 10 +-
program/steps/settings/func.inc | 5 +
config/main.inc.php.dist | 3 +
.htaccess | 2
program/js/app.js | 26 +++++---
9 files changed, 104 insertions(+), 21 deletions(-)
diff --git a/.htaccess b/.htaccess
index 0826245..b40b7ea 100644
--- a/.htaccess
+++ b/.htaccess
@@ -6,6 +6,7 @@
php_flag log_errors On
php_value error_log logs/errors
php_value upload_max_filesize 5M
+ php_value post_max_size 6M
</IfModule>
<IfModule mod_php5.c>
@@ -13,6 +14,7 @@
php_flag log_errors On
php_value error_log logs/errors
php_value upload_max_filesize 5M
+ php_value post_max_size 6M
</IfModule>
<FilesMatch "(\.inc|\~)$">
diff --git a/CHANGELOG b/CHANGELOG
index 12d7872..39f5050 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,14 @@
CHANGELOG RoundCube Webmail
---------------------------
+2007/09/18 (thomasb)
+----------
+- Eval PHP code in template includes (if configured)
+- Show message when folder is empty. Mo more static text in table (#1484395)
+- Only display unread count in page title when new messages arrived
+- Show mailbox name in page title
+
+
2007/09/09 (thomasb)
----------
- Fixed wrong delete button tooltip (#1483965)
diff --git a/config/main.inc.php.dist b/config/main.inc.php.dist
index 377aa2c..b948b38 100644
--- a/config/main.inc.php.dist
+++ b/config/main.inc.php.dist
@@ -87,6 +87,9 @@
// relative path to the skin folder
$rcmail_config['skin_path'] = 'skins/default/';
+// inludes shloud be interpreted as PHP files
+$rcmail_config['skin_include_php'] = true;
+
// use this folder to store temp files (must be writebale for apache user)
$rcmail_config['temp_dir'] = 'temp/';
diff --git a/program/include/rcmail_template.inc b/program/include/rcmail_template.inc
index 4acc717..734032e 100644
--- a/program/include/rcmail_template.inc
+++ b/program/include/rcmail_template.inc
@@ -322,6 +322,13 @@
join(',', $args));
}
+ // add command to set page title
+ if ($this->ajax_call && !empty($this->pagetitle))
+ $out .= sprintf(
+ "this.set_pagetitle('%s');\n",
+ JQ((!empty($this->config['product_name']) ? $this->config['product_name'].' :: ' : '') . $this->pagetitle)
+ );
+
return $out;
}
@@ -453,10 +460,15 @@
// include a file
case 'include':
$path = realpath($this->config['skin_path'].$attrib['file']);
- if (filesize($path) && ($fp = @fopen($path, 'r')))
+ if (filesize($path))
{
- $incl = fread($fp, filesize($path));
- fclose($fp);
+ if ($this->config['skin_include_php'])
+ $incl = $this->include_php($path);
+ else if ($fp = @fopen($path, 'r'))
+ {
+ $incl = fread($fp, filesize($path));
+ fclose($fp);
+ }
return $this->parse_xml($incl);
}
break;
@@ -494,13 +506,59 @@
}
break;
- }
+
+ // return variable
+ case 'var':
+ $var = explode(':', $attrib['name']);
+ $name = $var[1];
+ $value = '';
+
+ switch ($var[0])
+ {
+ case 'env':
+ $value = $this->env[$name];
+ break;
+ case 'config':
+ $value = $this->config[$name];
+ if (is_array($value) && $value[$_SESSION['imap_host']])
+ $value = $value[$_SESSION['imap_host']];
+ break;
+ case 'request':
+ $value = get_input_value($name, RCUBE_INPUT_GPC);
+ break;
+ case 'session':
+ $value = $_SESSION[$name];
+ break;
+ }
+
+ if (is_array($value))
+ $value = join(", ", $value);
+
+ return Q($value);
+ }
return '';
}
/**
+ * Include a specific file and return it's contents
+ *
+ * @param string File path
+ * @return string Contents of the processed file
+ */
+ function include_php($file)
+ {
+ ob_start();
+ @include($file);
+ $out = ob_get_contents();
+ ob_end_clean();
+
+ return $out;
+ }
+
+
+ /**
* Create and register a button
*
* @param array Button attributes
diff --git a/program/js/app.js b/program/js/app.js
index 5066835..9693ff5 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -2943,6 +2943,14 @@
};
+ // write to the document/window title
+ this.set_pagetitle = function(title)
+ {
+ if (title && document.title)
+ document.title = title;
+ }
+
+
// display a system message
this.display_message = function(msg, type, hold)
{
@@ -3129,9 +3137,6 @@
if (!this.gui_objects.mailboxlist)
return false;
- if (mbox==this.env.mailbox)
- set_title = true;
-
var reg, text_obj;
var item = this.get_folder_li(mbox);
mbox = String(mbox).toLowerCase().replace(this.identifier_expr, '');
@@ -3158,13 +3163,16 @@
if (set_title && document.title)
{
var doc_title = String(document.title);
+ var new_title = "";
if (count && doc_title.match(reg))
- document.title = doc_title.replace(reg, '('+count+') ');
+ new_title = doc_title.replace(reg, '('+count+') ');
else if (count)
- document.title = '('+count+') '+doc_title;
+ new_title = '('+count+') '+doc_title;
else
- document.title = doc_title.replace(reg, '');
+ new_title = doc_title.replace(reg, '');
+
+ this.set_pagetitle(new_title);
}
};
@@ -3318,7 +3326,8 @@
ctype = ctype_array[0];
}
- this.set_busy(false);
+ if (request_obj.__lock)
+ this.set_busy(false);
console.log(request_obj.get_text());
@@ -3381,8 +3390,7 @@
}
this.set_busy(true, 'checkingmail');
- var d = new Date();
- this.http_request('check-recent', '_t='+d.getTime());
+ this.http_request('check-recent', '_t='+(new Date().getTime()), true);
};
diff --git a/program/steps/mail/check_recent.inc b/program/steps/mail/check_recent.inc
index 119d481..a2100f1 100644
--- a/program/steps/mail/check_recent.inc
+++ b/program/steps/mail/check_recent.inc
@@ -31,7 +31,7 @@
$unread_count = $IMAP->messagecount(NULL, 'UNSEEN', TRUE);
$OUTPUT->set_env('messagecount', $count);
- $OUTPUT->command('set_unread_count', $mbox_name, $unread_count);
+ $OUTPUT->command('set_unread_count', $mbox_name, $unread_count, true);
$OUTPUT->command('set_rowcount', rcmail_get_messagecount_text());
$OUTPUT->command('set_quota', $IMAP->get_quota());
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index 9f4c714..0712ef8 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -75,6 +75,10 @@
if (!$OUTPUT->ajax_call)
rcube_add_label('checkingmail', 'deletemessage', 'movemessagetotrash');
+// set page title
+if (empty($_action) || $_action == 'list')
+ $OUTPUT->set_pagetitle(rcube_charset_convert($IMAP->get_mailbox_name(), 'UTF-7'));
+
// return the message list as HTML table
@@ -189,11 +193,7 @@
// no messages in this mailbox
if (!sizeof($a_headers))
- {
- $out .= sprintf('<tr><td colspan="%d">%s</td></tr>',
- sizeof($a_show_cols)+2,
- Q(rcube_label('nomessagesfound')));
- }
+ $OUTPUT->show_message('nomessagesfound', 'notice');
$a_js_message_arr = array();
diff --git a/program/steps/mail/list.inc b/program/steps/mail/list.inc
index 6c72706..568f3d5 100644
--- a/program/steps/mail/list.inc
+++ b/program/steps/mail/list.inc
@@ -58,7 +58,8 @@
// add message rows
if (isset($a_headers) && count($a_headers))
rcmail_js_message_list($a_headers);
-
+else
+ $OUTPUT->show_message('nomessagesfound', 'notice');
// send response
$OUTPUT->send();
diff --git a/program/steps/settings/func.inc b/program/steps/settings/func.inc
index ec9001f..18e8e52 100644
--- a/program/steps/settings/func.inc
+++ b/program/steps/settings/func.inc
@@ -26,7 +26,10 @@
$_SESSION['user_id']);
if ($USER_DATA = $DB->fetch_assoc($sql_result))
- $OUTPUT->set_pagetitle(sprintf('%s %s@%s', rcube_label('settingsfor'), $USER_DATA['username'], $USER_DATA['mail_host']));
+{
+ $username = $USER_DATA['username'] . (!strpos($USER_DATA['username'], '@') ? '@'.$USER_DATA['mail_host'] : '');
+ $OUTPUT->set_pagetitle(sprintf('%s %s', rcube_label('settingsfor'), $username));
+}
--
Gitblit v1.9.1