/**
  * Process an export request
  *
  * @return \Zend\Http\Response
  */
 protected function exportFavorites()
 {
     $format = $this->params()->fromPost('format');
     $url = Export::getBulkUrl($this->getViewRenderer(), $format, $this->params()->fromPost('ids', array()));
     $html = $this->getViewRenderer()->render('ajax/export-favorites.phtml', array('url' => $url, 'format' => $format));
     return $this->output(array('result' => $this->translate('Done'), 'result_additional' => $html), self::STATUS_OK);
 }
 /**
  * Set up export of a batch of records.
  *
  * @return mixed
  */
 public function exportAction()
 {
     // Get the desired ID list:
     $ids = is_null($this->params()->fromPost('selectAll')) ? $this->params()->fromPost('ids') : $this->params()->fromPost('idsAll');
     if (!is_array($ids) || empty($ids)) {
         return $this->redirectToSource('error', 'bulk_noitems_advice');
     }
     // Process form submission if necessary:
     if (!is_null($this->params()->fromPost('submit'))) {
         $format = $this->params()->fromPost('format');
         $url = Export::getBulkUrl($this->getViewRenderer(), $format, $ids);
         if (Export::needsRedirect($format)) {
             return $this->redirect()->toUrl($url);
         }
         $msg = array('translate' => false, 'html' => true, 'msg' => $this->getViewRenderer()->render('cart/export-success.phtml', array('url' => $url)));
         return $this->redirectToSource('info', $msg);
     }
     // Load the records:
     $view = $this->createViewModel();
     $view->records = $this->getRecordLoader()->loadBatch($ids);
     // Assign the list of legal export options.  We'll filter them down based
     // on what the selected records actually support.
     $view->exportOptions = Export::getBulkOptions();
     foreach ($view->records as $driver) {
         // Filter out unsupported export formats:
         $newFormats = array();
         foreach ($view->exportOptions as $current) {
             if ($driver->supportsExport($current)) {
                 $newFormats[] = $current;
             }
         }
         $view->exportOptions = $newFormats;
     }
     // No legal export options?  Display a warning:
     if (empty($view->exportOptions)) {
         $this->flashMessenger()->setNamespace('error')->addMessage('bulk_export_not_supported');
     }
     return $view;
 }