summaryrefslogtreecommitdiff
path: root/lib/exe/css.php
diff options
context:
space:
mode:
authorlisps <stummp@loewen.de>2014-03-19 08:07:16 +0100
committerlisps <stummp@loewen.de>2014-03-19 08:07:16 +0100
commite310313d794a3336d279ee09973508e794dbf08e (patch)
tree7f90b51d344f7163c6fbb109f04ff22dea5ae129 /lib/exe/css.php
parentcdb5e9613f7c4b1be4515715652aca451493d5d5 (diff)
parent177ef92c4ddd38cb906dd7d5f0208c698048cd57 (diff)
downloadrpg-e310313d794a3336d279ee09973508e794dbf08e.tar.gz
rpg-e310313d794a3336d279ee09973508e794dbf08e.tar.bz2
Merge remote-tracking branch 'remotes/origin/master' into revisions_local
Diffstat (limited to 'lib/exe/css.php')
-rw-r--r--lib/exe/css.php44
1 files changed, 42 insertions, 2 deletions
diff --git a/lib/exe/css.php b/lib/exe/css.php
index cab7384b2..30d0d18c5 100644
--- a/lib/exe/css.php
+++ b/lib/exe/css.php
@@ -56,7 +56,7 @@ function css_out(){
}
// cache influencers
- $tplinc = tpl_basedir($tpl);
+ $tplinc = tpl_incdir($tpl);
$cache_files = getConfigFiles('main');
$cache_files[] = $tplinc.'style.ini';
$cache_files[] = $tplinc.'style.local.ini'; // @deprecated
@@ -133,6 +133,9 @@ function css_out(){
$css = ob_get_contents();
ob_end_clean();
+ // strip any source maps
+ stripsourcemaps($css);
+
// apply style replacements
$css = css_applystyle($css, $styleini['replacements']);
@@ -552,7 +555,7 @@ function css_compress($css){
$css = preg_replace_callback('#(/\*)(.*?)(\*/)#s','css_comment_cb',$css);
//strip (incorrect but common) one line comments
- $css = preg_replace('/(?<!:)\/\/.*$/m','',$css);
+ $css = preg_replace_callback('/^.*\/\/.*$/m','css_onelinecomment_cb',$css);
// strip whitespaces
$css = preg_replace('![\r\n\t ]+!',' ',$css);
@@ -588,4 +591,41 @@ function css_comment_cb($matches){
return $matches[0];
}
+/**
+ * Callback for css_compress()
+ *
+ * Strips one line comments but makes sure it will not destroy url() constructs with slashes
+ *
+ * @param $matches
+ * @return string
+ */
+function css_onelinecomment_cb($matches) {
+ $line = $matches[0];
+
+ $out = '';
+ $i = 0;
+ $len = strlen($line);
+ while ($i< $len){
+ $nextcom = strpos($line, '//', $i);
+ $nexturl = stripos($line, 'url(', $i);
+
+ if($nextcom === false) {
+ // no more comments, we're done
+ $out .= substr($line, $i, $len-$i);
+ break;
+ }
+ if($nexturl === false || $nextcom < $nexturl) {
+ // no url anymore, strip comment and be done
+ $out .= substr($line, $i, $nextcom-$i);
+ break;
+ }
+ // we have an upcoming url
+ $urlclose = strpos($line, ')', $nexturl);
+ $out .= substr($line, $i, $urlclose-$i);
+ $i = $urlclose;
+ }
+
+ return $out;
+}
+
//Setup VIM: ex: et ts=4 :