Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 6759902a

Von Moritz Bunkus vor mehr als 13 Jahren hinzugefügt

  • ID 6759902aeb338d4f5efe8cadadf4103c2bf35849
  • Vorgänger 0fb93bcf
  • Nachfolger dfd2c90e

Beispieldatei bei CSV-Import herunterladen

Unterschiede anzeigen:

SL/Controller/CsvImport.pm
67 67
  $self->redirect_to(action => 'new', 'profile.type' => $self->type);
68 68
}
69 69

  
70
sub action_download_sample {
71
  my $self = shift;
72

  
73
  $self->profile_from_form;
74
  $self->setup_help;
75

  
76
  my $file_name = 'csv_import_sample_' . $self->type . '.csv';
77
  my $file      = SL::SessionFile->new($file_name, mode => '>', encoding => $self->profile->get('charset'));
78
  my $csv       = Text::CSV_XS->new({ binary => 1, map { ( $_ => $self->profile->get($_) ) } qw(sep_char escape_char quote_char),});
79

  
80
  $csv->print($file->fh, [ map { $_->{name}        } @{ $self->displayable_columns } ]);
81
  $file->fh->print("\r\n");
82
  $csv->print($file->fh, [ map { $_->{description} } @{ $self->displayable_columns } ]);
83
  $file->fh->print("\r\n");
84

  
85
  $file->fh->close;
86

  
87
  $self->send_file($file->file_name);
88
}
89

  
70 90
#
71 91
# filters
72 92
#

Auch abrufbar als: Unified diff