public function exportAction()
 {
     if (!$this->getRequest()->isPost()) {
         return $this->_forward('index', 'index');
     }
     $user = $this->getCurrentUser();
     $export = new Editor_Models_Export();
     $export->set('userId', $user['id']);
     $export->set('format', $this->getRequest()->getPost('format'));
     $export->set('type', $this->getRequest()->getPost('type'));
     $export->set('maxDepth', $this->getRequest()->getPost('maxDepth'));
     // Currently this applies only for rtf export.
     $outputFileName = $this->getRequest()->getPost('fileName');
     if (empty($outputFileName)) {
         $export->set('outputFileName', uniqid());
     } else {
         $export->set('outputFileName', $outputFileName);
     }
     $fieldsToExport = $this->getRequest()->getPost('fieldsToExport');
     if (empty($fieldsToExport)) {
         $export->set('fieldsToExport', array());
     } else {
         $export->set('fieldsToExport', explode(',', $this->getRequest()->getPost('fieldsToExport')));
     }
     switch ($export->get('type')) {
         case 'concept':
             $export->set('conceptUuid', $this->getRequest()->getPost('additionalData'));
             // We have the uuid in additionalData.
             break;
         case 'search':
             $searchFormData = Zend_Json::decode($this->getRequest()->getPost('additionalData'), Zend_Json::TYPE_ARRAY);
             // We have the json encoded search form data in additionalData.
             $searchFormData = $this->_fixJsSerializedArrayData('conceptScheme', $searchFormData);
             $searchFormData = $this->_fixJsSerializedArrayData('allowedConceptScheme', $searchFormData);
             $userForSearch = OpenSKOS_Db_Table_Users::requireById($searchFormData['user']);
             $userSearchOptions = $userForSearch->getSearchOptions($user['id'] != $userForSearch['id']);
             $export->set('searchOptions', Editor_Forms_Search::mergeSearchOptions($searchFormData, $userSearchOptions));
             break;
     }
     if ($export->isTimeConsumingExport()) {
         $export->exportWithBackgroundJob();
         $this->_redirect($this->getRequest()->getPost('currentUrl'));
     } else {
         $fileContent = $export->exportToString();
         $fileDetails = $export->getExportFileDetails();
         $this->getHelper('file')->sendFileContent($fileDetails['fileName'], $fileContent, $fileDetails['mimeType']);
     }
 }
Beispiel #2
0
 /**
  * Gets an instance of the api client. Sets the api client tenant.
  * 
  * return Editor_Models_ApiClient
  */
 protected function _getApiClientInstance()
 {
     if (null === $this->_apiClient) {
         $user = OpenSKOS_Db_Table_Users::requireById($this->get('userId'));
         $tenant = OpenSKOS_Db_Table_Tenants::fromCode($user->tenant);
         $this->_apiClient = Editor_Models_ApiClient::factory();
         $this->_apiClient->setTenant($tenant);
     }
     return $this->_apiClient;
 }