示例#1
0
 /**
  * Save changes to an entry
  *
  * @return  void
  */
 public function saveTask()
 {
     // Check for request forgeries
     Request::checkToken();
     // Incoming
     $page = Request::getVar('page', array(), 'post');
     $page = array_map('trim', $page);
     // Initiate extended database class
     $row = new Page(intval($page['id']));
     if (!$row->bind($page)) {
         $this->setMessage($row->getError(), 'error');
         $this->editTask($row);
         return;
     }
     // Get parameters
     $params = Request::getVar('params', array(), 'post');
     if (is_array($params)) {
         $pparams = new \Hubzero\Config\Registry($row->get('params'));
         $pparams->merge($params);
         $row->set('params', $pparams->toString());
     }
     // Store new content
     if (!$row->store(true)) {
         $this->setMessage($row->getError(), 'error');
         $this->editTask($row);
         return;
     }
     if (!$row->updateAuthors($page['authors'])) {
         $this->setMessage($row->getError(), 'error');
         $this->editTask($row);
         return;
     }
     $row->tag($page['tags']);
     if ($this->getTask() == 'apply') {
         Request::setVar('id', $row->get('id'));
         return $this->editTask($row);
     }
     // Set the redirect
     App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_WIKI_PAGE_SAVED'));
 }