public function init() { if (!Zend_Registry::isRegistered('extConfig')) { $configTable = new Application_Model_DbTable_Config(); Zend_Registry::set('extConfig', $configTable->selectConfig()); } }
public function zglosAction() { if (! $this->facebook->isPageFan()) { return $this->_forward('index', 'index', null, array('err' => 'no-fan')); } $config = new Application_Model_DbTable_Config(); if ($config->getCanEnter() == false) { return; } $request = $this->getRequest(); $form = new Application_Form_Zdjecie( $this->getInvokeArg('bootstrap')->getOption('zdjecie') ); $form->populate(array('fbid' => $this->fbUserId)); if ($this->getRequest()->isPost()) { if (! $form->isValid($this->getRequest()->getPost())) { $this->view->form = $form; return; } if (! $form->photo->receive()) { $form->photo->addErrorMessage('Dodanie zdjęcia nie powiodło się'); $this->view->form = $form; return; } $fbUser = $this->facebook->api('/me'); $zdjecia = new Application_Model_DbTable_Zdjecia(); $zdjecieId = $zdjecia->insert( array( 'fbuserid' => $fbUser['id'], 'fbname' => $fbUser['name'], 'fblink' => $fbUser['link'], 'dodano' => new Zend_Db_Expr('NOW()'), ) ); if (! is_numeric($zdjecieId)) { throw new RuntimeException('Błąd systemu. Zdjęcie nie zostało zapisane'); } $zdjecie = new Application_Model_Zdjecie( $form->photo->getFileName(), $this->getInvokeArg('bootstrap')->getOption('zdjecie') ); $zdjecie->resize(); $zdjecie->save($zdjecieId); $zdjecie->clear(); $this->_redirect('/zdjecia?msg=photo-added'); } $this->view->form = $form; }
public function init() { try { $this->_config = Zend_Registry::get('extConfig'); } catch (Zend_Exception $ze) { if (empty($this->_config)) { $configTable = new Application_Model_DbTable_Config(); $this->_config = $configTable->selectConfig(); Zend_Registry::set('extConfig', $this->_config); } } }
protected function _initLocale() { //Config $this->bootstrap('db'); $configDb = new Application_Model_DbTable_Config(); $config = $configDb->getConfig(); //Locale $language = new Zend_Locale($config['language']); Zend_Registry::set('Zend_Locale', $language); //Date $phpSettings = $this->getOption('phpSettings'); date_default_timezone_set($config['timezone']); $date = new Zend_Date(); //echo $date, "\n"; //echo $date->toString('YYYY-MM-dd HH:mm:ss'); /*$date = $date->get(Zend_date::WEEKDAY).', '.$date->get(Zend_date::DAY).' '.$date->get(Zend_date::MONTH_NAME).' '.$date->get(Zend_Date::YEAR);*/ }
public function indexAction() { if (!$this->facebook->getUser() || is_null($this->_getParam('code'))) { return $this->_forward('redirect'); } if (!is_null($this->_getParam('msg'))) { $this->view->messages = array($this->_getParam('msg')); } if (!is_null($this->_getParam('err'))) { $this->view->errors = array($this->_getParam('err')); } $this->view->isPageFan = $this->facebook->isPageFan(); $config = new Application_Model_DbTable_Config(); $this->view->canEnter = $config->getCanEnter(); }
public function configAction() { $table = new Application_Model_DbTable_Config(); $rowset = $table->fetchAll(); $config = array(); foreach ($rowset as $row) { $config[$row->code] = $row->value; } $form = new Application_Form_Config(); $form->populate($config); $request = $this->getRequest(); if ($request->isPost() && $form->isValid($request->getPost())) { $values = $form->getValues(); $table->update( array('value' => $values['can_vote']), $table->getAdapter()->quoteInto('code = "can_vote"') ); $table->update( array('value' => $values['can_enter']), $table->getAdapter()->quoteInto('code = "can_enter"') ); return $this->_redirect('/admin/config?msg=config-saved'); } $this->view->form = $form; }