Revision 60d0f05f
Von Moritz Bunkus vor fast 8 Jahren hinzugefügt
SL/AM.pm | ||
---|---|---|
410 | 410 |
return 1; |
411 | 411 |
} |
412 | 412 |
|
413 |
sub language { |
|
414 |
$main::lxdebug->enter_sub(); |
|
415 |
|
|
416 |
my ($self, $myconfig, $form, $return_list) = @_; |
|
417 |
|
|
418 |
my $dbh = SL::DB->client->dbh; |
|
419 |
|
|
420 |
my $query = |
|
421 |
"SELECT id, description, template_code, article_code, " . |
|
422 |
" output_numberformat, output_dateformat, output_longdates " . |
|
423 |
"FROM language ORDER BY description"; |
|
424 |
|
|
425 |
my $sth = $dbh->prepare($query); |
|
426 |
$sth->execute || $form->dberror($query); |
|
427 |
|
|
428 |
my $ary = []; |
|
429 |
|
|
430 |
while (my $ref = $sth->fetchrow_hashref("NAME_lc")) { |
|
431 |
push(@{ $ary }, $ref); |
|
432 |
} |
|
433 |
|
|
434 |
$sth->finish; |
|
435 |
|
|
436 |
$main::lxdebug->leave_sub(); |
|
437 |
|
|
438 |
if ($return_list) { |
|
439 |
return @{$ary}; |
|
440 |
} else { |
|
441 |
$form->{ALL} = $ary; |
|
442 |
} |
|
443 |
} |
|
444 |
|
|
445 |
sub get_language { |
|
446 |
$main::lxdebug->enter_sub(); |
|
447 |
|
|
448 |
my ($self, $myconfig, $form) = @_; |
|
449 |
|
|
450 |
my $dbh = SL::DB->client->dbh; |
|
451 |
|
|
452 |
my $query = |
|
453 |
"SELECT description, template_code, article_code, " . |
|
454 |
" output_numberformat, output_dateformat, output_longdates " . |
|
455 |
"FROM language WHERE id = ?"; |
|
456 |
my $sth = $dbh->prepare($query); |
|
457 |
$sth->execute($form->{"id"}) || $form->dberror($query . " ($form->{id})"); |
|
458 |
|
|
459 |
my $ref = $sth->fetchrow_hashref("NAME_lc"); |
|
460 |
|
|
461 |
map { $form->{$_} = $ref->{$_} } keys %$ref; |
|
462 |
|
|
463 |
$sth->finish; |
|
464 |
|
|
465 |
$main::lxdebug->leave_sub(); |
|
466 |
} |
|
467 |
|
|
468 | 413 |
sub get_language_details { |
469 | 414 |
$main::lxdebug->enter_sub(); |
470 | 415 |
|
... | ... | |
483 | 428 |
return @res; |
484 | 429 |
} |
485 | 430 |
|
486 |
sub save_language { |
|
487 |
$main::lxdebug->enter_sub(); |
|
488 |
|
|
489 |
my ($self, $myconfig, $form) = @_; |
|
490 |
|
|
491 |
SL::DB->client->with_transaction(sub { |
|
492 |
my $dbh = SL::DB->client->dbh; |
|
493 |
my (@values, $query); |
|
494 |
|
|
495 |
map({ push(@values, $form->{$_}); } |
|
496 |
qw(description template_code article_code |
|
497 |
output_numberformat output_dateformat output_longdates)); |
|
498 |
|
|
499 |
# id is the old record |
|
500 |
if ($form->{id}) { |
|
501 |
$query = |
|
502 |
"UPDATE language SET " . |
|
503 |
" description = ?, template_code = ?, article_code = ?, " . |
|
504 |
" output_numberformat = ?, output_dateformat = ?, " . |
|
505 |
" output_longdates = ? " . |
|
506 |
"WHERE id = ?"; |
|
507 |
push(@values, $form->{id}); |
|
508 |
} else { |
|
509 |
$query = |
|
510 |
"INSERT INTO language (" . |
|
511 |
" description, template_code, article_code, " . |
|
512 |
" output_numberformat, output_dateformat, output_longdates" . |
|
513 |
") VALUES (?, ?, ?, ?, ?, ?)"; |
|
514 |
} |
|
515 |
do_query($form, $dbh, $query, @values); |
|
516 |
1; |
|
517 |
}) or do { die SL::DB->client->error }; |
|
518 |
|
|
519 |
$main::lxdebug->leave_sub(); |
|
520 |
} |
|
521 |
|
|
522 |
sub delete_language { |
|
523 |
$main::lxdebug->enter_sub(); |
|
524 |
|
|
525 |
my ($self, $myconfig, $form) = @_; |
|
526 |
my $query; |
|
527 |
|
|
528 |
SL::DB->client->with_transaction(sub { |
|
529 |
my $dbh = SL::DB->client->dbh; |
|
530 |
|
|
531 |
foreach my $table (qw(generic_translations units_language)) { |
|
532 |
$query = qq|DELETE FROM $table WHERE language_id = ?|; |
|
533 |
do_query($form, $dbh, $query, $form->{"id"}); |
|
534 |
} |
|
535 |
|
|
536 |
$query = "DELETE FROM language WHERE id = ?"; |
|
537 |
do_query($form, $dbh, $query, $form->{"id"}); |
|
538 |
1; |
|
539 |
}) or do { die SL::DB->client->error }; |
|
540 |
|
|
541 |
$main::lxdebug->leave_sub(); |
|
542 |
} |
|
543 |
|
|
544 | 431 |
sub prepare_template_filename { |
545 | 432 |
$main::lxdebug->enter_sub(); |
546 | 433 |
|
Auch abrufbar als: Unified diff
SimpleSystemSetting: Umstellung von »Sprachen«