예제 #1
0
 /**
  * Save the new library file
  * @param $userId int The current user ID (for validation purposes)
  */
 function execute($userId)
 {
     // Fetch the temporary file storing the uploaded library file
     $temporaryFileDao =& DAORegistry::getDAO('TemporaryFileDAO');
     $temporaryFile =& $temporaryFileDao->getTemporaryFile($this->getData('temporaryFileId'), $userId);
     $libraryFileDao =& DAORegistry::getDAO('LibraryFileDAO');
     $libraryFileManager = new LibraryFileManager($this->pressId);
     // Convert the temporary file to a library file and store
     $libraryFile =& $libraryFileManager->copyFromTemporaryFile($temporaryFile);
     assert($libraryFile);
     $libraryFile->setPressId($this->pressId);
     $libraryFile->setName($this->getData('libraryFileName'), null);
     // Localized
     $libraryFile->setType($this->fileType);
     $libraryFileDao->insertObject($libraryFile);
     // Clean up the temporary file
     import('classes.file.TemporaryFileManager');
     $temporaryFileManager = new TemporaryFileManager();
     $temporaryFileManager->deleteFile($this->getData('temporaryFileId'), $userId);
 }
예제 #2
0
 /**
  * Save the new library file.
  * @param $userId int The current user ID (for validation purposes).
  * @return $fileId int The new library file id.
  */
 function execute($userId)
 {
     // Fetch the temporary file storing the uploaded library file
     $temporaryFileDao = DAORegistry::getDAO('TemporaryFileDAO');
     $temporaryFile = $temporaryFileDao->getTemporaryFile($this->getData('temporaryFileId'), $userId);
     $libraryFileDao = DAORegistry::getDAO('LibraryFileDAO');
     $libraryFileManager = new LibraryFileManager($this->contextId);
     // Convert the temporary file to a library file and store
     $libraryFile = $libraryFileManager->copyFromTemporaryFile($temporaryFile, $this->getData('fileType'));
     assert(isset($libraryFile));
     $libraryFile->setContextId($this->contextId);
     $libraryFile->setName($this->getData('libraryFileName'), null);
     // Localized
     $libraryFile->setType($this->getData('fileType'));
     $fileId = $libraryFileDao->insertObject($libraryFile);
     // Clean up the temporary file
     import('lib.pkp.classes.file.TemporaryFileManager');
     $temporaryFileManager = new TemporaryFileManager();
     $temporaryFileManager->deleteFile($this->getData('temporaryFileId'), $userId);
     return $fileId;
 }
예제 #3
0
 /**
  * Delete all attachments associated with this message.
  * Called from send().
  * @param $userId int
  */
 function _clearAttachments($userId)
 {
     import('file.TemporaryFileManager');
     $temporaryFileManager = new TemporaryFileManager();
     $persistAttachments = Request::getUserVar('persistAttachments');
     if (is_array($persistAttachments)) {
         foreach ($persistAttachments as $fileId) {
             $temporaryFile = $temporaryFileManager->getFile($fileId, $userId);
             if (!empty($temporaryFile)) {
                 $temporaryFileManager->deleteFile($temporaryFile->getId(), $userId);
             }
         }
     }
 }
 /**
  * Save the metadata and store the catalog data for this published
  * monograph.
  */
 function execute($request)
 {
     parent::execute();
     $monograph = $this->getMonograph();
     $monographDao = DAORegistry::getDAO('MonographDAO');
     $publishedMonographDao = DAORegistry::getDAO('PublishedMonographDAO');
     $publishedMonograph = $publishedMonographDao->getById($monograph->getId(), null, false);
     /* @var $publishedMonograph PublishedMonograph */
     $isExistingEntry = $publishedMonograph ? true : false;
     if (!$publishedMonograph) {
         $publishedMonograph = $publishedMonographDao->newDataObject();
         $publishedMonograph->setId($monograph->getId());
     }
     // Populate the published monograph with the cataloging metadata
     $publishedMonograph->setAudience($this->getData('audience'));
     $publishedMonograph->setAudienceRangeQualifier($this->getData('audienceRangeQualifier'));
     $publishedMonograph->setAudienceRangeFrom($this->getData('audienceRangeFrom'));
     $publishedMonograph->setAudienceRangeTo($this->getData('audienceRangeTo'));
     $publishedMonograph->setAudienceRangeExact($this->getData('audienceRangeExact'));
     // If a cover image was uploaded, deal with it.
     if ($temporaryFileId = $this->getData('temporaryFileId')) {
         // Fetch the temporary file storing the uploaded library file
         $temporaryFileDao = DAORegistry::getDAO('TemporaryFileDAO');
         $temporaryFile = $temporaryFileDao->getTemporaryFile($temporaryFileId, $this->_userId);
         $temporaryFilePath = $temporaryFile->getFilePath();
         import('classes.file.SimpleMonographFileManager');
         $simpleMonographFileManager = new SimpleMonographFileManager($monograph->getPressId(), $publishedMonograph->getId());
         $basePath = $simpleMonographFileManager->getBasePath();
         // Delete the old file if it exists
         $oldSetting = $publishedMonograph->getCoverImage();
         if ($oldSetting) {
             $simpleMonographFileManager->deleteFile($basePath . $oldSetting['thumbnailName']);
             $simpleMonographFileManager->deleteFile($basePath . $oldSetting['catalogName']);
             $simpleMonographFileManager->deleteFile($basePath . $oldSetting['name']);
         }
         // The following variables were fetched in validation
         assert($this->_sizeArray && $this->_imageExtension);
         // Load the cover image for surrogate production
         $cover = null;
         // Scrutinizer
         switch ($this->_imageExtension) {
             case '.jpg':
                 $cover = imagecreatefromjpeg($temporaryFilePath);
                 break;
             case '.png':
                 $cover = imagecreatefrompng($temporaryFilePath);
                 break;
             case '.gif':
                 $cover = imagecreatefromgif($temporaryFilePath);
                 break;
         }
         assert(isset($cover));
         // Copy the new file over (involves creating the appropriate subdirectory too)
         $filename = 'cover' . $this->_imageExtension;
         $simpleMonographFileManager->copyFile($temporaryFile->getFilePath(), $basePath . $filename);
         // Generate surrogate images (thumbnail and catalog image)
         $press = $request->getPress();
         $coverThumbnailsMaxWidth = $press->getSetting('coverThumbnailsMaxWidth');
         $coverThumbnailsMaxHeight = $press->getSetting('coverThumbnailsMaxHeight');
         $thumbnailImageInfo = $this->_buildSurrogateImage($cover, $basePath, SUBMISSION_IMAGE_TYPE_THUMBNAIL, $coverThumbnailsMaxWidth, $coverThumbnailsMaxHeight);
         $catalogImageInfo = $this->_buildSurrogateImage($cover, $basePath, SUBMISSION_IMAGE_TYPE_CATALOG);
         // Clean up
         imagedestroy($cover);
         $publishedMonograph->setCoverImage(array('name' => $filename, 'width' => $this->_sizeArray[0], 'height' => $this->_sizeArray[1], 'thumbnailName' => $thumbnailImageInfo['filename'], 'thumbnailWidth' => $thumbnailImageInfo['width'], 'thumbnailHeight' => $thumbnailImageInfo['height'], 'catalogName' => $catalogImageInfo['filename'], 'catalogWidth' => $catalogImageInfo['width'], 'catalogHeight' => $catalogImageInfo['height'], 'uploadName' => $temporaryFile->getOriginalFileName(), 'dateUploaded' => Core::getCurrentDate()));
         // Clean up the temporary file
         import('lib.pkp.classes.file.TemporaryFileManager');
         $temporaryFileManager = new TemporaryFileManager();
         $temporaryFileManager->deleteFile($temporaryFileId, $this->_userId);
     }
     if ($this->getData('attachPermissions')) {
         $monograph->setCopyrightYear($this->getData('copyrightYear'));
         $monograph->setCopyrightHolder($this->getData('copyrightHolder'), null);
         // Localized
         $monograph->setLicenseURL($this->getData('licenseURL'));
     } else {
         $monograph->setCopyrightYear(null);
         $monograph->setCopyrightHolder(null, null);
         $monograph->setLicenseURL(null);
     }
     $monographDao->updateObject($monograph);
     // Update the modified fields or insert new.
     if ($isExistingEntry) {
         $publishedMonographDao->updateObject($publishedMonograph);
     } else {
         $publishedMonographDao->insertObject($publishedMonograph);
     }
     import('classes.publicationFormat.PublicationFormatTombstoneManager');
     $publicationFormatTombstoneMgr = new PublicationFormatTombstoneManager();
     $publicationFormatDao = DAORegistry::getDAO('PublicationFormatDAO');
     $publicationFormatFactory = $publicationFormatDao->getBySubmissionId($monograph->getId());
     $publicationFormats = $publicationFormatFactory->toAssociativeArray();
     $notificationMgr = new NotificationManager();
     if ($this->getData('confirm')) {
         // Update the monograph status.
         $monograph->setStatus(STATUS_PUBLISHED);
         $monographDao->updateObject($monograph);
         $publishedMonograph->setDatePublished(Core::getCurrentDate());
         $publishedMonographDao->updateObject($publishedMonograph);
         $notificationMgr->updateNotification($request, array(NOTIFICATION_TYPE_APPROVE_SUBMISSION), null, ASSOC_TYPE_MONOGRAPH, $publishedMonograph->getId());
         // Remove publication format tombstones.
         $publicationFormatTombstoneMgr->deleteTombstonesByPublicationFormats($publicationFormats);
         // Update the search index for this published monograph.
         import('classes.search.MonographSearchIndex');
         MonographSearchIndex::indexMonographMetadata($monograph);
         // Log the publication event.
         import('lib.pkp.classes.log.SubmissionLog');
         SubmissionLog::logEvent($request, $monograph, SUBMISSION_LOG_METADATA_PUBLISH, 'submission.event.metadataPublished');
     } else {
         if ($isExistingEntry) {
             // Update the monograph status.
             $monograph->setStatus(STATUS_QUEUED);
             $monographDao->updateObject($monograph);
             // Unpublish monograph.
             $publishedMonograph->setDatePublished(null);
             $publishedMonographDao->updateObject($publishedMonograph);
             $notificationMgr->updateNotification($request, array(NOTIFICATION_TYPE_APPROVE_SUBMISSION), null, ASSOC_TYPE_MONOGRAPH, $publishedMonograph->getId());
             // Create tombstones for each publication format.
             $publicationFormatTombstoneMgr->insertTombstonesByPublicationFormats($publicationFormats, $request->getContext());
             // Log the unpublication event.
             import('lib.pkp.classes.log.SubmissionLog');
             SubmissionLog::logEvent($request, $monograph, SUBMISSION_LOG_METADATA_UNPUBLISH, 'submission.event.metadataUnpublished');
         }
     }
 }
예제 #5
0
 /**
  * Save series.
  * @param $args array
  * @param $request PKPRequest
  */
 function execute($args, $request)
 {
     $seriesDao = DAORegistry::getDAO('SeriesDAO');
     $press = $request->getPress();
     // Get or create the series object
     if ($this->getSeriesId()) {
         $series = $seriesDao->getById($this->getSeriesId(), $press->getId());
     } else {
         $series = $seriesDao->newDataObject();
         $series->setPressId($press->getId());
     }
     // Populate/update the series object from the form
     $series->setPath($this->getData('path'));
     $series->setFeatured($this->getData('featured'));
     $series->setTitle($this->getData('title'), null);
     // Localized
     $series->setDescription($this->getData('description'), null);
     // Localized
     $series->setPrefix($this->getData('prefix'), null);
     // Localized
     $series->setSubtitle($this->getData('subtitle'), null);
     // Localized
     $series->setEditorRestricted($this->getData('restricted'));
     $series->setOnlineISSN($this->getData('onlineIssn'));
     $series->setPrintISSN($this->getData('printIssn'));
     $series->setSortOption($this->getData('sortOption'));
     // Insert or update the series in the DB
     if ($this->getSeriesId()) {
         $seriesDao->updateObject($series);
     } else {
         $this->setSeriesId($seriesDao->insertObject($series));
     }
     // Handle the image upload if there was one.
     if ($temporaryFileId = $this->getData('temporaryFileId')) {
         // Fetch the temporary file storing the uploaded library file
         $temporaryFileDao = DAORegistry::getDAO('TemporaryFileDAO');
         $temporaryFile = $temporaryFileDao->getTemporaryFile($temporaryFileId, $this->_userId);
         $temporaryFilePath = $temporaryFile->getFilePath();
         import('lib.pkp.classes.file.ContextFileManager');
         $pressFileManager = new ContextFileManager($press->getId());
         $basePath = $pressFileManager->getBasePath() . '/series/';
         // Delete the old file if it exists
         $oldSetting = $series->getImage();
         if ($oldSetting) {
             $pressFileManager->deleteFile($basePath . $oldSetting['thumbnailName']);
             $pressFileManager->deleteFile($basePath . $oldSetting['name']);
         }
         // The following variables were fetched in validation
         assert($this->_sizeArray && $this->_imageExtension);
         // Generate the surrogate image.
         switch ($this->_imageExtension) {
             case '.jpg':
                 $image = imagecreatefromjpeg($temporaryFilePath);
                 break;
             case '.png':
                 $image = imagecreatefrompng($temporaryFilePath);
                 break;
             case '.gif':
                 $image = imagecreatefromgif($temporaryFilePath);
                 break;
             default:
                 $image = null;
                 // Suppress warn
         }
         assert($image);
         $coverThumbnailsMaxWidth = $press->getSetting('coverThumbnailsMaxWidth');
         $coverThumbnailsMaxHeight = $press->getSetting('coverThumbnailsMaxHeight');
         $thumbnailFilename = $series->getId() . '-series-thumbnail' . $this->_imageExtension;
         $xRatio = min(1, $coverThumbnailsMaxWidth / $this->_sizeArray[0]);
         $yRatio = min(1, $coverThumbnailsMaxHeight / $this->_sizeArray[1]);
         $ratio = min($xRatio, $yRatio);
         $thumbnailWidth = round($ratio * $this->_sizeArray[0]);
         $thumbnailHeight = round($ratio * $this->_sizeArray[1]);
         $thumbnail = imagecreatetruecolor($thumbnailWidth, $thumbnailHeight);
         imagecopyresampled($thumbnail, $image, 0, 0, 0, 0, $thumbnailWidth, $thumbnailHeight, $this->_sizeArray[0], $this->_sizeArray[1]);
         // Copy the new file over
         $filename = $series->getId() . '-series' . $this->_imageExtension;
         $pressFileManager->copyFile($temporaryFile->getFilePath(), $basePath . $filename);
         switch ($this->_imageExtension) {
             case '.jpg':
                 imagejpeg($thumbnail, $basePath . $thumbnailFilename);
                 break;
             case '.png':
                 imagepng($thumbnail, $basePath . $thumbnailFilename);
                 break;
             case '.gif':
                 imagegif($thumbnail, $basePath . $thumbnailFilename);
                 break;
         }
         imagedestroy($thumbnail);
         imagedestroy($image);
         $series->setImage(array('name' => $filename, 'width' => $this->_sizeArray[0], 'height' => $this->_sizeArray[1], 'thumbnailName' => $thumbnailFilename, 'thumbnailWidth' => $thumbnailWidth, 'thumbnailHeight' => $thumbnailHeight, 'uploadName' => $temporaryFile->getOriginalFileName(), 'dateUploaded' => Core::getCurrentDate()));
         // Clean up the temporary file
         import('lib.pkp.classes.file.TemporaryFileManager');
         $temporaryFileManager = new TemporaryFileManager();
         $temporaryFileManager->deleteFile($temporaryFileId, $this->_userId);
     }
     // Update series object to store image information.
     $seriesDao->updateObject($series);
     import('lib.pkp.classes.controllers.listbuilder.ListbuilderHandler');
     // Save the series editor associations.
     ListbuilderHandler::unpack($request, $this->getData('subEditors'), array(&$this, 'deleteSubEditorEntry'), array(&$this, 'insertSubEditorEntry'), array(&$this, 'updateSubEditorEntry'));
     // Save the category associations.
     ListbuilderHandler::unpack($request, $this->getData('categories'), array(&$this, 'deleteCategoryEntry'), array(&$this, 'insertCategoryEntry'), array(&$this, 'updateCategoryEntry'));
     return true;
 }
예제 #6
0
 /**
  * @see Form::execute()
  */
 function execute($request)
 {
     $categoryId = $this->getCategoryId();
     $categoryDao = DAORegistry::getDAO('CategoryDAO');
     // Get a category object to edit or create
     if ($categoryId == null) {
         $category = $categoryDao->newDataObject();
         $category->setPressId($this->getPressId());
     } else {
         $category = $categoryDao->getById($categoryId, $this->getPressId());
     }
     // Set the editable properties of the category object
     $category->setTitle($this->getData('name'), null);
     // Localized
     $category->setDescription($this->getData('description'), null);
     // Localized
     $category->setParentId($this->getData('parentId'));
     $category->setPath($this->getData('path'));
     $category->setSortOption($this->getData('sortOption'));
     // Update or insert the category object
     if ($categoryId == null) {
         $category->setId($categoryDao->insertObject($category));
     } else {
         $category->setSequence(REALLY_BIG_NUMBER);
         $categoryDao->updateObject($category);
         $categoryDao->resequenceCategories($this->getPressId());
     }
     // Handle the image upload if there was one.
     if ($temporaryFileId = $this->getData('temporaryFileId')) {
         // Fetch the temporary file storing the uploaded library file
         $temporaryFileDao = DAORegistry::getDAO('TemporaryFileDAO');
         $temporaryFile = $temporaryFileDao->getTemporaryFile($temporaryFileId, $this->_userId);
         $temporaryFilePath = $temporaryFile->getFilePath();
         import('lib.pkp.classes.file.ContextFileManager');
         $pressFileManager = new ContextFileManager($this->getPressId());
         $basePath = $pressFileManager->getBasePath() . '/categories/';
         // Delete the old file if it exists
         $oldSetting = $category->getImage();
         if ($oldSetting) {
             $pressFileManager->deleteFile($basePath . $oldSetting['thumbnailName']);
             $pressFileManager->deleteFile($basePath . $oldSetting['name']);
         }
         // The following variables were fetched in validation
         assert($this->_sizeArray && $this->_imageExtension);
         // Generate the surrogate images.
         switch ($this->_imageExtension) {
             case '.jpg':
                 $image = imagecreatefromjpeg($temporaryFilePath);
                 break;
             case '.png':
                 $image = imagecreatefrompng($temporaryFilePath);
                 break;
             case '.gif':
                 $image = imagecreatefromgif($temporaryFilePath);
                 break;
             default:
                 $image = null;
                 // Suppress warn
         }
         assert($image);
         $press = $request->getPress();
         $coverThumbnailsMaxWidth = $press->getSetting('coverThumbnailsMaxWidth');
         $coverThumbnailsMaxHeight = $press->getSetting('coverThumbnailsMaxHeight');
         $thumbnailFilename = $category->getId() . '-category-thumbnail' . $this->_imageExtension;
         $xRatio = min(1, $coverThumbnailsMaxWidth / $this->_sizeArray[0]);
         $yRatio = min(1, $coverThumbnailsMaxHeight / $this->_sizeArray[1]);
         $ratio = min($xRatio, $yRatio);
         $thumbnailWidth = round($ratio * $this->_sizeArray[0]);
         $thumbnailHeight = round($ratio * $this->_sizeArray[1]);
         $thumbnail = imagecreatetruecolor($thumbnailWidth, $thumbnailHeight);
         imagecopyresampled($thumbnail, $image, 0, 0, 0, 0, $thumbnailWidth, $thumbnailHeight, $this->_sizeArray[0], $this->_sizeArray[1]);
         // Copy the new file over
         $filename = $category->getId() . '-category' . $this->_imageExtension;
         $pressFileManager->copyFile($temporaryFile->getFilePath(), $basePath . $filename);
         switch ($this->_imageExtension) {
             case '.jpg':
                 imagejpeg($thumbnail, $basePath . $thumbnailFilename);
                 break;
             case '.png':
                 imagepng($thumbnail, $basePath . $thumbnailFilename);
                 break;
             case '.gif':
                 imagegif($thumbnail, $basePath . $thumbnailFilename);
                 break;
         }
         imagedestroy($thumbnail);
         imagedestroy($image);
         $category->setImage(array('name' => $filename, 'width' => $this->_sizeArray[0], 'height' => $this->_sizeArray[1], 'thumbnailName' => $thumbnailFilename, 'thumbnailWidth' => $thumbnailWidth, 'thumbnailHeight' => $thumbnailHeight, 'uploadName' => $temporaryFile->getOriginalFileName(), 'dateUploaded' => Core::getCurrentDate()));
         // Clean up the temporary file
         import('lib.pkp.classes.file.TemporaryFileManager');
         $temporaryFileManager = new TemporaryFileManager();
         $temporaryFileManager->deleteFile($temporaryFileId, $this->_userId);
     }
     // Update category object to store image information.
     $categoryDao->updateObject($category);
     return $category;
 }
 /**
  * Clean temporary file.
  * @param $request Request
  */
 function removeTemporaryFile($request)
 {
     $user = $request->getUser();
     import('lib.pkp.classes.file.TemporaryFileManager');
     $temporaryFileManager = new TemporaryFileManager();
     $temporaryFileManager->deleteFile($this->getData('temporaryFileId'), $user->getId());
 }
예제 #8
0
 /**
  * Display the plugin.
  * @param $args array
  * @param $request PKPRequest
  */
 function display($args, $request)
 {
     $templateMgr = TemplateManager::getManager($request);
     $context = $request->getContext();
     parent::display($args, $request);
     $templateMgr->assign('plugin', $this);
     switch (array_shift($args)) {
         case 'index':
         case '':
             $templateMgr->display($this->getTemplatePath() . 'index.tpl');
             break;
         case 'uploadImportXML':
             $user = $request->getUser();
             import('lib.pkp.classes.file.TemporaryFileManager');
             $temporaryFileManager = new TemporaryFileManager();
             $temporaryFile = $temporaryFileManager->handleUpload('uploadedFile', $user->getId());
             if ($temporaryFile) {
                 $json = new JSONMessage(true);
                 $json->setAdditionalAttributes(array('temporaryFileId' => $temporaryFile->getId()));
             } else {
                 $json = new JSONMessage(false, __('common.uploadFailed'));
             }
             return $json->getString();
         case 'importBounce':
             $json = new JSONMessage(true);
             $json->setEvent('addTab', array('title' => __('plugins.importexport.users.results'), 'url' => $request->url(null, null, null, array('plugin', $this->getName(), 'import'), array('temporaryFileId' => $request->getUserVar('temporaryFileId')))));
             return $json->getString();
         case 'import':
             $temporaryFileId = $request->getUserVar('temporaryFileId');
             $temporaryFileDao = DAORegistry::getDAO('TemporaryFileDAO');
             $user = $request->getUser();
             $temporaryFile = $temporaryFileDao->getTemporaryFile($temporaryFileId, $user->getId());
             if (!$temporaryFile) {
                 $json = new JSONMessage(true, __('plugins.importexport.users.uploadFile'));
                 return $json->getString();
             }
             $temporaryFilePath = $temporaryFile->getFilePath();
             libxml_use_internal_errors(true);
             $users = $this->importUsers(file_get_contents($temporaryFilePath), $context, $user);
             $validationErrors = array_filter(libxml_get_errors(), create_function('$a', 'return $a->level == LIBXML_ERR_ERROR ||  $a->level == LIBXML_ERR_FATAL;'));
             $templateMgr->assign('validationErrors', $validationErrors);
             libxml_clear_errors();
             $templateMgr->assign('users', $users);
             $json = new JSONMessage(true, $templateMgr->fetch($this->getTemplatePath() . 'results.tpl'));
             return $json->getString();
         case 'export':
             $exportXml = $this->exportUsers((array) $request->getUserVar('selectedUsers'), $request->getContext(), $request->getUser());
             import('lib.pkp.classes.file.FileManager');
             $fileManager = new FileManager();
             $exportFileName = $this->getExportFileName($this->getExportPath(), 'users', $context, '.xml');
             $fileManager->writeFile($exportFileName, $exportXml);
             $fileManager->downloadFile($exportFileName);
             $fileManager->deleteFile($exportFileName);
             break;
         case 'exportAllUsers':
             $exportXml = $this->exportAllUsers($request->getContext(), $request->getUser());
             import('lib.pkp.classes.file.TemporaryFileManager');
             $fileManager = new TemporaryFileManager();
             $exportFileName = $this->getExportFileName($this->getExportPath(), 'users', $context, '.xml');
             $fileManager->writeFile($exportFileName, $exportXml);
             $fileManager->downloadFile($exportFileName);
             $fileManager->deleteFile($exportFileName);
             break;
         default:
             $dispatcher = $request->getDispatcher();
             $dispatcher->handle404();
     }
 }
 /**
  * Batch import from an ONIX XML export.
  * @param array $args
  * @param PKPRequest $request
  */
 function uploadONIXObjectForReview($args, &$request)
 {
     $user = $request->getUser();
     $journal =& $request->getJournal();
     $ofrOrgDao =& DAORegistry::getDAO('ObjectForReviewOrganizationDAO');
     $ofrPlugin =& $this->_getObjectsForReviewPlugin();
     $ofrPlugin->import('classes.form.ObjectForReviewForm');
     $reviewObjectTypeId = (int) $request->getUserVar('reviewObjectTypeId');
     import('classes.file.TemporaryFileManager');
     $temporaryFileManager = new TemporaryFileManager();
     $temporaryFile = $temporaryFileManager->handleUpload('onixFile', $user->getId());
     $filePath = $temporaryFile->getFilePath();
     $parser = new XMLParser();
     $doc =& $parser->parse($filePath);
     $multiple = $request->getUserVar('multiple');
     if ($doc) {
         // Determine if we have short or long tags.
         $productNodes = $doc->getChildByName('product');
         $shortTags = $productNodes ? true : false;
         for ($index = 0; $productNode = $doc->getChildByName($this->_getOnixTag('Product', $shortTags), $index); $index++) {
             $importData = array();
             if ($productNode) {
                 $publisherNode = $productNode->getChildByName($this->_getOnixTag('Publisher', $shortTags));
                 if ($publisherNode) {
                     $publisherNameNode = $publisherNode->getChildByName($this->_getOnixTag('PublisherName', $shortTags));
                     if ($publisherNameNode) {
                         $publisher = $publisherNameNode->getValue();
                         $organization =& $ofrOrgDao->getOrganizationByName(trim($publisher));
                         if ($organization) {
                             $importData['publisherId'] = $organization->getId();
                         }
                     }
                 }
                 $websiteNode = $publisherNode->getChildByName($this->_getOnixTag('Website', $shortTags));
                 if ($websiteNode) {
                     $websiteLinkNode = $websiteNode->getChildByName($this->_getOnixTag('WebsiteLink', $shortTags));
                     $websiteLink = $websiteLinkNode->getValue();
                     $importData['book_publisher_url'] = $websiteLink;
                 }
                 $titleNode = $productNode->getChildByName($this->_getOnixTag('Title', $shortTags));
                 if ($titleNode) {
                     $titleTextNode = $titleNode->getChildByName($this->_getOnixTag('TitleText', $shortTags));
                     $title = $titleTextNode->getValue();
                     $importData['title'] = $title;
                 }
                 $subTitleNode = $titleNode->getChildByName($this->_getOnixTag('Subtitle', $shortTags));
                 if ($subTitleNode) {
                     $subTitle = $subTitleNode->getValue();
                     $importData['shortTitle'] = $subTitle;
                 }
                 $seriesNode = $productNode->getChildByName($this->_getOnixTag('Series', $shortTags));
                 if ($seriesNode) {
                     $seriesTextNode = $seriesNode->getChildByName($this->_getOnixTag('TitleOfSeries', $shortTags));
                     $series = $seriesTextNode->getValue();
                     $importData['book_series'] = $series;
                 }
                 $languageNode = $productNode->getChildByName($this->_getOnixTag('Language', $shortTags));
                 if ($languageNode) {
                     $languageCodeNode = $languageNode->getChildByName($this->_getOnixTag('LanguageCode', $shortTags));
                     $language = $languageCodeNode->getValue();
                     $importData['language'] = substr($language, 0, 2);
                 } else {
                     $importData['language'] = 'en';
                 }
                 $pageNode = $productNode->getChildByName($this->_getOnixTag('NumberOfPages', $shortTags));
                 if ($pageNode) {
                     $pages = $pageNode->getValue();
                     $importData['book_pages_no'] = $pages;
                 }
                 // Abstract. Look for OtherText with
                 // sub element of TextTypeCode of '01' (main description)
                 $abstract = '';
                 for ($authorIndex = 0; $node = $productNode->getChildByName($this->_getOnixTag('OtherText', $shortTags), $authorIndex); $authorIndex++) {
                     $typeNode = $node->getChildByName($this->_getOnixTag('TextTypeCode', $shortTags));
                     if ($typeNode && $typeNode->getValue() == '01') {
                         $textNode = $node->getChildByName($this->_getOnixTag('Text', $shortTags));
                         if ($textNode) {
                             $abstract = strip_tags($textNode->getValue());
                         }
                         break;
                     }
                 }
                 $importData['abstract'] = $abstract;
                 // ISBN-13
                 for ($productIdentifierIndex = 0; $node = $productNode->getChildByName($this->_getOnixTag('ProductIdentifier', $shortTags), $productIdentifierIndex); $productIdentifierIndex++) {
                     $idTypeNode = $node->getChildByName($this->_getOnixTag('ProductIDType', $shortTags));
                     if ($idTypeNode && $idTypeNode->getValue() == '15') {
                         // ISBN-13
                         $textNode = $node->getChildByName($this->_getOnixTag('IDValue', $shortTags));
                         if ($textNode) {
                             $importData['book_isbn'] = $textNode->getValue();
                         }
                         break;
                     }
                 }
                 // Subjects
                 $importData['subjectKeywords'] = '';
                 $subjects = array();
                 for ($subjectIndex = 0; $node = $productNode->getChildByName($this->_getOnixTag('Subject', $shortTags), $subjectIndex); $subjectIndex++) {
                     $textNode = $node->getChildByName($this->_getOnixTag('SubjectHeadingText', $shortTags));
                     if ($textNode) {
                         $subjects[] = $textNode->getValue();
                     }
                 }
                 $importData['subjectKeywords'] = join(', ', $subjects);
                 $publicationDateNode = $productNode->getChildByName($this->_getOnixTag('PublicationDate', $shortTags));
                 if ($publicationDateNode) {
                     $publicationDate = $publicationDateNode->getValue();
                     $importData['date'] = $publicationDate;
                 }
                 // Contributors.
                 $persons = array();
                 for ($authorIndex = 0; $node = $productNode->getChildByName($this->_getOnixTag('Contributor', $shortTags), $authorIndex); $authorIndex++) {
                     $firstNameNode = $node->getChildByName($this->_getOnixTag('NamesBeforeKey', $shortTags));
                     if ($firstNameNode) {
                         $firstName = $firstNameNode->getValue();
                     }
                     $lastNameNode = $node->getChildByName($this->_getOnixTag('KeyNames', $shortTags));
                     if ($lastNameNode) {
                         $lastName = $lastNameNode->getValue();
                     }
                     $seqNode = $node->getChildByName($this->_getOnixTag('SequenceNumber', $shortTags));
                     if ($seqNode) {
                         $seq = $seqNode->getValue();
                     }
                     $contributorRoleNode = $node->getChildByName($this->_getOnixTag('ContributorRole', $shortTags));
                     $contributorRole = '';
                     if ($contributorRoleNode) {
                         switch ($contributorRoleNode->getValue()) {
                             case 'A01':
                                 $contributorRole = '1';
                                 break;
                             case 'B01':
                                 $contributorRole = '3';
                                 break;
                             case 'B09':
                                 $contributorRole = '4';
                                 break;
                             case 'B06':
                                 $contributorRole = '5';
                                 break;
                             default:
                                 $contributorRole = '2';
                                 // Contributor
                                 break;
                         }
                     }
                     $persons[] = array('personId' => '', 'role' => $contributorRole, 'firstName' => $firstName, 'middleName' => '', 'lastName' => $lastName, 'seq' => (int) $seq);
                     unset($node);
                 }
                 $importData['persons'] = $persons;
                 if (!$multiple) {
                     $temporaryFileManager->deleteFile($temporaryFile->getId(), $user->getId());
                     $this->editObjectForReview($args, &$request, $importData);
                     break;
                 } else {
                     // we are processing more than one Product.  Instaniate the form and let it
                     // handle the object creation.
                     $ofrForm = new ObjectForReviewForm($ofrPlugin->getName(), null, $reviewObjectTypeId, $importData);
                     $ofrForm->initData();
                     $ofrForm->execute();
                 }
             } else {
                 $request->redirect(null, 'editor', 'objectsForReview', 'onixError');
             }
         }
         $request->redirect(null, 'editor', 'objectsForReview');
     } else {
         // this deleteFile is only called if the document does not parse.
         $temporaryFileManager->deleteFile($temporaryFile->getId(), $user->getId());
         $request->redirect(null, 'editor', 'objectsForReview');
     }
 }