Box: rdf_feeds_boxed
|
|
By phill , Section Code [] Posted on Tue Jun 22, 2004 at 12:00:00 PM PST
|
|
I'm not particularly fond of the one rdf box with all the links lumped inside. I had played around with a system to seperate the rdf feeds into boxes and then allow the user to determine their position as well as turn them off from the page they were displayed on. This is a slimed down version of that idea, minus the arrangement options.
There are four parts: rdf_feeds_boxed, rdf_feeds_single, box_rdf_box, and hiderdf_box.
|
Any improvements or suggestions are welcome. rdf_feeds_boxed
Type: box
Template: empty_box
Description: This is the main box that all the rdf feeds are nested inside and is losely based on the rdf_feeds box that comes with scoop. Because it is uses the empty_box template, you should not see it. It gets the $S->{prefs}->{rdf_feeds} from the userprefs table and uses that to populate the list of visible rdf feeds.
rdf_feeds_single
Type: box
Template: empty_box
Description: This is the box that formats the rdf feed data into the box. There is not a (known) variable for rdf feed id and this box works around that without modifying the base scoop code. The $c argument in rdf_feeds_boxed ($content.=qq~|BOX,rdf_box_single,$c|~;) feeds rdf_feeds_single the rid to build the box around.
box_rdf_box
Type: block
Category: Box Templates
Theme: default
Description: This is the html that would normally be called as the box template. The '|BOX,hiderdf_box,|RID||' statement calls the hiderdf_box and '|RID|' is replaced by the rdf_feeds_single box with the rdf ID number.
hiderdf_box
Type: box
Template: empty_box
Description: This is a modified version of Hillct's hidebox_box that hides changes the rdf_feeds userpref.
## start rdf_feeds_boxed box
##
## instead of the one box of RDF feeds lumped together, create a box for each feed and incorporate the hidebox_box functionality by Colin Hil
l (hillct)
## Version 0.1 by phill brown (pipebox.net)
##
## This box uses the empty_box template
##
return unless $S->{UI}->{VARS}->{use_rdf_feeds};
my $content;
my $channels = $S->rdf_channels();
my @feeds=split(/,/, $S->{prefs}->{rdf_feeds});
foreach my $c(@feeds){
$content.=qq~|BOX,rdf_box_single,$c|~;
}
return $content;
## end rdf_feeds_boxed
## start rdf_feeds_single box
##
## instead of the one box of RDF feeds lumped together, create a box for each feed and incorporate the hidebox_box functionality by Colin Hil
l (hillct)
## Version 0.1 by phill brown (pipebox.net)
##
## This box uses the empty_box template
##
my $content;
my $item= $S->rdf_channels($ARGS[0]);
my $title=$item->{title};
if ($S->{UI}->{VARS}->{rdf_use_images} && $item->{image_url}) {
$content .= qq~<A HREF="$item->{image_link}"><IMG SRC="$item->{image_url}" ALT="$item->{image_title}" BORDER="1"><
/a><br>\n~;
}
my $item_limit = defined($S->{prefs}->{rdf_max_headlines}) ?
$S->{prefs}->{rdf_max_headlines} :
defined($S->{UI}->{VARS}->{rdf_max_headlines}) ?
$S->{UI}->{VARS}->{rdf_max_headlines} : 15;
my $links = $S->rdf_items($ARGS[0], $item_limit);
foreach my $i (@{$links}) {
$content .= qq~|dot| <a class="light" href="$i->{link}">$i->{title}</a><br>\n~;
}
my $return=$S->{UI}->{BLOCKS}->{box_rdf_box};
$return =~ s/|content|/$content/g;
$return =~ s/|title|/$title/g;
$return =~ s/|RID|/$ARGS[0]/g;
return $return;
## end rdf_box_single box
## start box_rdf_box block
##
## instead of the one box of RDF feeds lumped together, create a box for each feed and incorporate the hidebox_box functionality by Colin Hil
l (hillct)
## Version 0.1 by phill brown (pipebox.net)
##
## I placed this block in the default theme and in the 'Box Templates' category. You might consider doing the same.
##
<TABLE WIDTH="100%" BORDER=1 CELLPADDING=2 CELLSPACING=0>
<TR>
<TD BGCOLOR="#006699">
|box_title_font||title||box_title_font_end||BOX,hiderdf_box,|RID||
</TD>
</TR>
<TR>
<TD>
|smallfont|
|content|
|smallfont_end|
</TD>
</TR>
</TABLE>
<P>
## end box_rdf_box block
## START hiderdf_box ##
# Requires an image name to be defined in the variable 'hidebox_icon'
# This box should be called from within the box rdf_box_single
# The call should be of the form:
# |BOX,hiderdf_box,|RID||
# an example box closer icon can be seen at:
# http://beta.evilplans.net/images/x.gif
### Really Start Hidebox Box ###
# Display a Box CLoser 'X' in box templates
# Version 0.1 by hillct
# Version 0.1a by phill brown (pipebox.net): modified to change RDF preferences
#
#
my($content);
my $uri=$S->apache->uri;
my $arg = $S->apache->args();
$arg =~ s/hide-rdf=\w+//g;
$arg =~ s/;$//;
my $redirect=($arg)?"$uri?$arg":$uri;
$uri .= ($arg) ? "?$arg;hide-rdf=$ARGS[0]" : "?hide-rdf=$ARGS[0]";
if($S->{GID} ne 'Anonymous') { # If logged in
if($S->cgi->param('hide-rdf')=~/$ARGS[0]/){
# Change the user pref for display of this box
my @feeds=split(/,/, $S->{prefs}->{rdf_feeds});
my @rids;
foreach my $c (@feeds){
push(@rids, $c) unless ($c == $ARGS[0]);
}
$S->rdf_set_prefs(\@rids);
# Redirect because we're actually running the box
$S->apache->header_out('location',$redirect);
$S->apache->header_out('connection','close');
$S->apache->status(301); $S->{HEADER_ONLY}=1;
} else {
# Display an 'X' with a link to 'URI' if allowed
$content.=qq{<a href="$uri"><img src="$S->{UI}->{VARS}->{'rootdir'}$S->{UI}->{VARS}->{'imagedir'}/$S->{UI}
->{VARS}->{'hidebox_icon'}" border="0" align="right" alt="close"></a>};
}
return {content => $content};
}
## END hiderdf_box ## |
|
Story Views
|
50 Scoop users have viewed this story.
|
|