public function editAction()
 {
     $this->assecoAction();
     $this->_helper->layout->setLayout('administrator');
     $form = new Application_Form_Noticia();
     $this->view->form = $form;
     if ($this->getRequest()->isPost()) {
         $formData = $this->getRequest()->getPost();
         if ($form->isValid($formData)) {
             $id = (int) $form->getValue('id');
             $foto = $form->getValue('foto');
             $foto1 = $form->getValue('foto1');
             $locationFile = $form->foto1->getFileName();
             $fotoantigo = $form->getElement('foto')->getValue();
             //the hidden field
             //if (file_exists('../public/upload/artigo/'.$fotoantigo))
             if (file_exists($this->_file_moticia . $fotoantigo)) {
                 $form->getElement('foto')->setIgnore(true);
                 $nomeFoto = $fotoantigo;
             } else {
                 // Delete it
                 $this->removeImages($_POST['foto'], $id);
                 $novonomeFoto = sha1(uniqid(rand(), true));
                 $nomeFoto = $novonomeFoto . '.jpg';
                 //$caminhoFoto =  '../public/upload/'.$nomeFoto;
                 $caminhoFoto = $this->_file_moticia . $nomeFoto;
                 // Rename uploaded file using Zend Framework
                 $filterRename = new Zend_Filter_File_Rename(array('target' => $caminhoFoto, 'overwrite' => true));
                 $filterRename->filter($locationFile);
                 // detination file
                 $imageAdapter = new Zend_File_Transfer_Adapter_Http();
                 $imageAdapter->setDestination($this->_file_moticia);
                 try {
                     $imageAdapter->receive();
                 } catch (Zend_File_Transfer_Exception $e) {
                     $e->getMessage();
                 }
             }
             //id  titulo  comentario  noticia foto  data  fonte ativo categoria_noticia_id
             $this->noticias->updates($id, $form->getValue('titulo'), $form->getValue('comentario'), $form->getValue('noticia'), $nomeFoto, $form->getValue('data'), $form->getValue('fonte'), $form->getValue('ativo'), $form->getValue('categoria_noticia_id'));
             if ($this->noticias) {
                 $this->_helper->flashMessenger->addMessage(array('successo' => 'Registro alterado com sucesso'));
                 $this->_helper->redirector('sucesso');
             }
         } else {
             $form->populate($formData);
         }
     } else {
         $id = $this->_getParam('id', 0);
         if ($id > 0) {
             $form->populate($this->noticias->getId($id));
         }
     }
 }
 public function editNoticiaAction()
 {
     // action body
     $form = new Application_Form_Noticia();
     $form->submit->setLabel('Salvar');
     //$form->removeElement("tabela_contratacao");
     $this->view->form = $form;
     $noticia = new Application_Model_DbTable_Noticia();
     if ($this->getRequest()->isPost()) {
         $formData = $this->getRequest()->getPost();
         if ($form->isValid($formData)) {
             $ID_NOTICIA = $form->getValue('ID_NOTICIA');
             $DS_TITULO = $form->getValue('DS_TITULO');
             $TX_NOTICIA = $form->getValue('TX_NOTICIA');
             $FK_ARQUIVO = $form->getValue('');
             $DS_RESUMO = $form->getValue('DS_RESUMO');
             //$DT_NOTICIA= $form->getValue('');
             $data_cadastro = new Zend_Date();
             $DT_NOTICIA = $data_cadastro->get('YYYY-MM-dd HH:mm:ss');
             $FK_TIPO_NOTICIA = $form->getValue('FK_TIPO_NOTICIA');
             $FK_OPERADOR = $this->user->getId();
             try {
                 $noticia->updateNoticia($ID_NOTICIA, $DS_TITULO, $TX_NOTICIA, $FK_ARQUIVO, $DS_RESUMO, $DT_NOTICIA, $FK_TIPO_NOTICIA, $FK_OPERADOR);
                 $this->view->mensagem = "Atualizado com sucesso";
                 $this->view->erro = 0;
                 //$this->_helper->redirector('lista-usuario');
             } catch (Exception $e) {
                 $this->view->mensagem = "Atualizar notícia";
                 $this->view->erro = 1;
                 $this->view->mensagemExcecao = $e->getMessage();
                 //  echo ($e->getCode()."teste".$e->getMessage() );
             }
         } else {
             $form->populate($formData);
             $arrMessages = $form->getMessages();
             foreach ($arrMessages as $field => $arrErrors) {
                 $this->view->erro = 1;
                 $this->view->mensagem = $this->view->mensagem . $form->getElement($field)->getLabel() . $this->view->formErrors($arrErrors) . "<br>";
             }
         }
     } else {
         $id = $this->_getParam('id', 0);
         if ($id > 0) {
             $form->populate($noticia->getNoticia($id));
         }
     }
 }