Ticket #513: view_patch.patch
| File view_patch.patch, 2.2 kB (added by memon, 10 months ago) |
|---|
-
home/maarten/webroot/kohana_trunk/system/libraries/View.php
42 42 * @param string type of file: html, css, js, etc. 43 43 * @return void 44 44 */ 45 public function __construct($name, $data = NULL, $type = NULL) 45 public function __construct($name = NULL, $data = NULL, $type = NULL) 46 { 47 if(!empty($name)) 48 { 49 $this->set_view_file($name,$type); 50 } 51 52 if (is_array($data) AND ! empty($data)) 53 { 54 // Preload data using array_merge, to allow user extensions 55 $this->data = array_merge($this->data, $data); 56 } 57 58 Log::add('debug', 'View Class Initialized ['.$name.']'); 59 } 60 61 /** 62 * Set the view file to be used 63 * 64 * @throws Kohana_Exception if the requested view cannot be found 65 * @param string $name 66 * @param string type of file: html, css, js, etc. 67 * @return void 68 */ 69 public function set_view_file($name,$type=NULL) 46 70 { 47 71 if (empty($type)) 48 72 { … … 59 83 // Load the filename and set the content type 60 84 $this->kohana_filename = Kohana::find_file('views', $name, TRUE, $type); 61 85 $this->kohana_filetype = Config::item('mimes.'.$type); 62 $this->kohana_filetype = empty($this->kohana_filetype) ? $type : $this->kohana_filetype; 86 $this->kohana_filetype = empty($this->kohana_filetype) ? $type : $this->kohana_filetype; 63 87 } 64 65 if (is_array($data) AND ! empty($data))66 {67 // Preload data using array_merge, to allow user extensions68 $this->data = array_merge($this->data, $data);69 }70 71 Log::add('debug', 'View Class Initialized ['.$name.']');72 88 } 73 89 74 90 /** 75 91 * Sets a view variable. 76 92 * … … 180 196 */ 181 197 public function render($print = FALSE, $renderer = FALSE) 182 198 { 199 if(empty($this->kohana_filename)) 200 throw new Kohana_Exception('core.view_not_set'); 201 202 if(empty($this->kohana_filetype)) 203 throw new Kohana_Exception('core.view_extension_not_set'); 204 183 205 if (is_string($this->kohana_filetype)) 184 206 { 185 207 // Merge global and local data, local overrides global with the same name
