/** * Returns the table of results to be displayed in the table of * details loaded from the file */ function displaytable() { // Check that a file was uploaded $tempFile = fopen($_FILES['ImportFile']['tmp_name'], 'r'); // display some error if the file cannot be opened if (!$tempFile) { return 'The selected file did not arrive at the server'; } $this->clientFileName = $_FILES['ImportFile']['name']; $table = $sessionTable = array(); while (($row = fgetcsv($tempFile)) !== false) { if (!$this->tableColumns) { $this->parseTableHeader($row); } else { $newRow = array(); $newSessionTableRow = array(); foreach ($row as $cell) { $newRow[] = $this->parseCSVCell($cell); $newSessionTableRow[] = $cell; } $cells = new DataObjectSet($newRow); $table[] = $cells->customise(array('Cells' => $cells)); $sessionTable[] = $newSessionTableRow; } } fclose($tempFile); $this->table = new DataObjectSet($table); Session::set("ImportFile.{$_REQUEST['ID']}", $sessionTable); return $this->renderWith('Newsletter_RecipientImportField_Table'); }