/** * Convert CSV to a PHP array * * @param string $data The CSV input * * @return array * @since 1.7.1 * * @deprecated 2.3.5 */ public function csv_to_php($data, $delimiter = ',') { pods_deprecated("PodsAPI->csv_to_php", '2.3.5'); $data = pods_migrate('sv', $delimiter, $data)->parse(); return $data['items']; }
public function export() { $export_type = pods_var('export_type', 'get', 'csv'); $type = 'sv'; // covers csv + tsv if (in_array($export_type, array('xml', 'json'))) { $type = $export_type; } $delimiter = ','; if ('tsv' == $export_type) { $delimiter = "\t"; } $columns = array(); if (empty($this->fields['export'])) { $this->fields['export'] = $this->pod->fields; $columns = array($this->pod->pod_data['field_id'] => 'ID'); } foreach ($this->fields['export'] as $field) { $columns[$field['name']] = $field['label']; } $params = array('full' => true, 'flatten' => true, 'fields' => array_keys($columns), 'type' => $type, 'delimiter' => $delimiter, 'columns' => $columns); $items = $this->get_data($params); $data = array('columns' => $columns, 'items' => $items, 'fields' => $this->fields['export']); $migrate = pods_migrate($type, $delimiter, $data); $migrate->export(); $export_file = $migrate->save(); $this->message(sprintf(__('<strong>Success:</strong> Your export is ready, you can download it <a href="%s" target="_blank">here</a>', 'pods'), $export_file)); //echo '<script type="text/javascript">window.open("' . esc_js( $export_file ) . '");</script>'; $this->get_data(); }