Changeset 117 for trunk/trax/vendor/trax/action_controller.php
- Timestamp:
- 01/18/06 18:45:19 (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
r113 r117 1 <? 1 <?php 2 2 # $Id$ 3 3 # … … 187 187 $GLOBALS['current_controller_path'] = "$this->added_path/$this->controller"; 188 188 $GLOBALS['current_controller_name'] = $this->controller; 189 $GLOBALS['current_controller_object'] = $this->controller_object;189 $GLOBALS['current_controller_object'] =& $this->controller_object; 190 190 } 191 191 … … 198 198 if(file_exists(TRAX_LIB_ROOT."/scaffold_controller.php")) { 199 199 include_once(TRAX_LIB_ROOT."/scaffold_controller.php"); 200 $GLOBALS['current_controller_object'] = $this->controller_object = new ScaffoldController($scaffold); 200 $this->controller_object = new ScaffoldController($scaffold); 201 $GLOBALS['current_controller_object'] =& $this->controller_object; 201 202 if($this->action) { 202 203 $this->view_file = TRAX_LIB_ROOT . "/templates/scaffolds/".$this->action.".phtml"; … … 350 351 function add_before_filter($filter_function_name) { 351 352 if(is_string($filter_function_name) && !empty($filter_function_name)) { 352 $this->before_filters[] = $filter_function_name; 353 if(!in_array($filter_function_name, $this->before_filters)) { 354 $this->before_filters[] = $filter_function_name; 355 } 353 356 } elseif(is_array($filter_function_name)) { 354 357 if(count($this->before_filters) > 0) { … … 372 375 function add_after_filter($filter_function_name) { 373 376 if(is_string($filter_function_name) && !empty($filter_function_name)) { 374 $this->after_filters[] = $filter_function_name; 377 if(!in_array($filter_function_name, $this->after_filters)) { 378 $this->after_filters[] = $filter_function_name; 379 } 375 380 } elseif(is_array($filter_function_name)) { 376 381 if(count($this->after_filters) > 0) { … … 383 388 384 389 function add_helper($helper_name) { 385 $this->helpers[] = $helper_name; 386 } 387 388 function render_partial($path) { 390 if(!in_array($helper_name, $this->helpers)) { 391 $this->helpers[] = $helper_name; 392 } 393 } 394 395 function render_partial($path, $options = array()) { 389 396 if(strstr($path, "/")) { 390 397 $file = substr(strrchr($path, "/"), 1); 391 398 $path = substr($path, 0, strripos($path, "/")); 392 $ path_with_file= TRAX_ROOT.$GLOBALS['TRAX_INCLUDES']['views']."/".$path."/_".$file.".".$this->views_file_extention;399 $file_with_path = TRAX_ROOT.$GLOBALS['TRAX_INCLUDES']['views']."/".$path."/_".$file.".".$this->views_file_extention; 393 400 } else { 394 $path_with_file = $this->views_path."/_".$path.".".$this->views_file_extention; 395 } 396 397 if(file_exists($path_with_file)) { 401 $file = $path; 402 $file_with_path = $this->views_path."/_".$file.".".$this->views_file_extention; 403 } 404 405 if(file_exists($file_with_path)) { 406 407 if(array_key_exists("spacer_template", $options)) { 408 $spacer_path = $options['spacer_template']; 409 if(strstr($spacer_path, "/")) { 410 $spacer_file = substr(strrchr($spacer_path, "/"), 1); 411 $spacer_path = substr($spacer_path, 0, strripos($spacer_path, "/")); 412 $spacer_file_with_file = TRAX_ROOT.$GLOBALS['TRAX_INCLUDES']['views']."/".$spacer_path."/_".$spacer_file.".".$this->views_file_extention; 413 } else { 414 $spacer_file = $spacer_path; 415 $spacer_file_with_file = $this->views_path."/_".$spacer_file.".".$this->views_file_extention; 416 } 417 if(file_exists($spacer_file_with_file)) { 418 $add_spacer = true; 419 } 420 } 421 398 422 # Pull all the class vars out and turn them from $this->var to $var 399 423 extract(get_object_vars($this->controller_object)); 400 include($path_with_file); 424 if(array_key_exists("collection", $options)) { 425 foreach($options['collection'] as $tmp_value) { 426 ${$file."_counter"}++; 427 ${$file} = $tmp_value; 428 unset($tmp_value); 429 include($file_with_path); 430 if($add_spacer && (${$file."_counter"} < count($options['collection']))) { 431 include($spacer_file_with_file); 432 } 433 } 434 } else { 435 if(array_key_exists("locals", $options)) { 436 foreach($options['locals'] as $tmp_key => $tmp_value) { 437 ${$tmp_key} = $tmp_value; 438 } 439 unset($tmp_key); 440 unset($tmp_value); 441 } 442 include($path_with_file); 443 } 401 444 } 402 445 }
