Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //-------------------------------------------------
- // questions controller
- //-------------------------------------------------
- class QuestionsController extends Controller {
- protected $_routes = array (
- 'add_form' => 'action=add_form',
- 'insert' => 'action=insert',
- 'edit_form' => 'action=edit_form&qid=%d',
- 'update' => 'action=update&qid=%d',
- 'delete_form' => 'action=delete_form&qid=%d',
- 'delete' => 'action=delete&qid=%d',
- 'view_single' => 'action=view_single&qid=%d',
- 'view_page' => 'action=view_page&qpageid=%d');
- //----------------------------------- declare params
- protected function declareParams() {
- $this->_params = array('qid'=>'','qcategory'=>'','qpageid'=>'');
- }
- //----------------------------------- common dispatch
- protected function commonDispatch() {
- $this->set('nav_categoryname', $this->Question->getCategory($this->p__qcategory));
- $this->set('nav_numpages', $this->Question->getNumPages());
- $this->set('nav_pageid', $this->p__qpageid);
- $this->set('nav_qid', $this->p__qid);
- }
- //--------------------------------- draw single record
- public function view_single() {
- //$this->_w ('qid='.$this->p__qid, __METHOD__);
- $el = $this->Question->getSingle($this->p__qid);
- $this->setAll($el);
- }
- //-------------------------------- draw page
- public function view_page() {
- $els = $this->Question->getPage($this->p__qpageid);
- //$this->_w($els,__METHOD__);
- $this->set('items',$els);
- }
- //-------------------------------- draw add form
- public function add_form() {
- }
- //-------------------------------- insert record
- public function insert() {
- $inf = $this->Question->insertItem();
- $this->set('message', $inf['message']);
- $this->set('newrecord_id', $inf['rid']);
- $els = $this->Question->getPage($this->p__qpageid);
- $this->set('items',$els);
- }
- //-------------------------------- draw edit form
- public function edit_form() {
- $el = $this->Question->getSingle($this->p__qid);
- $this->setAll($el);
- }
- //-------------------------------- update record
- public function update() {
- $this->set('message',$this->Question->updateItem($this->p__qid));
- $els = $this->Question->getPage($this->p__qpageid);
- $this->set('items',$els);
- }
- //-------------------------------- delete form
- public function delete_form() {
- $this->set('message', 'really delete record '.$this->p__qid.' ?');
- }
- //-------------------------------- delete record
- public function delete() {
- $this->set('message',$this->Question->deleteItem($this->p__qid));
- $els = $this->Question->getPage($this->p__qpageid);
- $this->set('items',$els);
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement