Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 7b03930b

Von Werner Hahn vor etwa 7 Jahren hinzugefügt

  • ID 7b03930ba3452d17c42a23958fbb0b85e350d48c
  • Vorgänger de7d54fb
  • Nachfolger c9ba2b5b

Shopmodul: Anpassungen nach mergen für master
Bis hier noch mit individuellen Kundenanpassungen

Unterschiede anzeigen:

SL/Controller/FileUploader.pm
21 21
  $self->render('fileuploader/test_page');
22 22
}
23 23

  
24
sub action_upload_form{
25
  my ($self) = @_;
26
  $self->file(SL::DB::File->new);
27
  $self->render('common/file_upload', {header => 0});
28
}
29

  
30
sub action_show_files {
31
  my ($self) = @_;
32
$main::lxdebug->dump(0, 'WH: Show_Files',\$::form);
33
  my $images = SL::DB::Manager::File->get_all( query => [ trans_id => $::form->{id}, modul => $::form->{modul} ] );
34
  $main::lxdebug->dump(0, 'WH: ',\$images);
35

  
36

  
37
}
38

  
39 24
sub action_ajax_add_file{
40 25
  my ($self) = @_;
41 26
  $self->file( $::form->{id} ? SL::DB::File->new(id => $::form->{id})->load : SL::DB::File->new );
......
60 45
  return @errors
61 46
}
62 47

  
63
sub action_upload_form{
64
  my ($self) = @_;
65
  $self->file(SL::DB::File->new);
66
  $self->render('common/file_upload', {header => 0});
67
}
68

  
69
sub action_show_files {
70
  my ($self) = @_;
71

  
72

  
73
sub action_ajax_add_file{
74
  my ($self) = @_;
75
  $self->file(SL::DB::File->new);
76
  $self->render('common/file_upload', { layout => 0}, DATA => $::form);
77
}
78

  
79
sub action_ajax_upload_file{
80
  my ($self, %params) = @_;
81
  my $attributes                  = $::form->{ $::form->{form_prefix} } || die "Missing FormPrefix";
82
  $attributes->{trans_id}         = $::form->{id} || die "Missing ID";
83
  $attributes->{modul}            = $::form->{modul} || die "Missing Modul";
84
  $attributes->{filename}         = $::form->{FILENAME} || die "Missing Filename";
85
  $attributes->{title}            = $::form->{ $::form->{form_prefix} }->{title};
86
  $attributes->{description}      = $::form->{ $::form->{form_prefix} }->{description};
87
  my @image_types = ("jpg","tif","png");
88

  
89
  my @errors = $self->file(SL::DB::File->new(%{ $attributes }))->validate;
90
  return $self->js->error(@errors)->render($self) if @errors;
91

  
92
  $self->file->save;
93

  
94
  # TODO js call
95
  $self->render('fileuploader/test_page');
96
}
97

  
98
#
99
# helpers
100
#
101

  
102 48
sub init_file {
103 49
  return SL::DB::File->new(id => $::form->{id})->load;
104 50
}
......
122 68

  
123 69
=head1 DESCRIPTION
124 70

  
125
# longer description...
71
 just the action ajax_add_file is needed and its automaticly called by. The other ones are for the testpage templates/webpages/testpage.html
72
 kivi.add.file(id[shop_part_id,part_id, cv_id, project_id,...],modul[part,shop_part,project,IC,...],controller_action[ShopPart/do_something_file],allowed_filestypes) in your template.
73
 [% L.button_tag("kivi.add_file(this.form.id.value,'shop_part', 'Part/do_something_with_file','jpg,png,gif,pdf')", 'Fileupload') %]
74

  
75
 The called Controller/Action deals with the uploaded file in wich you can do whatever you want with the file.
76
 like
77
 - Store it in the Database SL::DB::File
78
 - Store it in Webdav
79
 - Store it in Webdav and DB (be careful: files wich deleted in the filesystem will not be deleted in the database automaticly)
80
 - do something very fancy with the file
126 81

  
127 82

  
128 83
=head1 INTERFACE

Auch abrufbar als: Unified diff