2 // @todo nacitanie suborov a tried prepracovat pomocou Zend_Loader
3 require_once APPLICATION_PATH
.'/models/Game.php';
4 require_once APPLICATION_PATH
.'/models/GameManager.php';
5 require_once APPLICATION_PATH
.'/models/Player.php';
6 require_once APPLICATION_PATH
.'/models/PlayerList.php';
8 class IndexController
extends Zend_Controller_Action
10 const PLAYER_ID
= 'player_id';
13 public function indexAction()
15 $this->view
->actual_game_date
= $this->_getModel()->getActualGameDate();
16 $this->view
->player_list
= $this->getActualPlayerlist();
17 $this->view
->form
= $this->_getSignForm();
20 public function signAction()
23 $auth = Zend_Auth
::getInstance();
24 #$authAdapter = Zend_Registry::get('authAdapter');
25 $authAdapter = new Zend_Auth_Adapter_DbTable(Zend_Registry
::get('dbAdapter'));
26 $authAdapter->setTableName('player')
27 ->setIdentityColumn('login')
28 ->setCredentialColumn('passwd');
29 if ($auth->hasIdentity()) {
30 //zaznamena ucast hraca v DB
31 $storage = $auth->getStorage()->read();
32 $this->_signPlayer($storage->player_id
);
33 //aktualizovany view so zoznamom hracov
39 * metoda zisti informacie o hracoch prihlasenych na aktualnu hru
40 * @todo tuto informaciu by mal poskytovat model - bude
41 * treba zapracovat na presune metody do modelu
43 public function getActualPlayerlist()
45 return $this->_getModel()->getActualGame()->getPlayerList();
48 protected function _getModel()
50 if (null === $this->_model
) {
51 $this->_model
= new GameManager();
56 protected function _getSignForm() {
57 $form = new Zend_Form();
58 $form->setAction($this->_helper
->url('sign'))
60 $form->addElement('submit', 'prihlasit');
64 protected function _signPlayer($player_id) {
65 $_model = $this->_getModel();
66 $_model->signPlayer($player_id);