| 1 | package CatalystX::CMS::Model; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use base qw( CatalystX::CRUD::Model::File ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use MRO::Compat; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use mro 'c3'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use Data::Dump qw( dump ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use Path::Class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | our $VERSION = '0.011'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | my $DEBUG = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 2 | __PACKAGE__->config( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | object_class => 'CatalystX::CMS::Page', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | file_ext => '.tt', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 2 | __PACKAGE__->mk_accessors(qw( file_ext )); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | CatalystX::CMS::Model - manage template file paths | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | package MyCMS::Model::CMS; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | use base qw( CatalystX::CMS::Model ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | CatalystX::CMS::Model is a subclass of CatalystX::CRUD::Model::File. Be sure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | to read that documentation. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | Only new or overridden methods are documented here. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | =head2 Xsetup | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | Sets inc_path() based on the main application C<cms> config I<root> values. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 1 | ▶ | sub Xsetup { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Xsetup: called CC=4 SCAR=16.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 1 | my ( $self, $c ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 1 | $self->_make_inc($c); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | $self->{use_basename_fallback} = 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 1 | ▶ | if $c->config->{cms}->{use_basename_fallback}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 1 | $self->next::method($c); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 1 | ▶ | if ( $c->debug ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | my $t = Text::SimpleTable->new(74); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | $t->row("$_") for @{ $self->inc_path }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | $c->log->debug( "CMS Model inc path:\n" . $t->draw . "\n" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 1 | ▶ | sub _make_inc { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_make_inc: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 1 | my ( $self, $c ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 1 | my $conf = $c->config->{cms}->{root}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | # inc path is composite array of all paths, rw followed by r | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 1 | my @r = @{ $conf->{r} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 1 | my @rw = @{ $conf->{rw} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 1 | $self->{__make_copy}->{"$_"}++ for @r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 1 | $self->{inc_path} = [ @rw, @r ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | =head2 fetch( file => I<path/file> ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | Overrides base method to additionally set I<cms_root> and I<ext> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | in the returned CatalystX::CMS::Page object. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 5 | ▶ | sub fetch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fetch: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 5 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 5 | my $page = $self->new_object( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | ext => $self->file_ext, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | url => '/' . $self->context->req->path, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | @_, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 5 | return $self->find_page_in_inc($page); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | =head2 find_page_in_inc( I<cmspage> [, I<extra_paths>] ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | Called by fetch(). Locates I<cmspage> in the filesystem | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | if it exists, setting type and flavour flags and calling the read() method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | on I<cmspage> if found. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | Returns I<cmspage>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 5 | ▶ | sub find_page_in_inc { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_page_in_inc: called CC=26 SCAR=41.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 5 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 5 | ▶ | my $page = shift or croak "page required"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 5 | my @extra_paths = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 5 | my $delegate_class = $page->delegate_class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 5 | my $c = $self->context; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | my $type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | = $page->type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | || $c->req->params->{'cxcms-type'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | || $c->config->{cms}->{default_type} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 5 | ▶ | || 'html'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition37%3/8
$page->type || $c->req->params->{'cxcms-type'} || $c->config->{'cms'}{'default_type'} || 'html'
$page->type or $c->req->params->{"cxcms-type"} or $c->config->{"cms"}{"default_type"}
$page->type or $c->req->params->{"cxcms-type"}
MC/DC0%0/3
$page->type || $c->req->params->{'cxcms-type'} || $c->config->{'cms'}{'default_type'} || 'html'
$page->type
$c->req->params->{"cxcms-type"}
$c->config->{"cms"}{"default_type"}
Truth table25%1/4
A or B or C
A= $page->typeB= $c->req->params->{"cxcms-type"}C= $c->config->{"cms"}{"default_type"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | my $flav | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | = $page->flavour | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | || $c->req->params->{'cxcms-flavour'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | || $c->config->{cms}->{default_flavour} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 5 | ▶ | || 'default'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition37%3/8
$page->flavour || $c->req->params->{'cxcms-flavour'} || $c->config->{'cms'}{'default_flavour'} || 'default'
$page->flavour or $c->req->params->{"cxcms-flavour"} or $c->config->{"cms"}{"default_flavour"}
$page->flavour or $c->req->params->{"cxcms-flavour"}
MC/DC0%0/3
$page->flavour || $c->req->params->{'cxcms-flavour'} || $c->config->{'cms'}{'default_flavour'} || 'default'
$page->flavour
$c->req->params->{"cxcms-flavour"}
$c->config->{"cms"}{"default_flavour"}
Truth table25%1/4
A or B or C
A= $page->flavourB= $c->req->params->{"cxcms-flavour"}C= $c->config->{"cms"}{"default_flavour"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 5 | my $ext = $self->file_ext; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | # look through inc_path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 5 | DIR: for my $dir ( @{ $self->inc_path }, @extra_paths ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 7 | my $flavoured = Path::Class::dir( $dir, $type, $flav ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 7 | my $plain = Path::Class::dir($dir); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 7 | ▶ | $DEBUG and warn "inc_path flavoured: $flavoured"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 7 | SUBDIR: for my $subdir ( $flavoured, $plain ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 11 | ▶ | $c->log->debug("looking in $subdir for $page") if $c->debug; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 11 | my $test = $delegate_class->new( $subdir, $page ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 11 | ▶ | if ( -s $test ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 3 | ▶ | $c->log->debug("Found cms file: $test") if $c->debug; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 3 | $page->{delegate} = $test; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 3 | $page->{cms_root} = $dir; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 3 | $page->{type} = $type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 3 | $page->{flavour} = $flav; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 3 | $page->{copy} = exists $self->{__make_copy}->{"$dir"}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 3 | $page->read; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | #$c->log->debug( Data::Dump::dump($page) ) if $c->debug; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 3 | last DIR; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | # allow for (e.g.) CXCRUD templates, which we want to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | # edit but which are stored in @INC | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | # This logic mirrors what is done in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | # CatalystX::CRUD::YUI::View->process | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 5 | my $basename = $page->delegate->basename; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 5 | $basename =~ s/$ext$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 5 | ▶ | if ( $self->{use_basename_fallback} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
$self->{"use_basename_fallback"} and not -s $page->delegate and not $basename =~ /^(body|wrapper|header|footer)$/ and not $self->{"__no_recurse"}
$self->{"use_basename_fallback"} and not -s $page->delegate and not $basename =~ /^(body|wrapper|header|footer)$/
$self->{"use_basename_fallback"} and not -s $page->delegate
MC/DC0%0/4
$self->{"use_basename_fallback"} and not -s $page->delegate and not $basename =~ /^(body|wrapper|header|footer)$/ and not $self->{"__no_recurse"}
$self->{"use_basename_fallback"}
not -s $page->delegate
not $basename =~ /^(body|wrapper|header|footer)$/
not $self->{"__no_recurse"}
Truth table20%1/5
A and not(B) and not(C) and not(D)
A= $self->{"use_basename_fallback"}B= not -s $page->delegateC= not $basename =~ /^(body|wrapper|header|footer)$/D= not $self->{"__no_recurse"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | && !-s $page->delegate | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | && $basename !~ m/^(body|wrapper|header|footer)$/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | && !$self->{__no_recurse} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | $DEBUG and warn dump $page; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | $c->log->debug("$page does not exist -- trying $basename") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | if $c->debug; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | $self->{__no_recurse} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | $page = $self->fetch( file => $basename ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | delete $self->{__no_recurse}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | #$page->{delegate}->{dir} = Path::Class::dir( $crud_base, 'crud' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | $page->{copy} = 1; # make a local copy to edit | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | # make sure delegate() has absolute path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | # while page is relative to inc_path. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 5 | ▶ | if ( $page->dir eq '.' or !$page->dir->is_absolute ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$page->dir eq "." or not $page->dir->is_absolute
MC/DC50%1/2
$page->dir eq "." or not $page->dir->is_absolute
$page->dir eq "."
not $page->dir->is_absolute
Truth table66%2/3
A or not(B)
A= $page->dir eq "."B= not $page->dir->is_absolute
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 2 | ▶ | $c->log->debug("No absolute path for $page") if $c->debug; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | $page->{delegate} = $delegate_class->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | path => Path::Class::file( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 2 | $c->config->{cms}->{root}->{rw}->[0], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | $type, $flav, $page | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 2 | $page->{type} = $type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 2 | $page->{flavour} = $flav; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | # calculate url if it is empty | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 5 | ▶ | if ( !$page->url ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | $page->calc_url; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 5 | ▶ | $DEBUG and carp dump $page; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 5 | ▶ | $c->log->debug( "returning Model page: " . dump($page) ) if $c->debug; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 5 | return $page; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | =head2 make_query | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | Returns a CODE ref according to CatalystX::CRUD::Model::File API | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | to skip all C<.svn> dirs and files not ending with file_ext(). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | sub make_query { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_query: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | my $ext = quotemeta( $self->file_ext ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | my ( $root, $dir, $file ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | #warn $file; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | ▶ | return 0 if $dir =~ m/\.svn/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | ▶ | return 0 if $file =~ m/\.svn/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | #warn "$ext : considering $file"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | ▶ | return 0 unless $file =~ m/$ext$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | #warn " >>>>>>> match on $file"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | =head2 search | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | Overrides default method to call fetch() on each page. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | ▶ | sub search { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
search: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | my $filter_sub = shift || $self->make_query; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
shift() || $self->make_query
MC/DC0%0/2
shift() || $self->make_query
shift()
$self->make_query
Truth table0%0/3
A || B
A= shift()B= $self->make_query
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | my @objects; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | for my $root ( @{ $self->inc_path } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | my $files = $self->_find( $filter_sub, $root ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | for my $f ( sort keys %$files ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | my $page = $self->fetch( file => $f, url => '' ); # calc url | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | push @objects, $page; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | return \@objects; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||