function exportPapers(&$results, $outputFile = null) { $this->import('NativeExportDom'); $doc =& XMLCustomWriter::createDocument('papers', NATIVE_DTD_ID, NATIVE_DTD_URL); $papersNode =& XMLCustomWriter::createElement($doc, 'papers'); XMLCustomWriter::appendChild($doc, $papersNode); foreach ($results as $result) { $paper =& $result['publishedPaper']; $track =& $result['track']; $conference =& $result['conference']; $schedConf =& $result['schedConf']; $paperNode =& NativeExportDom::generatePaperDom($doc, $schedConf, $track, $paper); XMLCustomWriter::appendChild($papersNode, $paperNode); } if (!empty($outputFile)) { if (($h = fopen($outputFile, 'w')) === false) { return false; } fwrite($h, XMLCustomWriter::getXML($doc)); fclose($h); } else { header("Content-Type: application/xml"); header("Cache-Control: private"); header("Content-Disposition: attachment; filename=\"papers.xml\""); XMLCustomWriter::printXML($doc); } return true; }
function exportArticles(&$results, $outputFile = null) { $this->import('NativeExportDom'); $doc =& XMLCustomWriter::createDocument('articles', NATIVE_DTD_ID, NATIVE_DTD_URL); $articlesNode =& XMLCustomWriter::createElement($doc, 'articles'); XMLCustomWriter::appendChild($doc, $articlesNode); foreach ($results as $result) { $article =& $result['publishedArticle']; $section =& $result['section']; $issue =& $result['issue']; $journal =& $result['journal']; $articleNode =& NativeExportDom::generateArticleDom($doc, $journal, $issue, $section, $article); XMLCustomWriter::appendChild($articlesNode, $articleNode); } if (!empty($outputFile)) { if (($h = fopen($outputFile, 'w')) === false) { return false; } fwrite($h, XMLCustomWriter::getXML($doc)); fclose($h); } else { header("Content-Type: application/xml"); header("Cache-Control: private"); header("Content-Disposition: attachment; filename=\"articles.xml\""); XMLCustomWriter::printXML($doc); } return true; }
function &generateSuppFileDom(&$doc, &$journal, &$issue, &$article, &$suppFile) { $root =& XMLCustomWriter::createElement($doc, 'supplemental_file'); NativeExportDom::generatePubId($doc, $root, $suppFile, $issue); // FIXME: These should be constants! switch ($suppFile->getType()) { case __('author.submit.suppFile.researchInstrument'): $suppFileType = 'research_instrument'; break; case __('author.submit.suppFile.researchMaterials'): $suppFileType = 'research_materials'; break; case __('author.submit.suppFile.researchResults'): $suppFileType = 'research_results'; break; case __('author.submit.suppFile.transcripts'): $suppFileType = 'transcripts'; break; case __('author.submit.suppFile.dataAnalysis'): $suppFileType = 'data_analysis'; break; case __('author.submit.suppFile.dataSet'): $suppFileType = 'data_set'; break; case __('author.submit.suppFile.sourceText'): $suppFileType = 'source_text'; break; default: $suppFileType = 'other'; break; } XMLCustomWriter::setAttribute($root, 'type', $suppFileType); XMLCustomWriter::setAttribute($root, 'public_id', $suppFile->getPubId('publisher-id'), false); XMLCustomWriter::setAttribute($root, 'language', $suppFile->getLanguage(), false); XMLCustomWriter::setAttribute($root, 'show_reviewers', $suppFile->getShowReviewers() ? 'true' : 'false'); if (is_array($suppFile->getTitle(null))) { foreach ($suppFile->getTitle(null) as $locale => $title) { $titleNode =& XMLCustomWriter::createChildWithText($doc, $root, 'title', $title, false); if ($titleNode) { XMLCustomWriter::setAttribute($titleNode, 'locale', $locale); } unset($titleNode); } } if (is_array($suppFile->getCreator(null))) { foreach ($suppFile->getCreator(null) as $locale => $creator) { $creatorNode =& XMLCustomWriter::createChildWithText($doc, $root, 'creator', $creator, false); if ($creatorNode) { XMLCustomWriter::setAttribute($creatorNode, 'locale', $locale); } unset($creatorNode); } } if (is_array($suppFile->getSubject(null))) { foreach ($suppFile->getSubject(null) as $locale => $subject) { $subjectNode =& XMLCustomWriter::createChildWithText($doc, $root, 'subject', $subject, false); if ($subjectNode) { XMLCustomWriter::setAttribute($subjectNode, 'locale', $locale); } unset($subjectNode); } } if ($suppFileType == 'other') { if (is_array($suppFile->getTypeOther(null))) { foreach ($suppFile->getTypeOther(null) as $locale => $typeOther) { $typeOtherNode =& XMLCustomWriter::createChildWithText($doc, $root, 'type_other', $typeOther, false); if ($typeOtherNode) { XMLCustomWriter::setAttribute($typeOtherNode, 'locale', $locale); } unset($typeOtherNode); } } } if (is_array($suppFile->getDescription(null))) { foreach ($suppFile->getDescription(null) as $locale => $description) { $descriptionNode =& XMLCustomWriter::createChildWithText($doc, $root, 'description', $description, false); if ($descriptionNode) { XMLCustomWriter::setAttribute($descriptionNode, 'locale', $locale); } unset($descriptionNode); } } if (is_array($suppFile->getPublisher(null))) { foreach ($suppFile->getPublisher(null) as $locale => $publisher) { $publisherNode =& XMLCustomWriter::createChildWithText($doc, $root, 'publisher', $publisher, false); if ($publisherNode) { XMLCustomWriter::setAttribute($publisherNode, 'locale', $locale); } unset($publisherNode); } } if (is_array($suppFile->getSponsor(null))) { foreach ($suppFile->getSponsor(null) as $locale => $sponsor) { $sponsorNode =& XMLCustomWriter::createChildWithText($doc, $root, 'sponsor', $sponsor, false); if ($sponsorNode) { XMLCustomWriter::setAttribute($sponsorNode, 'locale', $locale); } unset($sponsorNode); } } XMLCustomWriter::createChildWithText($doc, $root, 'date_created', NativeExportDom::formatDate($suppFile->getDateCreated()), false); if (is_array($suppFile->getSource(null))) { foreach ($suppFile->getSource(null) as $locale => $source) { $sourceNode =& XMLCustomWriter::createChildWithText($doc, $root, 'source', $source, false); if ($sourceNode) { XMLCustomWriter::setAttribute($sourceNode, 'locale', $locale); } unset($sourceNode); } } import('classes.file.ArticleFileManager'); $articleFileManager = new ArticleFileManager($article->getId()); $fileNode =& XMLCustomWriter::createElement($doc, 'file'); XMLCustomWriter::appendChild($root, $fileNode); if ($suppFile->getRemoteURL()) { $remoteNode =& XMLCustomWriter::createElement($doc, 'remote'); XMLCustomWriter::appendChild($fileNode, $remoteNode); XMLCustomWriter::setAttribute($remoteNode, 'src', $suppFile->getRemoteURL()); } else { $embedNode =& XMLCustomWriter::createChildWithText($doc, $fileNode, 'embed', base64_encode($articleFileManager->readFile($suppFile->getFileId()))); XMLCustomWriter::setAttribute($embedNode, 'filename', $suppFile->getOriginalFileName()); XMLCustomWriter::setAttribute($embedNode, 'encoding', 'base64'); XMLCustomWriter::setAttribute($embedNode, 'mime_type', $suppFile->getFileType()); } return $root; }