summaryrefslogtreecommitdiff
path: root/program/include
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2013-12-18 21:41:56 +0100
committerAleksander Machniak <alec@alec.pl>2013-12-18 21:41:56 +0100
commitc562a316817091b80ac9c7d3efa31067850b03e6 (patch)
treee610a1c7b61413cdc3f82ae48128598760e2c370 /program/include
parent538e64c572220bba43960a3073468c0ce3dc5f4c (diff)
Improved minified files handling, added css minification (#1486988)
Diffstat (limited to 'program/include')
-rw-r--r--program/include/rcmail_output_html.php41
1 files changed, 24 insertions, 17 deletions
diff --git a/program/include/rcmail_output_html.php b/program/include/rcmail_output_html.php
index 7ff85e017..e4059b73d 100644
--- a/program/include/rcmail_output_html.php
+++ b/program/include/rcmail_output_html.php
@@ -662,23 +662,33 @@ class rcmail_output_html extends rcmail_output
// add file modification timestamp
if (preg_match('/\.(js|css)$/', $file, $m)) {
- $fs = false;
- $ext = $m[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)) {
- $file = $minified_file . '?s=' . $fs;
- }
- }
+ $file = $this->file_mod($file);
+ }
- if (!$fs && ($fs = @filemtime($file))) {
- $file .= '?s=' . $fs;
+ 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;
}
}
- return $matches[1] . '=' . $matches[2] . $file . $matches[4];
+ if ($fs = @filemtime($file)) {
+ $file .= '?s=' . $fs;
+ }
+
+ return $file;
}
/**
@@ -1225,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])) {