Changeset 2085
- Timestamp:
- 02/20/2008 08:43:34 AM (11 months ago)
- Files:
-
- 1 modified
-
trunk/modules/media/controllers/media.php (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/media/controllers/media.php
r2006 r2085 27 27 parent::__construct(); 28 28 29 $cache = Config::item('media.cache');29 $cache = Config::item('media.cache'); 30 30 $this->use_cache = ($cache > 0); 31 31 … … 36 36 else 37 37 { 38 $this->cache_lifetime = config::item('cache.lifetime') OR $this->cache_lifetime = 1800;38 Config::item('cache.lifetime') OR $this->cache_lifetime = 1800; 39 39 } 40 40 … … 45 45 46 46 $this->pack_css = (bool) Config::item('media.pack_css'); 47 $this->pack_js = Config::item('media.pack_js');47 $this->pack_js = Config::item('media.pack_js'); 48 48 49 49 if ($this->pack_js === TRUE) … … 53 53 } 54 54 55 public function css($querystr) { 56 // find all the individual files 57 $files = explode("+", $querystr); 55 public function css($querystr) 56 { 57 // Find all the individual files 58 $files = explode('+', $querystr); 58 59 59 60 $mimetype = config::item('mimes.css'); … … 65 66 { 66 67 $data = ''; 67 foreach ($files as $orig_filename) { 68 foreach ($files as $orig_filename) 69 { 68 70 $filename = $orig_filename; 71 69 72 if (substr($filename, -4) == ".css") 70 73 { … … 78 81 catch (Kohana_Exception $exception) 79 82 { 80 // try to load the file as a php view (eg, file.css.php)83 // Try to load the file as a php view (eg, file.css.php) 81 84 try 82 85 { 83 86 $view = new View('media/css/'.$orig_filename); 84 85 87 } 86 88 catch (Kohana_Exception $exception) 87 89 { 88 // not found90 // Not found 89 91 unset($view); 90 92 } … … 94 96 $filedata = $view->render(); 95 97 96 ($this->pack_css) and$filedata = $this->_css_compress($filedata);98 ($this->pack_css) AND $filedata = $this->_css_compress($filedata); 97 99 98 100 $data .= $filedata; … … 104 106 } 105 107 106 ($this->use_cache) and$this->cache->set('media.css.'.$querystr, $data, array('media'), $this->cache_lifetime);108 ($this->use_cache) AND $this->cache->set('media.css.'.$querystr, $data, array('media'), $this->cache_lifetime); 107 109 } 108 110 … … 111 113 } 112 114 113 public function js($orig_filename) { 115 public function js($orig_filename) 116 { 114 117 $filename = $orig_filename; 118 115 119 if (substr($filename, -3) == '.js') 116 120 { … … 121 125 $mimetype = (isset($mimetype[0])) ? $mimetype[0] : 'text/javascript'; 122 126 123 124 127 $this->use_cache AND $data = $this->cache->get('media.js.'.$filename); 125 128 … … 154 157 } 155 158 156 ($this->use_cache) and$this->cache->set('media.js.'.$filename, $data, array('media'), $this->cache_lifetime);159 ($this->use_cache) AND $this->cache->set('media.js.'.$filename, $data, array('media'), $this->cache_lifetime); 157 160 } 158 161 else … … 170 173 $type = $this->uri->segment(2); 171 174 $filename = $this->uri->segment(3); 172 // TODO: finish this for generic types173 / * issues: getting View to work with any types of files */175 // TODO: Finish this for generic types 176 // ISSUES: Getting View to work with any types of files 174 177 175 178 try … … 183 186 } 184 187 185 // Based on http://www.ibloomstudios.com/articles/php_css_compressor/ 188 /** 189 * @based_on http://www.ibloomstudios.com/articles/php_css_compressor/ 190 */ 186 191 public function _css_compress($data) 187 192 {
