00001 <?php
00002
00015 import('lib.pkp.classes.xml.XMLCustomWriter');
00016
00017 class Onix30ExportDom {
00018
00019 function Onix30ExportDom() {
00020
00021 }
00022
00023 function &generateMonographDom(&$doc, &$press, &$monograph, &$publicationFormat) {
00024
00025 $onixCodelistItemDao =& DAORegistry::getDAO('ONIXCodelistItemDAO');
00026
00027 $unavailableString = __('plugins.importexport.onix30.unavailable');
00028
00029 $root =& XMLCustomWriter::createElement($doc, 'ONIXMessage');
00030 XMLCustomWriter::setAttribute($root, 'release', '3.0');
00031 XMLCustomWriter::setAttribute($root, 'xmlns', 'http://ns.editeur.org/onix/3.0/reference');
00032
00033
00034
00035 $headerNode =& XMLCustomWriter::createElement($doc, 'Header');
00036 XMLCustomWriter::appendChild($root, $headerNode);
00037
00038
00039
00040 $senderNode =& XMLCustomWriter::createElement($doc, 'Sender');
00041 XMLCustomWriter::appendChild($headerNode, $senderNode);
00042
00043
00044
00045
00046 $senderIdentifierNode =& XMLCustomWriter::createElement($doc, 'SenderIdentifier');
00047 XMLCustomWriter::appendChild($senderNode, $senderIdentifierNode);
00048 $senderIdTypeNode =& XMLCustomWriter::createChildWithText($doc, $senderIdentifierNode, 'SenderIDType', $press->getSetting('codeType'));
00049 $senderNameNode =& XMLCustomWriter::createChildWithText($doc, $senderIdentifierNode, 'IDValue', $press->getSetting('codeValue'));
00050
00051 $senderNameNode =& XMLCustomWriter::createChildWithText($doc, $senderNode, 'SenderName', $press->getLocalizedName());
00052 $contactNameNode =& XMLCustomWriter::createChildWithText($doc, $senderNode, 'ContactName', $press->getContactName());
00053 $emailAddressNode =& XMLCustomWriter::createChildWithText($doc, $senderNode, 'EmailAddress', $press->getContactEmail());
00054
00055
00056
00057
00058 $addressee = strip_tags(Request::getUserVar('addressee'));
00059 if ($addressee != '') {
00060 $addresseeNode =& XMLCustomWriter::createElement($doc, 'Addressee');
00061 XMLCustomWriter::appendChild($headerNode, $addresseeNode);
00062 $addresseeNameNode =& XMLCustomWriter::createChildWithText($doc, $addresseeNode, 'AddresseeName', $addressee);
00063 }
00064
00065
00066 $sentDateTimeNode =& XMLCustomWriter::createChildWithText($doc, $headerNode, 'SentDateTime', date('Ymd'));
00067
00068
00069
00070 $productNode =& XMLCustomWriter::createElement($doc, 'Product');
00071 XMLCustomWriter::appendChild($root, $productNode);
00072 XMLCustomWriter::createChildWithText($doc, $productNode, 'RecordReference', Request::url($press->getPath(), 'monograph', 'view', array($monograph->getId())));
00073 XMLCustomWriter::createChildWithText($doc, $productNode, 'NotificationType', '03');
00074 XMLCustomWriter::createChildWithText($doc, $productNode, 'RecordSourceType', '04');
00075
00076 $identificationCodes =& $publicationFormat->getIdentificationCodes();
00077
00078 while ($code =& $identificationCodes->next()) {
00079 $productIdentifierNode =& XMLCustomWriter::createElement($doc, 'ProductIdentifier');
00080 XMLCustomWriter::appendChild($productNode, $productIdentifierNode);
00081 XMLCustomWriter::createChildWithText($doc, $productIdentifierNode, 'ProductIDType', $code->getCode());
00082 XMLCustomWriter::createChildWithText($doc, $productIdentifierNode, 'IDValue', $code->getValue());
00083 unset($productIdentifierNode);
00084 unset($code);
00085 }
00086
00087
00088 $descDetailNode =& XMLCustomWriter::createElement($doc, 'DescriptiveDetail');
00089 XMLCustomWriter::appendChild($productNode, $descDetailNode);
00090 XMLCustomWriter::createChildWithText($doc, $descDetailNode, 'ProductComposition',
00091 $publicationFormat->getProductCompositionCode() ? $publicationFormat->getProductCompositionCode() : '00');
00092 XMLCustomWriter::createChildWithText($doc, $descDetailNode, 'ProductForm', $publicationFormat->getEntryKey());
00093 XMLCustomWriter::createChildWithText($doc, $descDetailNode, 'ProductFormDetail', $publicationFormat->getProductFormDetailCode(), false);
00094
00095
00096 if ($publicationFormat->getPhysicalFormat()) {
00097
00098 if ($publicationFormat->getHeight() != '') {
00099 $measureNode =& XMLCustomWriter::createElement($doc, 'Measure');
00100 XMLCustomWriter::appendChild($descDetailNode, $measureNode);
00101 XMLCustomWriter::createChildWithText($doc, $measureNode, 'MeasureType', '01');
00102 XMLCustomWriter::createChildWithText($doc, $measureNode, 'Measurement', $publicationFormat->getHeight());
00103 XMLCustomWriter::createChildWithText($doc, $measureNode, 'MeasureUnitCode', $publicationFormat->getHeightUnitCode());
00104 unset($measureNode);
00105 }
00106
00107 if ($publicationFormat->getWidth() != '') {
00108 $measureNode =& XMLCustomWriter::createElement($doc, 'Measure');
00109 XMLCustomWriter::appendChild($descDetailNode, $measureNode);
00110 XMLCustomWriter::createChildWithText($doc, $measureNode, 'MeasureType', '02');
00111 XMLCustomWriter::createChildWithText($doc, $measureNode, 'Measurement', $publicationFormat->getWidth());
00112 XMLCustomWriter::createChildWithText($doc, $measureNode, 'MeasureUnitCode', $publicationFormat->getWidthUnitCode());
00113 unset($measureNode);
00114 }
00115
00116 if ($publicationFormat->getThickness() != '') {
00117 $measureNode =& XMLCustomWriter::createElement($doc, 'Measure');
00118 XMLCustomWriter::appendChild($descDetailNode, $measureNode);
00119 XMLCustomWriter::createChildWithText($doc, $measureNode, 'MeasureType', '03');
00120 XMLCustomWriter::createChildWithText($doc, $measureNode, 'Measurement', $publicationFormat->getThickness());
00121 XMLCustomWriter::createChildWithText($doc, $measureNode, 'MeasureUnitCode', $publicationFormat->getThicknessUnitCode());
00122 unset($measureNode);
00123 }
00124
00125 if ($publicationFormat->getWeight() != '') {
00126 $measureNode =& XMLCustomWriter::createElement($doc, 'Measure');
00127 XMLCustomWriter::appendChild($descDetailNode, $measureNode);
00128 XMLCustomWriter::createChildWithText($doc, $measureNode, 'MeasureType', '08');
00129 XMLCustomWriter::createChildWithText($doc, $measureNode, 'Measurement', $publicationFormat->getWeight());
00130 XMLCustomWriter::createChildWithText($doc, $measureNode, 'MeasureUnitCode', $publicationFormat->getWeightUnitCode());
00131 unset($measureNode);
00132 }
00133
00134 XMLCustomWriter::createChildWithText($doc, $descDetailNode, 'CountryOfManufacture', $publicationFormat->getCountryManufactureCode(), false);
00135 }
00136
00137 if (!$publicationFormat->getPhysicalFormat()) {
00138 XMLCustomWriter::createChildWithText($doc, $descDetailNode, 'EpubTechnicalProtection', $publicationFormat->getTechnicalProtectionCode(), false);
00139 }
00140
00141
00142
00143 $seriesCollectionNode =& XMLCustomWriter::createElement($doc, 'Collection');
00144 XMLCustomWriter::appendChild($descDetailNode, $seriesCollectionNode);
00145 XMLCustomWriter::createChildWithText($doc, $seriesCollectionNode, 'CollectionType', '10');
00146
00147 $seriesTitleDetailNode =& XMLCustomWriter::createElement($doc, 'TitleDetail');
00148 XMLCustomWriter::appendChild($seriesCollectionNode, $seriesTitleDetailNode);
00149 XMLCustomWriter::createChildWithText($doc, $seriesTitleDetailNode, 'TitleType', '01');
00150
00151 $titleElementNode =& XMLCustomWriter::createElement($doc, 'TitleElement');
00152 XMLCustomWriter::appendChild($seriesTitleDetailNode, $titleElementNode);
00153 XMLCustomWriter::createChildWithText($doc, $titleElementNode, 'TitleElementLevel', '02');
00154
00155
00156
00157 $seriesDao =& DAORegistry::getDAO('SeriesDAO');
00158 $series =& $seriesDao->getById($monograph->getSeriesId());
00159 if ($series != null) {
00160 XMLCustomWriter::createChildWithText($doc, $titleElementNode, 'PartNumber', $monograph->getSeriesPosition(), false);
00161 if ($series->getLocalizedPrefix() == '' || $series->getLocalizedTitle() == '') {
00162 XMLCustomWriter::createChildWithText($doc, $titleElementNode, 'TitleText', join(' ', array($series->getLocalizedPrefix(), $series->getLocalizedTitle())));
00163 } else {
00164 XMLCustomWriter::createChildWithText($doc, $titleElementNode, 'TitlePrefix', $series->getLocalizedPrefix(), false);
00165 XMLCustomWriter::createChildWithText($doc, $titleElementNode, 'TitleWithoutPrefix', $series->getLocalizedTitle());
00166 }
00167 XMLCustomWriter::createChildWithText($doc, $titleElementNode, 'Subtitle', $series->getLocalizedSubtitle(), false);
00168 }
00169
00170
00171
00172 $productTitleDetailNode =& XMLCustomWriter::createElement($doc, 'TitleDetail');
00173 XMLCustomWriter::appendChild($descDetailNode, $productTitleDetailNode);
00174 XMLCustomWriter::createChildWithText($doc, $productTitleDetailNode, 'TitleType', '01');
00175
00176 $titleElementNode =& XMLCustomWriter::createElement($doc, 'TitleElement');
00177 XMLCustomWriter::appendChild($productTitleDetailNode, $titleElementNode);
00178 XMLCustomWriter::createChildWithText($doc, $titleElementNode, 'TitleElementLevel', '01');
00179 if ($monograph->getLocalizedPrefix() == '' || $monograph->getLocalizedTitle() == '') {
00180 XMLCustomWriter::createChildWithText($doc, $titleElementNode, 'TitleText', join(' ', array($monograph->getLocalizedPrefix(), $monograph->getLocalizedTitle())));
00181 } else {
00182 XMLCustomWriter::createChildWithText($doc, $titleElementNode, 'TitlePrefix', $monograph->getLocalizedPrefix(), false);
00183 XMLCustomWriter::createChildWithText($doc, $titleElementNode, 'TitleWithoutPrefix', $monograph->getLocalizedTitle());
00184 }
00185 XMLCustomWriter::createChildWithText($doc, $titleElementNode, 'Subtitle', $monograph->getLocalizedSubtitle(), false);
00186
00187
00188
00189 $authors =& $monograph->getAuthors();
00190 $sequence = 1;
00191 foreach ($authors as $author) {
00192 $contributorNode =& XMLCustomWriter::createElement($doc, 'Contributor');
00193 XMLCustomWriter::appendChild($descDetailNode, $contributorNode);
00194 XMLCustomWriter::createChildWithText($doc, $contributorNode, 'SequenceNumber', $sequence);
00195 $userGroupDao =& DAORegistry::getDAO('UserGroupDAO');
00196 $userGroup =& $userGroupDao->getById($author->getUserGroupId(), $monograph->getPressId());
00197
00198 $userGroupOnixMap = array('AU' => 'A01', 'VE' => 'B01', 'CA' => 'A01', 'Trans' => 'B06');
00199
00200 XMLCustomWriter::createChildWithText($doc, $contributorNode, 'ContributorRole', $userGroupOnixMap[$userGroup->getLocalizedAbbrev()]);
00201 XMLCustomWriter::createChildWithText($doc, $contributorNode, 'PersonName', $author->getFullName());
00202 XMLCustomWriter::createChildWithText($doc, $contributorNode, 'PersonNameInverted', $author->getFullName(true));
00203 XMLCustomWriter::createChildWithText($doc, $contributorNode, 'NamesBeforeKey', join(' ', array($author->getFirstName(), $author->getMiddleName())));
00204 XMLCustomWriter::createChildWithText($doc, $contributorNode, 'KeyNames', $author->getLastName());
00205 XMLCustomWriter::createChildWithText($doc, $contributorNode, 'SuffixToKey', $author->getSuffix(), false);
00206
00207 XMLCustomWriter::createChildWithText($doc, $contributorNode, 'BiographicalNote', strip_tags($author->getLocalizedBiography()));
00208
00209 if ($author->getCountry() != '') {
00210 $contributorPlaceNode =& XMLCustomWriter::createElement($doc, 'ContributorPlace');
00211 XMLCustomWriter::appendChild($contributorNode, $contributorPlaceNode);
00212 XMLCustomWriter::createChildWithText($doc, $contributorPlaceNode, 'ContributorPlaceRelator', '04');
00213 XMLCustomWriter::createChildWithText($doc, $contributorPlaceNode, 'CountryCode', $author->getCountry());
00214 unset($contributorPlaceNode);
00215 }
00216
00217 $sequence++;
00218 unset($contributorNode);
00219 unset($userGroup);
00220 unset($author);
00221 }
00222
00223 if (sizeof($authors) == 0) {
00224 XMLCustomWriter::createChildWithText($doc, $descDetailNode, 'NoContributor', '');
00225 }
00226
00227
00228
00229 $monographLanguageDao =& DAORegistry::getDAO('MonographLanguageDAO');
00230 $allLanguages =& $monographLanguageDao->getLanguages($monograph->getId(), array_keys(AppLocale::getSupportedFormLocales()));
00231 $uniqueLanguages = array();
00232 foreach ($allLanguages as $locale => $languages) {
00233 $uniqueLanguages = array_merge($uniqueLanguages, $languages);
00234 }
00235
00236 foreach ($uniqueLanguages as $language) {
00237 $languageNode =& XMLCustomWriter::createElement($doc, 'Language');
00238 XMLCustomWriter::appendChild($descDetailNode, $languageNode);
00239 XMLCustomWriter::createChildWithText($doc, $languageNode, 'LanguageRole', '01');
00240 $onixLanguageCode = $onixCodelistItemDao->getCodeFromValue($language, 'List74');
00241 XMLCustomWriter::createChildWithText($doc, $languageNode, 'LanguageCode', $onixLanguageCode);
00242 unset($languageNode);
00243 }
00244
00245
00246
00247 if ($publicationFormat->getFrontMatter() > 0) {
00248 $extentNode =& XMLCustomWriter::createElement($doc, 'Extent');
00249 XMLCustomWriter::appendChild($descDetailNode, $extentNode);
00250 XMLCustomWriter::createChildWithText($doc, $extentNode, 'ExtentType', '00');
00251 XMLCustomWriter::createChildWithText($doc, $extentNode, 'ExtentValue', $publicationFormat->getFrontMatter());
00252 XMLCustomWriter::createChildWithText($doc, $extentNode, 'ExtentUnit', '03');
00253 unset($extentNode);
00254 }
00255
00256 if ($publicationFormat->getBackMatter() > 0) {
00257 $extentNode =& XMLCustomWriter::createElement($doc, 'Extent');
00258 XMLCustomWriter::appendChild($descDetailNode, $extentNode);
00259 XMLCustomWriter::createChildWithText($doc, $extentNode, 'ExtentType', '04');
00260 XMLCustomWriter::createChildWithText($doc, $extentNode, 'ExtentValue', $publicationFormat->getBackMatter());
00261 XMLCustomWriter::createChildWithText($doc, $extentNode, 'ExtentUnit', '03');
00262 unset($extentNode);
00263 }
00264
00265 if (!$publicationFormat->getPhysicalFormat()) {
00266 $extentNode =& XMLCustomWriter::createElement($doc, 'Extent');
00267 XMLCustomWriter::appendChild($descDetailNode, $extentNode);
00268 XMLCustomWriter::createChildWithText($doc, $extentNode, 'ExtentType', '08');
00269 $fileSize = $publicationFormat->getFileSize() ? $publicationFormat->getFileSize() : $publicationFormat->getCalculatedFileSize();
00270 XMLCustomWriter::createChildWithText($doc, $extentNode, 'ExtentValue', $fileSize);
00271 XMLCustomWriter::createChildWithText($doc, $extentNode, 'ExtentUnit', '05');
00272 unset($extentNode);
00273 }
00274
00275
00276
00277 $subjectNode =& XMLCustomWriter::createElement($doc, 'Subject');
00278 XMLCustomWriter::appendChild($descDetailNode, $subjectNode);
00279 XMLCustomWriter::createChildWithText($doc, $subjectNode, 'MainSubject', '');
00280 XMLCustomWriter::createChildWithText($doc, $subjectNode, 'SubjectSchemeIdentifier', '12');
00281 XMLCustomWriter::createChildWithText($doc, $subjectNode, 'SubjectSchemeVersion', '2');
00282
00283 $monographSubjectDao =& DAORegistry::getDAO('MonographSubjectDAO');
00284 $allSubjects =& $monographSubjectDao->getSubjects($monograph->getId(), array_keys(AppLocale::getSupportedFormLocales()));
00285 $uniqueSubjects = array();
00286 foreach ($allSubjects as $locale => $subjects) {
00287 $uniqueSubjects = array_merge($uniqueSubjects, $subjects);
00288 }
00289
00290 if (sizeof($uniqueSubjects) > 0) {
00291 XMLCustomWriter::createChildWithText($doc, $subjectNode, 'SubjectCode', join(' ', $uniqueSubjects));
00292 }
00293
00294
00295
00296 $audienceNode =& XMLCustomWriter::createElement($doc, 'Audience');
00297 XMLCustomWriter::appendChild($descDetailNode, $audienceNode);
00298 XMLCustomWriter::createChildWithText($doc, $audienceNode, 'AudienceCodeType', $monograph->getAudience());
00299 XMLCustomWriter::createChildWithText($doc, $audienceNode, 'AudienceCodeValue', '01');
00300
00301
00302
00303 if ($monograph->getAudienceRangeQualifier() != '') {
00304 $audienceRangeNode =& XMLCustomWriter::createElement($doc, 'AudienceRange');
00305 XMLCustomWriter::appendChild($descDetailNode, $audienceRangeNode);
00306 XMLCustomWriter::createChildWithText($doc, $audienceRangeNode, 'AudienceRangeQualifier', $monograph->getAudienceRangeQualifier());
00307 if ($monograph->getAudienceRangeExact() != '') {
00308 XMLCustomWriter::createChildWithText($doc, $audienceRangeNode, 'AudienceRangePrecision', '01');
00309 XMLCustomWriter::createChildWithText($doc, $audienceRangeNode, 'AudienceRangeValue', $monograph->getAudienceRangeExact());
00310 } else {
00311 if ($monograph->getAudienceRangeFrom() != '') {
00312 XMLCustomWriter::createChildWithText($doc, $audienceRangeNode, 'AudienceRangePrecision', '03');
00313 XMLCustomWriter::createChildWithText($doc, $audienceRangeNode, 'AudienceRangeValue', $monograph->getAudienceRangeFrom());
00314 }
00315 if ($monograph->getAudienceRangeTo() != '') {
00316 XMLCustomWriter::createChildWithText($doc, $audienceRangeNode, 'AudienceRangePrecision', '04');
00317 XMLCustomWriter::createChildWithText($doc, $audienceRangeNode, 'AudienceRangeValue', $monograph->getAudienceRangeTo());
00318 }
00319 }
00320 }
00321
00322
00323
00324 $collateralDetailNode =& XMLCustomWriter::createElement($doc, 'CollateralDetail');
00325 XMLCustomWriter::appendChild($productNode, $collateralDetailNode);
00326
00327 $abstract =& strip_tags($monograph->getLocalizedAbstract());
00328
00329 $textContentNode =& XMLCustomWriter::createElement($doc, 'TextContent');
00330 XMLCustomWriter::appendChild($collateralDetailNode, $textContentNode);
00331 XMLCustomWriter::createChildWithText($doc, $textContentNode, 'TextType', '02');
00332 XMLCustomWriter::createChildWithText($doc, $textContentNode, 'ContentAudience', '00');
00333 XMLCustomWriter::createChildWithText($doc, $textContentNode, 'Text', substr($abstract, 0, 250));
00334
00335 $textContentNode =& XMLCustomWriter::createElement($doc, 'TextContent');
00336 XMLCustomWriter::appendChild($collateralDetailNode, $textContentNode);
00337 XMLCustomWriter::createChildWithText($doc, $textContentNode, 'TextType', '03');
00338 XMLCustomWriter::createChildWithText($doc, $textContentNode, 'ContentAudience', '00');
00339 XMLCustomWriter::createChildWithText($doc, $textContentNode, 'Text', $abstract);
00340
00341
00342
00343 $publishingDetailNode =& XMLCustomWriter::createElement($doc, 'PublishingDetail');
00344 XMLCustomWriter::appendChild($productNode, $publishingDetailNode);
00345
00346 if ($publicationFormat->getImprint()) {
00347 $imprintNode =& XMLCustomWriter::createElement($doc, 'Imprint');
00348 XMLCustomWriter::appendChild($publishingDetailNode, $imprintNode);
00349 XMLCustomWriter::createChildWithText($doc, $imprintNode, 'ImprintName', $publicationFormat->getImprint());
00350 unset($imprintNode);
00351 }
00352
00353 $publisherNode =& XMLCustomWriter::createElement($doc, 'Publisher');
00354 XMLCustomWriter::appendChild($publishingDetailNode, $publisherNode);
00355 XMLCustomWriter::createChildWithText($doc, $publisherNode, 'PublishingRole', '01');
00356 XMLCustomWriter::createChildWithText($doc, $publisherNode, 'PublisherName', $press->getSetting('publisher'));
00357 XMLCustomWriter::createChildWithText($doc, $publishingDetailNode, 'CityOfPublication', $press->getSetting('location'), false);
00358
00359 $websiteNode =& XMLCustomWriter::createElement($doc, 'Website');
00360 XMLCustomWriter::appendChild($publisherNode, $websiteNode);
00361 XMLCustomWriter::createChildWithText($doc, $websiteNode, 'WebsiteRole', '18');
00362 XMLCustomWriter::createChildWithText($doc, $websiteNode, 'WebsiteLink', Request::url($press->getPath()));
00363
00364
00365
00366 $publicationDates =& $publicationFormat->getPublicationDates();
00367 while ($date =& $publicationDates->next()) {
00368 $pubDateNode =& XMLCustomWriter::createElement($doc, 'PublishingDate');
00369 XMLCustomWriter::appendChild($publishingDetailNode, $pubDateNode);
00370 XMLCustomWriter::createChildWithText($doc, $pubDateNode, 'PublishingDateRole', $date->getRole());
00371 $dateNode =& XMLCustomWriter::createElement($doc, 'Date');
00372 XMLCustomWriter::setAttribute($dateNode, 'dateformat', $date->getDateFormat());
00373 XMLCustomWriter::appendChild($pubDateNode, $dateNode);
00374 $dateTextNode =& XMLCustomWriter::createTextNode($doc, $date->getDate());
00375 XMLCustomWriter::appendChild($dateNode, $dateTextNode);
00376
00377 unset($pubDateNode);
00378 unset($dateNode);
00379 unset($date);
00380 }
00381
00382
00383
00384 $allSalesRights =& $publicationFormat->getSalesRights();
00385 $salesRightsROW = null;
00386 while ($salesRights =& $allSalesRights->next()) {
00387 if (!$salesRights->getROWSetting()) {
00388
00389 $salesRightsNode =& XMLCustomWriter::createElement($doc, 'SalesRights');
00390 XMLCustomWriter::appendChild($publishingDetailNode, $salesRightsNode);
00391
00392 XMLCustomWriter::createChildWithText($doc, $salesRightsNode, 'SalesRightsType', $salesRights->getType());
00393
00394 $territoryNode =& XMLCustomWriter::createElement($doc, 'Territory');
00395 XMLCustomWriter::appendChild($salesRightsNode, $territoryNode);
00396
00397 if (sizeof($salesRights->getRegionsIncluded()) > 0 && sizeof($salesRights->getCountriesExcluded()) > 0) {
00398 XMLCustomWriter::createChildWithText($doc, $territoryNode, 'RegionsIncluded', join(' ', $salesRights->getRegionsIncluded()));
00399 XMLCustomWriter::createChildWithText($doc, $territoryNode, 'CountriesExcluded', join(' ', $salesRights->getCountriesExcluded()));
00400 } else if (sizeof($salesRights->getCountriesIncluded()) > 0) {
00401 XMLCustomWriter::createChildWithText($doc, $territoryNode, 'CountriesIncluded', join(' ', $salesRights->getCountriesIncluded()));
00402 }
00403
00404 if (sizeof($salesRights->getRegionsExcluded()) > 0) {
00405 XMLCustomWriter::createChildWithText($doc, $territoryNode, 'RegionsExcluded', join(' ', $salesRights->getRegionsExcluded()));
00406 }
00407
00408 unset($territoryNode);
00409 unset($salesRightsNode);
00410
00411 } else {
00412 $salesRightsROW =& $salesRights;
00413 }
00414 unset($salesRights);
00415 }
00416 if ($salesRightsROW != null) {
00417 XMLCustomWriter::createChildWithText($doc, $publishingDetailNode, 'ROWSalesRightsType', $salesRightsROW->getType());
00418 }
00419
00420
00421
00422 $representativeDao =& DAORegistry::getDAO('RepresentativeDAO');
00423 $markets =& $publicationFormat->getMarkets();
00424
00425 while ($market =& $markets->next()) {
00426 $productSupplyNode =& XMLCustomWriter::createElement($doc, 'ProductSupply');
00427 XMLCustomWriter::appendChild($productNode, $productSupplyNode);
00428
00429 $marketNode =& XMLCustomWriter::createElement($doc, 'Market');
00430 XMLCustomWriter::appendChild($productSupplyNode, $marketNode);
00431 $territoryNode =& XMLCustomWriter::createElement($doc, 'Territory');
00432 XMLCustomWriter::appendChild($marketNode, $territoryNode);
00433
00434 if (sizeof($market->getRegionsIncluded()) > 0 && sizeof($market->getCountriesExcluded()) > 0) {
00435 XMLCustomWriter::createChildWithText($doc, $territoryNode, 'RegionsIncluded', join(' ', $market->getRegionsIncluded()));
00436 XMLCustomWriter::createChildWithText($doc, $territoryNode, 'CountriesExcluded', join(' ', $market->getCountriesExcluded()));
00437 } else if (sizeof($market->getCountriesIncluded()) > 0) {
00438 XMLCustomWriter::createChildWithText($doc, $territoryNode, 'CountriesIncluded', join(' ', $market->getCountriesIncluded()));
00439 }
00440
00441 if (sizeof($market->getRegionsExcluded()) > 0) {
00442 XMLCustomWriter::createChildWithText($doc, $territoryNode, 'RegionsExcluded', join(' ', $market->getRegionsExcluded()));
00443 }
00444
00445 unset($marketNode);
00446 unset($territoryNode);
00447
00448
00449
00450 $marketPubDetailNode =& XMLCustomWriter::createElement($doc, 'MarketPublishingDetail');
00451 XMLCustomWriter::appendChild($productSupplyNode, $marketPubDetailNode);
00452 $agent =& $representativeDao->getById($market->getAgentId());
00453
00454 if (isset($agent)) {
00455 $representativeNode =& XMLCustomWriter::createElement($doc, 'PublisherRepresentative');
00456 XMLCustomWriter::appendChild($marketPubDetailNode, $representativeNode);
00457 XMLCustomWriter::createChildWithText($doc, $representativeNode, 'AgentRole', $agent->getRole());
00458 XMLCustomWriter::createChildWithText($doc, $representativeNode, 'AgentName', $agent->getName());
00459 if ($agent->getUrl() != '') {
00460 $agentWebsiteNode =& XMLCustomWriter::createElement($doc, 'Website');
00461 XMLCustomWriter::appendChild($representativeNode, $agentWebsiteNode);
00462 XMLCustomWriter::createChildWithText($doc, $agentWebsiteNode, 'WebsiteRole', '18');
00463 XMLCustomWriter::createChildWithText($doc, $agentWebsiteNode, 'WebsiteLink', $agent->getUrl());
00464 unset($supplierWebsiteNode);
00465 }
00466 unset($representativeNode);
00467 }
00468
00469 XMLCustomWriter::createChildWithText($doc, $marketPubDetailNode, 'MarketPublishingStatus', '04');
00470
00471
00472 $marketDateNode =& XMLCustomWriter::createElement($doc, 'MarketDate');
00473 XMLCustomWriter::appendChild($marketPubDetailNode, $marketDateNode);
00474 XMLCustomWriter::createChildWithText($doc, $marketDateNode, 'MarketDateRole', $market->getDateRole());
00475 XMLCustomWriter::createChildWithText($doc, $marketDateNode, 'DateFormat', $market->getDateFormat());
00476 XMLCustomWriter::createChildWithText($doc, $marketDateNode, 'Date', $market->getDate());
00477
00478 unset($marketDateNode);
00479 unset($marketPubDetailNode);
00480
00481
00482
00483 $supplier =& $representativeDao->getById($market->getSupplierId());
00484 $supplyDetailNode =& XMLCustomWriter::createElement($doc, 'SupplyDetail');
00485 XMLCustomWriter::appendChild($productSupplyNode, $supplyDetailNode);
00486
00487 if (isset($supplier)) {
00488 $supplierNode =& XMLCustomWriter::createElement($doc, 'Supplier');
00489 XMLCustomWriter::appendChild($supplyDetailNode, $supplierNode);
00490 XMLCustomWriter::createChildWithText($doc, $supplierNode, 'SupplierRole', $supplier->getRole());
00491 XMLCustomWriter::createChildWithText($doc, $supplierNode, 'SupplierName', $supplier->getName());
00492 XMLCustomWriter::createChildWithText($doc, $supplierNode, 'TelephoneNumber', $supplier->getPhone(), false);
00493 XMLCustomWriter::createChildWithText($doc, $supplierNode, 'FaxNumber', $supplier->getFax(), false);
00494 XMLCustomWriter::createChildWithText($doc, $supplierNode, 'EmailAddress', $supplier->getEmail(), false);
00495 if ($supplier->getUrl() != '') {
00496 $supplierWebsiteNode =& XMLCustomWriter::createElement($doc, 'Website');
00497 XMLCustomWriter::appendChild($supplierNode, $supplierWebsiteNode);
00498 XMLCustomWriter::createChildWithText($doc, $supplierWebsiteNode, 'WebsiteRole', '18');
00499 XMLCustomWriter::createChildWithText($doc, $supplierWebsiteNode, 'WebsiteLink', $supplier->getUrl());
00500 unset($supplierWebsiteNode);
00501 }
00502 unset($supplierNode);
00503 unset($supplierWebsiteNode);
00504
00505 } else {
00506 $supplierNode =& XMLCustomWriter::createElement($doc, 'Supplier');
00507 XMLCustomWriter::appendChild($supplyDetailNode, $supplierNode);
00508 XMLCustomWriter::createChildWithText($doc, $supplierNode, 'SupplierRole', '09');
00509 XMLCustomWriter::createChildWithText($doc, $supplierNode, 'SupplierName', $press->getSetting('publisher'));
00510 XMLCustomWriter::createChildWithText($doc, $supplierNode, 'EmailAddress', $press->getSetting('contactEmail'), false);
00511 $supplierWebsiteNode =& XMLCustomWriter::createElement($doc, 'Website');
00512 XMLCustomWriter::appendChild($supplierNode, $supplierWebsiteNode);
00513 XMLCustomWriter::createChildWithText($doc, $supplierWebsiteNode, 'WebsiteRole', '18');
00514 XMLCustomWriter::createChildWithText($doc, $supplierWebsiteNode, 'WebsiteLink', Request::url($press->getPath()));
00515 unset($supplierNode);
00516 unset($supplierWebsiteNode);
00517 }
00518 if ($publicationFormat->getReturnableIndicatorCode() != '') {
00519 $returnsNode =& XMLCustomWriter::createElement($doc, 'ReturnsConditions');
00520 XMLCustomWriter::appendChild($supplyDetailNode, $returnsNode);
00521 XMLCustomWriter::createChildWithText($doc, $returnsNode, 'ReturnsCodeType', '02');
00522 XMLCustomWriter::createChildWithText($doc, $returnsNode, 'ReturnsCode', $publicationFormat->getReturnableIndicatorCode());
00523 unset($returnsNode);
00524 }
00525
00526 XMLCustomWriter::createChildWithText($doc, $supplyDetailNode, 'ProductAvailability',
00527 $publicationFormat->getProductAvailabilityCode() ? $publicationFormat->getProductAvailabilityCode() : '20');
00528
00529 $priceNode =& XMLCustomWriter::createElement($doc, 'Price');
00530 XMLCustomWriter::appendChild($supplyDetailNode, $priceNode);
00531 XMLCustomWriter::createChildWithText($doc, $priceNode, 'PriceType', $market->getPriceTypeCode(), false);
00532
00533 if ($market->getDiscount() != '') {
00534 $discountNode =& XMLCustomWriter::createElement($doc, 'Discount');
00535 XMLCustomWriter::appendChild($priceNode, $discountNode);
00536 XMLCustomWriter::createChildWithText($doc, $discountNode, 'DiscountPercent', $market->getDiscount());
00537 unset($discountNode);
00538 }
00539
00540 XMLCustomWriter::createChildWithText($doc, $priceNode, 'PriceAmount', $market->getPrice());
00541
00542 if ($market->getTaxTypeCode() != '' || $market->getTaxRateCode() != '') {
00543 $taxNode =& XMLCustomWriter::createElement($doc, 'Tax');
00544 XMLCustomWriter::appendChild($priceNode, $taxNode);
00545 XMLCustomWriter::createChildWithText($doc, $taxNode, 'TaxType', $market->getTaxTypeCode(), false);
00546 XMLCustomWriter::createChildWithText($doc, $taxNode, 'TaxRateCode', $market->getTaxRateCode(), false);
00547 unset($taxNode);
00548 }
00549 XMLCustomWriter::createChildWithText($doc, $priceNode, 'CurrencyCode', $market->getCurrencyCode(), false);
00550
00551 unset($priceNode);
00552 unset($supplyDetailNode);
00553 unset($market);
00554 }
00555
00556 return $root;
00557 }
00558 }
00559 ?>