Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 7e0ad798

Von Moritz Bunkus vor fast 14 Jahren hinzugefügt

  • ID 7e0ad798bc842b710a27b0e1a7a720b117b2566a
  • Vorgänger a97d97a0
  • Nachfolger a1d1605e

Umstellung DBUpgrade2-Modul auf Objekt-Aufrufsyntax

Unterschiede anzeigen:

SL/DBUpgrade2.pm
2 2

  
3 3
use SL::Common;
4 4

  
5
require Exporter;
6
our @ISA = qw(Exporter);
7

  
8
our @EXPORT = qw(parse_dbupdate_controls sort_dbupdate_controls);
9

  
10 5
use strict;
11 6

  
7
sub new {
8
  my ($package, $form, $dbdriver) = @_;
9
  my $self                        = { form => $form, dbdriver => $dbdriver };
10
  return bless($self, $package);
11
}
12

  
12 13
sub parse_dbupdate_controls {
13 14
  $main::lxdebug->enter_sub();
14 15

  
15
  my ($form, $dbdriver) = @_;
16
  my ($self) = @_;
16 17

  
18
  my $form   = $self->{form};
17 19
  my $locale = $main::locale;
18 20

  
19 21
  local *IN;
20 22
  my %all_controls;
21 23

  
22
  my $path = "sql/${dbdriver}-upgrade2";
24
  my $path = "sql/" . $self->{dbdriver} . "-upgrade2";
23 25

  
24 26
  foreach my $file_name (<$path/*.sql>, <$path/*.pl>) {
25 27
    next unless (open(IN, $file_name));
......
92 94
  map({ _dbupdate2_calculate_depth(\%all_controls, $_->{"tag"}) }
93 95
      values(%all_controls));
94 96

  
97
  $self->{all_controls} = \%all_controls;
98

  
95 99
  $main::lxdebug->leave_sub();
96 100

  
97 101
  return \%all_controls;
......
148 152
}
149 153

  
150 154
sub sort_dbupdate_controls {
155
  my $self = shift;
156

  
151 157
  return sort({   $a->{"depth"}    !=  $b->{"depth"}    ? $a->{"depth"}    <=> $b->{"depth"}
152 158
                : $a->{"priority"} !=  $b->{"priority"} ? $a->{"priority"} <=> $b->{"priority"}
153
                :                                         $a->{"tag"}      cmp $b->{"tag"}      } values(%{$_[0]}));
159
                :                                         $a->{"tag"}      cmp $b->{"tag"}      } values(%{ $self->{all_controls} }));
154 160
}
155 161

  
156 162
1;

Auch abrufbar als: Unified diff