Пример #1
0
 function &generateIssueDom(&$doc, &$journal, &$issue)
 {
     $root =& XMLCustomWriter::createElement($doc, 'issue');
     NativeExportDom::generatePubId($doc, $root, $issue, $issue);
     XMLCustomWriter::setAttribute($root, 'published', $issue->getPublished() ? 'true' : 'false');
     switch ((int) $issue->getShowVolume() . (int) $issue->getShowNumber() . (int) $issue->getShowYear() . (int) $issue->getShowTitle()) {
         case '1111':
             $idType = 'num_vol_year_title';
             break;
         case '1110':
             $idType = 'num_vol_year';
             break;
         case '1010':
             $idType = 'vol_year';
             break;
         case '0111':
             $idType = 'num_year_title';
             break;
         case '0010':
             $idType = 'year';
             break;
         case '1000':
             $idType = 'vol';
             break;
         case '0001':
             $idType = 'title';
             break;
         default:
             $idType = null;
     }
     XMLCustomWriter::setAttribute($root, 'identification', $idType, false);
     XMLCustomWriter::setAttribute($root, 'current', $issue->getCurrent() ? 'true' : 'false');
     XMLCustomWriter::setAttribute($root, 'public_id', $issue->getPubId('publisher-id'), false);
     if (is_array($issue->getTitle(null))) {
         foreach ($issue->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($issue->getDescription(null))) {
         foreach ($issue->getDescription(null) as $locale => $description) {
             $descriptionNode =& XMLCustomWriter::createChildWithText($doc, $root, 'description', $description, false);
             if ($descriptionNode) {
                 XMLCustomWriter::setAttribute($descriptionNode, 'locale', $locale);
             }
             unset($descriptionNode);
         }
     }
     XMLCustomWriter::createChildWithText($doc, $root, 'volume', $issue->getVolume(), false);
     XMLCustomWriter::createChildWithText($doc, $root, 'number', $issue->getNumber(), false);
     XMLCustomWriter::createChildWithText($doc, $root, 'year', $issue->getYear(), false);
     if (is_array($issue->getShowCoverPage(null))) {
         foreach (array_keys($issue->getShowCoverPage(null)) as $locale) {
             if ($issue->getShowCoverPage($locale)) {
                 $coverNode =& XMLCustomWriter::createElement($doc, 'cover');
                 XMLCustomWriter::appendChild($root, $coverNode);
                 XMLCustomWriter::setAttribute($coverNode, 'locale', $locale);
                 XMLCustomWriter::createChildWithText($doc, $coverNode, 'caption', $issue->getCoverPageDescription($locale), false);
                 $coverFile = $issue->getFileName($locale);
                 if ($coverFile != '') {
                     $imageNode =& XMLCustomWriter::createElement($doc, 'image');
                     XMLCustomWriter::appendChild($coverNode, $imageNode);
                     import('classes.file.PublicFileManager');
                     $publicFileManager = new PublicFileManager();
                     $coverPagePath = $publicFileManager->getJournalFilesPath($journal->getId()) . '/';
                     $coverPagePath .= $coverFile;
                     $embedNode =& XMLCustomWriter::createChildWithText($doc, $imageNode, 'embed', base64_encode($publicFileManager->readFile($coverPagePath)));
                     XMLCustomWriter::setAttribute($embedNode, 'filename', $issue->getOriginalFileName($locale));
                     XMLCustomWriter::setAttribute($embedNode, 'encoding', 'base64');
                     XMLCustomWriter::setAttribute($embedNode, 'mime_type', String::mime_content_type($coverPagePath));
                 }
                 unset($coverNode);
             }
         }
     }
     XMLCustomWriter::createChildWithText($doc, $root, 'date_published', NativeExportDom::formatDate($issue->getDatePublished()), false);
     if (XMLCustomWriter::createChildWithText($doc, $root, 'access_date', NativeExportDom::formatDate($issue->getOpenAccessDate()), false) == null) {
         // This may be an open access issue. Check and flag
         // as necessary.
         if ($issue->getAccessStatus() == ISSUE_ACCESS_OPEN || $journal->getSetting('publishingMode') == PUBLISHING_MODE_OPEN) {
             $accessNode =& XMLCustomWriter::createElement($doc, 'open_access');
             XMLCustomWriter::appendChild($root, $accessNode);
         }
     }
     $sectionDao =& DAORegistry::getDAO('SectionDAO');
     foreach ($sectionDao->getSectionsForIssue($issue->getId()) as $section) {
         $sectionNode =& NativeExportDom::generateSectionDom($doc, $journal, $issue, $section);
         XMLCustomWriter::appendChild($root, $sectionNode);
         unset($sectionNode);
     }
     return $root;
 }
Пример #2
0
 function &generateIssueDom(&$doc, &$journal, &$issue)
 {
     $root =& XMLCustomWriter::createElement($doc, 'issue');
     XMLCustomWriter::setAttribute($root, 'published', $issue->getPublished() ? 'true' : 'false');
     XMLCustomWriter::setAttribute($root, 'current', $issue->getCurrent() ? 'true' : 'false');
     XMLCustomWriter::setAttribute($root, 'public_id', $issue->getPublicIssueId(), false);
     if (is_array($issue->getTitle(null))) {
         foreach ($issue->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($issue->getDescription(null))) {
         foreach ($issue->getDescription(null) as $locale => $description) {
             $descriptionNode =& XMLCustomWriter::createChildWithText($doc, $root, 'description', $description, false);
             if ($descriptionNode) {
                 XMLCustomWriter::setAttribute($descriptionNode, 'locale', $locale);
             }
             unset($descriptionNode);
         }
     }
     XMLCustomWriter::createChildWithText($doc, $root, 'volume', $issue->getVolume(), false);
     XMLCustomWriter::createChildWithText($doc, $root, 'number', $issue->getNumber(), false);
     XMLCustomWriter::createChildWithText($doc, $root, 'year', $issue->getYear(), false);
     if (is_array($issue->getShowCoverPage(null))) {
         foreach (array_keys($issue->getShowCoverPage(null)) as $locale) {
             if ($issue->getShowCoverPage($locale)) {
                 $coverNode =& XMLCustomWriter::createElement($doc, 'cover');
                 XMLCustomWriter::appendChild($root, $coverNode);
                 XMLCustomWriter::setAttribute($coverNode, 'locale', $locale);
                 XMLCustomWriter::createChildWithText($doc, $coverNode, 'caption', $issue->getCoverPageDescription($locale), false);
                 $coverFile = $issue->getFileName($locale);
                 if ($coverFile != '') {
                     $imageNode =& XMLCustomWriter::createElement($doc, 'image');
                     XMLCustomWriter::appendChild($coverNode, $imageNode);
                     import('file.PublicFileManager');
                     $publicFileManager =& new PublicFileManager();
                     $coverPagePath = $publicFileManager->getJournalFilesPath($journal->getJournalId()) . '/';
                     $coverPagePath .= $coverFile;
                     $embedNode =& XMLCustomWriter::createChildWithText($doc, $imageNode, 'embed', base64_encode($publicFileManager->readFile($coverPagePath)));
                     XMLCustomWriter::setAttribute($embedNode, 'filename', $issue->getOriginalFileName($locale));
                     XMLCustomWriter::setAttribute($embedNode, 'encoding', 'base64');
                     XMLCustomWriter::setAttribute($embedNode, 'mime_type', String::mime_content_type($coverPagePath));
                 }
                 unset($coverNode);
             }
         }
     }
     XMLCustomWriter::createChildWithText($doc, $root, 'date_published', NativeExportDom::formatDate($issue->getDatePublished()), false);
     if (XMLCustomWriter::createChildWithText($doc, $root, 'access_date', NativeExportDom::formatDate($issue->getDatePublished()), false) == null) {
         // This may be an open access issue. Check and flag
         // as necessary.
         if ($issue->getAccessStatus() == OPEN_ACCESS || !$journal->getSetting('enableSubscriptions') && $issue->getAccessStatus() == ISSUE_DEFAULT) {
             $accessNode =& XMLCustomWriter::createElement($doc, 'open_access');
             XMLCustomWriter::appendChild($root, $accessNode);
         }
     }
     $sectionDao =& DAORegistry::getDAO('SectionDAO');
     foreach ($sectionDao->getSectionsForIssue($issue->getIssueId()) as $section) {
         $sectionNode =& NativeExportDom::generateSectionDom($doc, $journal, $issue, $section);
         XMLCustomWriter::appendChild($root, $sectionNode);
         unset($sectionNode);
     }
     return $root;
 }