コード例 #1
0
 function exportArticle(&$journal, &$issue, &$article, &$galley, $outputFile = null)
 {
     $this->import('EruditExportDom');
     $doc =& XMLCustomWriter::createDocument('article', '-//ERUDIT//Erudit Article DTD 3.0.0//EN', 'http://www.erudit.org/dtd/article/3.0.0/en/eruditarticle.dtd');
     $articleNode =& EruditExportDom::generateArticleDom($doc, $journal, $issue, $article, $galley);
     XMLCustomWriter::appendChild($doc, $articleNode);
     if (!empty($outputFile)) {
         if (($h = fopen($outputFile, 'wb')) === 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=\"erudit.xml\"");
         XMLCustomWriter::printXML($doc);
     }
     return true;
 }
コード例 #2
0
 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;
 }
コード例 #3
0
 /**
  * Export a journal's content
  * @param $journal object
  * @param $outputFile string
  */
 function exportJournal(&$journal, $outputFile = null)
 {
     $this->import('DOAJExportDom');
     $doc =& XMLCustomWriter::createDocument();
     $journalNode =& DOAJExportDom::generateJournalDom($doc, $journal);
     $journalNode->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
     $journalNode->setAttribute('xsi:noNamespaceSchemaLocation', DOAJ_XSD_URL);
     XMLCustomWriter::appendChild($doc, $journalNode);
     if (!empty($outputFile)) {
         if (($h = fopen($outputFile, 'wb')) === 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=\"journal-" . $journal->getId() . ".xml\"");
         XMLCustomWriter::printXML($doc);
     }
     return true;
 }
コード例 #4
0
 /**
  * @see DOIExportPlugin::generateExportFiles()
  */
 function generateExportFiles($request, $exportType, &$objects, $targetPath, $journal, &$errors)
 {
     assert(count($objects) >= 1);
     // Identify the O4DOI schema to export.
     $exportIssuesAs = $this->getSetting($journal->getId(), 'exportIssuesAs');
     $schema = $this->_identifyO4DOISchema($exportType, $journal, $exportIssuesAs);
     assert(!is_null($schema));
     // Create the XML DOM and document.
     $this->import('classes.O4DOIExportDom');
     $dom = new O4DOIExportDom($request, $this, $schema, $journal, $this->getCache(), $exportIssuesAs);
     $doc =& $dom->generate($objects);
     if ($doc === false) {
         $errors =& $dom->getErrors();
         return false;
     }
     // Write the result to the target file.
     $exportFileName = $this->getTargetFileName($targetPath, $exportType);
     file_put_contents($exportFileName, XMLCustomWriter::getXML($doc));
     $generatedFiles = array($exportFileName => &$objects);
     return $generatedFiles;
 }
コード例 #5
0
 function exportIssues(&$journal, &$issues, $outputFile = null)
 {
     $this->import('PubMedExportDom');
     $doc =& PubMedExportDom::generatePubMedDom();
     $articleSetNode =& PubMedExportDom::generateArticleSetDom($doc);
     $sectionDao = DAORegistry::getDAO('SectionDAO');
     $publishedArticleDao = DAORegistry::getDAO('PublishedArticleDAO');
     foreach ($issues as $issue) {
         foreach ($sectionDao->getByIssueId($issue->getId()) as $section) {
             foreach ($publishedArticleDao->getPublishedArticlesBySectionId($section->getId(), $issue->getId()) as $article) {
                 $articleNode = PubMedExportDom::generateArticleDom($doc, $journal, $issue, $section, $article);
                 XMLCustomWriter::appendChild($articleSetNode, $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=\"pubmed.xml\"");
         XMLCustomWriter::printXML($doc);
     }
     return true;
 }
コード例 #6
0
 /**
  * @see DOIExportPlugin::generateExportFiles()
  */
 function generateExportFiles($request, $exportType, &$objects, $targetPath, $journal, &$errors)
 {
     // Additional locale file.
     AppLocale::requireComponents(array(LOCALE_COMPONENT_APP_EDITOR));
     // Export objects one by one (DataCite does not allow
     // multiple objects per file).
     $this->import('classes.DataciteExportDom');
     $exportFiles = array();
     foreach ($objects as $object) {
         // Generate the export XML.
         $dom = new DataciteExportDom($request, $this, $journal, $this->getCache());
         $doc =& $dom->generate($object);
         if ($doc === false) {
             $this->cleanTmpfiles($targetPath, array_keys($exportFiles));
             $errors =& $dom->getErrors();
             return false;
         }
         // Write the result.
         $exportFile = $this->getTargetFileName($targetPath, $exportType, $object->getId());
         file_put_contents($exportFile, XMLCustomWriter::getXML($doc));
         $fileManager = new FileManager();
         $fileManager->setMode($exportFile, FILE_MODE_MASK);
         $exportFiles[$exportFile] = array(&$object);
         unset($object);
     }
     return $exportFiles;
 }
コード例 #7
0
 /**
  * Execute import/export tasks using the command-line interface.
  * @param $args Parameters to the plugin
  */
 function executeCLI($scriptName, &$args)
 {
     $command = array_shift($args);
     $xmlFile = array_shift($args);
     $schedConfPath = array_shift($args);
     $flags =& $args;
     $schedConfDao =& DAORegistry::getDAO('SchedConfDAO');
     $userDao =& DAORegistry::getDAO('UserDAO');
     $schedConf =& $schedConfDao->getSchedConfByPath($schedConfPath);
     if (!$schedConf) {
         if ($schedConfPath != '') {
             echo Locale::translate('plugins.importexport.users.import.errorsOccurred') . ":\n";
             echo Locale::translate('plugins.importexport.users.unknownSchedConf', array('schedConfPath' => $schedConfPath)) . "\n\n";
         }
         $this->usage($scriptName);
         return;
     }
     switch ($command) {
         case 'import':
             $this->import('UserXMLParser');
             $sendNotify = in_array('send_notify', $flags);
             $continueOnError = in_array('continue_on_error', $flags);
             import('file.FileManager');
             // Import the uploaded file
             $parser = new UserXMLParser($schedConf->getConferenceId(), $schedConf->getId());
             $users =& $parser->parseData($xmlFile);
             if (!$parser->importUsers($sendNotify, $continueOnError)) {
                 // Failure.
                 echo Locale::translate('plugins.importexport.users.import.errorsOccurred') . ":\n";
                 foreach ($parser->getErrors() as $error) {
                     echo "\t{$error}\n";
                 }
                 return false;
             }
             // Success.
             echo Locale::translate('plugins.importexport.users.import.usersWereImported') . ":\n";
             foreach ($parser->getImportedUsers() as $user) {
                 echo "\t" . $user->getUserName() . "\n";
             }
             return true;
             break;
         case 'export':
             $this->import('UserExportDom');
             $roleDao =& DAORegistry::getDAO('RoleDAO');
             $rolePaths = null;
             if (empty($args)) {
                 $users =& $roleDao->getUsersBySchedConfId($schedConf->getId());
                 $users =& $users->toArray();
             } else {
                 $users = array();
                 $rolePaths = array();
                 foreach ($args as $rolePath) {
                     $roleId = $roleDao->getRoleIdFromPath($rolePath);
                     $thisRoleUsers =& $roleDao->getUsersByRoleId($roleId, $schedConf->getId());
                     foreach ($thisRoleUsers->toArray() as $user) {
                         $users[$user->getId()] = $user;
                     }
                     $rolePaths[] = $rolePath;
                 }
                 $users = array_values($users);
             }
             $doc =& UserExportDom::exportUsers($schedConf, $users, $rolePaths);
             if (($h = fopen($xmlFile, 'wb')) === false) {
                 echo Locale::translate('plugins.importexport.users.export.errorsOccurred') . ":\n";
                 echo Locale::translate('plugins.importexport.users.export.couldNotWriteFile', array('fileName' => $xmlFile)) . "\n";
                 return false;
             }
             fwrite($h, XMLCustomWriter::getXML($doc));
             fclose($h);
             return true;
     }
     $this->usage($scriptName);
 }
コード例 #8
0
 function exportIssues(&$journal, &$issues, $outputFile = null)
 {
     $this->import('CrossRefExportDom');
     $doc =& CrossRefExportDom::generateCrossRefDom();
     $doiBatchNode =& CrossRefExportDom::generateDoiBatchDom($doc);
     $journal =& Request::getJournal();
     // Create Head Node and all parts inside it
     $head =& CrossRefExportDom::generateHeadDom($doc, $journal);
     // attach it to the root node
     XMLCustomWriter::appendChild($doiBatchNode, $head);
     $bodyNode =& XMLCustomWriter::createElement($doc, 'body');
     XMLCustomWriter::appendChild($doiBatchNode, $bodyNode);
     $sectionDao =& DAORegistry::getDAO('SectionDAO');
     $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
     foreach ($issues as $issue) {
         foreach ($sectionDao->getSectionsForIssue($issue->getId()) as $section) {
             foreach ($publishedArticleDao->getPublishedArticlesBySectionId($section->getId(), $issue->getId()) as $article) {
                 // Create the metadata node
                 // this does not need to be repeated for every article
                 // but its allowed to be and its simpler to do so
                 $journalNode =& XMLCustomWriter::createElement($doc, 'journal');
                 $journalMetadataNode =& CrossRefExportDom::generateJournalMetadataDom($doc, $journal);
                 XMLCustomWriter::appendChild($journalNode, $journalMetadataNode);
                 $journalIssueNode =& CrossRefExportDom::generateJournalIssueDom($doc, $journal, $issue, $section, $article);
                 XMLCustomWriter::appendChild($journalNode, $journalIssueNode);
                 // Article node
                 $journalArticleNode =& CrossRefExportDom::generateJournalArticleDom($doc, $journal, $issue, $section, $article);
                 XMLCustomWriter::appendChild($journalNode, $journalArticleNode);
                 // DOI data node
                 $DOIdataNode =& CrossRefExportDom::generateDOIdataDom($doc, $article->getDOI(), Request::url(null, 'article', 'view', $article->getId()));
                 XMLCustomWriter::appendChild($journalArticleNode, $DOIdataNode);
                 XMLCustomWriter::appendChild($bodyNode, $journalNode);
             }
         }
     }
     // dump out results
     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=\"crossref.xml\"");
         XMLCustomWriter::printXML($doc);
     }
     return true;
 }
コード例 #9
0
 function exportPapers(&$results, $outputFile = null)
 {
     $this->import('NativeExportDom');
     $doc =& XMLCustomWriter::createDocument('papers', NATIVE_DTD_ID, NATIVE_DTD_URL);
     $papersNode =& XMLCustomWriter::createElement($doc, 'papers');
     XMLCustomWriter::appendChild($doc, $papersNode);
     foreach ($results as $result) {
         $paper =& $result['publishedPaper'];
         $track =& $result['track'];
         $conference =& $result['conference'];
         $schedConf =& $result['schedConf'];
         $paperNode =& NativeExportDom::generatePaperDom($doc, $schedConf, $track, $paper);
         XMLCustomWriter::appendChild($papersNode, $paperNode);
     }
     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=\"papers.xml\"");
         XMLCustomWriter::printXML($doc);
     }
     return true;
 }
 /**
  * Export public identifiers of one or more issues.
  * @param $journal object
  * @param $issues array
  * @param $outputFile xml file containing the exported public identifiers
  */
 function exportPubIdsForIssues($journal, $issues, $outputFile = null)
 {
     $doc =& XMLCustomWriter::createDocument('pubIds', PID_DTD_URL, PID_DTD_URL);
     $pubIdsNode =& XMLCustomWriter::createElement($doc, 'pubIds');
     XMLCustomWriter::appendChild($doc, $pubIdsNode);
     foreach ($issues as $issue) {
         $this->generatePubId($doc, $pubIdsNode, $issue, $journal->getId());
         $publishedArticleDao = DAORegistry::getDAO('PublishedArticleDAO');
         foreach ($publishedArticleDao->getPublishedArticles($issue->getId()) as $publishedArticle) {
             $this->generatePubId($doc, $pubIdsNode, $publishedArticle, $journal->getId());
             $articleGalleyDao = DAORegistry::getDAO('ArticleGalleyDAO');
             $galleys = $articleGalleyDao->getBySubmissionId($publishedArticle->getId());
             while ($galley = $galleys->next()) {
                 $this->generatePubId($doc, $pubIdsNode, $galley, $journal->getId());
             }
         }
     }
     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=\"pubIds.xml\"");
         XMLCustomWriter::printXML($doc);
     }
     return true;
 }
コード例 #11
0
ファイル: NLMExportPlugin.inc.php プロジェクト: jalperin/ocs
 function exportPapers(&$results, $outputFile = null)
 {
     $this->import('NLMExportDom');
     $doc =& NLMExportDom::generateNLMDom();
     $paperSetNode =& NLMExportDom::generatePaperSetDom($doc);
     foreach ($results as $result) {
         $conference =& $result['conference'];
         $track =& $result['track'];
         $paper =& $result['publishedPaper'];
         $paperNode =& NLMExportDom::generatePaperDom($doc, $conference, $track, $paper);
         XMLCustomWriter::appendChild($paperSetNode, $paperNode);
     }
     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=\"nlm.xml\"");
         XMLCustomWriter::printXML($doc);
         //echo '<pre>'.htmlentities(preg_replace('/></', ">\n<", XMLCustomWriter::getXML($doc))).'</pre>';
     }
     return true;
 }
コード例 #12
0
 /**
  * @see DOIExportPlugin::generateExportFiles()
  */
 function generateExportFiles(&$request, $exportType, &$objects, $targetPath, &$journal, &$errors)
 {
     // Additional locale file.
     AppLocale::requireComponents(array(LOCALE_COMPONENT_OJS_EDITOR));
     $this->import('classes.CrossRefExportDom');
     $dom = new CrossRefExportDom($request, $this, $journal, $this->getCache());
     $doc =& $dom->generate($objects);
     if ($doc === false) {
         $errors =& $dom->getErrors();
         return false;
     }
     // Write the result to the target file.
     $exportFileName = $this->getTargetFileName($targetPath, $exportType);
     file_put_contents($exportFileName, XMLCustomWriter::getXML($doc));
     $generatedFiles = array($exportFileName => &$objects);
     return $generatedFiles;
 }
コード例 #13
0
 function processRegisterObjects(&$request, $exportType, &$objects, $exportPath, &$journal, &$errors)
 {
     // Run through the export types and generate the corresponding
     // export files.
     $exportFiles = array();
     // Export the object(s) to file(s).
     // Additional locale file.
     AppLocale::requireComponents(array(LOCALE_COMPONENT_OJS_EDITOR));
     $this->import('classes.EzidExportDom');
     foreach ($objects as $object) {
         // Write the result to the target file.
         $exportFileName = $this->getTargetFileName($exportPath, $exportType, $object->getId());
         $dom = new EzidExportDom($request, $this, $journal, $this->getCache());
         $object_array = array();
         array_push($object_array, $object);
         $doc =& $dom->generate($object_array);
         if ($doc === false) {
             $errors =& $dom->getErrors();
             return $errors;
         }
         file_put_contents($exportFileName, XMLCustomWriter::getXML($doc));
         $result = $this->registerDoi($request, $journal, $object, $exportFileName);
         if ($result !== true) {
             $this->cleanTmpfiles($exportPath, $exportFiles);
             return $result;
         }
     }
     // Remove all temporary files.
     $this->cleanTmpfiles($exportPath, $exportFiles);
     return true;
 }
コード例 #14
0
 /**
  * Export a journal's content
  * @param $journal object
  * @param $outputFile string
  */
 function exportJournal(&$journal, $outputFile = null)
 {
     $this->import('DOAJExportDom');
     $doc =& XMLCustomWriter::createDocument('journal', DOAJ_XSD_URL);
     $journalNode =& DOAJExportDom::generateJournalDom($doc, $journal);
     XMLCustomWriter::appendChild($doc, $journalNode);
     if (!empty($outputFile)) {
         if (($h = fopen($outputFile, 'wb')) === 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=\"journal-" . $journal->getJournalId() . ".xml\"");
         XMLCustomWriter::printXML($doc);
     }
     return true;
 }