private function exportToCsv($delimiter) { $this->ci->load->helper('csv'); $this->reorder(); $this->itemids = array(); foreach ($this->key->items as $item) { $this->itemids[] = $item->item_id; } $csv = array(); foreach ($this->leads as $lead) { $csvRow = array(); $csvRow[] = $lead->fromNode; $csvRow[] = $lead->lead_text; if (isset($lead->item) && $lead->item) { $csvRow[] = $this->getItemName($lead->item); } else { $csvRow[] = $lead->toNode; } $csv[] = $csvRow; } return arrayToCsv($csv, $delimiter); }
} break; case 'checkbox': $value = explode(',', $__value); if (!empty($value) && is_array($value) && count($value) > 0) { $tmp1 = array(); foreach ($value as $k2 => $v2) { if (isset($this->form[$v1]['element'][1][$v2])) { $tmp1[] = $this->form[$v1]['element'][1][$v2]; } } $value = implode(', ', $tmp1); } else { $value = ''; } $tmp[] = $value; break; default: $tmp[] = $__value; break; } } $csv[] = $tmp; } header("Content-type: text/csv"); header("Content-Disposition: attachment; filename=" . $_GET['table'] . "-" . date("YmdHis") . ".csv"); header("Pragma: no-cache"); header("Expires: 0"); foreach ($csv as $v) { echo arrayToCsv($v) . "\n"; }
$obj_keys = array_keys($obj); file_put_contents('output/projects.csv', arrayToCsv($obj_keys) . "\n", FILE_APPEND); } file_put_contents('output/projects.csv', arrayToCsv($obj) . "\n", FILE_APPEND); } /* ========== EVENTOS ========== */ $sql_events = file_get_contents(__DIR__ . '/_events.sql'); $rs = $conn->fetchAll($sql_events); foreach ($rs as $i => $obj) { $obj['linguagem'] = fetchTerms(3, 'Event', $obj['id']); unset($obj['id']); if ($i == 0) { $obj_keys = array_keys($obj); file_put_contents('output/events.csv', arrayToCsv($obj_keys) . "\n", FILE_APPEND); } file_put_contents('output/events.csv', arrayToCsv($obj) . "\n", FILE_APPEND); } /* ========== OCORRENCIAS ========== */ $sql_events = file_get_contents(__DIR__ . '/_occurrences.sql'); $rs = $conn->fetchAll($sql_events); foreach ($rs as $i => $obj) { $obj['evento_linguagens'] = fetchTerms(3, 'Event', $obj['event_id']); $obj['espaco_areas'] = fetchTerms(3, 'Event', $obj['space_id']); unset($obj['event_id']); unset($obj['space_id']); if ($i == 0) { $obj_keys = array_keys($obj); file_put_contents('output/occurrences.csv', arrayToCsv($obj_keys) . "\n", FILE_APPEND); } file_put_contents('output/occurrences.csv', arrayToCsv($obj) . "\n", FILE_APPEND); }