You are here

function views_data_export_plugin_display_export::execute in Views data export 7.4

Same name and namespace in other branches
  1. 6.3 plugins/views_data_export_plugin_display_export.inc \views_data_export_plugin_display_export::execute()
  2. 6 plugins/views_data_export_plugin_display_export.inc \views_data_export_plugin_display_export::execute()
  3. 6.2 plugins/views_data_export_plugin_display_export.inc \views_data_export_plugin_display_export::execute()
  4. 7 plugins/views_data_export_plugin_display_export.inc \views_data_export_plugin_display_export::execute()
  5. 7.3 plugins/views_data_export_plugin_display_export.inc \views_data_export_plugin_display_export::execute()

Execute this display handler.

This is the main entry point for this display. We do different things based on the stage in the rendering process.

If we are being called for the very first time, the user has usually just followed a link to our view. For this phase we:

  • Register a new batched export with our parent module.
  • Build and execute the view, redirecting the output into a temporary table.
  • Set up the batch.

If we are being called during batch processing we:

  • Set up our variables from the context into the display.
  • Call the rendering layer.
  • Return with the appropriate progress value for the batch.

If we are being called after the batch has completed we:

  • Remove the index table.
  • Show the complete page with a download link.
  • Transfer the file if the download link was clicked.

Overrides views_plugin_display_feed::execute

File

plugins/views_data_export_plugin_display_export.inc, line 235
Contains the bulk export display plugin.

Class

views_data_export_plugin_display_export
The plugin that batches its rendering.

Code

function execute() {
  if (!$this
    ->is_batched()) {
    return parent::execute();
  }

  // Try and get a batch context if possible.
  $eid = !empty($_GET['eid']) ? $_GET['eid'] : (!empty($this->batched_execution_state->eid) ? $this->batched_execution_state->eid : FALSE);
  if ($eid) {
    $this->batched_execution_state = views_data_export_get($eid);
  }

  // First time through
  if (empty($this->batched_execution_state)) {
    $output = $this
      ->execute_initial();
  }

  // Call me on the cached version of this view please
  // This allows this view to be programatically executed with nothing
  // more than the eid in $_GET in order for it to execute the next chunk
  // TODO: What is going on here?

  /*
       Jamsilver tells me this might be useful one day.
      if (!$this->views_data_export_cached_view_loaded) {
        $view = views_data_export_view_retrieve($this->batched_execution_state->eid);
        $view->set_display($this->view->current_display);
        $view->display_handler->batched_execution_state->eid = $this->batched_execution_state->eid;
        $view->display_handler->views_data_export_cached_view_loaded = TRUE;
        $ret =  $view->execute_display($this->view->current_display);
        $this->batched_execution_state = &$view->display_handler->batched_execution_state;
        return $ret;
      }*/

  // Last time through
  if ($this->batched_execution_state->batch_state == VIEWS_DATA_EXPORT_FINISHED) {
    $output = $this
      ->execute_final();
  }
  else {
    $output = $this
      ->execute_normal();
  }

  //Ensure any changes we made to the database sandbox are saved
  views_data_export_update($this->batched_execution_state);
  return $output;
}