@ISA = qw/Squirrel::Row BSE::TB::SiteCommon BSE::TB::TagOwner/;
use Carp 'confess';
-our $VERSION = "1.022";
+our $VERSION = "1.023";
=head1 NAME
my $section = $self;
while ($section->{parentid} > 0
- and my $parent = Articles->getByPkey($section->{parentid})) {
+ and my $parent = $section->parent) {
$section = $parent;
}
sub parent {
my ($self) = @_;
- $self->{parentid} == -1 and return;
- return Articles->getByPkey($self->{parentid});
+
+ my $parentid = $self->parentid;
+
+ $parentid == -1
+ and return;
+ $self->{_parent} && $self->{_parent}->id == $parentid
+ and return $self->{_parent};
+ return ($self->{_parent} = Articles->getByPkey($self->{parentid}));
}
sub update_dynamic {
return $self->is_linked && $self->listed && $self->is_released && !$self->is_expired;
}
+=item should_index
+
+Returns true if the article should be indexed.
+
+=cut
+
+sub should_index {
+ my ($self) = @_;
+
+ return ($self->listed || $self->is_index_even_if_hidden)
+ && $self->is_linked
+ && !$self->is_dont_index
+ && !$self->is_dont_index_or_kids
+}
+
+=item is_index_even_if_hidden
+
+Return true if the article's index even if hidden flag is set.
+
+=cut
+
+sub is_index_even_if_hidden {
+ my ($self) = @_;
+
+ return $self->flags =~ /I/;
+}
+
+=item is_dont_index
+
+Return true if the "don't index" flag (C<N>) is set.
+
+=cut
+
+sub is_dont_index {
+ return $_[0]->flags =~ /N/;
+}
+
+=item is_dont_index_or_kids
+
+Return true if the article or any of it's parents have the "don't
+index me or my children" flag (C<C>) set.
+
+=cut
+
+sub is_dont_index_or_kids {
+ my ($self) = @_;
+
+ $self->flags =~ /C/ and return 1;
+
+ my $parent = $self->parent
+ or return 0;
+
+ return $parent->is_dont_index_or_kids;
+}
+
sub restricted_method {
my ($self, $name) = @_;
$self->set_lastModifiedBy(ref $opts{actor} ? $opts{actor}->logon : "");
}
+=item uncache
+
+Free any cached data.
+
+=cut
+
+sub uncache {
+ my ($self) = @_;
+
+ delete @{$self}{qw/_parent/};
+
+ $self->SUPER::uncache();
+}
+
1;
__END__
use Constants qw(@SEARCH_EXCLUDE @SEARCH_INCLUDE);
use Articles;
-our $VERSION = "1.003";
+our $VERSION = "1.004";
my %default_scores =
(
# find the section
my $article = Articles->getByPkey($id);
next unless $article;
- next unless ($article->{listed} || $article->{flags} =~ /I/);
- next unless $article->is_linked;
- next if $article->{flags} =~ /[CN]/;
- my $section = $article;
- while ($section->{parentid} >= 1) {
- $section = Articles->getByPkey($section->{parentid});
- next INDEX if $section->{flags} =~ /C/;
- }
+ next unless $article->should_index;
+ my $section = $article->section;
my $id = $article->{id};
my $indexas = $article->{level} > $self->{max_level} ? $article->{parentid} : $id;
my $sectionid = $section->{id};
use strict;
use Carp qw(confess);
-our $VERSION = "1.017";
+our $VERSION = "1.018";
=head1 NAME
return @new_order;
}
+=item uncache
+
+Clear any locally cached info.
+
+=cut
+
+sub uncache {
+ my ($self) = @_;
+
+ $self->uncache_images;
+ $self->uncache_files;
+}
+
1;
__END__
#!perl -w
use strict;
use BSE::Test qw(make_ua base_url);
-use Test::More tests => 68;
+use Test::More tests => 76;
use File::Spec;
use File::Slurp;
use Carp qw(confess);
}
}
+{ # testing the indexing flags
+ my $index = bse_make_article(cfg => $cfg,
+ title => "index test child",
+ parentid => $art->id);
+ ok($index, "make article for should_index tests");
+ ok($index->should_index, "default should be indexed");
+ $index->set_listed(0);
+ $index->uncache;
+ ok(!$index->should_index, "not indexed if not listed");
+ $index->set_flags("I");
+ $index->uncache;
+ ok($index->should_index, "indexed if I flag set");
+ $index->set_listed(1);
+ $index->set_flags("N");
+ $index->uncache;
+ ok(!$index->should_index, "not indexed if N flag set");
+ $index->set_flags("C");
+ $index->uncache;
+ ok(!$index->should_index, "not indexed if C flag set");
+ $index->set_flags("");
+ $art->set_flags("C");
+ $art->save;
+ $index->uncache;
+ ok(!$index->should_index, "not indexed if parent's C flag set");
+
+ ok($index->remove($cfg), "remove index test");
+ undef $index;
+
+ END {
+ $index->remove($cfg) if $index;
+ }
+}
+
ok($child->remove($cfg), "remove child");
undef $child;
ok($art->remove($cfg), "remove article");