Show
Ignore:
Timestamp:
02/20/2008 08:43:34 AM (11 months ago)
Author:
armen
Message:

Code cleanup.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/modules/media/controllers/media.php

    r2006 r2085  
    2727                parent::__construct(); 
    2828 
    29                 $cache = Config::item('media.cache'); 
     29                $cache           = Config::item('media.cache'); 
    3030                $this->use_cache = ($cache > 0); 
    3131 
     
    3636                else 
    3737                { 
    38                         $this->cache_lifetime = config::item('cache.lifetime') OR $this->cache_lifetime = 1800; 
     38                        Config::item('cache.lifetime') OR $this->cache_lifetime = 1800; 
    3939                } 
    4040 
     
    4545 
    4646                $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'); 
    4848 
    4949                if ($this->pack_js === TRUE) 
     
    5353        } 
    5454 
    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); 
    5859 
    5960                $mimetype = config::item('mimes.css'); 
     
    6566                { 
    6667                        $data = ''; 
    67                         foreach ($files as $orig_filename) { 
     68                        foreach ($files as $orig_filename)  
     69                        { 
    6870                                $filename = $orig_filename; 
     71 
    6972                                if (substr($filename, -4) == ".css") 
    7073                                { 
     
    7881                                catch (Kohana_Exception $exception) 
    7982                                { 
    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) 
    8184                                        try 
    8285                                        { 
    8386                                                $view = new View('media/css/'.$orig_filename); 
    84  
    8587                                        } 
    8688                                        catch (Kohana_Exception $exception) 
    8789                                        { 
    88                                                 // not found 
     90                                                // Not found 
    8991                                                unset($view); 
    9092                                        } 
     
    9496                                        $filedata = $view->render(); 
    9597 
    96                                         ($this->pack_css) and $filedata = $this->_css_compress($filedata); 
     98                                        ($this->pack_css) AND $filedata = $this->_css_compress($filedata); 
    9799 
    98100                                        $data .= $filedata; 
     
    104106                        } 
    105107 
    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); 
    107109                } 
    108110 
     
    111113        } 
    112114 
    113         public function js($orig_filename) { 
     115        public function js($orig_filename)  
     116        { 
    114117                $filename = $orig_filename; 
     118 
    115119                if (substr($filename, -3) == '.js') 
    116120                { 
     
    121125                $mimetype = (isset($mimetype[0])) ? $mimetype[0] : 'text/javascript'; 
    122126 
    123  
    124127                $this->use_cache AND $data = $this->cache->get('media.js.'.$filename); 
    125128 
     
    154157                                } 
    155158 
    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); 
    157160                        } 
    158161                        else 
     
    170173                $type = $this->uri->segment(2); 
    171174                $filename = $this->uri->segment(3); 
    172                 // TODO: finish this for generic types 
    173                 /* 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 
    174177 
    175178                try 
     
    183186        } 
    184187 
    185         // Based on http://www.ibloomstudios.com/articles/php_css_compressor/ 
     188        /** 
     189         * @based_on   http://www.ibloomstudios.com/articles/php_css_compressor/ 
     190         */ 
    186191        public function _css_compress($data) 
    187192        {