예제 #1
0
 /**
  * Save the submitted form
  * @param $args array
  */
 function saveSubmit($args)
 {
     $templateMgr =& TemplateManager::getManager();
     $this->import('QuickSubmitForm');
     if (checkPhpVersion('5.0.0')) {
         // WARNING: This form needs $this in constructor
         $form = new QuickSubmitForm($this);
     } else {
         $form =& new QuickSubmitForm($this);
     }
     $form->readInputData();
     $formLocale = $form->getFormLocale();
     if (Request::getUserVar('addAuthor')) {
         $editData = true;
         $authors = $form->getData('authors');
         $authors[] = array();
         $form->setData('authors', $authors);
     } else {
         if (($delAuthor = Request::getUserVar('delAuthor')) && count($delAuthor) == 1) {
             $editData = true;
             list($delAuthor) = array_keys($delAuthor);
             $delAuthor = (int) $delAuthor;
             $authors = $form->getData('authors');
             if (isset($authors[$delAuthor]['authorId']) && !empty($authors[$delAuthor]['authorId'])) {
                 $deletedAuthors = explode(':', $form->getData('deletedAuthors'));
                 array_push($deletedAuthors, $authors[$delAuthor]['authorId']);
                 $form->setData('deletedAuthors', join(':', $deletedAuthors));
             }
             array_splice($authors, $delAuthor, 1);
             $form->setData('authors', $authors);
             if ($form->getData('primaryContact') == $delAuthor) {
                 $form->setData('primaryContact', 0);
             }
         } else {
             if (Request::getUserVar('moveAuthor')) {
                 $editData = true;
                 $moveAuthorDir = Request::getUserVar('moveAuthorDir');
                 $moveAuthorDir = $moveAuthorDir == 'u' ? 'u' : 'd';
                 $moveAuthorIndex = (int) Request::getUserVar('moveAuthorIndex');
                 $authors = $form->getData('authors');
                 if (!($moveAuthorDir == 'u' && $moveAuthorIndex <= 0 || $moveAuthorDir == 'd' && $moveAuthorIndex >= count($authors) - 1)) {
                     $tmpAuthor = $authors[$moveAuthorIndex];
                     $primaryContact = $form->getData('primaryContact');
                     if ($moveAuthorDir == 'u') {
                         $authors[$moveAuthorIndex] = $authors[$moveAuthorIndex - 1];
                         $authors[$moveAuthorIndex - 1] = $tmpAuthor;
                         if ($primaryContact == $moveAuthorIndex) {
                             $form->setData('primaryContact', $moveAuthorIndex - 1);
                         } else {
                             if ($primaryContact == $moveAuthorIndex - 1) {
                                 $form->setData('primaryContact', $moveAuthorIndex);
                             }
                         }
                     } else {
                         $authors[$moveAuthorIndex] = $authors[$moveAuthorIndex + 1];
                         $authors[$moveAuthorIndex + 1] = $tmpAuthor;
                         if ($primaryContact == $moveAuthorIndex) {
                             $form->setData('primaryContact', $moveAuthorIndex + 1);
                         } else {
                             if ($primaryContact == $moveAuthorIndex + 1) {
                                 $form->setData('primaryContact', $moveAuthorIndex);
                             }
                         }
                     }
                 }
                 $form->setData('authors', $authors);
             } else {
                 if (Request::getUserVar('uploadSubmissionFile')) {
                     $editData = true;
                     $tempFileId = $form->getData('tempFileId');
                     $tempFileId[$formLocale] = $form->uploadSubmissionFile('submissionFile');
                     $form->setData('tempFileId', $tempFileId);
                 }
             }
         }
     }
     if (Request::getUserVar('createAnother') && $form->validate()) {
         $form->execute();
         Request::redirect(null, 'manager', 'importexport', array('plugin', $this->getName()));
     } else {
         if (!isset($editData) && $form->validate()) {
             $form->execute();
             $templateMgr->display($this->getTemplatePath() . 'submitSuccess.tpl');
         } else {
             $form->display();
         }
     }
 }