Show
Ignore:
Timestamp:
02/09/2008 12:23:27 AM (11 months ago)
Author:
PugFish
Message:

Converted comments for media module

Files:
1 modified

Legend:

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

    r2005 r2006  
    11<?php defined('SYSPATH') or die('No direct script access.'); 
    2 /** 
    3  * Kohana - The Swift PHP Framework 
    4  * 
    5  *  License: 
    6  *  author    - Kohana Team 
    7  *  copyright - (c) 2007 Kohana Team 
    8  *  license   - <http://kohanaphp.com/license.html> 
    9  */ 
    10  
    112/** 
    123 * Handles loading of site resources (CSS, JS, images) using Views. 
     
    167 * Usage: 
    178 *  `http://example.com/index.php/media/css/styles.css` 
     9 * 
     10 * $Id$ 
     11 * 
     12 * @package        Media Module 
     13 * @author         Kohana Team 
     14 * @copyright  (c) 2007-2008 Kohana Team 
     15 * @license        http://kohanaphp.com/license.html 
    1816 */ 
    1917class Media_Controller extends Controller { 
     
    4139                } 
    4240 
    43                 if ($this->use_cache AND ! isset($this->cache))  
     41                if ($this->use_cache AND ! isset($this->cache)) 
    4442                { 
    4543                        $this->cache = new Cache; 
     
    5452                } 
    5553        } 
    56          
     54 
    5755        public function css($querystr) { 
    58                 // find all the individual files  
     56                // find all the individual files 
    5957                $files = explode("+", $querystr); 
    6058 
     
    6967                        foreach ($files as $orig_filename) { 
    7068                                $filename = $orig_filename; 
    71                                 if (substr($filename, -4) == ".css")  
     69                                if (substr($filename, -4) == ".css") 
    7270                                { 
    7371                                        $filename = substr($filename, 0, -4); 
    7472                                } 
    75                                  
     73 
    7674                                try 
    7775                                { 
     
    8078                                catch (Kohana_Exception $exception) 
    8179                                { 
    82                                         // try to load the file as a php view (eg, file.css.php)  
     80                                        // try to load the file as a php view (eg, file.css.php) 
    8381                                        try 
    8482                                        { 
    8583                                                $view = new View('media/css/'.$orig_filename); 
    86                                                  
     84 
    8785                                        } 
    8886                                        catch (Kohana_Exception $exception) 
     
    9593                                if (isset($view)) { 
    9694                                        $filedata = $view->render(); 
    97                                          
     95 
    9896                                        ($this->pack_css) and $filedata = $this->_css_compress($filedata); 
    99                                          
     97 
    10098                                        $data .= $filedata; 
    10199                                } 
    102100                                else 
    103                                 {        
     101                                { 
    104102                                        $data .= "\n/**** stylesheet ".$filename." not found ****/\n\n\n"; 
    105103                                } 
    106104                        } 
    107                          
     105 
    108106                        ($this->use_cache) and $this->cache->set('media.css.'.$querystr, $data, array('media'), $this->cache_lifetime); 
    109107                } 
     
    126124                $this->use_cache AND $data = $this->cache->get('media.js.'.$filename); 
    127125 
    128                 if ( ! isset($data) OR empty($data))  
     126                if ( ! isset($data) OR empty($data)) 
    129127                { 
    130128                        try 
     
    134132                        catch (Kohana_Exception $exception) 
    135133                        { 
    136                                 // Try to load the file as a php view (eg, file.js.php)  
     134                                // Try to load the file as a php view (eg, file.js.php) 
    137135                                try 
    138136                                { 
     
    146144                        } 
    147145 
    148                         if (isset($view))  
     146                        if (isset($view)) 
    149147                        { 
    150148                                $data = $view->render(); 
    151149 
    152                                 if ($this->pack_js)  
     150                                if ($this->pack_js) 
    153151                                { 
    154152                                        $packer = new JavaScriptPacker($data, $this->pack_js); 
     
    157155 
    158156                                ($this->use_cache) and $this->cache->set('media.js.'.$filename, $data, array('media'), $this->cache_lifetime); 
    159                         }  
    160                         else  
     157                        } 
     158                        else 
    161159                        { 
    162160                                $data = '/* script not found */'; 
     
    174172                // TODO: finish this for generic types 
    175173                /* issues: getting View to work with any types of files */ 
    176                  
     174 
    177175                try 
    178176                {