WebEditor/OldController/Msg.pm

filter: Statementstmt 31.5% 12 / 38 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 50.0% 3 / 6 Podpod 33.3% 1 / 3 totaltotal 25.8% 16 / 62 CC 9 SCAR 37.5
CC
9
Cov
23%
msg
72.0
new
6.0
fmt_msg
2.0
CRAP 42.4
« WE/DB/Glossary.pm ↑ Summary WebEditor/OldFeatures/PrintTemplates.pm »
1 package WebEditor::OldController::Msg;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 $VERSION = sprintf("%d.%02d", q$Revision: 1.2 $ =~ /(\d+)\.(\d+)/);
6  
7 1 ▶use base 'Class::Accessor';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 __PACKAGE__->mk_accessors(qw(C EditorLang Messages));
10  
11 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod documented
12 0 my($class, $c, $lang) = @_;
13 0 ▶ my $self = { C => $c,
Condition0%0/2
$lang || 'en'
l!l
00
MC/DC0%0/1
$lang || 'en'
$lang
Truth table0%0/2
A
A= $lang
Aresult
11
00
14 EditorLang => $lang||"en", # named EditorLang for OldController.pm compat
15 Messages => {},
16 };
17 0 bless $self, $class;
18 }
19  
20 0 ▶sub msg {
Subroutine msg: not called CC=8 SCAR=42.8
Pod undocumented
21 0 my($self, $key) = @_;
22 0 my $stash = $self->Messages->{$self->EditorLang};
23 0 ▶ if (!$stash) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($stash) 0 0 0
24 0 my $c = $self->C;
25 0 my @try_langs = ($self->EditorLang);
26 0 ▶ push @try_langs, "en" if $self->EditorLang ne "en";
Branch: 1 branch
BranchTrueFalseTotal
if $self->EditorLang ne "en" 0 0 0
27 0 for my $lang (@try_langs) {
28 0 my $langres_file = $c->paths->we_templatebase . "/langres_$lang";
29 0 ▶ if (-r $langres_file) {
Branch: 1 branch
BranchTrueFalseTotal
if (-r $langres_file) 0 0 0
30 0 require Template::Context;
31 0 my $ctx = Template::Context->new({ ABSOLUTE => 1});
32 0 $ctx->process($langres_file);
33 0 $stash = $ctx->stash;
34 0 ▶ last if $stash;
Branch: 1 branch
BranchTrueFalseTotal
if $stash 0 0 0
35 }
36 }
37 0 ▶ if (!$stash) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($stash) 0 0 0
38 0 return "[[$key]]";
39 }
40 0 $self->Messages->{$self->EditorLang} = $stash;
41 }
42 0 my $val = $stash->get($key);
43 0 ▶ if (!defined $val) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $val) { } 0 0 0
44 0 "[[$key]]";
45 } else {
46 0 $val;
47 }
48 }
49  
50 0 ▶sub fmt_msg {
Subroutine fmt_msg: not called CC=1 SCAR=6.9
Pod undocumented
51 0 my($self, $key, @arg) = @_;
52 0 sprintf $self->msg($key), @arg;
53 }
54  
55 1 1;
« WE/DB/Glossary.pm ↑ Summary WebEditor/OldFeatures/PrintTemplates.pm »