public function modifyAction() { $request = $this->getRequest(); $id = $request->getParam('id', null); if (is_null($id)) { $this->_helper->redirector('index', 'onlinelibrary'); } else { $video = new Application_Model_Video(); Application_Model_VideosMapper::i()->find($id, $video); if ($video->getId() == $id) { $form = new Application_Form_Video(); $form->setAction($this->_helper->url('add')); try { $_hosters = X_VlcShares_Plugins::helpers()->hoster()->getHosters(); $hosters = array('direct-url' => 'direct-url'); foreach ($_hosters as $idHoster => $pattern) { $hosters[$idHoster] = $idHoster; } $form->hoster->setMultiOptions($hosters); } catch (Exception $e) { } $form->addElement('hidden', 'id'); $form->setDefaults(array('id' => $video->getId(), 'title' => $video->getTitle(), 'idVideo' => $video->getIdVideo(), 'hoster' => $video->getHoster(), 'category' => $video->getCategory(), 'description' => $video->getDescription(), 'thumbnail' => $video->getThumbnail())); $this->view->video = $video; $this->view->form = $form; $this->render('add'); } else { $this->_helper->redirector('index', 'onlinelibrary'); } } }
public function editVideoAction() { $idEvento = $this->_request->getParam("idEvento"); $form = new Application_Form_Video(); $form->submit->setLabel('Salvar video'); $this->view->form = $form; if ($this->getRequest()->isPost()) { $formData = $this->getRequest()->getPost(); if ($form->isValid($formData)) { $id = (int) $form->getValue('id'); $nome = $form->getValue('nome'); $url = $form->getValue('url'); $fk_evento = $form->getValue('fk_evento'); //$form->getValue('interior_capital'); $videos = new Application_Model_DbTable_Video(); $videos->updateVideo($id, $nome, $url, $fk_evento); $this->_redirect('/upload/lista-videos/idEvento/' . $idEvento); } else { $form->populate($formData); } } else { $id = $this->_getParam('id', 0); if ($id > 0) { $videos = new Application_Model_DbTable_Video(); $form->populate($videos->getVideo($id)); } } }