예제 #1
0
 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 .= "&quot;";
                 } 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;
 }