- Timestamp:
- 01/18/06 18:45:19 (6 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/trax/vendor/trax/templates/scaffolds/generator_templates/controller.php
r113 r117 1 < ? 1 < ?php 2 2 3 class <? =$controller_class_name ?>Controller extends ApplicationController {3 class <?php echo $controller_class_name ?>Controller extends ApplicationController { 4 4 5 <? foreach($non_scaffolded_actions as $action): ?>6 function <? =$action ?>() {5 <?php foreach($non_scaffolded_actions as $action): ?> 6 function <?php echo $action ?>() { 7 7 } 8 8 9 <? endforeach; ?>9 <?php endforeach; ?> 10 10 function index() { 11 $<? =$singluar_model_name?> = new <?=$model_class_name?>();12 $this-><? =$plural_model_name?> = $<?=$singluar_model_name?>->find_all();13 $this->content_columns = $<? =$singluar_model_name?>->content_columns;11 $<?php echo $singluar_model_name ?> = new <?php echo $model_class_name ?>(); 12 $this-><?php echo $plural_model_name ?> = $<?php echo $singluar_model_name ?>->find_all(); 13 $this->content_columns = $<?php echo $singluar_model_name ?>->content_columns; 14 14 } 15 15 16 16 function show() { 17 $<? =$singluar_model_name?> = new <?=$model_class_name?>();18 $this-><? =$singluar_model_name?> = $<?=$singluar_model_name?>->find($_REQUEST['id']);17 $<?php echo $singluar_model_name ?> = new <?php echo $model_class_name ?>(); 18 $this-><?php echo $singluar_model_name ?> = $<?php echo $singluar_model_name ?>->find($_REQUEST['id']); 19 19 } 20 20 21 21 function add() { 22 $this-><? =$singluar_model_name?> = new <?=$model_class_name?>($_REQUEST['<?=$singluar_model_name?>']);22 $this-><?php echo $singluar_model_name ?> = new <?php echo $model_class_name ?>($_REQUEST['<?php echo $singluar_model_name ?>']); 23 23 if($_POST) { 24 if($this-><? =$singluar_model_name?>->save($_POST['<?=$singluar_model_name?>'])) {25 Session::flash('notice', "<? =$human_model_name?> was successfully created.");24 if($this-><?php echo $singluar_model_name ?>->save($_POST['<?php echo $singluar_model_name ?>'])) { 25 Session::flash('notice', "<?php echo $human_model_name ?> was successfully created."); 26 26 $this->redirect_to = url_for(array(":action" => "index")); 27 27 } else { 28 Session::flash('error', "Error adding <? =$singluar_model_name?> to the database.");28 Session::flash('error', "Error adding <?php echo $singluar_model_name ?> to the database."); 29 29 } 30 30 } … … 32 32 33 33 function edit() { 34 $<? =$singluar_model_name?> = new <?=$model_class_name?>();35 $this-><? =$singluar_model_name?> = $<?=$singluar_model_name?>->find($_REQUEST['id']);34 $<?php echo $singluar_model_name ?> = new <?php echo $model_class_name ?>(); 35 $this-><?php echo $singluar_model_name ?> = $<?php echo $singluar_model_name ?>->find($_REQUEST['id']); 36 36 if($_POST) { 37 if($this-><? =$singluar_model_name?>->save($_POST['<?=$singluar_model_name?>'])) {38 Session::flash('notice', "<? =$human_model_name?> was successfully updated.");39 $this->redirect_to = url_for(array(":action" => "show", ":id" => $this-><? =$singluar_model_name?>));37 if($this-><?php echo $singluar_model_name ?>->save($_POST['<?php echo $singluar_model_name ?>'])) { 38 Session::flash('notice', "<?php echo $human_model_name ?> was successfully updated."); 39 $this->redirect_to = url_for(array(":action" => "show", ":id" => $this-><?php echo $singluar_model_name ?>)); 40 40 } else { 41 Session::flash('error', "Error saving <? =$singluar_model_name?> to the database.");41 Session::flash('error', "Error saving <?php echo $singluar_model_name ?> to the database."); 42 42 } 43 43 } … … 46 46 function delete() { 47 47 if($_REQUEST['id'] > 0) { 48 $<? =$singluar_model_name?> = new <?=$model_class_name?>();49 $<? =$singluar_model_name?> = $<?=$singluar_model_name?>->find($_REQUEST['id']);50 if($<? =$singluar_model_name?>->delete()) {51 Session::flash('notice', "<? =$human_model_name?> was successfully deleted.");48 $<?php echo $singluar_model_name ?> = new <?php echo $model_class_name ?>(); 49 $<?php echo $singluar_model_name ?> = $<?php echo $singluar_model_name ?>->find($_REQUEST['id']); 50 if($<?php echo $singluar_model_name ?>->delete()) { 51 Session::flash('notice', "<?php echo $human_model_name ?> was successfully deleted."); 52 52 } else { 53 Session::flash('error', "Error deleting <? =$singluar_model_name?> from the database.");53 Session::flash('error', "Error deleting <?php echo $singluar_model_name ?> from the database."); 54 54 } 55 55 }
