/** * Export the record * * @return mixed */ public function exportAction() { $driver = $this->loadRecord(); $view = $this->createViewModel(); $format = $this->params()->fromQuery('style'); // Display export menu if missing/invalid option if (empty($format) || !$driver->supportsExport($format)) { if (!empty($format)) { $this->flashMessenger()->setNamespace('error')->addMessage('export_invalid_format'); } $view->setTemplate('record/export-menu'); return $view; } // If this is an export format that redirects to an external site, perform // the redirect now (unless we're being called back from that service!): if (Export::needsRedirect($format) && !$this->params()->fromQuery('callback')) { // Build callback URL: $parts = explode('?', $this->getServerUrl(true)); $callback = $parts[0] . '?callback=1&style=' . urlencode($format); return $this->redirect()->toUrl(Export::getRedirectUrl($format, $callback)); } // Send appropriate HTTP headers for requested format: $response = $this->getResponse(); $response->getHeaders()->addHeaders(Export::getHeaders($format)); // Actually export the record $recordHelper = $this->getViewRenderer()->plugin('record'); $response->setContent($recordHelper($driver)->getExport($format)); return $response; }