Ticket #779: general.css.3.php

File general.css.3.php, 3.0 KB (added by Volker Strähle, 10 years ago)
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_foundation_plain = DIR_FS_CATALOG.'templates/'.CURRENT_TEMPLATE.'/css/foundation.css';
17$css_foundation_min = DIR_FS_CATALOG.'templates/'.CURRENT_TEMPLATE.'/css/foundation.min.css';
18$css_app_plain = DIR_FS_CATALOG.'templates/'.CURRENT_TEMPLATE.'/css/app.css';
19$css_app_min = DIR_FS_CATALOG.'templates/'.CURRENT_TEMPLATE.'/css/app.min.css';
20
21
22function compress_stylesheet($css_plain, $css_min, $css_filename = 'stylesheet.css', $css_filename_min = 'stylesheet.min.css'){
23 // function should be moved to /includes/somefilename.php
24 require_once(DIR_FS_EXTERNAL.'compactor/compactor.php');
25
26 $css_file = $css_filename;
27
28 if (($css_content = file_get_contents($css_plain)) !== false) {
29 $compactor = new Compactor(array('strip_php_comments' => true));
30 $css_content = $compactor->squeeze($css_content);
31 try {
32 if (file_put_contents($css_min, $css_content, LOCK_EX) !== false) {
33 $css_file = $css_filename_min;
34 }
35 } catch (Exception $e) {
36 trigger_error('func compress_stylesheet', $e->getMessage());
37 }
38 }
39 return $css_file;
40
41}
42
43function auto_compress_stylesheet($css_plain, $css_min, $css_filename = 'stylesheet.css', $css_filename_min = 'stylesheet.min.css'){
44
45 $css_file = $css_filename;
46
47 if (COMPRESS_STYLESHEET == 'true') {
48 //require_once(DIR_FS_EXTERNAL.'compactor/compactor.php');
49 if (file_exists($css_min)){
50 if (filemtime($css_plain) > filemtime($css_min)) {
51 compress_stylesheet($css_plain, $css_min, $css_filename, $css_filename_min);
52 } else {
53 //stylesheet.css is older than stylesheet.min.css => nothing to do
54 $css_file = $css_filename_min;
55 }
56 } else{
57 // stylesheet.min.css does not exist => create
58 compress_stylesheet($css_plain, $css_min, $css_filename, $css_filename_min);
59 }
60 }
61
62 return $css_file;
63
64}
65
66
67$css_foundation_file = auto_compress_stylesheet($css_foundation_plain,$css_foundation_min, 'foundation.css','foundation.min.css');
68$css_app_file = auto_compress_stylesheet($css_app_plain,$css_app_min, 'app.css', 'app.min.css');
69
70
71 // Put CSS-Inline-Definitions here, these CSS-files will be loaded at the TOP of every page
72?>
73<link rel="stylesheet" href="<?php echo DIR_WS_BASE.'templates/'.CURRENT_TEMPLATE.'/css/'.$css_foundation_file; ?>" type="text/css" media="screen" />
74<link rel="stylesheet" href="<?php echo DIR_WS_BASE.'templates/'.CURRENT_TEMPLATE.'/css/'.$css_app_file; ?>" type="text/css" media="screen" />