3 # represents an article from the database
6 @ISA = qw/Squirrel::Row/;
9 return qw/id parentid displayOrder title titleImage body
10 thumbImage thumbWidth thumbHeight imagePos
11 release expire keyword template link admin threshold
12 summaryLength generator level listed lastModified/;
18 Articles->getSpecial('stepParents', $self->{id});
21 sub visible_step_parents {
24 use BSE::Util::SQL qw/now_datetime/;
25 my $now = now_datetime();
26 grep $_->{release} le $now && $now le $_->{expire}, $self->step_parents;
32 if ($self->{generator} eq 'Generate::Catalog') {
33 require 'Products.pm';
34 return Products->getSpecial('stepProducts', $self->{id});
37 return Articles->getSpecial('stepKids', $self->{id});
42 sub visible_stepkids {
45 use BSE::Util::SQL qw/now_sqldate/;
46 my $today = now_sqldate();
48 if ($self->{generator} eq 'Generate::Catalog') {
49 require 'Products.pm';
51 return Products->getSpecial('visibleStep', $self->{id}, $today);
54 return Articles->getSpecial('visibleStepKids', $self->{id}, $today);
60 # returns a list of all children in the correct sort order
65 require 'OtherParents.pm';
67 my @otherlinks = OtherParents->getBy(parentId=>$self->{id});
68 my @normalkids = Articles->children($self->{id});
70 (map { $_->{id}, $_->{displayOrder} } @normalkids ),
71 (map { $_->{childId}, $_->{parentDisplayOrder} } @otherlinks),
73 my @stepkids = $self->stepkids;
74 my %kids = map { $_->{id}, $_ } @stepkids, @normalkids;
76 return @kids{ sort { $order{$b} <=> $order{$a} } keys %kids };
79 # returns a list of all visible children in the correct sort order
81 sub all_visible_kids {
84 require 'OtherParents.pm';
86 my @otherlinks = OtherParents->getBy(parentId=>$self->{id});
87 my @normalkids = Articles->listedChildren($self->{id});
89 (map { $_->{id}, $_->{displayOrder} } @normalkids ),
90 (map { $_->{childId}, $_->{parentDisplayOrder} } @otherlinks),
92 my @stepkids = $self->visible_stepkids;
93 my %kids = map { $_->{id}, $_ } @stepkids, @normalkids;
95 return @kids{ sort { $order{$b} <=> $order{$a} } keys %kids };