PHPonTrax
[ class tree: PHPonTrax ] [ index: PHPonTrax ] [ all elements ]

Source for file controller.php

Documentation is available at controller.php

  1. < ?php
  2.  
  3. class <?php echo $controller_class_name ?>Controller extends ApplicationController {
  4.  
  5. <?php foreach($non_scaffolded_actions as $action)?>
  6.     function <?php echo $action ?>() {
  7.     }
  8.    
  9. <?php endforeach?>
  10.     function index() {
  11.         $<?php echo $singular_model_name ?> = new <?php echo $model_class_name ?>();
  12.         $this-><?php echo $plural_model_name ?> = $<?php echo $singular_model_name ?>->find_all();
  13.         $this->content_columns = $<?php echo $singular_model_name ?>->content_columns;
  14.     }
  15.     
  16.     function show() {
  17.         $<?php echo $singular_model_name ?> = new <?php echo $model_class_name ?>();
  18.         $this-><?php echo $singular_model_name ?> = $<?php echo $singular_model_name ?>->find($_REQUEST['id']);
  19.     }
  20.     
  21.     function add() {
  22.       $this-><?php echo $singular_model_name ?> = new <?php echo $model_class_name ?>(array_key_exists('<?php echo $singular_model_name ?>',$_REQUEST) ? $_REQUEST['<?php echo $singular_model_name ?>'] : null );
  23.         if($_POST) {
  24.             if($this-><?php echo $singular_model_name ?>->save($_POST['<?php echo $singular_model_name ?>'])) {
  25.                 Session::flash('notice', "<?php echo $human_model_name ?> was successfully created.");
  26.                 $this->redirect_to = url_for(array(":action" => "index"));
  27.             } else {
  28.                 Session::flash('error', "Error adding <?php echo $singular_model_name ?> to the database.");
  29.             }
  30.         }
  31.     }
  32.     
  33.     function edit() {
  34.         $<?php echo $singular_model_name ?> = new <?php echo $model_class_name ?>();
  35.         $this-><?php echo $singular_model_name ?> = $<?php echo $singular_model_name ?>->find($_REQUEST['id']);    
  36.         if($_POST) {
  37.             if($this-><?php echo $singular_model_name ?>->save($_POST['<?php echo $singular_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 $singular_model_name ?>));
  40.             } else {
  41.                 Session::flash('error', "Error saving <?php echo $singular_model_name ?> to the database.");
  42.             }
  43.         }
  44.     }
  45.     
  46.     function delete() {
  47.         if($_REQUEST['id'] > 0) {
  48.             $<?php echo $singular_model_name ?> = new <?php echo $model_class_name ?>();
  49.             $<?php echo $singular_model_name ?> = $<?php echo $singular_model_name ?>->find($_REQUEST['id']);
  50.             if($<?php echo $singular_model_name ?>->delete()) {
  51.                 Session::flash('notice', "<?php echo $human_model_name ?> was successfully deleted.");
  52.             } else {
  53.                 Session::flash('error', "Error deleting <?php echo $singular_model_name ?> from the database.");
  54.             }
  55.         }
  56.         $this->redirect_to = url_for(array(":action" => "index"));
  57.     }
  58. }
  59.  
  60. ? >

Documentation generated on Mon, 21 May 2007 22:28:10 -0600 by phpDocumentor 1.3.2