| 1 | package Labyrinth::Plugin::Articles::Sections; | ||||||||||||
| 2 | |||||||||||||
| 3 | 4 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 4 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | |||||||||||||
| 6 | 4 | ▶ | use vars qw($VERSION $ALLSQL $SECTIONID); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | 4 | $VERSION = '5.19'; | |||||||||||
| 8 | |||||||||||||
| 9 | =head1 NAME | ||||||||||||
| 10 | |||||||||||||
| 11 | Labyrinth::Plugin::Articles::Sections - Sections handler plugin for Labyrinth | ||||||||||||
| 12 | |||||||||||||
| 13 | =head1 DESCRIPTION | ||||||||||||
| 14 | |||||||||||||
| 15 | Contains all the section handling functionality for the Labyrinth | ||||||||||||
| 16 | framework. | ||||||||||||
| 17 | |||||||||||||
| 18 | =cut | ||||||||||||
| 19 | |||||||||||||
| 20 | # ------------------------------------- | ||||||||||||
| 21 | # Library Modules | ||||||||||||
| 22 | |||||||||||||
| 23 | 4 | ▶ | use base qw(Labyrinth::Plugin::Articles); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 24 | |||||||||||||
| 25 | 4 | ▶ | use Clone qw(clone); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 26 | |||||||||||||
| 27 | 4 | ▶ | use Labyrinth::Audit; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 28 | 4 | ▶ | use Labyrinth::DBUtils; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 29 | 4 | ▶ | use Labyrinth::DTUtils; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 30 | 4 | ▶ | use Labyrinth::MLUtils; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 31 | 4 | ▶ | use Labyrinth::Session; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 32 | 4 | ▶ | use Labyrinth::Support; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 33 | 4 | ▶ | use Labyrinth::Variables; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 34 | |||||||||||||
| 35 | # ------------------------------------- | ||||||||||||
| 36 | # Variables | ||||||||||||
| 37 | |||||||||||||
| 38 | # type: 0 = optional, 1 = mandatory | ||||||||||||
| 39 | # html: 0 = none, 1 = text, 2 = textarea | ||||||||||||
| 40 | |||||||||||||
| 41 | 4 | my %fields = ( | |||||||||||
| 42 | articleid => { type => 0, html => 0 }, | ||||||||||||
| 43 | quickname => { type => 1, html => 0 }, | ||||||||||||
| 44 | title => { type => 1, html => 1 }, | ||||||||||||
| 45 | ); | ||||||||||||
| 46 | |||||||||||||
| 47 | 4 | my (@mandatory,@allfields); | |||||||||||
| 48 | 4 | for(keys %fields) { | |||||||||||
| 49 | 12 | ▶ | push @mandatory, $_ if($fields{$_}->{type}); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 50 | 12 | push @allfields, $_; | |||||||||||
| 51 | } | ||||||||||||
| 52 | |||||||||||||
| 53 | 4 | $ALLSQL = 'AllArticles'; | |||||||||||
| 54 | 4 | $SECTIONID = 2; | |||||||||||
| 55 | |||||||||||||
| 56 | # ------------------------------------- | ||||||||||||
| 57 | # The Subs | ||||||||||||
| 58 | |||||||||||||
| 59 | =head1 PUBLIC INTERFACE METHODS | ||||||||||||
| 60 | |||||||||||||
| 61 | =over 4 | ||||||||||||
| 62 | |||||||||||||
| 63 | =item GetSection | ||||||||||||
| 64 | |||||||||||||
| 65 | Retrieves the section articles used for introductory passages. | ||||||||||||
| 66 | |||||||||||||
| 67 | GetSection can be called with a named section, or it will use the section | ||||||||||||
| 68 | of the current request. | ||||||||||||
| 69 | |||||||||||||
| 70 | =back | ||||||||||||
| 71 | |||||||||||||
| 72 | =cut | ||||||||||||
| 73 | |||||||||||||
| 74 | 0 | ▶ | sub GetSection { | ||||||||||
|
Subroutine
GetSection: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||
| 75 | 0 | my ($self, $section) = @_; | |||||||||||
| 76 | 0 | my $name = $cgiparams{name}; | |||||||||||
| 77 | 0 | $cgiparams{sectionid} = $SECTIONID; | |||||||||||
| 78 | |||||||||||||
| 79 | 0 | ▶ | if($section) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 80 | 0 | $cgiparams{name} = $section; | |||||||||||
| 81 | } else { | ||||||||||||
| 82 | 0 | ▶ | my $request = $cgiparams{act} || 'home-public'; | ||||||||||
|
Condition0%0/2
$Labyrinth::Plugin::Articles::Sections::cgiparams{'act'} || 'home-public'
MC/DC0%0/1
$Labyrinth::Plugin::Articles::Sections::cgiparams{'act'} || 'home-public'
$Labyrinth::Plugin::Articles::Sections::cgiparams{'act'}
Truth table0%0/2
A
A= $Labyrinth::Plugin::Articles::Sections::cgiparams{'act'}
| |||||||||||||
| 83 | 0 | ▶ | $request = 'home-public' if($request eq 'user-logout'); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 84 | 0 | ($cgiparams{name}) = split("-",$request); | |||||||||||
| 85 | } | ||||||||||||
| 86 | |||||||||||||
| 87 | 0 | $self->SUPER::Item(); | |||||||||||
| 88 | 0 | ▶ | $tvars{page}->{section} = $tvars{articles}->{$cgiparams{name}} if($tvars{articles}->{$cgiparams{name}}); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 89 | 0 | $cgiparams{name} = $name; # revert back to what it should be! | |||||||||||
| 90 | } | ||||||||||||
| 91 | |||||||||||||
| 92 | =head1 ADMIN INTERFACE METHODS | ||||||||||||
| 93 | |||||||||||||
| 94 | Standard actions to administer the section content. | ||||||||||||
| 95 | |||||||||||||
| 96 | =over 4 | ||||||||||||
| 97 | |||||||||||||
| 98 | =item Access | ||||||||||||
| 99 | |||||||||||||
| 100 | Determine with user has access to administration features. | ||||||||||||
| 101 | |||||||||||||
| 102 | =item Admin | ||||||||||||
| 103 | |||||||||||||
| 104 | Provide list of the sections currently available. | ||||||||||||
| 105 | |||||||||||||
| 106 | =item Add | ||||||||||||
| 107 | |||||||||||||
| 108 | Add a new section article. | ||||||||||||
| 109 | |||||||||||||
| 110 | =item Edit | ||||||||||||
| 111 | |||||||||||||
| 112 | Edit an existing section article. | ||||||||||||
| 113 | |||||||||||||
| 114 | =item Save | ||||||||||||
| 115 | |||||||||||||
| 116 | Save the current section article. | ||||||||||||
| 117 | |||||||||||||
| 118 | =item Delete | ||||||||||||
| 119 | |||||||||||||
| 120 | Delete a section article. | ||||||||||||
| 121 | |||||||||||||
| 122 | =back | ||||||||||||
| 123 | |||||||||||||
| 124 | =cut | ||||||||||||
| 125 | |||||||||||||
| 126 | 0 | ▶ | sub Access { Authorised(MASTER) } | ||||||||||
|
Subroutine
Access: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 127 | |||||||||||||
| 128 | 0 | ▶ | sub Admin { | ||||||||||
|
Subroutine
Admin: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||
| 129 | 0 | ▶ | return unless AccessUser(MASTER); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 130 | 0 | $cgiparams{sectionid} = $SECTIONID; | |||||||||||
| 131 | 0 | shift->SUPER::Admin(); | |||||||||||
| 132 | } | ||||||||||||
| 133 | |||||||||||||
| 134 | 0 | ▶ | sub Add { | ||||||||||
|
Subroutine
Add: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||
| 135 | 0 | ▶ | return unless AccessUser(MASTER); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 136 | 0 | $cgiparams{sectionid} = $SECTIONID; | |||||||||||
| 137 | 0 | shift->SUPER::Add(); | |||||||||||
| 138 | } | ||||||||||||
| 139 | |||||||||||||
| 140 | 0 | ▶ | sub Edit { | ||||||||||
|
Subroutine
Edit: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||
| 141 | 0 | ▶ | return unless AccessUser(MASTER); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 142 | 0 | $cgiparams{sectionid} = $SECTIONID; | |||||||||||
| 143 | 0 | shift->SUPER::Edit(); | |||||||||||
| 144 | } | ||||||||||||
| 145 | |||||||||||||
| 146 | 0 | ▶ | sub Save { | ||||||||||
|
Subroutine
Save: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||
| 147 | 0 | ▶ | return unless AccessUser(MASTER); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 148 | 0 | $cgiparams{sectionid} = $SECTIONID; | |||||||||||
| 149 | 0 | shift->SUPER::Save(); | |||||||||||
| 150 | } | ||||||||||||
| 151 | |||||||||||||
| 152 | 0 | ▶ | sub Delete { | ||||||||||
|
Subroutine
Delete: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||
| 153 | 0 | ▶ | return unless AccessUser(MASTER); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 154 | 0 | $cgiparams{sectionid} = $SECTIONID; | |||||||||||
| 155 | 0 | shift->SUPER::Delete(); | |||||||||||
| 156 | } | ||||||||||||
| 157 | |||||||||||||
| 158 | 4 | 1; | |||||||||||
| 159 | |||||||||||||
| 160 | __END__ | ||||||||||||