diff --git a/plugins/views_data_export_plugin_display_export.inc b/plugins/views_data_export_plugin_display_export.inc index 741d488..8644ec9 100644 --- a/plugins/views_data_export_plugin_display_export.inc +++ b/plugins/views_data_export_plugin_display_export.inc @@ -299,7 +299,7 @@ class views_data_export_plugin_display_export extends views_plugin_display_feed // Initialize the progress counter. if (db_table_exists($this->index_tablename())) { - $this->batched_execution_state->sandbox['max'] = db_query('SELECT COUNT(*) FROM {' . $this->index_tablename() . '}')->fetchField(); + $this->batched_execution_state->sandbox['max'] = db_query('SELECT COUNT(*) FROM {' . $this->index_tablename() . '}')->fetchField(); } // Record the time we started. @@ -685,20 +685,33 @@ class views_data_export_plugin_display_export extends views_plugin_display_feed } /** - * Called on export initialization - * Creates the output file, registers it as a temporary file with Drupal - * and returns the fid + * Called on export initialization. + * + * Creates the output file, registers it as a temporary file with Drupal and + * returns the fid. */ protected function outputfile_create() { + $style_options = $this->options['style_options']; + + if (empty($style_options['permanent_file']) || empty($style_options['file_path'])) { + $dir = variable_get('views_data_export_directory', 'temporary://views_plugin_display'); + } + else { + $dir = dirname($style_options['file_path']); + } - $dir = variable_get('views_data_export_directory', 'temporary://views_plugin_display'); // Make sure the directory exists first. if (!file_prepare_directory($dir, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) { $this->abort_export(t('Could not create temporary directory for result export (@dir). Check permissions.', array ('@dir' => $dir))); } - $path = drupal_tempnam($dir, 'views_data_export'); + if (empty($style_options['permanent_file']) || empty($style_options['file_path'])) { + $path = drupal_tempnam($dir, 'views_data_export'); + } + else { + $path = $style_options['file_path']; + } // Save the file into the DB. $file = $this->file_save_file($path); diff --git a/plugins/views_data_export_plugin_style_export.inc b/plugins/views_data_export_plugin_style_export.inc index 8d7eed6..e9f1bfb 100644 --- a/plugins/views_data_export_plugin_style_export.inc +++ b/plugins/views_data_export_plugin_style_export.inc @@ -42,14 +42,12 @@ class views_data_export_plugin_style_export extends views_plugin_style { /** * Options form mini callback. * - * @param $form - * Form array to add additional fields to. - * @param $form_state - * State of the form. - * @return - * None. + * @param array $form + * Form array to add additional fields to. + * @param array $form_state + * State of the form. */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { $form['attach_text'] = array( '#type' => 'textfield', '#title' => t('Attach text'), @@ -85,7 +83,8 @@ class views_data_export_plugin_style_export extends views_plugin_style { // Get a list of the available arguments for token replacement. $options = array(); - $count = 0; // This lets us prepare the key as we want it printed. + // This lets us prepare the key as we want it printed. + $count = 0; foreach ($this->view->display_handler->get_handlers('argument') as $arg => $handler) { $options[t('Arguments')]['%' . ++$count . '-title'] = t('@argument title', array('@argument' => $handler->ui_name())); $options[t('Arguments')]['%' . $count . '-value'] = t('@argument value', array('@argument' => $handler->ui_name())); @@ -134,6 +133,24 @@ class views_data_export_plugin_style_export extends views_plugin_style { 'edit-style-options-provide-file' => array(1), ), ); + $form['permanent_file'] = array( + '#type' => 'checkbox', + '#title' => t('Permanent file'), + '#default_value' => $this->options['permanent_file'], + '#description' => t('By selecting this, the file will be saved as permanent.'), + '#dependency' => array( + 'edit-style-options-provide-file' => array(TRUE), + ), + ); + $form['file_path'] = array( + '#type' => 'textfield', + '#title' => t('File path'), + '#default_value' => $this->options['file_path'], + '#description' => t('The permanent file path where the file will be stored.'), + '#dependency' => array( + 'edit-style-options-permanent-file' => array(TRUE), + ), + ); $form['parent_sort'] = array( '#type' => 'checkbox', '#title' => t('Parent sort'),