/**
  * Update citation with POST request data.
  * @param $args array
  * @param $request PKPRequest
  * @return Citation the saved Citation object, null on error
  */
 function &_saveCitation(&$args, &$request)
 {
     assert($request->isPost());
     // Identify the citation to be updated
     $citation =& $this->_getCitationFromArgs($args, true);
     // Form initialization
     import('controllers.grid.citation.form.CitationForm');
     $citationForm = new CitationForm($citation);
     $citationForm->readInputData();
     // Form validation
     if ($citationForm->validate()) {
         $citationForm->execute();
         return $citationForm->getCitation();
     } else {
         $nullVar = null;
         return $nullVar;
     }
 }
 /**
  * Create and validate a citation form with POST
  * request data and (optionally) persist the citation.
  * @param $args array
  * @param $request PKPRequest
  * @param $persist boolean
  * @return CitationForm the citation form for further processing
  */
 function &_handleCitationForm(&$args, &$request, $persist = true)
 {
     if (!$request->isPost()) {
         fatalError('Cannot update citation via GET request!');
     }
     // Identify the citation to be updated
     $citation =& $this->getCitationFromArgs($request, $args, true);
     // Form initialization
     import('lib.pkp.classes.controllers.grid.citation.form.CitationForm');
     $citationForm = new CitationForm($request, $citation, $this->getAssocObject());
     $citationForm->readInputData();
     // Form validation
     if ($citationForm->validate() && $persist) {
         // Persist the citation.
         $citationForm->execute();
     } else {
         // Mark the citation form "dirty".
         $citationForm->setUnsavedChanges(true);
     }
     return $citationForm;
 }
 /**
  * Update a citation
  * @param $args array
  * @param $request PKPRequest
  * @return string
  */
 function updateCitation(&$args, &$request)
 {
     // Identify the citation to be updated
     $citation =& $this->_getCitationFromArgs($args, true);
     // Form initialization
     import('controllers.grid.citation.form.CitationForm');
     $citationForm = new CitationForm($citation);
     $citationForm->readInputData();
     // Form validation
     if ($citationForm->validate()) {
         $citationForm->execute();
         // Prepare the grid row data
         $row =& $this->getRowInstance();
         $row->setGridId($this->getId());
         $row->setId($citation->getId());
         $row->setData($citation);
         $row->initialize($request);
         // Render the row into a JSON response
         $json = new JSON('true', $this->_renderRowInternally($request, $row));
     } else {
         // Return an error
         $json = new JSON('false');
     }
     // Return the serialized JSON response
     return $json->getString();
 }