You are here

class ViewsDataExportExporterTXT in Views data export 7.4

Exporter for creating TXT files.

Hierarchy

Expanded class hierarchy of ViewsDataExportExporterTXT

2 string references to 'ViewsDataExportExporterTXT'
TXTExportViewsDataExportExporterTests::getExporterClassName in tests/exporter_tests/txt.test
views_data_export_views_plugins in ./views_data_export.views.inc
Implementation of hook_views_plugins().

File

exporters/views_data_export_exporter_txt.inc, line 8

View source
class ViewsDataExportExporterTXT extends ViewsDataExportExporter {
  function __construct($options) {
    $this->options = $options;
    parent::__construct($options);
  }

  /**
   * Tell the world whether we support Hide If Empty views option
   */
  function supports_hide_if_empty() {
    return TRUE;
  }

  /**
   * Set options fields and default values.
   *
   * @return
   * An array of options information.
   */
  function option_definition() {

    //$options = parent::option_definition();
    $options = array();
    return $options;
  }
  function add_row(&$file_handle, $data, $row_count, $field_titles) {
    $row = '';
    foreach ($data as $key => $value) {
      $row .= '[' . $field_titles[$key] . ']' . PHP_EOL . PHP_EOL;
      $row .= $value . PHP_EOL;
    }
    $row .= '----------------------------------------' . PHP_EOL . PHP_EOL;
    fwrite($file_handle, $row);
  }
  function add_header(&$file_handle, $filename) {
    return 'file header';
  }
  function get_headers($filename) {
    $headers = parent::get_headers($filename);
    $extension = 'txt';
    $content_type = 'text/txt';
    $headers['Content-Type'] = $content_type;
    $headers['Content-Disposition'] = "attachment; filename={$filename}.{$extension}";
    return $headers;
  }

  /**
   * Write the start of the export file.
   *
   * @param $file_handle
   *   A PHP file handle to the export file.
   */
  function bof(&$file_handle) {
  }

  /**
   * Write the end of the export file.
   *
   * @param $file_handle
   *   A PHP file handle to the export file.
   */
  function eof(&$file_handle, $row_count, $col_count) {
  }

  /**
   * Allow final processing of the results.
   *
   * @param $results
   *   An array of result data, including:
   *   - file_name: The full file path of the generated file.
   *   - row_count: The final number of rows in the generated file.
   */
  function post_process(&$results) {
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ViewsDataExportExporter::$options public property
ViewsDataExportExporter::clean_xml_tag function
ViewsDataExportExporterTXT::add_header function
ViewsDataExportExporterTXT::add_row function Add a single row to the export file. Overrides ViewsDataExportExporter::add_row
ViewsDataExportExporterTXT::bof function Write the start of the export file. Overrides ViewsDataExportExporter::bof
ViewsDataExportExporterTXT::eof function Write the end of the export file. Overrides ViewsDataExportExporter::eof
ViewsDataExportExporterTXT::get_headers function Provide headers to the page when an export file is being downloaded. Overrides ViewsDataExportExporter::get_headers
ViewsDataExportExporterTXT::option_definition function Set options fields and default values. Overrides ViewsDataExportExporter::option_definition
ViewsDataExportExporterTXT::post_process function Allow final processing of the results. Overrides ViewsDataExportExporter::post_process
ViewsDataExportExporterTXT::supports_hide_if_empty function Tell the world whether we support Hide If Empty views option Overrides ViewsDataExportExporter::supports_hide_if_empty
ViewsDataExportExporterTXT::__construct function Constructor for views_data_export_exporter classes. Overrides ViewsDataExportExporter::__construct