/** * * */ public function DownloadRepresentations() { if ($t_subject = $this->opo_datamodel->getInstanceByTableName($this->ops_tablename, true)) { $pa_ids = null; if ($vs_ids = trim($this->request->getParameter($t_subject->tableName(), pString))) { if ($vs_ids != 'all') { $pa_ids = explode(';', $vs_ids); foreach ($pa_ids as $vn_i => $vs_id) { if (!trim($vs_id) || !(int) $vs_id) { unset($pa_ids[$vn_i]); } } } } if (!is_array($pa_ids) || !sizeof($pa_ids)) { $pa_ids = $this->opo_result_context->getResultList(); } $vn_file_count = 0; if (is_array($pa_ids) && sizeof($pa_ids)) { $ps_version = $this->request->getParameter('version', pString); if ($qr_res = $t_subject->makeSearchResult($t_subject->tableName(), $pa_ids, array('filterNonPrimaryRepresentations' => false))) { $o_zip = new ZipFile(); if (!($vn_limit = ini_get('max_execution_time'))) { $vn_limit = 30; } set_time_limit($vn_limit * 2); while ($qr_res->nextHit()) { if (!is_array($va_version_list = $qr_res->getMediaVersions('ca_object_representations.media')) || !in_array($ps_version, $va_version_list)) { $vs_version = 'original'; } else { $vs_version = $ps_version; } $va_paths = $qr_res->getMediaPaths('ca_object_representations.media', $vs_version); $va_infos = $qr_res->getMediaInfos('ca_object_representations.media'); $va_representation_ids = $qr_res->get('ca_object_representations.representation_id', array('returnAsArray' => true)); foreach ($va_paths as $vn_i => $vs_path) { $vs_ext = array_pop(explode(".", $vs_path)); $vs_idno_proc = preg_replace('![^A-Za-z0-9_\\-]+!', '_', $qr_res->get($t_subject->tableName() . '.idno')); $vs_original_name = $va_infos[$vn_i]['ORIGINAL_FILENAME']; $vn_index = sizeof($va_paths) > 1 ? "_" . ($vn_i + 1) : ''; $vn_representation_id = $va_representation_ids[$vn_i]; // make sure we don't download representations the user isn't allowed to read if (!caCanRead($this->request->user->getPrimaryKey(), 'ca_object_representations', $vn_representation_id)) { continue; } switch ($this->request->user->getPreference('downloaded_file_naming')) { case 'idno': $vs_filename = "{$vs_idno_proc}{$vn_index}.{$vs_ext}"; break; case 'idno_and_version': $vs_filename = "{$vs_idno_proc}_{$vs_version}{$vn_index}.{$vs_ext}"; break; case 'idno_and_rep_id_and_version': $vs_filename = "{$vs_idno_proc}_representation_{$vn_representation_id}_{$vs_version}{$vn_index}.{$vs_ext}"; break; case 'original_name': default: if ($vs_original_name) { $va_tmp = explode('.', $vs_original_name); if (sizeof($va_tmp) > 1) { if (strlen($vs_ext = array_pop($va_tmp)) < 3) { $va_tmp[] = $vs_ext; } } $vs_filename = join('_', $va_tmp) . "{$vn_index}.{$vs_ext}"; } else { $vs_filename = "{$vs_idno_proc}_representation_{$vn_representation_id}_{$vs_version}{$vn_index}.{$vs_ext}"; } break; } if ($vs_path_with_embedding = caEmbedMetadataIntoRepresentation(new ca_objects($qr_res->get('ca_objects.object_id')), new ca_object_representations($vn_representation_id), $vs_version)) { $vs_path = $vs_path_with_embedding; } $o_zip->addFile($vs_path, $vs_filename, 0, array('compression' => 0)); $vn_file_count++; } } $this->view->setVar('zip', $o_zip); $this->view->setVar('download_name', 'media_for_' . mb_substr(preg_replace('![^A-Za-z0-9]+!u', '_', $this->getCriteriaForDisplay()), 0, 20) . '.zip'); set_time_limit($vn_limit); } } if ($vn_file_count > 0) { $this->render('Results/object_representation_download_binary.php'); } else { $this->response->setHTTPResponseCode(204, _t('No files to download')); } return; } // post error $this->postError(3100, _t("Could not generate ZIP file for download"), "BaseEditorController->DownloadRepresentation()"); }
/** * Export a record set as defined by the given search expression and the table_num for this exporter. * This function wraps the record-level exports using the settings 'wrap_before' and 'wrap_after' if they are set. * @param string $ps_exporter_code defines the exporter to use * @param SearchResult $po_result An existing SearchResult object * @param string $ps_filename Destination filename (we can't keep everything in memory here) * @param array $pa_options * progressCallback = callback function for asynchronous UI status reporting * showCLIProgressBar = Show command-line progress bar. Default is false. * logDirectory = path to directory where logs should be written * logLevel = KLogger constant for minimum log level to record. Default is KLogger::INFO. Constants are, in descending order of shrillness: * KLogger::EMERG = Emergency messages (system is unusable) * KLogger::ALERT = Alert messages (action must be taken immediately) * KLogger::CRIT = Critical conditions * KLogger::ERR = Error conditions * KLogger::WARN = Warnings * KLogger::NOTICE = Notices (normal but significant conditions) * KLogger::INFO = Informational messages * KLogger::DEBUG = Debugging messages * @return boolean success state */ public static function exportRecordsFromSearchResult($ps_exporter_code, $po_result, $ps_filename, $pa_options = array()) { if (!$po_result instanceof SearchResult) { return false; } $vs_log_dir = caGetOption('logDirectory', $pa_options); if (!file_exists($vs_log_dir) || !is_writable($vs_log_dir)) { $vs_log_dir = caGetTempDirPath(); } if (!($vn_log_level = caGetOption('logLevel', $pa_options))) { $vn_log_level = KLogger::INFO; } $o_log = new KLogger($vs_log_dir, $vn_log_level); ca_data_exporters::$s_exporter_cache = array(); ca_data_exporters::$s_exporter_item_cache = array(); $vb_show_cli_progress_bar = isset($pa_options['showCLIProgressBar']) && $pa_options['showCLIProgressBar']; $po_request = caGetOption('request', $pa_options, null); $vb_have_request = $po_request instanceof RequestHTTP; if (!($t_mapping = ca_data_exporters::loadExporterByCode($ps_exporter_code))) { return false; } $va_errors = ca_data_exporters::checkMapping($ps_exporter_code); if (sizeof($va_errors) > 0) { if ($po_request && isset($pa_options['progressCallback']) && ($ps_callback = $pa_options['progressCallback'])) { $ps_callback($po_request, 0, -1, _t('Export failed: %1', join("; ", $va_errors)), 0, memory_get_usage(true), 0); } return false; } $o_log->logInfo(_t("Starting SearchResult-based multi-record export for mapping %1.", $ps_exporter_code)); $vn_start_time = time(); $vs_wrap_before = $t_mapping->getSetting('wrap_before'); $vs_wrap_after = $t_mapping->getSetting('wrap_after'); $t_instance = $t_mapping->getAppDatamodel()->getInstanceByTableNum($t_mapping->get('table_num')); $vn_num_items = $po_result->numHits(); $o_log->logInfo(_t("SearchResult contains %1 results. Now calling single-item export for each record.", $vn_num_items)); if ($vs_wrap_before) { file_put_contents($ps_filename, $vs_wrap_before . "\n", FILE_APPEND); } if ($vb_show_cli_progress_bar) { print CLIProgressBar::start($vn_num_items, _t('Processing search result')); } if ($po_request && isset($pa_options['progressCallback']) && ($ps_callback = $pa_options['progressCallback'])) { if ($vn_num_items > 0) { $ps_callback($po_request, 0, $vn_num_items, _t("Exporting result"), time() - $vn_start_time, memory_get_usage(true), 0); } else { $ps_callback($po_request, 0, -1, _t('Found no records to export'), time() - $vn_start_time, memory_get_usage(true), 0); } } $vn_num_processed = 0; if ($t_mapping->getSetting('CSV_print_field_names')) { $va_header = $va_header_sources = array(); $va_mapping_items = $t_mapping->getItems(); foreach ($va_mapping_items as $vn_i => $va_mapping_item) { $va_settings = caUnserializeForDatabase($va_mapping_item['settings']); $va_header_sources[(int) $va_mapping_item['element']] = $va_settings['_id'] ? $va_settings['_id'] : $va_mapping_item['source']; } ksort($va_header_sources); foreach ($va_header_sources as $vn_element => $vs_source) { $va_tmp = explode(".", $vs_source); if ($t_table = $t_mapping->getAppDatamodel()->getInstanceByTableName($va_tmp[0], true)) { $va_header[] = $t_table->getDisplayLabel($vs_source); } else { $va_header[] = $vs_source; } } file_put_contents($ps_filename, join(",", $va_header) . "\n", FILE_APPEND); } $i = 0; while ($po_result->nextHit()) { // clear caches every once in a while. doesn't make much sense to keep them around while exporting if (++$i % 1000 == 0) { SearchResult::clearCaches(); ca_data_exporters::clearCaches(); } if ($vb_have_request) { if (!caCanRead($po_request->getUserID(), $t_instance->tableNum(), $po_result->get($t_instance->primaryKey()))) { continue; } } $vs_item_export = ca_data_exporters::exportRecord($ps_exporter_code, $po_result->get($t_instance->primaryKey()), array('logger' => $o_log)); file_put_contents($ps_filename, $vs_item_export . "\n", FILE_APPEND); if ($vb_show_cli_progress_bar) { print CLIProgressBar::next(1, _t("Exporting records ...")); } $vn_num_processed++; if ($vb_have_request && isset($pa_options['progressCallback']) && ($ps_callback = $pa_options['progressCallback'])) { $ps_callback($po_request, $vn_num_processed, $vn_num_items, _t("Exporting ... [%1/%2]", $vn_num_processed, $vn_num_items), time() - $vn_start_time, memory_get_usage(true), $vn_num_processed); } } if ($vs_wrap_after) { file_put_contents($ps_filename, $vs_wrap_after . "\n", FILE_APPEND); } if ($vb_show_cli_progress_bar) { print CLIProgressBar::finish(); } if ($po_request && isset($pa_options['progressCallback']) && ($ps_callback = $pa_options['progressCallback'])) { $ps_callback($po_request, $vn_num_items, $vn_num_items, _t('Export completed'), time() - $vn_start_time, memory_get_usage(true), $vn_num_processed); } return true; }
/** * Fetch details on an item from a remote data source and output results of the 'display' key in the response. * */ public function GetDetail() { $pn_element_id = $this->request->getParameter('element_id', pInteger); $t_element = new ca_metadata_elements($pn_element_id); $va_data = array(); if (!$t_element->getPrimaryKey()) { // error $va_items['error'] = array('label' => _t('ERROR: Invalid element_id'), 'idno' => ''); } else { $vs_service = $t_element->getSetting('service'); $va_settings = $t_element->getSettings(); $pn_attribute_id = $this->request->getParameter('id', pInteger); $t_attr_val = new ca_attribute_values(); if ($t_attr_val->load(array('attribute_id' => $pn_attribute_id, 'element_id' => $pn_element_id))) { $t_attr = new ca_attributes(); if ($t_attr->load($pn_attribute_id)) { if (!caCanRead($this->request->getUserID(), $t_attr->get('table_num'), $t_attr->get('row_id'), $t_element->get('element_code'))) { $va_items['error'] = array('label' => _t('ERROR: You do not have access to this item'), 'idno' => ''); } else { $vs_url = $t_attr_val->get('value_longtext2'); if (!($o_plugin = InformationServiceManager::getInformationServiceInstance($vs_service))) { $va_items['error'] = array('label' => _t('ERROR: Invalid service'), 'idno' => ''); } else { $vs_cache_key = md5(print_r($va_settings, true) . $vs_url); if (CompositeCache::contains($vs_cache_key, 'InformationServiceExtendedInfo')) { $va_data = CompositeCache::fetch($vs_cache_key, 'InformationServiceExtendedInfo'); } else { $va_data = $o_plugin->getExtendedInformation($va_settings, $vs_url); CompositeCache::save($vs_cache_key, $va_data, 'InformationServiceExtendedInfo'); } } } } } } $this->view->setVar('detail', $va_data); return $this->render('ajax_information_service_detail_html.php'); }
/** * Returns information about representations linked to the currently loaded item. Use this if you want to get the urls, tags and other information for all representations associated with a given item. * * @param array $pa_versions An array of media versions to include information for. If you omit this then a single version, 'preview170', is assumed by default. * @param array $pa_version_sizes Optional array of sizes to force specific versions to. The array keys are version names; the values are arrays with two keys: 'width' and 'height'; if present these values will be used in lieu of the actual values in the database * @param array $pa_options An optional array of options to use when getting representation information. Supported options are: * return_primary_only - If true then only the primary representation will be returned * return_with_access - Set to an array of access values to filter representation through; only representations with an access value in the list will be returned * checkAccess - synonym for return_with_access * start = * limit = * restrict_to_types = An array of type_ids or type codes to restrict count to specified types of representations to * restrict_to_relationship_types = An array of relationship type_ids or relationship codes to restrict count to * .. and options supported by getMediaTag() .. [they are passed through] * * @return array An array of information about the linked representations */ public function getRepresentations($pa_versions = null, $pa_version_sizes = null, $pa_options = null) { global $AUTH_CURRENT_USER_ID; if (!($vn_id = $this->getPrimaryKey())) { return null; } if (!is_array($pa_options)) { $pa_options = array(); } $pn_start = caGetOption('start', $pa_options, 0); $pn_limit = caGetOption('limit', $pa_options, null); if (caGetBundleAccessLevel($this->tableName(), 'ca_object_representations') == __CA_BUNDLE_ACCESS_NONE__) { return null; } if (!is_array($pa_versions)) { $pa_versions = array('preview170'); } if (isset($pa_options['return_primary_only']) && $pa_options['return_primary_only']) { $vs_is_primary_sql = ' AND (caoor.is_primary = 1)'; } else { $vs_is_primary_sql = ''; } if ($pa_options['checkAccess']) { $pa_options['return_with_access'] = $pa_options['checkAccess']; } if (is_array($pa_options['return_with_access']) && sizeof($pa_options['return_with_access']) > 0) { $vs_access_sql = ' AND (caor.access IN (' . join(", ", $pa_options['return_with_access']) . '))'; } else { $vs_access_sql = ''; } $o_db = $this->getDb(); if (!($vs_linking_table = RepresentableBaseModel::getRepresentationRelationshipTableName($this->tableName()))) { return null; } $vs_pk = $this->primaryKey(); $vs_limit_sql = ''; if ($pn_limit > 0) { if ($pn_start > 0) { $vs_limit_sql = "LIMIT {$pn_start}, {$pn_limit}"; } else { $vs_limit_sql = "LIMIT {$pn_limit}"; } } $va_type_restriction_filters = $this->_getRestrictionSQL($vs_linking_table, (int) $vn_id, $pa_options); $qr_reps = $o_db->query("\n\t\t\t\tSELECT caor.representation_id, caor.media, caoor.is_primary, caor.access, caor.status, l.name, caor.locale_id, caor.media_metadata, caor.type_id, caor.idno, caor.idno_sort, caor.md5, caor.mimetype, caor.original_filename, caoor.rank, caoor.relation_id\n\t\t\t\tFROM ca_object_representations caor\n\t\t\t\tINNER JOIN {$vs_linking_table} AS caoor ON caor.representation_id = caoor.representation_id\n\t\t\t\tLEFT JOIN ca_locales AS l ON caor.locale_id = l.locale_id\n\t\t\t\tWHERE\n\t\t\t\t\tcaoor.{$vs_pk} = ? AND deleted = 0\n\t\t\t\t\t{$vs_is_primary_sql}\n\t\t\t\t\t{$vs_access_sql}\n\t\t\t\t\t{$va_type_restriction_filters['sql']}\n\t\t\t\tORDER BY\n\t\t\t\t\tcaoor.rank, caoor.is_primary DESC\n\t\t\t\t{$vs_limit_sql}\n\t\t\t", $va_type_restriction_filters['params']); $va_reps = array(); $t_rep = new ca_object_representations(); if ($AUTH_CURRENT_USER_ID) { $va_can_read = caCanRead($AUTH_CURRENT_USER_ID, 'ca_object_representations', $qr_reps->getAllFieldValues('representation_id'), null, array('returnAsArray' => true)); } else { $va_can_read = $qr_reps->getAllFieldValues('representation_id'); } $qr_reps->seek(0); while ($qr_reps->nextRow()) { $vn_rep_id = $qr_reps->get('representation_id'); if (!in_array($vn_rep_id, $va_can_read)) { continue; } $va_tmp = $qr_reps->getRow(); $va_tmp['tags'] = array(); $va_tmp['urls'] = array(); $va_info = $qr_reps->getMediaInfo('media'); $va_tmp['info'] = array('original_filename' => $va_info['ORIGINAL_FILENAME']); foreach ($pa_versions as $vs_version) { if (is_array($pa_version_sizes) && isset($pa_version_sizes[$vs_version])) { $vn_width = $pa_version_sizes[$vs_version]['width']; $vn_height = $pa_version_sizes[$vs_version]['height']; } else { $vn_width = $vn_height = 0; } if ($vn_width && $vn_height) { $va_tmp['tags'][$vs_version] = $qr_reps->getMediaTag('media', $vs_version, array_merge($pa_options, array('viewer_width' => $vn_width, 'viewer_height' => $vn_height))); } else { $va_tmp['tags'][$vs_version] = $qr_reps->getMediaTag('media', $vs_version, $pa_options); } $va_tmp['urls'][$vs_version] = $qr_reps->getMediaUrl('media', $vs_version); $va_tmp['paths'][$vs_version] = $qr_reps->getMediaPath('media', $vs_version); $va_tmp['info'][$vs_version] = $qr_reps->getMediaInfo('media', $vs_version); $va_tmp['dimensions'][$vs_version] = caGetRepresentationDimensionsForDisplay($qr_reps, 'original', array()); } if (isset($va_info['INPUT']['FETCHED_FROM']) && ($vs_fetched_from_url = $va_info['INPUT']['FETCHED_FROM'])) { $va_tmp['fetched_from'] = $vs_fetched_from_url; $va_tmp['fetched_on'] = (int) $va_info['INPUT']['FETCHED_ON']; } if (isset($va_info['REPLICATION_KEYS'])) { $va_tmp['REPLICATION_KEYS'] = $va_info['REPLICATION_KEYS']; } $va_tmp['num_multifiles'] = $t_rep->numFiles($vn_rep_id); $va_captions = $t_rep->getCaptionFileList($vn_rep_id); if (is_array($va_captions) && sizeof($va_captions) > 0) { $va_tmp['captions'] = $va_captions; } $va_reps[$vn_rep_id] = $va_tmp; } $va_labels = $t_rep->getPreferredDisplayLabelsForIDs(array_keys($va_reps)); foreach ($va_labels as $vn_rep_id => $vs_label) { $va_reps[$vn_rep_id]['label'] = $vs_label; } return $va_reps; }
public function getLotMedia() { //if ((bool)$this->request->config->get('allow_download_of_all_object_media_in_a_lot')) { // DO WE NEED TO REINSTATE THIS OPTIN? set_time_limit(600); // allow a lot of time for this because the sets can be potentially large $t_lot = new ca_object_lots($this->request->getParameter('lot_id', pInteger)); $o_media_metadata_conf = Configuration::load($t_lot->getAppConfig()->get('media_metadata')); if ($t_lot->getPrimaryKey()) { $va_object_ids = $t_lot->get('ca_objects.object_id', array('returnAsArray' => true, 'limit' => 100000)); if (!is_array($va_object_ids) || !sizeof($va_object_ids)) { $this->notification->addNotification(_t('No media is available for download'), __NOTIFICATION_TYPE_ERROR__); $this->opo_response->setRedirect(caEditorUrl($this->opo_request, 'ca_object_lots', $t_lot->getPrimaryKey())); return; } $qr_res = ca_objects::createResultSet($va_object_ids); $qr_res->filterNonPrimaryRepresentations(false); $va_paths = array(); while ($qr_res->nextHit()) { $va_original_paths = $qr_res->getMediaPaths('ca_object_representations.media', 'original'); if (sizeof($va_original_paths) > 0) { $va_paths[$qr_res->get('object_id')] = array('idno' => $qr_res->get('idno'), 'type_code' => caGetListItemIdno($qr_res->get('type_id')), 'paths' => $va_original_paths, 'representation_ids' => $qr_res->get('ca_object_representations.representation_id', array('returnAsArray' => true)), 'representation_types' => $qr_res->get('ca_object_representations.type_id', array('returnAsArray' => true))); } } if (sizeof($va_paths) > 0) { $o_zip = new ZipStream(); foreach ($va_paths as $vn_object_id => $va_path_info) { // make sure we don't download representations the user isn't allowed to read if (!caCanRead($this->request->user->getPrimaryKey(), 'ca_objects', $vn_object_id)) { continue; } $vn_c = 1; foreach ($va_path_info['paths'] as $vn_i => $vs_media_path) { if (!file_exists($vs_media_path)) { continue; } if ($o_media_metadata_conf->get('do_metadata_embedding_for_lot_media_download')) { if (!($vs_path = caEmbedMediaMetadataIntoFile($vs_media_path, 'ca_objects', $vn_object_id, $va_path_info['type_code'], $va_path_info['representation_ids'][$vn_i], $va_path_info['representation_types'][$vn_i]))) { $vs_path = $vs_media_path; } } else { $vs_path = $vs_media_path; } $vs_filename = $va_path_info['idno'] ? $va_path_info['idno'] : $vn_object_id; $vs_filename .= "_{$vn_c}"; if ($vs_ext = pathinfo($vs_media_path, PATHINFO_EXTENSION)) { $vs_filename .= ".{$vs_ext}"; } $o_zip->addFile($vs_path, $vs_filename); $vn_c++; } } $o_view = new View($this->request, $this->request->getViewsDirectoryPath() . '/bundles/'); // send files $o_view->setVar('zip_stream', $o_zip); $o_view->setVar('archive_name', 'media_for_' . mb_substr(preg_replace('![^A-Za-z0-9]+!u', '_', ($vs_idno = $t_lot->get('idno_stub')) ? $vs_idno : $t_lot->getPrimaryKey()), 0, 20) . '.zip'); $this->response->addContent($o_view->render('download_file_binary.php')); return; } else { $this->notification->addNotification(_t('No files to download'), __NOTIFICATION_TYPE_ERROR__); $this->opo_response->setRedirect(caEditorUrl($this->opo_request, 'ca_object_lots', $t_lot->getPrimaryKey())); return; } } //} return $this->Edit(); }
/** * Export single record (usually via inspector) */ public function ExportSingleData() { $t_exporter = $this->getExporterInstance(); if (!$t_exporter->getPrimaryKey()) { $this->getResponse()->setRedirect($this->getRequest()->config->get('error_display_url') . '/n/3420?r=' . urlencode($this->getRequest()->getFullUrlPath())); return; } $t_subject = $t_exporter->getAppDatamodel()->getInstanceByTableNum($t_exporter->get('table_num'), true); // Can user export records of this type? if (!$this->getRequest()->user->canDoAction('can_export_' . $t_subject->tableName())) { $this->getResponse()->setRedirect($this->getRequest()->config->get('error_display_url') . '/n/3430?r=' . urlencode($this->getRequest()->getFullUrlPath())); return; } $va_errors = ca_data_exporters::checkMapping($t_exporter->get('exporter_code')); if (is_array($va_errors) && sizeof($va_errors) > 0) { $this->getView()->setVar("errors", $va_errors); $this->render('export/export_errors_html.php'); } else { set_time_limit(3600); $o_config = $t_subject->getAppConfig(); $vn_id = $this->getRequest()->getParameter('item_id', pInteger); $this->getView()->setVar("t_subject", $t_subject); // alternate destinations $va_alt_dest = $o_config->getAssoc('exporter_alternate_destinations'); $this->getView()->setVar('exporter_alternate_destinations', $va_alt_dest); // filename set via request wins $vs_filename = $this->getRequest()->getParameter('file_name', pString); // else run template from config if (!$vs_filename && ($vs_export_filename_template = $o_config->get($t_subject->tableName() . "_single_item_export_filename"))) { if ($vs_filename = caProcessTemplateForIDs($vs_export_filename_template, $t_subject->tableNum(), array($vn_id))) { // processed template comes without file extension $vs_filename = $vs_filename . '.' . $t_exporter->getFileExtension(); } } // still no filename? use hardcoded default if (!$vs_filename) { $vs_filename = $vn_id . '.' . $t_exporter->getFileExtension(); } // pass to view as default value for form field $this->getView()->setVar('file_name', $vs_filename); // Can user read this particular item? if (!caCanRead($this->getRequest()->getUserID(), $t_exporter->get('table_num'), $vn_id)) { $this->getResponse()->setRedirect($this->getRequest()->config->get('error_display_url') . '/n/2320?r=' . urlencode($this->getRequest()->getFullUrlPath())); return; } $this->getView()->setVar('item_id', $vn_id); // do item export and dump into tmp file $vs_export = ca_data_exporters::exportRecord($t_exporter->get('exporter_code'), $vn_id, array('singleRecord' => true)); $this->getView()->setVar("export", $vs_export); $vs_tmp_file = tempnam(__CA_APP_DIR__ . DIRECTORY_SEPARATOR . 'tmp', 'dataExport'); file_put_contents($vs_tmp_file, $vs_export); // Store file name and exporter data in session for later retrieval. We don't want to have to pass that on through a bunch of requests. $o_session = $this->getRequest()->getSession(); $o_session->setVar('export_file', $vs_tmp_file); $o_session->setVar('export_content_type', $t_exporter->getContentType()); $o_session->setVar('exporter_id', $t_exporter->getPrimaryKey()); $this->render('export/export_destination_html.php'); } }