Advertisement
terorama

mvc / questionscontroller.inc.php

Dec 22nd, 2012
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.98 KB | None | 0 0
  1. <?php
  2.  
  3. //-------------------------------------------------
  4. //            questions controller
  5. //-------------------------------------------------
  6. class QuestionsController extends Controller {
  7.  
  8.  
  9.    protected $_routes = array (
  10.                        
  11.                         'add_form'     => 'action=add_form',
  12.                         'insert'       => 'action=insert',
  13.                         'edit_form'    => 'action=edit_form&qid=%d',
  14.                         'update'       => 'action=update&qid=%d',
  15.                         'delete_form'  => 'action=delete_form&qid=%d',
  16.                         'delete'       => 'action=delete&qid=%d',
  17.                         'view_single'  => 'action=view_single&qid=%d',
  18.                         'view_page'    => 'action=view_page&qpageid=%d');
  19.                              
  20.    //----------------------------------- declare params
  21.    protected function declareParams() {
  22.    
  23.       $this->_params = array('qid'=>'','qcategory'=>'','qpageid'=>'');
  24.    }
  25.    
  26.    //----------------------------------- common dispatch
  27.    protected function commonDispatch() {
  28.    
  29.      
  30.       $this->set('nav_categoryname', $this->Question->getCategory($this->p__qcategory));
  31.       $this->set('nav_numpages', $this->Question->getNumPages());
  32.      
  33.       $this->set('nav_pageid', $this->p__qpageid);
  34.       $this->set('nav_qid', $this->p__qid);
  35.  
  36.    }
  37.    
  38.    //---------------------------------  draw single record  
  39.    public function view_single() {
  40.    
  41.       //$this->_w ('qid='.$this->p__qid, __METHOD__);
  42.      
  43.      
  44.       $el = $this->Question->getSingle($this->p__qid);
  45.       $this->setAll($el);
  46.      
  47.    }
  48.    //--------------------------------  draw page
  49.    public function view_page() {
  50.    
  51.       $els = $this->Question->getPage($this->p__qpageid);
  52.       //$this->_w($els,__METHOD__);
  53.       $this->set('items',$els);
  54.    }
  55.    
  56.    //--------------------------------  draw add form
  57.    public function add_form() {
  58.    
  59.      
  60.    }
  61.    //--------------------------------  insert record
  62.    public function insert() {
  63.    
  64.       $inf = $this->Question->insertItem();
  65.       $this->set('message', $inf['message']);
  66.       $this->set('newrecord_id', $inf['rid']);
  67.      
  68.       $els = $this->Question->getPage($this->p__qpageid);
  69.       $this->set('items',$els);
  70.    }
  71.    //--------------------------------  draw edit form
  72.    public function edit_form() {
  73.    
  74.       $el = $this->Question->getSingle($this->p__qid);
  75.       $this->setAll($el);
  76.      
  77.    }
  78.    //--------------------------------  update record
  79.    public function update() {
  80.    
  81.       $this->set('message',$this->Question->updateItem($this->p__qid));
  82.      
  83.       $els = $this->Question->getPage($this->p__qpageid);
  84.       $this->set('items',$els);
  85.    }
  86.    //--------------------------------  delete form
  87.    public function delete_form() {
  88.      
  89.       $this->set('message', 'really delete record '.$this->p__qid.' ?');
  90.    }
  91.    //--------------------------------  delete record
  92.    public function delete() {
  93.      
  94.       $this->set('message',$this->Question->deleteItem($this->p__qid));
  95.      
  96.       $els = $this->Question->getPage($this->p__qpageid);
  97.       $this->set('items',$els);
  98.    }
  99. }
  100. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement