Esempio n. 1
0
 /** Edit a news story
  */
 public function editAction()
 {
     $form = new NewsStoryForm();
     $form->submit->setLabel('Update story');
     $this->view->form = $form;
     if ($this->getRequest()->isPost() && $form->isValid($this->_request->getPost())) {
         if ($form->isValid($form->getValues())) {
             $this->_news->updateNews($form->getValues(), $this->_getParam('id'));
             $this->_flashMessenger->addMessage('News story information updated!');
             $this->_redirect(self::REDIRECT);
         } else {
             $form->populate($form->getValues());
         }
     } else {
         // find id is expected in $params['id']
         $id = (int) $this->_request->getParam('id', 0);
         if ($id > 0) {
             $form->populate($this->_news->fetchRow('id=' . $id)->toArray());
         }
     }
 }
Esempio n. 2
0
 /** Edit a news story
  * @access public
  * @return void
  */
 public function editAction()
 {
     $form = new NewsStoryForm();
     $form->submit->setLabel('Update details...');
     $this->view->form = $form;
     if ($this->_request->isPost()) {
         $formData = $this->_request->getPost();
         if ($form->isValid($formData)) {
             $address = $form->getValue('primaryNewsLocation');
             $coords = $this->_geocoder->getCoordinates($address);
             if ($coords) {
                 $lat = $coords['lat'];
                 $long = $coords['lon'];
             } else {
                 $lat = null;
                 $lon = null;
             }
             $row = $this->_news->fetchRow('id =' . $this->getParam('id'));
             $row->title = $form->getValue('title');
             $row->summary = $form->getValue('summary');
             $row->contents = $form->getValue('contents');
             $row->author = $form->getValue('author');
             $row->contactTel = $form->getValue('contactTel');
             $row->contactEmail = $form->getValue('contactEmail');
             $row->contactName = $form->getValue('contactName');
             $row->keywords = $form->getValue('keywords');
             $row->primaryNewsLocation = $address;
             $row->latitude = $lat;
             $row->longitude = $long;
             $row->updatedBy = $this->getIdentityForForms();
             $row->updated = $this->getTimeForForms();
             $row->golive = $form->getValue('golive');
             $row->publish_state = $form->getValue('publish_state');
             $row->datePublished = $this->getTimeForForms();
             $row->save();
             $this->getFlash()->addMessage('News story information updated!');
             $this->redirect(self::REDIRECT);
         } else {
             $form->populate($formData);
         }
     } else {
         // find id is expected in $params['id']
         $id = (int) $this->_request->getParam('id', 0);
         if ($id > 0) {
             $new = $this->_news->fetchRow('id= ' . (int) $id);
             $form->populate($new->toArray());
         }
     }
 }