Changeset 1766 for trunk/modules/media/controllers/media.php
- Timestamp:
- 01/21/2008 06:56:39 AM (10 months ago)
- Files:
-
- 1 modified
-
trunk/modules/media/controllers/media.php (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/media/controllers/media.php
r1765 r1766 21 21 protected $use_cache = FALSE; 22 22 protected $cache_lifetime; 23 23 24 24 protected $pack_css = FALSE; 25 25 protected $pack_js = FALSE; 26 26 27 27 public function __construct() 28 28 { 29 29 parent::__construct(); 30 30 31 31 $cache = Config::item('media.cache'); 32 32 $this->use_cache = ($cache > 0); 33 33 34 34 if (is_int($cache)) 35 35 { … … 40 40 $this->cache_lifetime = config::item('cache.lifetime') OR $this->cache_lifetime = 1800; 41 41 } 42 42 43 43 if ($this->use_cache AND ! isset($this->cache)) 44 44 { 45 45 $this->load->library('cache'); 46 46 } 47 47 48 48 $this->pack_css = (bool) Config::item('media.pack_css'); 49 49 $this->pack_js = Config::item('media.pack_js'); 50 50 51 51 if ($this->pack_js === TRUE) 52 52 { … … 54 54 } 55 55 } 56 56 57 57 public function css() 58 58 { … … 62 62 $filename = substr($filename, 0, -4); 63 63 } 64 64 65 65 $mimetype = config::item('mimes.css'); 66 66 $mimetype = (isset($mimetype[0])) ? $mimetype[0] : 'text/stylesheet'; 67 67 68 68 $this->use_cache AND $data = $this->cache->get('media.css.'.$filename); 69 69 70 70 if ( ! isset($data) OR empty($data)) 71 71 { … … 87 87 } 88 88 } 89 89 90 90 if (isset($view)) 91 91 { 92 92 $data = $view->render(); 93 93 94 94 if ($this->pack_css) 95 95 { 96 96 $data = $this->_css_compress($data); 97 97 } 98 98 99 99 if ($this->use_cache) 100 100 { … … 107 107 } 108 108 } 109 109 110 110 $mimetype AND header('Content-type: '.$mimetype); 111 111 echo $data; … … 119 119 $filename = substr($filename, 0, -3); 120 120 } 121 121 122 122 $mimetype = Config::item('mimes.js'); 123 123 $mimetype = (isset($mimetype[0])) ? $mimetype[0] : 'text/javascript'; 124 124 125 125 126 126 $this->use_cache AND $data = $this->cache->get('media.js.'.$filename); 127 127 128 128 if ( ! isset($data) OR empty($data)) 129 129 { … … 145 145 } 146 146 } 147 147 148 148 if (isset($view)) 149 149 { 150 150 $data = $view->render(); 151 151 152 152 if ($this->pack_js) 153 153 { … … 155 155 $data = $packer->pack(); 156 156 } 157 157 158 158 if ($this->use_cache) 159 159 { … … 166 166 } 167 167 } 168 168 169 169 $mimetype AND header('Content-type: '.$mimetype); 170 170 echo $data; … … 184 184 // Remove comments 185 185 $data = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $data); 186 186 187 187 // Remove tabs, spaces, newlines, etc. 188 188 $data = preg_replace('/\s+/s', ' ', $data);
