コード例 #1
0
 /**
  * Update a filter
  * @param $args array
  * @param $request PKPRequest
  * @return JSONMessage JSON object
  */
 function updateFilter(&$args, $request)
 {
     if (!$request->isPost()) {
         fatalError('Cannot update filter via GET request!');
     }
     // Identify the citation to be updated
     $filter =& $this->getFilterFromArgs($request, $args, true);
     // Form initialization
     import('lib.pkp.classes.controllers.grid.filter.form.FilterForm');
     $nullVar = null;
     $filterForm = new FilterForm($filter, $this->getTitle(), $this->getFormDescription(), $nullVar);
     // No filter group required here.
     $filterForm->readInputData();
     // Form validation
     if ($filterForm->validate()) {
         // Persist the filter.
         $filterForm->execute($request);
         return DAO::getDataChangedEvent();
     } else {
         // Re-display the filter form with error messages
         // so that the user can fix it.
         return new JSONMessage(false, $filterForm->fetch($request));
     }
 }
コード例 #2
0
 /**
  * Update a filter
  * @param $args array
  * @param $request PKPRequest
  * @return string
  */
 function updateFilter(&$args, &$request)
 {
     if (!$request->isPost()) {
         fatalError('Cannot update filter via GET request!');
     }
     // Identify the citation to be updated
     $filter =& $this->getFilterFromArgs($args, true);
     // Form initialization
     import('lib.pkp.classes.controllers.grid.filter.form.FilterForm');
     $nullVar = null;
     $filterForm = new FilterForm($filter, $this->getTitle(), $this->getFormDescription(), $nullVar);
     // No filter group required here.
     $filterForm->readInputData();
     // Form validation
     if ($filterForm->validate()) {
         // Persist the filter.
         $filterForm->execute($request);
         // Render the updated filter row into
         // a JSON response
         $row =& $this->getRowInstance();
         $row->setGridId($this->getId());
         $row->setId($filter->getId());
         $row->setData($filter);
         $row->initialize($request);
         $json = new JSON('true', $this->_renderRowInternally($request, $row));
     } else {
         // Re-display the filter form with error messages
         // so that the user can fix it.
         $json = new JSON('false', $filterForm->fetch($request));
     }
     // Return the serialized JSON response
     return $json->getString();
 }