Changeset 201 for trunk/trax/vendor/trax/action_controller.php
- Timestamp:
- 05/25/06 02:58:10 (6 years ago)
- Files:
-
- 1 modified
-
trunk/trax/vendor/trax/action_controller.php (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/trax/vendor/trax/action_controller.php
r200 r201 282 282 283 283 /** 284 * File extension appended to view files285 *286 * Set from a define in {@link environment.php}. Usually phtml287 * @var string288 */289 public $views_file_extention = TRAX_VIEWS_EXTENTION;290 291 /**292 284 * Render controllers layout 293 285 * … … 375 367 376 368 // Load the routes. 377 require(T RAX_ROOT.$GLOBALS['TRAX_INCLUDES']['config']."/routes.php");369 require(Trax::$config_path."/routes.php"); 378 370 $this->router = $router; 379 371 if(is_object($this->router)) { … … 410 402 * @uses set_paths() 411 403 * @uses $url_path 412 * @uses $views_file_extention413 404 * @uses $views_path 414 405 * @return boolean … … 432 423 //error_log('browser url='.$browser_url); 433 424 # strip off url prefix, if any 434 if(!is_null(T RAX_URL_PREFIX)) {435 $browser_url = str_replace(T RAX_URL_PREFIX,"",$browser_url);425 if(!is_null(Trax::$url_prefix)) { 426 $browser_url = str_replace(Trax::$url_prefix, "", $browser_url); 436 427 } 437 428 … … 453 444 454 445 if($this->router->routes_count > 0) { 455 $this->controllers_path = T RAX_ROOT . $GLOBALS['TRAX_INCLUDES']['controllers'];456 $this->helpers_path = $this->helpers_base_path = T RAX_ROOT . $GLOBALS['TRAX_INCLUDES']['helpers'];446 $this->controllers_path = Trax::$controllers_path; 447 $this->helpers_path = $this->helpers_base_path = Trax::$helpers_path; 457 448 $this->application_controller_file = $this->controllers_path . "/application.php"; 458 449 $this->application_helper_file = $this->helpers_path . "/application_helper.php"; 459 $this->layouts_path = T RAX_ROOT . $GLOBALS['TRAX_INCLUDES']['layouts'];460 $this->views_path = T RAX_ROOT . $GLOBALS['TRAX_INCLUDES']['views'];450 $this->layouts_path = Trax::$layouts_path; 451 $this->views_path = Trax::$views_path; 461 452 462 453 $route = $this->router->find_route($browser_url); … … 560 551 * @uses Session::unset_var() 561 552 * @uses $view_file 562 * @uses $views_file_extention563 553 * @uses $views_path 564 554 * @return boolean true … … 598 588 $this->controller_object->views_path = $this->views_path; 599 589 $this->controller_object->layouts_path = $this->layouts_path; 600 $GLOBALS['current_controller_path']= "$this->added_path/$this->controller";601 $GLOBALS['current_controller_name']= $this->controller;602 $GLOBALS['current_action_name']= $this->action;603 $GLOBALS['current_controller_object']=& $this->controller_object;590 Trax::$current_controller_path = "$this->added_path/$this->controller"; 591 Trax::$current_controller_name = $this->controller; 592 Trax::$current_action_name = $this->action; 593 Trax::$current_controller_object =& $this->controller_object; 604 594 # Which layout should we use? 605 595 $layout_file = $this->controller_object->determine_layout(); … … 611 601 include_once(TRAX_LIB_ROOT."/scaffold_controller.php"); 612 602 $this->controller_object = new ScaffoldController($scaffold); 613 $GLOBALS['current_controller_object']=& $this->controller_object;603 Trax::$current_controller_object =& $this->controller_object; 614 604 $render_options['scaffold'] = true; 615 605 if(!file_exists($layout_file)) { … … 667 657 // .var_export($this->action_params,true)); 668 658 $this->controller_object->$action($this->action_params); 669 } elseif(file_exists($this->views_path . "/" . $this->action . "." . $this->views_file_extention)) {659 } elseif(file_exists($this->views_path . "/" . $this->action . "." . Trax::$views_extension)) { 670 660 //error_log('views file "'.$this->action.'"'); 671 661 $action = $this->action; … … 722 712 if(!$this->controller_object->render_file($layout_file, false, $locals)) { 723 713 # No layout template so just echo out whatever is in $content_for_layout 724 echo "HERE";714 //echo "HERE"; 725 715 echo $content_for_layout; 726 716 } … … 991 981 $this->view_file = TRAX_LIB_ROOT."/templates/scaffolds/".$action.".phtml"; 992 982 } else { 993 $this->view_file = $this->views_path . "/" . $action . "." . $this->views_file_extention;983 $this->view_file = $this->views_path . "/" . $action . "." . Trax::$views_extension; 994 984 } 995 985 //error_log(get_class($this)." - render_action() view_file: $this->view_file"); … … 1030 1020 # Renders a template relative to app/views 1031 1021 if($use_full_path) { 1032 $path = $this->views_path."/".$path.".". $this->views_file_extention;1022 $path = $this->views_path."/".$path.".".Trax::$views_extension; 1033 1023 } 1034 1024 … … 1097 1087 $file = substr(strrchr($path, "/"), 1); 1098 1088 $path = substr($path, 0, strripos($path, "/")); 1099 $file_with_path = T RAX_ROOT.$GLOBALS['TRAX_INCLUDES']['views']."/".$path."/_".$file.".".$this->views_file_extention;1089 $file_with_path = Trax::$views_path."/".$path."/_".$file.".".Trax::$views_extension; 1100 1090 } else { 1101 1091 $file = $path; 1102 $file_with_path = $this->views_path."/_".$file.".". $this->views_file_extention;1092 $file_with_path = $this->views_path."/_".$file.".".Trax::$views_extension; 1103 1093 } 1104 1094 … … 1110 1100 $spacer_file = substr(strrchr($spacer_path, "/"), 1); 1111 1101 $spacer_path = substr($spacer_path, 0, strripos($spacer_path, "/")); 1112 $spacer_file_with_file = TRAX_ROOT.$GLOBALS['TRAX_INCLUDES']['views']."/".$spacer_path."/_".$spacer_file.".". $this->views_file_extention;1102 $spacer_file_with_file = TRAX_ROOT.$GLOBALS['TRAX_INCLUDES']['views']."/".$spacer_path."/_".$spacer_file.".".Trax::$views_extension; 1113 1103 } else { 1114 1104 $spacer_file = $spacer_path; 1115 $spacer_file_with_file = $this->views_path."/_".$spacer_file.".". $this->views_file_extention;1105 $spacer_file_with_file = $this->views_path."/_".$spacer_file.".".Trax::$views_extension; 1116 1106 } 1117 1107 if(file_exists($spacer_file_with_file)) { … … 1170 1160 1171 1161 # Default settings 1172 $layouts_base_path = T RAX_ROOT . $GLOBALS['TRAX_INCLUDES']['layouts'];1173 $default_layout_file = $layouts_base_path . "/application." . $this->views_file_extention;1162 $layouts_base_path = Trax::$layouts_path; 1163 $default_layout_file = $layouts_base_path . "/application." . Trax::$views_extension; 1174 1164 1175 1165 if(!$full_path && $layout) { … … 1180 1170 $file = substr(strrchr($layout, "/"), 1); 1181 1171 $path = substr($layout, 0, strripos($layout, "/")); 1182 $layout = $layouts_base_path."/".$path."/".$file.".". $this->views_file_extention;1172 $layout = $layouts_base_path."/".$path."/".$file.".".Trax::$views_extension; 1183 1173 } else { 1184 1174 # Is there a layout for the current controller 1185 $layout = $this->layouts_path."/".$layout.".". $this->views_file_extention;1175 $layout = $this->layouts_path."/".$layout.".".Trax::$views_extension; 1186 1176 } 1187 1177 … … 1261 1251 header('status: {$error_code} {$error_heading}'); 1262 1252 # check for user's layout for errors 1263 if( DEBUG && file_exists(TRAX_ROOT.$GLOBALS['TRAX_INCLUDES']['layouts']."/trax_error.".TRAX_VIEWS_EXTENTION)) {1264 include(T RAX_ROOT.$GLOBALS['TRAX_INCLUDES']['layouts']."/trax_error.".TRAX_VIEWS_EXTENTION);1265 } elseif( DEBUG&& file_exists(TRAX_LIB_ROOT."/templates/error.phtml")) {1253 if(TRAX_ENV == "development" && file_exists(Trax::$layouts_path."/trax_error.".Trax::$views_extension)) { 1254 include(Trax::$layouts_path."/trax_error.".Trax::$views_extension); 1255 } elseif(TRAX_ENV == "development" && file_exists(TRAX_LIB_ROOT."/templates/error.phtml")) { 1266 1256 # use default layout for errors 1267 1257 include(TRAX_LIB_ROOT."/templates/error.phtml"); 1268 } elseif( DEBUG) {1258 } elseif(TRAX_ENV == "development") { 1269 1259 echo "<font face=\"verdana, arial, helvetica, sans-serif\">\n"; 1270 1260 echo "<h1>$error_heading</h1>\n";
