summaryrefslogtreecommitdiff
path: root/program
diff options
context:
space:
mode:
Diffstat (limited to 'program')
-rw-r--r--program/include/main.inc16
-rw-r--r--program/include/rcube_config.php2
-rwxr-xr-xprogram/include/rcube_template.php27
-rw-r--r--program/steps/addressbook/edit.inc2
-rw-r--r--program/steps/error.inc2
-rw-r--r--program/steps/mail/show.inc6
-rw-r--r--program/steps/settings/edit_identity.inc2
7 files changed, 34 insertions, 23 deletions
diff --git a/program/include/main.inc b/program/include/main.inc
index 73b9c4124..2740ee35d 100644
--- a/program/include/main.inc
+++ b/program/include/main.inc
@@ -503,22 +503,6 @@ function strip_newlines($str)
/**
- * Check if a specific template exists
- *
- * @param string Template name
- * @return boolean True if template exists
- */
-function template_exists($name)
- {
- global $CONFIG;
- $skin_path = $CONFIG['skin_path'];
-
- // check template file
- return is_file("$skin_path/templates/$name.html");
- }
-
-
-/**
* Create a HTML table based on the given data
*
* @param array Named table attributes
diff --git a/program/include/rcube_config.php b/program/include/rcube_config.php
index 5c744ba53..b862bf769 100644
--- a/program/include/rcube_config.php
+++ b/program/include/rcube_config.php
@@ -61,7 +61,7 @@ class rcube_config
$this->load_host_config();
// fix paths
- $this->prop['skin_path'] = $this->prop['skin_path'] ? unslashify($this->prop['skin_path']) : 'skins/default';
+ $this->prop['default_skin'] = $this->prop['default_skin'] ? unslashify($this->prop['default_skin']) : 'default';
$this->prop['log_dir'] = $this->prop['log_dir'] ? unslashify($this->prop['log_dir']) : INSTALL_PATH . 'logs';
// handle aliases
diff --git a/program/include/rcube_template.php b/program/include/rcube_template.php
index 5834e42ab..9bc918e9a 100755
--- a/program/include/rcube_template.php
+++ b/program/include/rcube_template.php
@@ -57,6 +57,12 @@ class rcube_template extends rcube_html_page
//$this->framed = $framed;
$this->set_env('task', $task);
+ // load the correct skin (in case user-defined)
+ if (empty($this->config['skin']) || !is_readable('skins/'.$this->config['skin']))
+ $this->config['skin'] = $this->config['default_skin'];
+
+ $this->config['skin_path'] = 'skins/'.$this->config['skin'];
+
// add common javascripts
$javascript = 'var '.JS_OBJECT_NAME.' = new rcube_webmail();';
@@ -102,6 +108,27 @@ class rcube_template extends rcube_html_page
$this->pagetitle = $title;
}
+ /**
+ * Set skin
+ */
+ public function set_skin($skin)
+ {
+ if (!empty($skin) && is_dir('skins/'.$skin) && is_readable('skins/'.$skin))
+ $this->config['skin_path'] = 'skins/'.$skin;
+ }
+
+ /**
+ * Check if a specific template exists
+ *
+ * @param string Template name
+ * @return boolean True if template exists
+ */
+ public function template_exists($name)
+ {
+ $filename = $this->config['skin_path'] . '/templates/' . $name . '.html';
+
+ return (is_file($filename) && is_readable($filename));
+ }
/**
* Register a template object handler
diff --git a/program/steps/addressbook/edit.inc b/program/steps/addressbook/edit.inc
index 9cda22b5b..4b50fa26f 100644
--- a/program/steps/addressbook/edit.inc
+++ b/program/steps/addressbook/edit.inc
@@ -113,7 +113,7 @@ function get_form_tags($attrib)
-if (!$CONTACTS->get_result() && template_exists('addcontact'))
+if (!$CONTACTS->get_result() && $OUTPUT->template_exists('addcontact'))
$OUTPUT->send('addcontact');
// this will be executed if no template for addcontact exists
diff --git a/program/steps/error.inc b/program/steps/error.inc
index 5cde93cfc..bd6fa2873 100644
--- a/program/steps/error.inc
+++ b/program/steps/error.inc
@@ -97,7 +97,7 @@ EOF;
-if (template_exists('error'))
+if ($OUTPUT->template_exists('error'))
{
$OUTPUT->reset();
$OUTPUT->send('error');
diff --git a/program/steps/mail/show.inc b/program/steps/mail/show.inc
index 3cdf2c9a5..bff4e6861 100644
--- a/program/steps/mail/show.inc
+++ b/program/steps/mail/show.inc
@@ -32,7 +32,7 @@ if ($_GET['_uid']) {
// go back to list if message not found (wrong UID)
if (empty($MESSAGE->headers)) {
$OUTPUT->show_message('messageopenerror', 'error');
- if ($RCMAIL->action=='preview' && template_exists('messagepreview'))
+ if ($RCMAIL->action=='preview' && $OUTPUT->template_exists('messagepreview'))
$OUTPUT->send('messagepreview');
else {
$RCMAIL->action = 'list';
@@ -194,9 +194,9 @@ $OUTPUT->add_handlers(array(
'blockedobjects' => 'rcmail_remote_objects_msg'));
-if ($RCMAIL->action=='print' && template_exists('printmessage'))
+if ($RCMAIL->action=='print' && $OUTPUT->template_exists('printmessage'))
$OUTPUT->send('printmessage');
-else if ($RCMAIL->action=='preview' && template_exists('messagepreview'))
+else if ($RCMAIL->action=='preview' && $OUTPUT->template_exists('messagepreview'))
$OUTPUT->send('messagepreview');
else
$OUTPUT->send('message');
diff --git a/program/steps/settings/edit_identity.inc b/program/steps/settings/edit_identity.inc
index 43cbf3d17..cc541a6ef 100644
--- a/program/steps/settings/edit_identity.inc
+++ b/program/steps/settings/edit_identity.inc
@@ -136,7 +136,7 @@ function rcube_identity_form($attrib)
$OUTPUT->add_handler('identityform', 'rcube_identity_form');
-if ($RCMAIL->action=='add-identity' && template_exists('addidentity'))
+if ($RCMAIL->action=='add-identity' && $OUTPUT->template_exists('addidentity'))
$OUTPUT->send('addidentity');
$OUTPUT->send('editidentity');