Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
Onix30ExportPlugin.inc.php
1 <?php
2 
16 import('classes.plugins.ImportExportPlugin');
17 
22  function Onix30ExportPlugin() {
23  parent::ImportExportPlugin();
24  }
25 
33  function register($category, $path) {
34  $success = parent::register($category, $path);
35  $this->addLocaleData();
36  $this->import('Onix30ExportDeployment');
37  return $success;
38  }
39 
43  function getTemplatePath($inCore = false) {
44  return parent::getTemplatePath($inCore) . 'templates/';
45  }
46 
52  function getName() {
53  return 'Onix30ExportPlugin';
54  }
55 
60  function getDisplayName() {
61  return __('plugins.importexport.onix30.displayName');
62  }
63 
68  function getDescription() {
69  return __('plugins.importexport.onix30.description');
70  }
71 
77  function display($args, $request) {
78  $templateMgr = TemplateManager::getManager($request);
79  $press = $request->getPress();
80 
81  parent::display($args, $request);
82 
83  $templateMgr->assign('plugin', $this);
84 
85  switch (array_shift($args)) {
86  case 'index':
87  case '':
88  $templateMgr->display($this->getTemplatePath() . 'index.tpl');
89  break;
90  case 'export':
91  $exportXml = $this->exportSubmissions(
92  (array) $request->getUserVar('selectedSubmissions'),
93  $request->getContext(),
94  $request->getUser()
95  );
96  header('Content-type: application/xml');
97  echo $exportXml;
98  break;
99  default:
100  $dispatcher = $request->getDispatcher();
101  $dispatcher->handle404();
102  }
103  }
104 
112  function exportSubmissions($submissionIds, $context, $user) {
113  $submissionDao = Application::getSubmissionDAO();
114  $xml = '';
115  $filterDao = DAORegistry::getDAO('FilterDAO');
116  $nativeExportFilters = $filterDao->getObjectsByGroup('monograph=>onix30-xml');
117  assert(count($nativeExportFilters) == 1); // Assert only a single serialization filter
118  $exportFilter = array_shift($nativeExportFilters);
119  $exportFilter->setDeployment(new Onix30ExportDeployment($context, $user));
120  $submissions = array();
121  foreach ($submissionIds as $submissionId) {
122  $submission = $submissionDao->getById($submissionId, $context->getId());
123  if ($submission) $submissions[] = $submission;
124  }
125  $submissionXml = $exportFilter->execute($submission);
126  if ($submissionXml) $xml = $submissionXml->saveXml();
127  else fatalError('Could not convert submissions.');
128  return $xml;
129  }
130 }
131 
132 ?>
static & getDAO($name, $dbconn=null)
ONIX 3.0 XML import/export plugin.
static getSubmissionDAO()
exportSubmissions($submissionIds, $context, $user)
addLocaleData($locale=null)
Definition: Plugin.inc.php:347
Abstract class for import/export plugins.
getTemplatePath($inCore=false)
Class configuring the native import/export process to this application&#39;s specifics.