00001 <?php
00002
00015
00016
00017
00018 import('xml.XMLCustomWriter');
00019
00020
00021
00022
00023
00024 define('CROSSREF_XMLNS_XSI' , 'http://www.w3.org/2001/XMLSchema-instance');
00025 define('CROSSREF_XMLNS' , 'http://www.crossref.org/schema/3.0.3');
00026 define('CROSSREF_VERSION' , '3.0.3');
00027 define('CROSSREF_XSI_SCHEMALOCATION' , 'http://www.crossref.org/schema/3.0.3 http://www.crossref.org/schema/3.0.3/crossref3.0.3.xsd');
00028
00029
00030 class CrossRefExportDom {
00031
00039 function &generateCrossRefDom() {
00040
00041 $doc = &XMLCustomWriter::createDocument('', '', '');
00042
00043 return $doc;
00044 }
00045
00046 function &generateDoiBatchDom(&$doc) {
00047
00048
00049 $root = &XMLCustomWriter::createElement($doc, 'doi_batch');
00050
00051
00052
00053
00054 XMLCustomWriter::setAttribute($root, 'xmlns:xsi', CROSSREF_XMLNS_XSI);
00055 XMLCustomWriter::setAttribute($root, 'xmlns', CROSSREF_XMLNS);
00056 XMLCustomWriter::setAttribute($root, 'version', CROSSREF_VERSION);
00057 XMLCustomWriter::setAttribute($root, 'xsi:schemaLocation', CROSSREF_XSI_SCHEMALOCATION);
00058
00059 XMLCustomWriter::appendChild($doc, $root);
00060
00061 return $root;
00062 }
00063
00064
00065 function &generateHeadDom(&$doc, &$journal ) {
00066 $head = &XMLCustomWriter::createElement($doc, 'head');
00067
00068
00069 XMLCustomWriter::createChildWithText($doc, $head, 'doi_batch_id', $journal->getLocalizedSetting('initials') . '_' . time());
00070 XMLCustomWriter::createChildWithText($doc, $head, 'timestamp', time());
00071
00072 $journalId = $journal->getJournalId();
00073
00074
00075 $depositorNode = &CrossRefExportDom::generateDepositorDom($doc, $journal->getSetting('supportName'), $journal->getSetting('supportEmail'));
00076 XMLCustomWriter::appendChild($head, $depositorNode);
00077
00078
00079 $publisherInstitution = $journal->getSetting('publisherInstitution');
00080 XMLCustomWriter::createChildWithText($doc, $head, 'registrant', $publisherInstitution);
00081
00082
00083 return $head;
00084 }
00085
00086
00087 function &generateDepositorDom( &$doc, $name, $email ) {
00088 $depositor = &XMLCustomWriter::createElement($doc, 'depositor');
00089 XMLCustomWriter::createChildWithText($doc, $depositor, 'name', $name);
00090 XMLCustomWriter::createChildWithText($doc, $depositor, 'email_address', $email);
00091
00092 return $depositor;
00093 }
00094
00095
00096 function &generateJournalMetadataDom( &$doc, &$journal ) {
00097 $journalMetadataNode = &XMLCustomWriter::createElement($doc, 'journal_metadata');
00098
00099
00100
00101 XMLCustomWriter::createChildWithText($doc, $journalMetadataNode, 'full_title', $journal->getJournalTitle());
00102
00103
00104 if ($journal->getLocalizedSetting('abbreviation') != '' ) {
00105 XMLCustomWriter::createChildWithText($doc, $journalMetadataNode, 'abbrev_title', $journal->getLocalizedSetting('abbreviation'));
00106 }
00107
00108
00109 if ( $ISSN = $journal->getSetting('onlineIssn') ) {
00110 $onlineISSN = &XMLCustomWriter::createChildWithText($doc, $journalMetadataNode, 'issn', $ISSN);
00111 XMLCustomWriter::setAttribute($onlineISSN, 'media_type', 'electronic');
00112 }
00113
00114
00115
00116 if ( $ISSN = $journal->getSetting('printIssn') ) {
00117 $printISSN = &XMLCustomWriter::createChildWithText($doc, $journalMetadataNode, 'issn', $ISSN);
00118 XMLCustomWriter::setAttribute($printISSN, 'media_type', 'print');
00119 }
00120
00121
00122 return $journalMetadataNode;
00123 }
00124
00125
00126 function &generateJournalIssueDom( &$doc, &$journal, &$issue, &$section, &$article) {
00127 $journalIssueNode = &XMLCustomWriter::createElement($doc, 'journal_issue');
00128
00129 $publicationDateNode = &CrossRefExportDom::generatePublisherDateDom($doc, $issue->getDatePublished());
00130 XMLCustomWriter::appendChild($journalIssueNode, $publicationDateNode);
00131
00132 $journalVolumeNode = &XMLCustomWriter::createElement($doc, 'journal_volume');
00133 XMLCustomWriter::appendChild($journalIssueNode, $journalVolumeNode);
00134 XMLCustomWriter::createChildWithText($doc, $journalVolumeNode, 'volume', $issue->getVolume());
00135
00136 XMLCustomWriter::createChildWithText($doc, $journalIssueNode, 'issue', $issue->getNumber());
00137
00138 return $journalIssueNode;
00139 }
00140
00141
00142 function &generateJournalArticleDom(&$doc, &$journal, &$issue, &$section, &$article) {
00143
00144
00145 $journalArticleNode = &XMLCustomWriter::createElement($doc, 'journal_article');
00146 XMLCustomWriter::setAttribute($journalArticleNode, 'publication_type', 'full_text');
00147
00148
00149 $titlesNode = &XMLCustomWriter::createElement($doc, 'titles');
00150 XMLCustomWriter::createChildWithText($doc, $titlesNode, 'title', $article->getArticleTitle());
00151 XMLCustomWriter::appendChild($journalArticleNode, $titlesNode);
00152
00153 $contributorsNode = &XMLCustomWriter::createElement($doc, 'contributors');
00154
00155
00156 foreach ($article->getAuthors() as $author) {
00157 $authorNode =& CrossRefExportDom::generateAuthorDom($doc, $author);
00158 XMLCustomWriter::appendChild($contributorsNode, $authorNode);
00159 }
00160 XMLCustomWriter::appendChild($journalArticleNode, $contributorsNode);
00161
00162
00163 $publicationDateNode = &CrossRefExportDom::generatePublisherDateDom($doc, $issue->getDatePublished());
00164 XMLCustomWriter::appendChild($journalArticleNode, $publicationDateNode);
00165
00166
00167 if ($article->getPages() != '') {
00168 $publisherItemNode = &XMLCustomWriter::createElement($doc, 'publisher_item');
00169 XMLCustomWriter::createChildWithText($doc, $publisherItemNode, 'item_number', $article->getPages());
00170 XMLCustomWriter::appendChild($journalArticleNode, $publisherItemNode);
00171 }
00172
00173 return $journalArticleNode;
00174 }
00175
00176
00177 function &generateDOIdataDom( &$doc, $DOI, $url ) {
00178 $DOIdataNode = & XMLCustomWriter::createElement($doc, 'doi_data');
00179 XMLCustomWriter::createChildWithText($doc, $DOIdataNode, 'doi', $DOI);
00180 XMLCustomWriter::createChildWithText($doc, $DOIdataNode, 'resource', $url);
00181
00182 return $DOIdataNode;
00183 }
00184
00185
00186 function &generateAuthorDom(&$doc, &$author) {
00187 $authorNode = &XMLCustomWriter::createElement($doc, 'person_name');
00188 XMLCustomWriter::setAttribute($authorNode, 'contributor_role', 'author');
00189
00190
00191 if ($author->getPrimaryContact()) {
00192 XMLCustomWriter::setAttribute($authorNode, 'sequence', 'first');
00193 } else {
00194 XMLCustomWriter::setAttribute($authorNode, 'sequence', 'additional');
00195 }
00196
00197 XMLCustomWriter::createChildWithText($doc, $authorNode, 'given_name', ucfirst($author->getFirstName()).(($author->getMiddleName())?' '.ucfirst($author->getMiddleName()):''));
00198 XMLCustomWriter::createChildWithText($doc, $authorNode, 'surname', ucfirst($author->getLastName()));
00199
00200 return $authorNode;
00201 }
00202
00203
00204 function &generatePublisherDateDom(&$doc, $pubdate) {
00205 $publicationDateNode = &XMLCustomWriter::createElement($doc, 'publication_date');
00206 XMLCustomWriter::setAttribute($publicationDateNode, 'media_type', 'online');
00207
00208 XMLCustomWriter::createChildWithText($doc, $publicationDateNode, 'month', date('m', strtotime($pubdate)), false );
00209 XMLCustomWriter::createChildWithText($doc, $publicationDateNode, 'day', date('d', strtotime($pubdate)), false );
00210 XMLCustomWriter::createChildWithText($doc, $publicationDateNode, 'year', date('Y', strtotime($pubdate)) );
00211
00212
00213 return $publicationDateNode;
00214 }
00215
00216 }
00217 ?>