Advertisement
dragonbe

Untitled

Nov 16th, 2011
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.71 KB | None | 0 0
  1. <?php // file: application/views/scripts/user/list.phtml ?>
  2. <?php if (!empty($this->userList)): ?>
  3. <?php echo $this->htmlList($this->userList); ?>
  4. <?php else : ?>
  5. <p>No users found</p>
  6. <?php endif; ?>
  7. <?php
  8. //file: application/controllers/UserController.php
  9.  
  10. class UserController extends Zend_Controller_Action
  11. {
  12.     protected $_pageCache;
  13.  
  14.     public function init()
  15.     {
  16.         $this->_pageCache = Zend_Cache::factory(
  17.             'Page',
  18.             'File',
  19.             array ('debug_header' => true),
  20.             array ('cache_dir' => '/tmp')
  21.         );
  22.     }
  23.  
  24.     public function indexAction()
  25.     {
  26.         $this->_pageCache->start();
  27.         $user = new Application_Model_DbTable_User();
  28.         $users = array ();
  29.         try {
  30.             $users = $user->fetchAll();
  31.         } catch (Zend_Db_Exception $e) {
  32.             echo $e->getMessage() . "<br/>";
  33.         }
  34.         $this->view->users = $users;
  35.     }
  36.  
  37.     public function oneAction()
  38.     {
  39.         $id = $this->getRequest()->getParam('id',0);
  40.         $user = new Application_Model_DbTable_User();
  41.         $this->view->user = $user->find($id);
  42.     }
  43.  
  44.     public function loginAction()
  45.     {
  46.         $form = $this->_getForm();
  47.         $this->view->form = $form;
  48.     }
  49.  
  50.     protected function _getForm()
  51.     {
  52.          return new Application_Form_Login(array (
  53.              'method' => 'post',
  54.              'action' => $this->view->url(array (
  55.                  'controller' => 'user',
  56.                  'action' => 'auth',
  57.              )),
  58.          ));
  59.     }
  60.  
  61.     public function cacheAction()
  62.     {
  63.         $username = $this->getRequest()->getParam('username', 'foo');
  64.         $user = new Application_Model_DbTable_User();
  65.         $this->view->username = $user->getUserByName($username);
  66.     }
  67.  
  68.     public function listAction()
  69.     {
  70.         $this->view->userList = array ('Bob','Rob','Dianne');
  71.     }
  72.  
  73.  
  74. }
  75.  
  76.  
  77.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement