Show
Ignore:
Timestamp:
02/26/06 02:04:33 (6 years ago)
Author:
john
Message:

added asset_host to controller for use in helper

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/trax/vendor/trax/action_controller.php

    r138 r142  
    204204        $helpers = array(), 
    205205        $before_filters = array(), 
    206         $after_filters = array(); 
     206        $after_filters = array();      
    207207    protected 
    208208        $before_filter = null, 
     
    212212        $view_file, 
    213213        $views_path, 
    214         $controller_class, $controller_object, 
     214        $controller_class,  
     215        $controller_object, 
     216        $asset_host = null, 
    215217        $views_file_extention = TRAX_VIEWS_EXTENTION; 
    216218 
     
    234236    } 
    235237 
     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 
    236254    function load_router() { 
    237255        $this->router_loaded = false; 
     
    347365                $this->controller_object = new $class(); 
    348366                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"; 
    349370                    $GLOBALS['current_controller_path'] = "$this->added_path/$this->controller"; 
    350371                    $GLOBALS['current_controller_name'] = $this->controller; 
     
    420441                # Find out if there was a redirect to some other page 
    421442                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); 
    425444                } else { 
    426445                    # Pull all the class vars out and turn them from $this->var to $var 
     
    696715 
    697716    /** 
     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    /** 
    698745     *  Raise an ActionControllerError exception 
    699746     *