Show
Ignore:
Timestamp:
12/05/05 00:20:32 (6 years ago)
Author:
john
Message:

fixed flash stuff

Files:
1 modified

Legend:

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

    r72 r73  
    11<? 
    2 # $Id: action_controller.php 55 2005-11-11 22:38:37Z john $ 
     2# $Id$ 
    33# 
    44# Copyright (c) 2005 John Peterson 
     
    9191            $browser_url = str_replace(TRAX_URL_PREFIX,"",$browser_url); 
    9292        } 
    93          
     93 
    9494        # strip leading slash 
    9595        $browser_url = substr($browser_url,1); 
     
    181181                $class = $this->controller_class; 
    182182                $this->controller_object = new $class(); 
    183     
     183 
    184184                $layout = $this->controller_object->layout; 
    185185                # Call class method to set the layout dynamically at runtime 
    186                 if(method_exists($this->controller_object, $layout)) {                     
    187                     $layout = $this->controller_object->$layout();         
    188                 } 
    189                                          
     186                if(method_exists($this->controller_object, $layout)) { 
     187                    $layout = $this->controller_object->$layout(); 
     188                } 
     189 
    190190                # Check if there is any defined scaffolding to load 
    191                 if($this->controller_object->scaffold) {                       
    192                     $scaffold = $this->controller_object->scaffold;                            
    193                     if(file_exists(TRAX_ROOT.$GLOBALS['TRAX_INCLUDES']['lib']."/scaffold_controller.php")) { 
    194                         include_once(TRAX_ROOT.$GLOBALS['TRAX_INCLUDES']['lib']."/scaffold_controller.php"); 
    195                         $this->controller_object = new ScaffoldController($scaffold, $this->controller, $this->action);                          
     191                if($this->controller_object->scaffold) { 
     192                    $scaffold = $this->controller_object->scaffold; 
     193                    if(file_exists(TRAX_LIB_ROOT."/scaffold_controller.php")) { 
     194                        include_once(TRAX_LIB_ROOT."/scaffold_controller.php"); 
     195                        $this->controller_object = new ScaffoldController($scaffold, $this->controller, $this->action); 
    196196                        if($this->action) { 
    197                             $this->view_file = TRAX_ROOT.$GLOBALS['TRAX_INCLUDES']['lib'] . "/templates/scaffolds/".$this->action.".phtml";     
     197                            $this->view_file = TRAX_LIB_ROOT . "/templates/scaffolds/".$this->action.".phtml"; 
    198198                        } else { 
    199                             $this->view_file = TRAX_ROOT.$GLOBALS['TRAX_INCLUDES']['lib'] . "/templates/scaffolds/index.phtml";             
     199                            $this->view_file = TRAX_LIB_ROOT . "/templates/scaffolds/index.phtml"; 
    200200                        } 
    201201                        if($layout == "") { 
    202202                            # the generic scaffold layout 
    203                             $this->layout_file = TRAX_ROOT.$GLOBALS['TRAX_INCLUDES']['lib'] . "/templates/scaffolds/layout.phtml"; 
    204                         }                                         
     203                            $this->layout_file = TRAX_LIB_ROOT . "/templates/scaffolds/layout.phtml"; 
     204                        } 
    205205                    } 
    206206                } 
    207                  
    208207            } 
    209208 
     
    257256                        } else { 
    258257                            $this->view_file = $this->views_path . "/" . "index" . "." . $this->views_file_extention; 
    259                         }                     
     258                        } 
    260259                    } 
    261                                          
     260 
    262261                    if(file_exists($this->view_file)) { 
    263262                        # grab view html 
     
    265264                    } else { 
    266265                        $this->raise("No view file found $action ($this->view_file).", "Unknown view", "404"); 
    267                     }      
    268                      
     266                    } 
     267 
    269268                    # Grab all the html from the view to put into the layout 
    270269                    $content_for_layout .= ob_get_contents(); 
    271270                    ob_end_clean(); 
    272271 
    273                     if(!$this->layout_file) {                        
     272                    if(!$this->layout_file) { 
    274273                        $this->layout_file = $this->layouts_path . "/" . $layout . "." . $this->views_file_extention; 
    275                     }     
    276                      
     274                    } 
     275 
    277276                    if(file_exists($this->layout_file)) { 
    278277                        # render user defined layout 
     
    286285                        # No layout template so just echo out whatever is in $content_for_layout 
    287286                        echo $content_for_layout; 
    288                     }                                    
     287                    } 
    289288                } 
    290289            } else { 
     
    296295 
    297296        if(!$this->keep_flash) { 
    298             # Nuke the flash array 
    299             Session:: 
    300             unset($_SESSION['flash']); 
     297            # Nuke the flash 
     298            Session::unset_var('flash'); 
    301299        } 
    302300 
     
    307305        if(is_array($this->url_path)) { 
    308306            foreach($this->url_path as $path) { 
    309                 if(file_exists($this->controllers_path . "/$path")) { 
     307                if(file_exists($this->controllers_path . "/$path")) { 
    310308                    $this->controllers_path .= "/$path"; 
    311309                    $this->helpers_path .= "/$path"; 
     
    332330                $filter_function = $this->controller_object->before_filter; 
    333331                $this->controller_object->$filter_function(); 
    334             }                 
     332            } 
    335333        } 
    336334    } 
     
    339337        if (is_array($filter_function_name)) { 
    340338            if(count($this->before_filter) > 0) { 
    341                 $this->before_filter = array_merge($this->before_filter, $filter_function_name);         
     339                $this->before_filter = array_merge($this->before_filter, $filter_function_name); 
    342340            } else { 
    343341                $this->before_filter = $filter_function_name; 
     
    346344            $this->before_filter = array($this->before_filter, $filter_function_name); 
    347345        } else { 
    348             $this->before_filter = $filter_function_name;       
     346            $this->before_filter = $filter_function_name; 
    349347        } 
    350348    } 
     
    361359                $filter_function = $this->controller_object->after_filter; 
    362360                $this->controller_object->$filter_function(); 
    363             }                 
     361            } 
    364362        } 
    365363    } 
     
    368366        if (is_array($filter_function_name)) { 
    369367            if(count($this->after_filter) > 0) { 
    370                 $this->after_filter = array_merge($this->after_filter, $filter_function_name);         
     368                $this->after_filter = array_merge($this->after_filter, $filter_function_name); 
    371369            } else { 
    372370                $this->after_filter = $filter_function_name; 
    373             }             
     371            } 
    374372        } elseif($this->after_filter != "") { 
    375373            $this->after_filter = array($this->after_filter, $filter_function_name); 
    376374        } else { 
    377             $this->after_filter = $filter_function_name;       
     375            $this->after_filter = $filter_function_name; 
    378376        } 
    379377    } 
     
    405403    } 
    406404 
    407     function raise($error_message, $error_heading, $error_code = "404") {        
    408         throw new ActionControllerError("Error Message: ".$error_message, $error_heading, $error_code);         
     405    function raise($error_message, $error_heading, $error_code = "404") { 
     406        throw new ActionControllerError("Error Message: ".$error_message, $error_heading, $error_code); 
    409407    } 
    410408 
     
    414412        $error_message = $exception->error_message; 
    415413        $trace = $exception->getTraceAsString(); 
    416         header("HTTP/1.0 {$error_code} {$error_heading}");         
     414        header("HTTP/1.0 {$error_code} {$error_heading}"); 
    417415        # check for user's layout for errors 
    418416        if(DEBUG && file_exists(TRAX_ROOT.$GLOBALS['TRAX_INCLUDES']['layouts']."/error.phtml")) {