plugins/importexport/nlm/NLMExportDom.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00016 //$Id$
00017 
00018 import('xml.XMLCustomWriter');
00019 
00020 define('NLM_DTD_URL', 'http://www.nlm.nih.gov/databases/dtd/nlmmeetingabstractinput_060101.dtd');
00021 define('NLM_DTD_ID', '-//NLM/DTD MeetingAbstract, 1st  January, 2006//EN');
00022 
00023 class NLMExportDom {
00024 
00034    function &generateNLMDom() {
00035       // create the output XML document in DOM with a root node
00036       $doc =& XMLCustomWriter::createDocument('InputMeetingAbstractSet', NLM_DTD_ID, NLM_DTD_URL);
00037 
00038       return $doc;
00039    }
00040 
00041    function &generatePaperSetDom(&$doc) {
00042       $root =& XMLCustomWriter::createElement($doc, 'InputMeetingAbstractSet');
00043       XMLCustomWriter::appendChild($doc, $root);
00044 
00045       return $root;
00046    }
00047 
00048    function &generatePaperDom(&$doc, &$conference, &$track, &$paper) {
00049 
00050       // register the editor submission DAO for use later
00051 //    $editorSubmissionDao =& DAORegistry::getDAO('EditorSubmissionDAO');
00052 
00053       /* --- MeetingAbstract --- */
00054       $root =& XMLCustomWriter::createElement($doc, 'MeetingAbstract');
00055       XMLCustomWriter::setAttribute($root, 'Status', 'Completed');
00056 
00057       /* --- DateCreated --- */
00058       $dateNode =& XMLCustomWriter::createElement($doc, 'DateCreated');
00059       XMLCustomWriter::appendChild($root, $dateNode);
00060 
00061       XMLCustomWriter::createChildWithText($doc, $dateNode, 'Year', date('Y') );
00062       XMLCustomWriter::createChildWithText($doc, $dateNode, 'Month', date('m') );
00063       XMLCustomWriter::createChildWithText($doc, $dateNode, 'Day', date('d') );
00064 
00065       /* --- Article/Paper --- */
00066       $articleNode =& XMLCustomWriter::createElement($doc, 'Article');
00067       XMLCustomWriter::setAttribute($articleNode, 'PubModel', 'Electronic');
00068       XMLCustomWriter::appendChild($root, $articleNode);
00069 
00070       /* --- Journal/Book --- */
00071       // FIXME: at the moment this is a null element required by NLM
00072       $journalNode =& XMLCustomWriter::createChildWithText($doc, $articleNode, 'Journal', null);
00073 
00074       $journalIssueNode =& XMLCustomWriter::createElement($doc, 'JournalIssue');
00075       XMLCustomWriter::setAttribute($journalIssueNode, 'CitedMedium', 'Internet');
00076       XMLCustomWriter::appendChild($journalNode, $journalIssueNode);
00077 
00078       $journalDateNode =& XMLCustomWriter::createElement($doc, 'PubDate');
00079       XMLCustomWriter::appendChild($journalIssueNode, $journalDateNode);
00080       XMLCustomWriter::createChildWithText($doc, $journalDateNode, 'MedlineDate', date('Y') );
00081 
00082       /* --- ArticleTitle --- */
00083       // NLM requires english titles for PaperTitle
00084       XMLCustomWriter::createChildWithText($doc, $articleNode, 'ArticleTitle', $paper->getLocalizedTitle());
00085 
00086       /* --- Pagination --- */
00087       // If there is no page number, then use abstract number
00088       $paginationNode =& XMLCustomWriter::createElement($doc, 'Pagination');
00089       XMLCustomWriter::appendChild($articleNode, $paginationNode);
00090 
00091       $pages = $paper->getPages();
00092 
00093       if (preg_match("/([0-9]+)\s*-\s*([0-9]+)/i", $pages, $matches)) {
00094          // simple pagination (eg. "pp. 3-      8")
00095          XMLCustomWriter::createChildWithText($doc, $paginationNode, 'MedlinePgn', $matches[1].'-'.$matches[2]);        
00096       } elseif (preg_match("/(e[0-9]+)/i", $pages, $matches)) {
00097          // elocation-id (eg. "e12")
00098          XMLCustomWriter::createChildWithText($doc, $paginationNode, 'MedlinePgn', $matches[1]);
00099       } else {
00100          // we need to insert something, so use the best ID possible
00101          XMLCustomWriter::createChildWithText($doc, $paginationNode, 'MedlinePgn', $paper->getBestPaperId($conference));         
00102       }
00103 
00104       /* --- Abstract --- */
00105       $abstractNode =& XMLCustomWriter::createElement($doc, 'Abstract');
00106       XMLCustomWriter::appendChild($articleNode, $abstractNode);
00107 
00108       XMLCustomWriter::createChildWithText($doc, $abstractNode, 'AbstractText', strip_tags($paper->getLocalizedAbstract()), false);
00109 
00110       /* --- Affiliation --- */
00111       $sponsor = $paper->getLocalizedSponsor();
00112 
00113       if ($sponsor != '') {
00114          XMLCustomWriter::createChildWithText($doc, $articleNode, 'Affiliation', $sponsor);
00115       }
00116 
00117       /* --- AuthorList --- */
00118       $authorListNode =& XMLCustomWriter::createElement($doc, 'AuthorList');
00119       XMLCustomWriter::setAttribute($authorListNode, 'CompleteYN', 'Y');
00120       XMLCustomWriter::appendChild($articleNode, $authorListNode);
00121 
00122       foreach ($paper->getAuthors() as $author) {
00123          $authorNode =& NLMExportDom::generateAuthorDom($doc, $author);
00124          XMLCustomWriter::appendChild($authorListNode, $authorNode);
00125       }
00126 
00127       /* --- Conference --- */ 
00128       $conferenceNode =& XMLCustomWriter::createElement($doc, 'Author');
00129       XMLCustomWriter::appendChild($authorListNode, $conferenceNode);
00130 
00131       XMLCustomWriter::createChildWithText($doc, $conferenceNode, 'CollectiveName', $conference->getConferenceTitle());
00132 
00133       // OtherInformation element goes here with location for current conference
00134 
00135       /* --- Language --- */
00136       XMLCustomWriter::createChildWithText($doc, $articleNode, 'Language', strtolower($paper->getLanguage()), false);
00137 
00138       /* --- MedlineJournalInfo--- */
00139       // FIXME: at the moment this is a null element required by NLM
00140       $journalInfoNode =& XMLCustomWriter::createChildWithText($doc, $root, 'MedlineJournalInfo', null);
00141       XMLCustomWriter::createChildWithText($doc, $journalInfoNode, 'MedlineTA', null);
00142 
00143       return $root;
00144    }
00145 
00146    function &generateAuthorDom(&$doc, &$author) {
00147       $root =& XMLCustomWriter::createElement($doc, 'Author');
00148 
00149       $foreName = trim($author->getFirstName() .' '.$author->getMiddleName());
00150 
00151       XMLCustomWriter::createChildWithText($doc, $root, 'LastName', ucfirst($author->getLastName()));
00152       XMLCustomWriter::createChildWithText($doc, $root, 'ForeName', ucwords($foreName));
00153 
00154       return $root;
00155    }
00156 
00157 }
00158 
00159 ?>

Generated on 25 Jul 2013 for Open Conference Systems by  doxygen 1.4.7