<?php

class Export_Txt extends View {

// if a simple table has been created, use DataTables to display it
	public function render($data) {
		header('Content-type: text/plain; charset=UTF-8');
		reset($data);
		$k = key($data);
		if (!is_array($data[$k])) {		// simple array
			$data = $this->_convert_to_table($data);
		}
		echo var_export($data, 1);
	}
	
	private function _convert_to_table($data) {
		$output = array();
		foreach($data as $key => $value) {
			$output[] = array('key' => $key, 'value' => $value);
		}
		return $output;
	}

}