/** * Sets up export options and exports items * * @return void */ public function onExport() { $filename = 'export.csv'; /* Bail out if we don't have a valid data item type. */ if (!$this->isRequiredIDValid('dataItemType', $_GET)) { CommonErrors::fatal(COMMONERROR_BADFIELDS, $this, 'Invalid data item type.'); } $dataItemType = $_GET['dataItemType']; /* Are we in "Only Selected" mode? */ if ($this->isChecked('onlySelected', $_GET)) { foreach ($_GET as $key => $value) { if (!strstr($key, 'checked_')) { continue; } $IDs[] = str_replace('checked_', '', $key); } } else { /* No; do we have a list of IDs to export (Page Mode)? */ $tempIDs = $this->getTrimmedInput('ids', $_GET); if (!empty($tempIDs)) { $IDs = explode(',', $tempIDs); } else { /* No; All Records Mode. */ $IDs = array(); } } $export = new Export($dataItemType, $IDs, ',', $this->_siteID); $output = $export->getFormattedOutput(); if (!eval(Hooks::get('EXPORT'))) return; header('Content-Disposition: attachment; filename="' . $filename . '"'); header('Content-Length: ' . strlen($output)); header('Connection: close'); header('Content-Type: text/x-csv; name=' . $filename); echo $output;exit; }