Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Sample usage
- # for a in /home/linguamatica/root/locale/*/emailTemplates.xml; do perl emailTemplates.pl $a notification; done
- #!/usr/bin/perl
- use XML::DT;
- use warnings;
- use strict;
- use v5.26;
- use utf8;
- my $filename = shift;
- my $db = {
- username => 'XXX',
- password => 'XXX',
- database => 'ojs',
- };
- use DBI;
- my $DB = DBI->connect("DBI:mysql:database=$db->{database};host=localhost", $db->{username}, $db->{password});
- my $key = shift;
- my $locale = undef;
- my $subject = undef;
- my $body = undef;
- my $description = undef;
- my %handler=(
- 'body' => sub{ father->{body} = $c; },
- 'description' => sub{ father->{description} = $c; },
- 'email_text' => sub{
- if (uc($key) eq $v{key}) {
- $body = $v{body};
- $description = $v{description};
- $subject = $v{subject};
- }
- },
- 'email_texts' => sub{ $locale = $v{locale}; },
- 'subject' => sub{ father->{subject} = $c; },
- );
- dt($filename, %handler);
- if (defined $subject and defined $body) {
- utf8::decode($subject);
- utf8::decode($body);
- utf8::decode($description);
- my $dbh = $DB->prepare("INSERT INTO email_templates_default_data VALUES (?,?,?,?,?);");
- $dbh->execute(uc($key), $locale, $subject, $body, $description);
- say "DONE $locale!";
- } else {
- say "Not found for $locale!"
- }
Add Comment
Please, Sign In to add comment