summaryrefslogtreecommitdiff
path: root/program/include/rcmail_output_html.php
diff options
context:
space:
mode:
Diffstat (limited to 'program/include/rcmail_output_html.php')
-rw-r--r--program/include/rcmail_output_html.php39
1 files changed, 30 insertions, 9 deletions
diff --git a/program/include/rcmail_output_html.php b/program/include/rcmail_output_html.php
index 6db826e2e..e4059b73d 100644
--- a/program/include/rcmail_output_html.php
+++ b/program/include/rcmail_output_html.php
@@ -45,6 +45,7 @@ class rcmail_output_html extends rcmail_output
protected $footer = '';
protected $body = '';
protected $base_path = '';
+ protected $devel_mode = false;
// deprecated names of templates used before 0.5
protected $deprecated_templates = array(
@@ -64,6 +65,8 @@ class rcmail_output_html extends rcmail_output
{
parent::__construct();
+ $this->devel_mode = $this->config->get('devel_mode');
+
//$this->framed = $framed;
$this->set_env('task', $task);
$this->set_env('x_frame_options', $this->config->get('x_frame_options', 'sameorigin'));
@@ -658,16 +661,37 @@ class rcmail_output_html extends rcmail_output
}
// add file modification timestamp
- if (preg_match('/\.(js|css)$/', $file)) {
- if ($fs = @filemtime($file)) {
- $file .= '?s=' . $fs;
- }
+ if (preg_match('/\.(js|css)$/', $file, $m)) {
+ $file = $this->file_mod($file);
}
return $matches[1] . '=' . $matches[2] . $file . $matches[4];
}
/**
+ * Modify file by adding mtime indicator
+ */
+ protected function file_mod($file)
+ {
+ $fs = false;
+ $ext = substr($file, strrpos($file, '.') + 1);
+
+ // use minified file if exists (not in development mode)
+ if (!$this->devel_mode && !preg_match('/\.min\.' . $ext . '$/', $file)) {
+ $minified_file = substr($file, 0, strlen($ext) * -1) . 'min.' . $ext;
+ if ($fs = @filemtime($minified_file)) {
+ return $minified_file . '?s=' . $fs;
+ }
+ }
+
+ if ($fs = @filemtime($file)) {
+ $file .= '?s=' . $fs;
+ }
+
+ return $file;
+ }
+
+ /**
* Public wrapper to dipp into template parsing.
*
* @param string $input
@@ -971,7 +995,7 @@ class rcmail_output_html extends rcmail_output
$content = html::quote($this->get_pagetitle());
}
else if ($object == 'pagetitle') {
- if ($this->config->get('devel_mode') && !empty($_SESSION['username']))
+ if ($this->devel_mode && !empty($_SESSION['username']))
$title = $_SESSION['username'].' :: ';
else if ($prod_name = $this->config->get('product_name'))
$title = $prod_name . ' :: ';
@@ -1211,10 +1235,7 @@ class rcmail_output_html extends rcmail_output
public function include_script($file, $position='head')
{
if (!preg_match('|^https?://|i', $file) && $file[0] != '/') {
- $file = $this->scripts_path . $file;
- if ($fs = @filemtime($file)) {
- $file .= '?s=' . $fs;
- }
+ $file = $this->file_mod($this->scripts_path . $file);
}
if (!is_array($this->script_files[$position])) {