Ticket #779: general.css.2.php

File general.css.2.php, 3.1 KB (added by Volker Strähle, 10 years ago)

fehlerbereinigte general.css.php v. 26.02.2016

Line 
1<?php
2/* -----------------------------------------------------------------------------------------
3 $Id: general.css.php 4200 2013-01-10 19:47:11Z Tomcraft1980 $
4
5 modified eCommerce Shopsoftware
6 http://www.modified-shop.org
7
8 Copyright (c) 2009 - 2013 [www.modified-shop.org]
9 -----------------------------------------------------------------------------------------
10 based on:
11 (c) 2006 XT-Commerce
12
13 Released under the GNU General Public License
14 ---------------------------------------------------------------------------------------*/
15
16 $css_plain = DIR_FS_CATALOG.'templates/'.CURRENT_TEMPLATE.'/stylesheet.css';
17 $css_min = DIR_FS_CATALOG.'templates/'.CURRENT_TEMPLATE.'/stylesheet.min.css';
18
19function compress_stylesheet($css_plain, $css_min){
20
21 $css_file = '/stylesheet.css';
22
23 if (COMPRESS_STYLESHEET == 'true') {
24 require_once(DIR_FS_EXTERNAL.'compactor/compactor.php');
25 if (file_exists($css_min)){
26 if (filemtime($css_plain) > filemtime($css_min)) {
27 if (($css_content = file_get_contents($css_plain)) !== false) {
28 $compactor = new Compactor(array('strip_php_comments' => true));
29 $css_content = $compactor->squeeze($css_content);
30 if (file_put_contents($css_min, $css_content, LOCK_EX) !== false) {
31 $css_file = '/stylesheet.min.css';
32 }
33 }
34 } else {
35 //stylesheet.css is older than stylesheet.min.css => nothing to do
36 $css_file = '/stylesheet.min.css';
37 }
38 } else{
39 // stylesheet.min.css does not exist => create
40 if (($css_content = file_get_contents($css_plain)) !== false) {
41 $compactor = new Compactor(array('strip_php_comments' => true));
42 $css_content = $compactor->squeeze($css_content);
43 if (file_put_contents($css_min, $css_content, LOCK_EX) !== false) {
44 $css_file = '/stylesheet.min.css';
45 }
46 }
47 }
48 }
49
50 return $css_file;
51
52}
53
54$css_file = compress_stylesheet($css_plain,$css_min);
55
56 /* old version
57
58$css_file = '/stylesheet.css';
59 if (COMPRESS_STYLESHEET == 'true') {
60 echo 'COMPRESS_STYLESHEET == true >>> ';
61 $css_plain_ts = filemtime($css_plain);
62 echo 'css_plain_ts = '.$css_plain_ts.' >>> ';
63 $css_min_ts = is_writeable($css_min) ? filemtime($css_min) : false;
64 echo 'css_min_ts = '.$css_min_ts.' >>> ';
65 if ($css_min_ts && ( $css_plain_ts > $css_min_ts ) ) {
66 echo 'COMPRESS_STYLESHEET if >>> ';
67 require_once(DIR_FS_EXTERNAL.'compactor/compactor.php');
68 if (($css_content = file_get_contents($css_plain)) !== false) {
69 $compactor = new Compactor(array('strip_php_comments' => true));
70 $css_content = $compactor->squeeze($css_content);
71 if (file_put_contents($css_min, $css_content, LOCK_EX) !== false) {
72 $css_file = '/stylesheet.min.css?v='.$css_min_ts;
73 }
74 }
75 } elseif ($css_min_ts) {
76 $css_file = '/stylesheet.min.css?v='.$css_min_ts;
77 }
78 }
79*/
80
81 // Put CSS-Inline-Definitions here, these CSS-files will be loaded at the TOP of every page
82?>
83<link rel="stylesheet" href="<?php echo DIR_WS_BASE.'templates/'.CURRENT_TEMPLATE.$css_file; ?>" type="text/css" media="screen" />