Revision c0c6c815
Von Moritz Bunkus vor etwa 12 Jahren hinzugefügt
bin/mozilla/admin.pl | ||
---|---|---|
40 | 40 |
use File::Find; |
41 | 41 |
use File::Spec; |
42 | 42 |
use Cwd; |
43 |
use IO::Dir; |
|
43 | 44 |
use IO::File; |
44 | 45 |
use POSIX qw(strftime); |
45 | 46 |
use Sys::Hostname; |
... | ... | |
745 | 746 |
|
746 | 747 |
$form->{CHARTS} = []; |
747 | 748 |
|
748 |
opendir SQLDIR, "sql/." or $form->error($ERRNO); |
|
749 |
foreach my $item (sort grep /-chart\.sql\z/, readdir SQLDIR) { |
|
750 |
next if ($item eq 'Default-chart.sql'); |
|
751 |
$item =~ s/-chart\.sql//; |
|
752 |
push @{ $form->{CHARTS} }, { "name" => $item, |
|
753 |
"selected" => $item eq "Germany-DATEV-SKR03EU" }; |
|
749 |
tie my %dir_h, 'IO::Dir', 'sql/'; |
|
750 |
foreach my $item (map { s/-chart\.sql$//; $_ } sort grep { /-chart\.sql\z/ && !/Default-chart.sql\z/ } keys %dir_h) { |
|
751 |
push @{ $form->{CHARTS} }, { name => $item, |
|
752 |
selected => $item eq "Germany-DATEV-SKR03EU" }; |
|
754 | 753 |
} |
755 |
closedir SQLDIR; |
|
756 | 754 |
|
757 |
$form->{ACCOUNTING_METHODS} = []; |
|
758 |
foreach my $item ( qw(accrual cash) ) { |
|
759 |
push @{ $form->{ACCOUNTING_METHODS} }, { "name" => $item, |
|
760 |
"selected" => $item eq "cash" }; |
|
761 |
}; |
|
762 |
|
|
763 |
$form->{INVENTORY_SYSTEMS} = []; |
|
764 |
foreach my $item ( qw(perpetual periodic) ) { |
|
765 |
push @{ $form->{INVENTORY_SYSTEMS} }, { "name" => $item, |
|
766 |
"selected" => $item eq "periodic" }; |
|
767 |
}; |
|
768 |
|
|
769 |
$form->{PROFIT_DETERMINATIONS} = []; |
|
770 |
foreach my $item ( qw(balance income) ) { |
|
771 |
push @{ $form->{PROFIT_DETERMINATIONS} }, { "name" => $item, |
|
772 |
"selected" => $item eq "income" }; |
|
773 |
}; |
|
755 |
$form->{ACCOUNTING_METHODS} = [ map { { name => $_, selected => $_ eq 'cash' } } qw(accrual cash) ]; |
|
756 |
$form->{INVENTORY_SYSTEMS} = [ map { { name => $_, selected => $_ eq 'periodic' } } qw(perpetual periodic) ]; |
|
757 |
$form->{PROFIT_DETERMINATIONS} = [ map { { name => $_, selected => $_ eq 'income' } } qw(balance income) ]; |
|
774 | 758 |
|
775 |
my $default_charset = $::lx_office_conf{system}->{dbcharset}; |
|
776 |
$default_charset ||= Common::DEFAULT_CHARSET; |
|
759 |
my $default_charset = $::lx_office_conf{system}->{dbcharset} || Common::DEFAULT_CHARSET; |
|
777 | 760 |
|
778 | 761 |
my $cluster_encoding = User->dbclusterencoding($form); |
779 | 762 |
if ($cluster_encoding && ($cluster_encoding =~ m/^(?:UTF-?8|UNICODE)$/i)) { |
... | ... | |
786 | 769 |
$form->{FORCE_DBENCODING} = 'UNICODE'; |
787 | 770 |
|
788 | 771 |
} else { |
789 |
$form->{DBENCODINGS} = []; |
|
790 |
|
|
791 |
foreach my $encoding (@Common::db_encodings) { |
|
792 |
push @{ $form->{DBENCODINGS} }, { "dbencoding" => $encoding->{dbencoding}, |
|
793 |
"label" => $encoding->{label}, |
|
794 |
"selected" => $encoding->{charset} eq $default_charset }; |
|
795 |
} |
|
772 |
$form->{DBENCODINGS} = [ map { { %{$_}, selected => $_->{charset} eq $default_charset } } @Common::db_encodings ]; |
|
796 | 773 |
} |
797 | 774 |
|
798 | 775 |
$form->{title} = "kivitendo " . $locale->text('Database Administration') . " / " . $locale->text('Create Dataset'); |
... | ... | |
1198 | 1175 |
$::form->error(sprintf($::locale->text("The directory %s does not exist."), $::lx_office_conf{paths}->{templates})); |
1199 | 1176 |
} |
1200 | 1177 |
|
1201 |
opendir TEMPLATEDIR, $::lx_office_conf{paths}->{templates} or $::form->error($::lx_office_conf{paths}->{templates} . " : $ERRNO"); |
|
1202 |
my @all = readdir(TEMPLATEDIR); |
|
1203 |
my @alldir = sort grep { -d ($::lx_office_conf{paths}->{templates} . "/$_") && !/^\.\.?$/ } @all; |
|
1204 |
closedir TEMPLATEDIR; |
|
1205 |
|
|
1206 |
@alldir = grep !/\.(html|tex|sty|odt|xml|txb)$/, @alldir; |
|
1207 |
@alldir = grep !/^(webpages|print|\.svn)$/, @alldir; |
|
1178 |
tie my %dir_h, 'IO::Dir', $::lx_office_conf{paths}->{templates}; |
|
1208 | 1179 |
|
1209 |
# mastertemplates |
|
1210 |
opendir TEMPLATEDIR, "$::lx_office_conf{paths}->{templates}/print" or $::form->error("$::lx_office_conf{paths}->{templates}/print" . " : $ERRNO"); |
|
1211 |
my @allmaster = readdir(TEMPLATEDIR); |
|
1212 |
closedir TEMPLATEDIR; |
|
1180 |
my @alldir = sort grep { |
|
1181 |
-d ($::lx_office_conf{paths}->{templates} . "/$_") |
|
1182 |
&& !/^\.\.?$/ |
|
1183 |
&& !m/\.(?:html|tex|sty|odt|xml|txb)$/ |
|
1184 |
&& !m/^(?:webpages$|print$|\.)/ |
|
1185 |
} keys %dir_h; |
|
1213 | 1186 |
|
1214 |
@allmaster = ('Standard', sort grep { -d ("$::lx_office_conf{paths}->{templates}/print" . "/$_") && !/^\.\.?$/ && !/^Standard$/ } @allmaster); |
|
1187 |
tie %dir_h, 'IO::Dir', "$::lx_office_conf{paths}->{templates}/print"; |
|
1188 |
my @allmaster = ('Standard', sort grep { -d ("$::lx_office_conf{paths}->{templates}/print" . "/$_") && !/^\.\.?$/ && !/^Standard$/ } keys %dir_h); |
|
1215 | 1189 |
|
1216 | 1190 |
return \@alldir, \@allmaster; |
1217 | 1191 |
} |
Auch abrufbar als: Unified diff
Refactoring