/** * Actually perform the export operation. * * @return mixed */ public function doexportAction() { // We use abbreviated parameters here to keep the URL short (there may // be a long list of IDs, and we don't want to run out of room): $ids = $this->params()->fromQuery('i', array()); $format = $this->params()->fromQuery('f'); // Make sure we have IDs to export: if (!is_array($ids) || empty($ids)) { return $this->redirectToSource('error', 'bulk_noitems_advice'); } // Send appropriate HTTP headers for requested format: $response = $this->getResponse(); $response->getHeaders()->addHeaders(Export::getHeaders($format)); // Actually export the records $records = $this->getRecordLoader()->loadBatch($ids); $recordHelper = $this->getViewRenderer()->plugin('record'); $parts = array(); foreach ($records as $record) { $parts[] = $recordHelper($record)->getExport($format); } // Process and display the exported records $response->setContent(Export::processGroup($format, $parts)); return $response; }
/** * 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; }