|
From: Chris W. <la...@us...> - 2001-10-24 19:56:42
|
Update of /cvsroot/openinteract/OpenInteract/pkg/base_box/OpenInteract/Handler
In directory usw-pr-cvs1:/tmp/cvs-serv7379/OpenInteract/Handler
Modified Files:
Box.pm
Log Message:
allow you to remove boxes
Index: Box.pm
===================================================================
RCS file: /cvsroot/openinteract/OpenInteract/pkg/base_box/OpenInteract/Handler/Box.pm,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** Box.pm 2001/10/11 03:53:21 1.12
--- Box.pm 2001/10/24 19:56:38 1.13
***************
*** 55,62 ****
# Next, weed out boxes without at least a name and assign
! # class/method or template information as needed
!
! my @good_boxes = ();
BOX:
foreach my $box_info ( @{ $R->{boxes} } ) {
--- 55,66 ----
# Next, weed out boxes without at least a name and assign
! # class/method or template information as needed. Also be able to
! # remove a box from the boxes previously marked as good if someone
! # has asked us NOT to display it. For instance, if an app doesn't
! # want a login box it can do:
! # push @{ $R->{boxes} }, { name => 'login_box', remove => 'yes' };
+ my %good_boxes = ();
+ my @to_remove = ();
BOX:
foreach my $box_info ( @{ $R->{boxes} } ) {
***************
*** 70,73 ****
--- 74,84 ----
}
+ # See if this is a 'remove' request
+
+ if ( $box_info->{remove} ) {
+ push @to_remove, $box_info->{name};
+ next;
+ }
+
unless ( $box_info->{name} ) {
$R->scrib( 0, "Box put into the holding area without a name! Not processed.\n",
***************
*** 116,127 ****
$R->DEBUG && $R->scrib( 1, "Putting box ($box_info->{name}) onto the",
"stack with weight $box_info->{weight}" );
! push @good_boxes, $box_info;
}
! # Now, sort the boxes by weight then name
my @sorted_boxes = sort { $a->{weight} <=> $b->{weight} ||
$a->{name} cmp $b->{name} }
! @good_boxes;
# Grab the template that we'll plug the box content into
--- 127,144 ----
$R->DEBUG && $R->scrib( 1, "Putting box ($box_info->{name}) onto the",
"stack with weight $box_info->{weight}" );
! $good_boxes{ $box_info->{name} } = $box_info;
}
! # Remove the boxes as requested
!
! foreach my $remove_name ( @to_remove ) {
! delete $good_boxes{ $remove_name } if ( $remove_name );
! }
!
! # Sort the boxes by weight then name
my @sorted_boxes = sort { $a->{weight} <=> $b->{weight} ||
$a->{name} cmp $b->{name} }
! values %good_boxes;
# Grab the template that we'll plug the box content into
***************
*** 216,219 ****
--- 233,240 ----
push @{ $R->{boxes} }, $box;
+ # Remove a box added in another part of the system
+
+ push @{ $R->{boxes} }, { name => 'motd', remove => 'yes' };
+
=head1 DESCRIPTION
***************
*** 333,336 ****
--- 354,372 ----
Just used to identify the box.
+
+ =item *
+
+ B<remove> ($) (optional)
+
+ If you use this parameter you are telling the box handler to remove a
+ box with name 'name'. This box does not have to be added by you or in
+ your package -- for instance, you might want to always get rid of the
+ 'user_info' and 'login' boxes that come with OI:
+
+ push @{ $R->{boxes} }, { name => 'user_info_box', remove => 'yes' },
+ { name => 'login_box', remove => 'yes' };
+
+ This does require you to know the name, but that should not be too
+ onerous a burden.
=item *
|