| 1 | package Labyrinth::Plugin::Articles::Site; | ||||||||||||||||||||
| 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 | our $VERSION = '5.19'; | |||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | =head1 NAME | ||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | Labyrinth::Plugin::Articles::Site - Site Pages handler plugin for Labyrinth | ||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | =head1 DESCRIPTION | ||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | Contains all the site pages handling functionality for the Labyrinth | ||||||||||||||||||||
| 15 | framework. | ||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | =cut | ||||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | # ------------------------------------- | ||||||||||||||||||||
| 20 | # Library Modules | ||||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | 4 | ▶ | use base qw(Labyrinth::Plugin::Articles); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | 4 | ▶ | use Clone qw(clone); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 25 | 4 | ▶ | use Time::Local; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 26 | 4 | ▶ | use Data::Dumper; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | 4 | ▶ | use Labyrinth::Audit; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 29 | 4 | ▶ | use Labyrinth::DBUtils; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 30 | 4 | ▶ | use Labyrinth::DTUtils; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 31 | 4 | ▶ | use Labyrinth::Globals; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 32 | 4 | ▶ | use Labyrinth::MLUtils; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 33 | 4 | ▶ | use Labyrinth::Session; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 34 | 4 | ▶ | use Labyrinth::Support; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 35 | 4 | ▶ | use Labyrinth::Variables; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 36 | 4 | ▶ | use Labyrinth::Writer; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 37 | 4 | ▶ | use Labyrinth::Metadata; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | # ------------------------------------- | ||||||||||||||||||||
| 40 | # Variables | ||||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | # type: 0 = optional, 1 = mandatory | ||||||||||||||||||||
| 43 | # html: 0 = none, 1 = text, 2 = textarea | ||||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | 4 | my %fields = ( | |||||||||||||||||||
| 46 | articleid => { type => 0, html => 0 }, | ||||||||||||||||||||
| 47 | quickname => { type => 1, html => 0 }, | ||||||||||||||||||||
| 48 | title => { type => 1, html => 1 }, | ||||||||||||||||||||
| 49 | ); | ||||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | 4 | my (@mandatory,@allfields); | |||||||||||||||||||
| 52 | 4 | for(keys %fields) { | |||||||||||||||||||
| 53 | 12 | ▶ | push @mandatory, $_ if($fields{$_}->{type}); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 54 | 12 | push @allfields, $_; | |||||||||||||||||||
| 55 | } | ||||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | 4 | my $SECTIONID = 3; | |||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | # ------------------------------------- | ||||||||||||||||||||
| 60 | # The Subs | ||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | =head1 PUBLIC INTERFACE METHODS | ||||||||||||||||||||
| 63 | |||||||||||||||||||||
| 64 | =over 4 | ||||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | =item Archive | ||||||||||||||||||||
| 67 | |||||||||||||||||||||
| 68 | Retrieves a list of the volumes available. | ||||||||||||||||||||
| 69 | |||||||||||||||||||||
| 70 | =item List | ||||||||||||||||||||
| 71 | |||||||||||||||||||||
| 72 | Retrieves a list of site pages. | ||||||||||||||||||||
| 73 | |||||||||||||||||||||
| 74 | =item Meta | ||||||||||||||||||||
| 75 | |||||||||||||||||||||
| 76 | Retrieves pages based on given meta tag. | ||||||||||||||||||||
| 77 | |||||||||||||||||||||
| 78 | =item Cloud | ||||||||||||||||||||
| 79 | |||||||||||||||||||||
| 80 | Provides a tag cloud for the current site pages. | ||||||||||||||||||||
| 81 | |||||||||||||||||||||
| 82 | =item Search | ||||||||||||||||||||
| 83 | |||||||||||||||||||||
| 84 | Retrieves a list of site pages based on a given search string. | ||||||||||||||||||||
| 85 | |||||||||||||||||||||
| 86 | =item Item | ||||||||||||||||||||
| 87 | |||||||||||||||||||||
| 88 | Provides the content of a named site page. | ||||||||||||||||||||
| 89 | |||||||||||||||||||||
| 90 | =back | ||||||||||||||||||||
| 91 | |||||||||||||||||||||
| 92 | =cut | ||||||||||||||||||||
| 93 | |||||||||||||||||||||
| 94 | 0 | ▶ | sub Archive { | ||||||||||||||||||
|
Subroutine
Archive: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 95 | 0 | $cgiparams{sectionid} = $SECTIONID; | |||||||||||||||||||
| 96 | 0 | $cgiparams{section} = 'site'; | |||||||||||||||||||
| 97 | |||||||||||||||||||||
| 98 | 0 | shift->SUPER::Archive(); | |||||||||||||||||||
| 99 | 0 | $tvars{articles} = undef; | |||||||||||||||||||
| 100 | } | ||||||||||||||||||||
| 101 | |||||||||||||||||||||
| 102 | 0 | ▶ | sub List { | ||||||||||||||||||
|
Subroutine
List: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 103 | 0 | $cgiparams{sectionid} = $SECTIONID; | |||||||||||||||||||
| 104 | 0 | $settings{limit} = 1; | |||||||||||||||||||
| 105 | |||||||||||||||||||||
| 106 | 0 | shift->SUPER::List(); | |||||||||||||||||||
| 107 | } | ||||||||||||||||||||
| 108 | |||||||||||||||||||||
| 109 | 0 | ▶ | sub Meta { | ||||||||||||||||||
|
Subroutine
Meta: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 110 | 0 | ▶ | return unless($cgiparams{data}); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 111 | |||||||||||||||||||||
| 112 | 0 | $cgiparams{sectionid} = $SECTIONID; | |||||||||||||||||||
| 113 | 0 | $settings{limit} = 10; | |||||||||||||||||||
| 114 | |||||||||||||||||||||
| 115 | 0 | shift->SUPER::Meta(); | |||||||||||||||||||
| 116 | } | ||||||||||||||||||||
| 117 | |||||||||||||||||||||
| 118 | 0 | ▶ | sub Cloud { | ||||||||||||||||||
|
Subroutine
Cloud: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 119 | 0 | $cgiparams{sectionid} = $SECTIONID; | |||||||||||||||||||
| 120 | 0 | $cgiparams{actcode} = 'site-meta'; | |||||||||||||||||||
| 121 | 0 | shift->SUPER::Cloud(); | |||||||||||||||||||
| 122 | } | ||||||||||||||||||||
| 123 | |||||||||||||||||||||
| 124 | 0 | ▶ | sub Search { | ||||||||||||||||||
|
Subroutine
Search: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 125 | 0 | ▶ | return unless($cgiparams{data}); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 126 | |||||||||||||||||||||
| 127 | 0 | $cgiparams{sectionid} = $SECTIONID; | |||||||||||||||||||
| 128 | 0 | $settings{limit} = 10; | |||||||||||||||||||
| 129 | |||||||||||||||||||||
| 130 | 0 | shift->SUPER::Search(); | |||||||||||||||||||
| 131 | } | ||||||||||||||||||||
| 132 | |||||||||||||||||||||
| 133 | 0 | ▶ | sub Item { | ||||||||||||||||||
|
Subroutine
Item: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 134 | 0 | $cgiparams{sectionid} = $SECTIONID; | |||||||||||||||||||
| 135 | 0 | shift->SUPER::Item(); | |||||||||||||||||||
| 136 | } | ||||||||||||||||||||
| 137 | |||||||||||||||||||||
| 138 | =head1 ADMIN INTERFACE METHODS | ||||||||||||||||||||
| 139 | |||||||||||||||||||||
| 140 | Standard actions to administer the section content. | ||||||||||||||||||||
| 141 | |||||||||||||||||||||
| 142 | =over 4 | ||||||||||||||||||||
| 143 | |||||||||||||||||||||
| 144 | =item Access | ||||||||||||||||||||
| 145 | |||||||||||||||||||||
| 146 | Determine with user has access to administration features. | ||||||||||||||||||||
| 147 | |||||||||||||||||||||
| 148 | =item Admin | ||||||||||||||||||||
| 149 | |||||||||||||||||||||
| 150 | Provide list of the site pages currently available. | ||||||||||||||||||||
| 151 | |||||||||||||||||||||
| 152 | =item Add | ||||||||||||||||||||
| 153 | |||||||||||||||||||||
| 154 | Add a new site page. | ||||||||||||||||||||
| 155 | |||||||||||||||||||||
| 156 | =item Edit | ||||||||||||||||||||
| 157 | |||||||||||||||||||||
| 158 | Edit an existing site page. | ||||||||||||||||||||
| 159 | |||||||||||||||||||||
| 160 | =item Save | ||||||||||||||||||||
| 161 | |||||||||||||||||||||
| 162 | Save the current site page. | ||||||||||||||||||||
| 163 | |||||||||||||||||||||
| 164 | =item Delete | ||||||||||||||||||||
| 165 | |||||||||||||||||||||
| 166 | Delete a site page. | ||||||||||||||||||||
| 167 | |||||||||||||||||||||
| 168 | =back | ||||||||||||||||||||
| 169 | |||||||||||||||||||||
| 170 | =cut | ||||||||||||||||||||
| 171 | |||||||||||||||||||||
| 172 | 0 | ▶ | sub Access { Authorised(EDITOR) } | ||||||||||||||||||
|
Subroutine
Access: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 173 | |||||||||||||||||||||
| 174 | 0 | ▶ | sub Admin { | ||||||||||||||||||
|
Subroutine
Admin: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 175 | 0 | ▶ | return unless AccessUser(EDITOR); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 176 | 0 | $cgiparams{sectionid} = $SECTIONID; | |||||||||||||||||||
| 177 | 0 | shift->SUPER::Admin(); | |||||||||||||||||||
| 178 | } | ||||||||||||||||||||
| 179 | |||||||||||||||||||||
| 180 | 0 | ▶ | sub Add { | ||||||||||||||||||
|
Subroutine
Add: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 181 | 0 | ▶ | return unless AccessUser(EDITOR); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 182 | 0 | $cgiparams{sectionid} = $SECTIONID; | |||||||||||||||||||
| 183 | 0 | my $self = shift; | |||||||||||||||||||
| 184 | 0 | $self->SUPER::Add(); | |||||||||||||||||||
| 185 | 0 | $self->SUPER::Tags(); | |||||||||||||||||||
| 186 | } | ||||||||||||||||||||
| 187 | |||||||||||||||||||||
| 188 | 0 | ▶ | sub Edit { | ||||||||||||||||||
|
Subroutine
Edit: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 189 | 0 | ▶ | return unless AccessUser(EDITOR); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 190 | 0 | $cgiparams{sectionid} = $SECTIONID; | |||||||||||||||||||
| 191 | 0 | my $self = shift; | |||||||||||||||||||
| 192 | 0 | $self->SUPER::Edit(); | |||||||||||||||||||
| 193 | 0 | $self->SUPER::Tags(); | |||||||||||||||||||
| 194 | } | ||||||||||||||||||||
| 195 | |||||||||||||||||||||
| 196 | 0 | ▶ | sub Save { | ||||||||||||||||||
|
Subroutine
Save: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||
| 197 | 0 | ▶ | return unless AccessUser(EDITOR); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 198 | 0 | $cgiparams{sectionid} = $SECTIONID; | |||||||||||||||||||
| 199 | 0 | ▶ | $cgiparams{quickname} ||= formatDate(0); | ||||||||||||||||||
|
Condition0%0/3
$Labyrinth::Plugin::Articles::Site::cgiparams{"quickname"} ||= formatDate(0)
MC/DC0%0/2
$Labyrinth::Plugin::Articles::Site::cgiparams{"quickname"} ||= formatDate(0)
$Labyrinth::Plugin::Articles::Site::cgiparams{"quickname"}
formatDate(0)
Truth table0%0/3
A ||= B
A= $Labyrinth::Plugin::Articles::Site::cgiparams{"quickname"}B= formatDate(0)
| |||||||||||||||||||||
| 200 | 0 | shift->SUPER::Save(); | |||||||||||||||||||
| 201 | } | ||||||||||||||||||||
| 202 | |||||||||||||||||||||
| 203 | 0 | ▶ | sub Delete { | ||||||||||||||||||
|
Subroutine
Delete: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 204 | 0 | ▶ | return unless AccessUser(ADMIN); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 205 | 0 | $cgiparams{sectionid} = $SECTIONID; | |||||||||||||||||||
| 206 | 0 | shift->SUPER::Delete(); | |||||||||||||||||||
| 207 | } | ||||||||||||||||||||
| 208 | |||||||||||||||||||||
| 209 | 4 | 1; | |||||||||||||||||||
| 210 | |||||||||||||||||||||
| 211 | __END__ | ||||||||||||||||||||