예제 #1
0
 /**
  * @copydoc PKPManageFileApiHandler::removeFileIndex()
  */
 function removeFileIndex($submission, $submissionFile)
 {
     // update the submission's search index if this was a proof file
     if ($submissionFile->getFileStage() == SUBMISSION_FILE_PROOF) {
         import('lib.pkp.classes.search.SubmissionSearch');
         import('classes.search.MonographSearchIndex');
         MonographSearchIndex::deleteTextIndex($submission->getId(), SUBMISSION_SEARCH_GALLEY_FILE, $submissionFile->getFileId());
     }
 }
예제 #2
0
 /**
  * @see Filter::process()
  * @param $document DOMDocument|string
  * @return array Array of imported documents
  */
 function &process(&$document)
 {
     $importedObjects =& parent::process($document);
     // Index imported content
     import('classes.search.MonographSearchIndex');
     foreach ($importedObjects as $submission) {
         assert(is_a($submission, 'Submission'));
         MonographSearchIndex::indexMonographMetadata($submission);
         MonographSearchIndex::indexMonographFiles($submission);
     }
     return $importedObjects;
 }
예제 #3
0
 /**
  * Save changes to submission.
  * @param $request PKPRequest
  */
 function execute($request)
 {
     parent::execute($request);
     $submission = $this->getSubmission();
     $submissionDao = Application::getSubmissionDAO();
     // Clean any new release or feature object that may
     // exist associated with the current submission series.
     $newReleaseDao = DAORegistry::getDAO('NewReleaseDAO');
     /* @var $newReleaseDao NewReleaseDAO */
     $newReleaseDao->deleteNewRelease($submission->getId(), ASSOC_TYPE_SERIES, $submission->getSeriesId());
     $featureDao = DAORegistry::getDAO('FeatureDAO');
     /* @var $featureDao FeatureDAO */
     $featureDao->deleteFeature($submission->getId(), ASSOC_TYPE_SERIES, $submission->getSeriesId());
     $submission->setSeriesId($this->getData('seriesId'));
     $submission->setSeriesPosition($this->getData('seriesPosition'));
     $submissionDao->updateObject($submission);
     if ($submission->getDatePublished()) {
         import('classes.search.MonographSearchIndex');
         MonographSearchIndex::indexMonographMetadata($submission);
     }
 }
 /**
  * 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');
         }
     }
 }
 /**
  * Rebuild the search index for all monographs in all presses.
  */
 function execute()
 {
     MonographSearchIndex::rebuildIndex(true);
 }
 /**
  * Approve a proof submission file.
  * @param $args array
  * @param $request PKPRequest
  * @return JSONMessage JSON object
  */
 function saveApproveProof($args, $request)
 {
     $submissionFile = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION_FILE);
     $submission = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION);
     // Make sure we only alter files associated with a publication format.
     if ($submissionFile->getAssocType() !== ASSOC_TYPE_PUBLICATION_FORMAT) {
         fatalError('The requested file is not associated with any publication format.');
     }
     if ($submissionFile->getViewable()) {
         // No longer expose the file to readers.
         $submissionFile->setViewable(false);
     } else {
         // Expose the file to readers (e.g. via e-commerce).
         $submissionFile->setViewable(true);
         // Log the approve proof event.
         import('lib.pkp.classes.log.SubmissionLog');
         import('classes.log.SubmissionEventLogEntry');
         // constants
         $user = $request->getUser();
         $publicationFormatDao = DAORegistry::getDAO('PublicationFormatDAO');
         $publicationFormat = $publicationFormatDao->getById($submissionFile->getAssocId(), $submission->getId());
         SubmissionLog::logEvent($request, $submission, SUBMISSION_LOG_PROOFS_APPROVED, 'submission.event.proofsApproved', array('formatName' => $publicationFormat->getLocalizedName(), 'name' => $user->getFullName(), 'username' => $user->getUsername()));
     }
     $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO');
     $submissionFileDao->updateObject($submissionFile);
     // update the submission's file index
     import('classes.search.MonographSearchIndex');
     MonographSearchIndex::clearMonographFiles($submission);
     MonographSearchIndex::indexMonographFiles($submission);
     return DAO::getDataChangedEvent($submissionFile->getId());
 }
예제 #7
0
 /**
  * @copydoc SubmissionDAO::deleteById
  */
 function deleteById($submissionId)
 {
     parent::deleteById($submissionId);
     $publishedMonographDao = DAORegistry::getDAO('PublishedMonographDAO');
     $publishedMonographDao->deleteById($submissionId);
     // Delete chapters and assigned chapter authors.
     $chapterDao = DAORegistry::getDAO('ChapterDAO');
     $chapters = $chapterDao->getChapters($submissionId);
     while ($chapter = $chapters->next()) {
         // also removes Chapter Author associations
         $chapterDao->deleteObject($chapter);
     }
     // Delete references to features or new releases.
     $featureDao = DAORegistry::getDAO('FeatureDAO');
     $featureDao->deleteByMonographId($submissionId);
     $newReleaseDao = DAORegistry::getDAO('NewReleaseDAO');
     $newReleaseDao->deleteByMonographId($submissionId);
     import('classes.search.MonographSearchIndex');
     MonographSearchIndex::deleteTextIndex($submissionId);
 }
예제 #8
0
 /**
  * Rebuild the search index for all presses.
  */
 function rebuildIndex($log = false)
 {
     // Clear index
     if ($log) {
         echo 'Clearing index ... ';
     }
     $searchDao =& DAORegistry::getDAO('MonographSearchDAO');
     // FIXME Abstract into MonographSearchDAO?
     $searchDao->update('DELETE FROM monograph_search_object_keywords');
     $searchDao->update('DELETE FROM monograph_search_objects');
     $searchDao->update('DELETE FROM monograph_search_keyword_list');
     $searchDao->setCacheDir(Config::getVar('files', 'files_dir') . '/_db');
     $searchDao->_dataSource->CacheFlush();
     if ($log) {
         echo "done\n";
     }
     // Build index
     $pressDao =& DAORegistry::getDAO('PressDAO');
     $monographDao =& DAORegistry::getDAO('MonographDAO');
     $presses =& $pressDao->getPresses();
     while (!$presses->eof()) {
         $press =& $presses->next();
         $numIndexed = 0;
         if ($log) {
             echo "Indexing \"", $press->getLocalizedTitle(), "\" ... ";
         }
         $monographs =& $monographDao->getMonographs($press->getPressId());
         while (!$monographs->eof()) {
             $monograph =& $monographs->next();
             if ($monograph->getDateSubmitted()) {
                 MonographSearchIndex::indexMonographMetadata($monograph);
                 MonographSearchIndex::indexMonographFiles($monograph);
                 $numIndexed++;
             }
             unset($monograph);
         }
         if ($log) {
             echo $numIndexed, " monographs indexed\n";
         }
         unset($press);
     }
 }
예제 #9
0
 /**
  * Query parsing helper routine.
  * Returned structure is based on that used by the Search::QueryParser Perl module.
  */
 function _parseQuery($signTokens, $tokens, &$pos, $total)
 {
     $return = array('+' => array(), '' => array(), '-' => array());
     $postBool = $preBool = '';
     $notOperator = String::strtolower(Locale::translate('search.operator.not'));
     $andOperator = String::strtolower(Locale::translate('search.operator.and'));
     $orOperator = String::strtolower(Locale::translate('search.operator.or'));
     while ($pos < $total) {
         if (!empty($signTokens[$pos])) {
             $sign = $signTokens[$pos];
         } else {
             if (empty($sign)) {
                 $sign = '+';
             }
         }
         $token = String::strtolower($tokens[$pos++]);
         switch ($token) {
             case $notOperator:
                 $sign = '-';
                 break;
             case ')':
                 return $return;
             case '(':
                 $token = MonographSearch::_parseQuery($signTokens, $tokens, $pos, $total);
             default:
                 $postBool = '';
                 if ($pos < $total) {
                     $peek = String::strtolower($tokens[$pos]);
                     if ($peek == $orOperator) {
                         $postBool = 'or';
                         $pos++;
                     } else {
                         if ($peek == $andOperator) {
                             $postBool = 'and';
                             $pos++;
                         }
                     }
                 }
                 $bool = empty($postBool) ? $preBool : $postBool;
                 $preBool = $postBool;
                 if ($bool == 'or') {
                     $sign = '';
                 }
                 if (is_array($token)) {
                     $k = $token;
                 } else {
                     $k = MonographSearchIndex::filterKeywords($token, true);
                 }
                 if (!empty($k)) {
                     $return[$sign][] = $k;
                 }
                 $sign = '';
                 break;
         }
     }
     return $return;
 }