echo $OUTPUT->footer(); die; } if (array_key_exists('portfolio', $formdata) && !empty($formdata['portfolio'])) { // fake portfolio callback stuff and redirect $formdata['id'] = $cm->id; $formdata['exporttype'] = 'csv'; // force for now $url = portfolio_fake_add_url($formdata['portfolio'], 'data_portfolio_caller', '/mod/data/lib.php', $formdata); redirect($url); } $selectedfields = array(); foreach ($formdata as $key => $value) { if (strpos($key, 'field_') === 0) { $selectedfields[] = substr($key, 6); } } $exportdata = data_get_exportdata($data->id, $fields, $selectedfields); $count = count($exportdata); switch ($formdata['exporttype']) { case 'csv': data_export_csv($exportdata, $formdata['delimiter_name'], $data->name, $count); break; case 'xls': data_export_xls($exportdata, $data->name, $count); break; case 'ods': data_export_ods($exportdata, $data->name, $count); break; } die;
public function prepare_package() { global $DB; $count = count($this->exportdata); $content = ''; $filename = ''; switch ($this->exporttype) { case 'singlefile': return $this->get('exporter')->copy_existing_file($this->singlefile); case 'single': $content = $this->exportsingle(); $filename = clean_filename($this->cm->name . '-entry.html'); break; case 'csv': $content = data_export_csv($this->exportdata, $this->delimiter_name, $this->cm->name, $count, true); $filename = clean_filename($this->cm->name . '.csv'); break; case 'xls': throw new portfolio_caller_exception('notimplemented', 'portfolio', '', 'xls'); $content = data_export_xls($this->exportdata, $this->cm->name, $count, true); break; case 'ods': throw new portfolio_caller_exception('notimplemented', 'portfolio', '', 'ods'); $content = data_export_ods($this->exportdata, $this->cm->name, $count, true); break; default: throw new portfolio_caller_exception('notimplemented', 'portfolio', '', $this->exporttype); break; } return $this->exporter->write_new_file($content, $filename, $this->exporter->get('format') instanceof PORTFOLIO_FORMAT_RICH); }