/** * Creates a METS:file for the paperfile * checks if METS:FContent or METS:FLocat should be used */ function generateArticleFileDom(&$doc, &$root, $article, &$galleyFile, $useAttribute) { import('classes.file.PublicFileManager'); import('classes.file.FileManager'); $contentWrapper = $this->getSetting($this->journalId, 'contentWrapper'); $mfile =& XMLCustomWriter::createElement($doc, 'METS:file'); $filePath = MetsExportDom::getPublicFilePath($galleyFile, '/public/'); $chkmd5return = md5_file($filePath); XMLCustomWriter::setAttribute($mfile, 'ID', 'F' . $galleyFile->getFileId() . '-A' . $galleyFile->getArticleId()); if ($useAttribute != null) { XMLCustomWriter::setAttribute($mfile, 'USE', $useAttribute); } XMLCustomWriter::setAttribute($mfile, 'SIZE', $galleyFile->getFileSize()); XMLCustomWriter::setAttribute($mfile, 'MIMETYPE', $galleyFile->getFileType()); XMLCustomWriter::setAttribute($mfile, 'OWNERID', $galleyFile->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::getPublicFileUrl($galleyFile); XMLCustomWriter::setAttribute($fLocat, 'xlink:href', $fileUrl); XMLCustomWriter::setAttribute($fLocat, 'LOCTYPE', 'URL'); XMLCustomWriter::appendChild($mfile, $fLocat); } XMLCustomWriter::appendChild($root, $mfile); }