function exportArticles(&$results, $outputFile = null)
 {
     $this->import('NativeExportDom');
     $doc =& XMLCustomWriter::createDocument('articles', NATIVE_DTD_ID, NATIVE_DTD_URL);
     $articlesNode =& XMLCustomWriter::createElement($doc, 'articles');
     XMLCustomWriter::appendChild($doc, $articlesNode);
     foreach ($results as $result) {
         $article =& $result['publishedArticle'];
         $section =& $result['section'];
         $issue =& $result['issue'];
         $journal =& $result['journal'];
         $articleNode =& NativeExportDom::generateArticleDom($doc, $journal, $issue, $section, $article);
         XMLCustomWriter::appendChild($articlesNode, $articleNode);
     }
     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=\"articles.xml\"");
         XMLCustomWriter::printXML($doc);
     }
     return true;
 }
Пример #2
0
 function &generateSectionDom(&$doc, &$journal, &$issue, &$section)
 {
     $root =& XMLCustomWriter::createElement($doc, 'section');
     if (is_array($section->getTitle(null))) {
         foreach ($section->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($section->getAbbrev(null))) {
         foreach ($section->getAbbrev(null) as $locale => $abbrev) {
             $abbrevNode =& XMLCustomWriter::createChildWithText($doc, $root, 'abbrev', $abbrev, false);
             if ($abbrevNode) {
                 XMLCustomWriter::setAttribute($abbrevNode, 'locale', $locale);
             }
             unset($abbrevNode);
         }
     }
     if (is_array($section->getIdentifyType(null))) {
         foreach ($section->getIdentifyType(null) as $locale => $identifyType) {
             $identifyTypeNode =& XMLCustomWriter::createChildWithText($doc, $root, 'identify_type', $identifyType, false);
             if ($identifyTypeNode) {
                 XMLCustomWriter::setAttribute($identifyTypeNode, 'locale', $locale);
             }
             unset($identifyTypeNode);
         }
     }
     if (is_array($section->getPolicy(null))) {
         foreach ($section->getPolicy(null) as $locale => $policy) {
             $policyNode =& XMLCustomWriter::createChildWithText($doc, $root, 'policy', $policy, false);
             if ($policyNode) {
                 XMLCustomWriter::setAttribute($policyNode, 'locale', $locale);
             }
             unset($policyNode);
         }
     }
     $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
     foreach ($publishedArticleDao->getPublishedArticlesBySectionId($section->getId(), $issue->getId()) as $article) {
         $articleNode =& NativeExportDom::generateArticleDom($doc, $journal, $issue, $section, $article);
         XMLCustomWriter::appendChild($root, $articleNode);
         unset($articleNode);
     }
     return $root;
 }