Event/Types.pm

filter: Statementstmt 46.8% 22 / 47 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 66.6% 6 / 9 Podpod 100% 2 / 2 totaltotal 39.4% 30 / 76 SCAR 37.9
CC
11
Cov
35%
EventTypeSelect
30.0
AUTOLOAD
20.0
EventType
20.0
CRAP 44.4
« Event/Sponsors.pm ↑ Summary
1 package Labyrinth::Plugin::Event::Types;
2  
3 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 6 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 6 $VERSION = '1.09';
8  
9 =head1 NAME
10  
11 Labyrinth::Plugin::Event::Types - Event Type handler for the Labyrinth framework.
12  
13 =head1 DESCRIPTION
14  
15 Contains all the event type functionality for Labyrinth.
16  
17 This package can be overridden to extended to the event types available.
18  
19 =cut
20  
21 # -------------------------------------
22 # Library Modules
23  
24 6 ▶use base qw(Labyrinth::Plugin::Base);
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 6 ▶use Labyrinth::MLUtils;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 6 ▶use Labyrinth::Variables;
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29 # -------------------------------------
30 # Variables
31  
32 6 my %eventtypes;
33 6 our $AUTOLOAD;
34  
35 # -------------------------------------
36 # The Subs
37  
38 =head1 Pub INTERFACE METHODS
39  
40 =over 4
41  
42 =item SetType<n>
43  
44 An AUTOLOADed method to set the event type. Note if the type does not exist
45 within the database, the value is set to 0.
46  
47 =item EventType
48  
49 Provides the name of a specified event type.
50  
51 =item EventTypeSelect
52  
53 Provides a dropdown list of event types available.
54  
55 =back
56  
57 =cut
58  
59 sub AUTOLOAD {
60 0 ▶ my $self = shift;
Subroutine AUTOLOAD: not called CC=4 SCAR=30.0
61 0 ▶ ref($self) or die "$self is not an object";
Branch: 1 branch
BranchTrueFalseTotal
ref $self or die "$self is not an object" 0 0 0
62  
63 0 my $name = $AUTOLOAD;
64 0 $name =~ s/.*://; # strip fully-qualified portion
65  
66 0 my ($type) = $name =~ /SetType(\d+)/;
67 0 ▶ if($type) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type) { } 0 0 0
68 0 my @rows = $dbi->GetQuery('hash','GetEventType',$type);
69 0 ▶ if(@rows) { $cgiparams{eventtypeid} = $type }
Branch: 1 branch
BranchTrueFalseTotal
if (@rows) { } 0 0 0
70 0 else { $cgiparams{eventtypeid} = 0 }
71 0 } else { $cgiparams{eventtypeid} = 0 }
72 }
73  
74 sub EventType {
75 0 ▶ my ($self,$type) = @_;
Subroutine EventType: not called CC=4 SCAR=30.0
Pod documented
76  
77 0 ▶ unless(%eventtypes) {
Branch: 1 branch
BranchTrueFalseTotal
unless (%eventtypes) 0 0 0
78 0 my @rows = $dbi->GetQuery('hash','AllEventTypes');
79 0 $eventtypes{$_->{eventtypeid}} = $_->{eventtype} for(@rows);
80 }
81  
82 0 ▶ return $eventtypes{$type} || '';
Condition0%0/2
$eventtypes{$type} || ''
l!l
00
MC/DC0%0/1
$eventtypes{$type} || ''
$eventtypes{$type}
Truth table0%0/2
A
A= $eventtypes{$type}
Aresult
11
00
83 }
84  
85 sub EventTypeSelect {
86 0 ▶ my ($self,$opt,$blank) = @_;
Subroutine EventTypeSelect: not called CC=5 SCAR=34.0
Pod documented
87 0 ▶ $blank ||= 0;
Condition0%0/2
$blank ||= 0
l!l
00
MC/DC0%0/1
$blank ||= 0
$blank
Truth table0%0/2
A
A= $blank
Aresult
11
00
88  
89 0 ▶ unless(%eventtypes) {
Branch: 1 branch
BranchTrueFalseTotal
unless (%eventtypes) 0 0 0
90 0 my @rows = $dbi->GetQuery('hash','AllEventTypes');
91 0 $eventtypes{$_->{eventtypeid}} = $_->{eventtype} for(@rows);
92 }
93  
94 0 my @list = map { { 'id' => $_, 'value' => $eventtypes{$_} } } sort keys %eventtypes;
95 0 ▶ unshift @list, { id => 0, value => 'Select An Event Type' } if($blank == 1);
Branch: 1 branch
BranchTrueFalseTotal
if $blank == 1 0 0 0
96 0 return DropDownRows($opt,'eventtypeid','id','value',@list);
97 }
98  
99 6 1;
100  
101 __END__
102  
103 =head1 SEE ALSO
104  
105 L<Labyrinth>
106  
107 =head1 AUTHOR
108  
109 Barbie, <barbie@missbarbell.co.uk> for
110 Miss Barbell Productions, L<http://www.missbarbell.co.uk/>
111  
112 =head1 COPYRIGHT & LICENSE
113  
114 Copyright (C) 2002-2015 Barbie for Miss Barbell Productions
115 All Rights Reserved.
116  
117 This module is free software; you can redistribute it and/or
118 modify it under the Artistic License 2.0.
119  
120 =cut
« Event/Sponsors.pm ↑ Summary