Changeset 3171

Show
Ignore:
Timestamp:
07/20/2008 09:27:11 PM (4 months ago)
Author:
Shadowhand
Message:

Optimizations to Input, URI, View, and Controller

Location:
trunk/system/libraries
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/system/libraries/Controller.php

    r2229 r3171  
    2323        public function __construct() 
    2424        { 
    25                 if (Kohana::$instance === NULL) 
     25                if (Kohana::$instance == NULL) 
    2626                { 
    2727                        // Set the instance to the first controller loaded 
    2828                        Kohana::$instance = $this; 
     29                } 
    2930 
    30                         // URI should always be available 
    31                         $this->uri = new URI; 
     31                // URI should always be available 
     32                $this->uri = URI::instance(); 
    3233 
    33                         // Input should always be available 
    34                         $this->input = new Input; 
    35                 } 
    36                 else 
    37                 { 
    38                         // URI should always be available 
    39                         $this->uri = Kohana::$instance->uri; 
    40  
    41                         // Input should always be available 
    42                         $this->input = Kohana::$instance->input; 
    43                 } 
     34                // Input should always be available 
     35                $this->input = Input::instance(); 
    4436        } 
    4537 
  • trunk/system/libraries/Input.php

    r3160 r3171  
    1212class Input_Core { 
    1313 
    14         // Singleton instance 
    15         protected static $instance; 
    16  
    1714        // Enable or disable automatic XSS cleaning 
    1815        protected $use_xss_clean = FALSE; 
     
    2926        public static function instance() 
    3027        { 
    31                 // Create an instance if none exists 
    32                 empty(self::$instance) and new Input; 
    33  
    34                 return self::$instance; 
     28                static $instance; 
     29 
     30                if ($instance == NULL) 
     31                { 
     32                        // Create a new instance 
     33                        $instance = new Input; 
     34                } 
     35 
     36                return $instance; 
    3537        } 
    3638 
     
    268270 
    269271                // Do not clean empty strings 
    270                 if (trim($string) === '') 
     272                if (trim($string) == '') 
    271273                        return $string; 
    272274 
    273                 if ( ! is_string($tool)) 
    274                 { 
    275                         // Fetch the configured tool 
    276                         if (is_bool($tool = Kohana::config('core.global_xss_filtering'))) 
    277                         { 
    278                                 // Make sure that the default tool is used 
    279                                 $tool = 'default'; 
    280                         } 
     275                if ($tool === NULL) 
     276                { 
     277                        // Use the default tool 
     278                        $tool = Kohana::config('core.global_xss_filtering'); 
    281279                } 
    282280 
  • trunk/system/libraries/URI.php

    r3119 r3171  
    2121                static $instance; 
    2222 
    23                 // Initialize the URI instance 
    24                 empty($instance) and $instance = new URI; 
     23                if ($instance == NULL) 
     24                { 
     25                        // Initialize the URI instance 
     26                        $instance = new URI; 
     27                } 
    2528 
    2629                return $instance; 
  • trunk/system/libraries/View.php

    r3160 r3171  
    6868        public function set_filename($name, $type = NULL) 
    6969        { 
    70                 if (empty($type)) 
     70                if ($type == NULL) 
    7171                { 
    7272                        // Load the filename and set the content type 
     
    8383                        $this->kohana_filename = Kohana::find_file('views', $name, TRUE, $type); 
    8484                        $this->kohana_filetype = Kohana::config('mimes.'.$type); 
    85                         $this->kohana_filetype = empty($this->kohana_filetype) ? $type : $this->kohana_filetype; 
     85 
     86                        if ($this->kohana_filetype == NULL) 
     87                        { 
     88                                // Use the specified type 
     89                                $this->kohana_filetype = $type; 
     90                        } 
    8691                } 
    8792 
     
    232237                { 
    233238                        // Set the content type and size 
    234                         header('Content-Type: '.$this->kohana_filetype[0]); 
     239                        header('Content-type: '.$this->kohana_filetype[0]); 
    235240 
    236241                        if ($print === TRUE)