Changeset 142 for trunk/trax/vendor/trax/action_controller.php
- Timestamp:
- 02/26/06 02:04:33 (6 years ago)
- Files:
-
- 1 modified
-
trunk/trax/vendor/trax/action_controller.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/trax/vendor/trax/action_controller.php
r138 r142 204 204 $helpers = array(), 205 205 $before_filters = array(), 206 $after_filters = array(); 206 $after_filters = array(); 207 207 protected 208 208 $before_filter = null, … … 212 212 $view_file, 213 213 $views_path, 214 $controller_class, $controller_object, 214 $controller_class, 215 $controller_object, 216 $asset_host = null, 215 217 $views_file_extention = TRAX_VIEWS_EXTENTION; 216 218 … … 234 236 } 235 237 238 function __call($method_name, $parameters) { 239 if(method_exists($this, $method_name)) { 240 # If the method exists, just call it 241 $result = call_user_func(array($this, $method_name), $parameters); 242 } else { 243 if($method_name == "before_filter") { 244 $result = call_user_func(array($this, 'add_before_filter'), $parameters); 245 } elseif($method_name == "after_filter") { 246 $result = call_user_func(array($this, 'add_after_filter'), $parameters); 247 } elseif($method_name == "helper") { 248 $result = call_user_func(array($this, 'add_helper'), $parameters); 249 } 250 } 251 return $result; 252 } 253 236 254 function load_router() { 237 255 $this->router_loaded = false; … … 347 365 $this->controller_object = new $class(); 348 366 if(is_object($this->controller_object)) { 367 $this->controller_object->controller = $this->controller; 368 $this->controller_object->action = $this->action; 369 $this->controller_object->controller_path = "$this->added_path/$this->controller"; 349 370 $GLOBALS['current_controller_path'] = "$this->added_path/$this->controller"; 350 371 $GLOBALS['current_controller_name'] = $this->controller; … … 420 441 # Find out if there was a redirect to some other page 421 442 if($this->controller_object->redirect_to) { 422 echo "<html><head><META HTTP-EQUIV=\"REFRESH\" CONTENT=\"0; URL=".$this->controller_object->redirect_to."\"></head></html>"; 423 #header("Location: ".$this->controller_object->redirect_to); 424 exit; 443 $this->redirect_to($this->controller_object->redirect_to); 425 444 } else { 426 445 # Pull all the class vars out and turn them from $this->var to $var … … 696 715 697 716 /** 717 * Redirects the browser to the target specified in options. This parameter can take one of three forms: 718 * 719 * * Array: The URL will be generated by calling url_for() with the options. 720 * * String starting with protocol:// (like http://): Is passed straight through as the target for redirection. 721 * * String not containing a protocol: The current protocol and host is prepended to the string. 722 * * back: Back to the page that issued the request. Useful for forms that are triggered from multiple places. Short-hand for redirect_to(request.env["HTTP_REFERER"]) 723 * 724 * Examples: 725 * 726 * redirect_to(array(":action" => "show", ":id" => 5)) 727 * redirect_to("http://www.rubyonrails.org") 728 * redirect_to("/images/screenshot.jpg") 729 * redirect_to("back") 730 * 731 * @param mixed $options array or string url 732 */ 733 function redirect_to($options = null) { 734 if($options == "back") { 735 $url = $_SERVER["HTTP_REFERER"]; 736 } else { 737 $url = url_for($options); 738 } 739 echo "<html><head><META HTTP-EQUIV=\"REFRESH\" CONTENT=\"0; URL=".$url."\"></head></html>"; 740 #header("Location: ".$url); 741 exit; 742 } 743 744 /** 698 745 * Raise an ActionControllerError exception 699 746 *
