function &generatePaperDom(&$doc, &$conference, &$track, &$paper) { // register the editor submission DAO for use later // $editorSubmissionDao =& DAORegistry::getDAO('EditorSubmissionDAO'); /* --- MeetingAbstract --- */ $root =& XMLCustomWriter::createElement($doc, 'MeetingAbstract'); XMLCustomWriter::setAttribute($root, 'Status', 'Completed'); /* --- DateCreated --- */ $dateNode =& XMLCustomWriter::createElement($doc, 'DateCreated'); XMLCustomWriter::appendChild($root, $dateNode); XMLCustomWriter::createChildWithText($doc, $dateNode, 'Year', date('Y')); XMLCustomWriter::createChildWithText($doc, $dateNode, 'Month', date('m')); XMLCustomWriter::createChildWithText($doc, $dateNode, 'Day', date('d')); /* --- Article/Paper --- */ $articleNode =& XMLCustomWriter::createElement($doc, 'Article'); XMLCustomWriter::setAttribute($articleNode, 'PubModel', 'Electronic'); XMLCustomWriter::appendChild($root, $articleNode); /* --- Journal/Book --- */ // FIXME: at the moment this is a null element required by NLM $journalNode =& XMLCustomWriter::createChildWithText($doc, $articleNode, 'Journal', null); $journalIssueNode =& XMLCustomWriter::createElement($doc, 'JournalIssue'); XMLCustomWriter::setAttribute($journalIssueNode, 'CitedMedium', 'Internet'); XMLCustomWriter::appendChild($journalNode, $journalIssueNode); $journalDateNode =& XMLCustomWriter::createElement($doc, 'PubDate'); XMLCustomWriter::appendChild($journalIssueNode, $journalDateNode); XMLCustomWriter::createChildWithText($doc, $journalDateNode, 'MedlineDate', date('Y')); /* --- ArticleTitle --- */ // NLM requires english titles for PaperTitle XMLCustomWriter::createChildWithText($doc, $articleNode, 'ArticleTitle', $paper->getLocalizedTitle()); /* --- Pagination --- */ // If there is no page number, then use abstract number $paginationNode =& XMLCustomWriter::createElement($doc, 'Pagination'); XMLCustomWriter::appendChild($articleNode, $paginationNode); $pages = $paper->getPages(); if (preg_match("/([0-9]+)\\s*-\\s*([0-9]+)/i", $pages, $matches)) { // simple pagination (eg. "pp. 3- 8") XMLCustomWriter::createChildWithText($doc, $paginationNode, 'MedlinePgn', $matches[1] . '-' . $matches[2]); } elseif (preg_match("/(e[0-9]+)/i", $pages, $matches)) { // elocation-id (eg. "e12") XMLCustomWriter::createChildWithText($doc, $paginationNode, 'MedlinePgn', $matches[1]); } else { // we need to insert something, so use the best ID possible XMLCustomWriter::createChildWithText($doc, $paginationNode, 'MedlinePgn', $paper->getBestPaperId($conference)); } /* --- Abstract --- */ $abstractNode =& XMLCustomWriter::createElement($doc, 'Abstract'); XMLCustomWriter::appendChild($articleNode, $abstractNode); XMLCustomWriter::createChildWithText($doc, $abstractNode, 'AbstractText', strip_tags($paper->getLocalizedAbstract()), false); /* --- Affiliation --- */ $sponsor = $paper->getLocalizedSponsor(); if ($sponsor != '') { XMLCustomWriter::createChildWithText($doc, $articleNode, 'Affiliation', $sponsor); } /* --- AuthorList --- */ $authorListNode =& XMLCustomWriter::createElement($doc, 'AuthorList'); XMLCustomWriter::setAttribute($authorListNode, 'CompleteYN', 'Y'); XMLCustomWriter::appendChild($articleNode, $authorListNode); foreach ($paper->getAuthors() as $author) { $authorNode =& NLMExportDom::generateAuthorDom($doc, $author); XMLCustomWriter::appendChild($authorListNode, $authorNode); } /* --- Conference --- */ $conferenceNode =& XMLCustomWriter::createElement($doc, 'Author'); XMLCustomWriter::appendChild($authorListNode, $conferenceNode); XMLCustomWriter::createChildWithText($doc, $conferenceNode, 'CollectiveName', $conference->getConferenceTitle()); // OtherInformation element goes here with location for current conference /* --- Language --- */ XMLCustomWriter::createChildWithText($doc, $articleNode, 'Language', strtolower($paper->getLanguage()), false); /* --- MedlineJournalInfo--- */ // FIXME: at the moment this is a null element required by NLM $journalInfoNode =& XMLCustomWriter::createChildWithText($doc, $root, 'MedlineJournalInfo', null); XMLCustomWriter::createChildWithText($doc, $journalInfoNode, 'MedlineTA', null); return $root; }
function exportPapers(&$results, $outputFile = null) { $this->import('NLMExportDom'); $doc =& NLMExportDom::generateNLMDom(); $paperSetNode =& NLMExportDom::generatePaperSetDom($doc); foreach ($results as $result) { $conference =& $result['conference']; $track =& $result['track']; $paper =& $result['publishedPaper']; $paperNode =& NLMExportDom::generatePaperDom($doc, $conference, $track, $paper); XMLCustomWriter::appendChild($paperSetNode, $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=\"nlm.xml\""); XMLCustomWriter::printXML($doc); //echo '<pre>'.htmlentities(preg_replace('/></', ">\n<", XMLCustomWriter::getXML($doc))).'</pre>'; } return true; }