Ejemplo n.º 1
0
 /**
  *  Creates a METS:file for the Supplementary File
  *  checks if METS:FContent or METS:FLocat should be used
  */
 function generateArticleSuppFileDom(&$doc, &$root, &$article, &$suppFile, &$journal)
 {
     import('classes.file.PublicFileManager');
     import('lib.pkp.classes.file.FileManager');
     $fileManager = new FileManager();
     $contentWrapper = Request::getUserVar('contentWrapper');
     $mfile =& XMLCustomWriter::createElement($doc, 'METS:file');
     $filePath = MetsExportDom::getPublicFilePath($suppFile, '/supp/', $journal);
     $chkmd5return = md5_file($filePath);
     XMLCustomWriter::setAttribute($mfile, 'ID', 'SF' . $suppFile->getFileId() . '-A' . $suppFile->getArticleId());
     XMLCustomWriter::setAttribute($mfile, 'SIZE', $suppFile->getFileSize());
     XMLCustomWriter::setAttribute($mfile, 'MIMETYPE', $suppFile->getFileType());
     XMLCustomWriter::setAttribute($mfile, 'OWNERID', $suppFile->getFileName());
     XMLCustomWriter::setAttribute($mfile, 'CHECKSUM', $chkmd5return);
     XMLCustomWriter::setAttribute($mfile, 'CHECKSUMTYPE', 'MD5');
     if ($contentWrapper == 'FContent') {
         $fileContent =& $fileManager->readFile($filePath);
         $fContent =& XMLCustomWriter::createElement($doc, 'METS:FContent');
         $fNameNode =& XMLCustomWriter::createChildWithText($doc, $fContent, 'METS:binData', base64_encode($fileContent));
         XMLCustomWriter::appendChild($mfile, $fContent);
     } else {
         $fLocat =& XMLCustomWriter::createElement($doc, 'METS:FLocat');
         XMLCustomWriter::setAttribute($fLocat, 'xlink:href', Request::url($journal->getPath(), 'article', 'downloadSuppFile', array($suppFile->getArticleId(), $suppFile->getId())));
         XMLCustomWriter::setAttribute($fLocat, 'LOCTYPE', 'URL');
         XMLCustomWriter::appendChild($mfile, $fLocat);
     }
     XMLCustomWriter::appendChild($root, $mfile);
 }
Ejemplo n.º 2
0
 /**
  * Creates a METS:file for the Supplementary File
  * checks if METS:FContent or METS:FLocat should be used
  */
 function generateArticleSuppFileDom(&$doc, &$root, $article, &$suppFile)
 {
     import('classes.file.PublicFileManager');
     import('classes.file.FileManager');
     $contentWrapper = $this->getSetting($this->journalId, 'contentWrapper');
     $mfile =& XMLCustomWriter::createElement($doc, 'METS:file');
     $filePath = MetsExportDom::getPublicFilePath($suppFile, '/supp/');
     $chkmd5return = md5_file($filePath);
     XMLCustomWriter::setAttribute($mfile, 'ID', 'SF' . $suppFile->getFileId() . '-A' . $suppFile->getArticleId());
     XMLCustomWriter::setAttribute($mfile, 'SIZE', $suppFile->getFileSize());
     XMLCustomWriter::setAttribute($mfile, 'MIMETYPE', $suppFile->getFileType());
     XMLCustomWriter::setAttribute($mfile, 'OWNERID', $suppFile->getFileName());
     XMLCustomWriter::setAttribute($mfile, 'CHECKSUM', $chkmd5return);
     XMLCustomWriter::setAttribute($mfile, 'CHECKSUMTYPE', 'MD5');
     if ($contentWrapper == 'FContent') {
         $fileContent =& FileManager::readFile($filePath);
         $fContent =& XMLCustomWriter::createElement($doc, 'METS:FContent');
         $fNameNode =& XMLCustomWriter::createChildWithText($doc, $fContent, 'METS:binData', base64_encode($fileContent));
         XMLCustomWriter::appendChild($mfile, $fContent);
     } else {
         $fLocat =& XMLCustomWriter::createElement($doc, 'METS:FLocat');
         $fileUrl = MetsExportDom::getPublicSuppFileUrl($suppFile);
         XMLCustomWriter::setAttribute($fLocat, 'xlink:href', $fileUrl);
         XMLCustomWriter::setAttribute($fLocat, 'LOCTYPE', 'URL');
         XMLCustomWriter::appendChild($mfile, $fLocat);
     }
     XMLCustomWriter::appendChild($root, $mfile);
 }