public function addAction() { $form = new Form_News(); $request = $this->getRequest(); if ($request->isPost()) { if ($form->isValid($this->_request->getPost())) { $title = $this->_request->getParam('title'); $content = $this->_request->getParam('textcontent'); //$isActive = $this -> _request -> getParam('isactive'); $content = $this->check($content); echo 'end'; $user_id = Zend_Registry::get('uid'); $category = "news"; $isping = 0; $date = date("Y-m-d H:i:s"); $convert = ""; $len = strlen($content); for ($i = 0; $i < $len; $i++) { if ($content[$i] == "\"") { $convert .= """; } else { $convert .= $content[$i]; } } $content = $convert; $news = new Model_DbTable_News(); $news->insert(array('user_id' => $user_id, 'title' => $title, 'content' => $content, 'date' => $date)); $this->_redirect('index/index'); } } $form->setAction('add'); $this->view->form = $form; }
public function editnewsAction() { global $mySession; $db = new Db(); $newsId = $this->getRequest()->getParam('newsId'); $this->view->newsId = $newsId; $myform = new Form_News($newsId); $this->view->myform = $myform; $this->view->pageHeading = "Edit News"; if ($this->getRequest()->isPost()) { $request = $this->getRequest(); if ($myform->isValid($request->getPost())) { $dataForm = $myform->getValues(); $myObj = new News(); $Result = $myObj->UpdateNews($dataForm, $newsId); if ($Result == 1) { $mySession->sucessMsg = "News details updated successfully."; $this->_redirect('property/news'); } else { $mySession->errorMsg = "News date is already exists."; } } } }