RSS should be 2.0 compatible everywhere now.
This commit is contained in:
parent
8e03386e39
commit
c53725921a
1 changed files with 22 additions and 15 deletions
|
|
@ -15,6 +15,7 @@ package WebGUI::Asset::RSSFromParent;
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
|
use HTML::Entities;
|
||||||
use Tie::IxHash;
|
use Tie::IxHash;
|
||||||
use base 'WebGUI::Asset';
|
use base 'WebGUI::Asset';
|
||||||
use WebGUI::Utility;
|
use WebGUI::Utility;
|
||||||
|
|
@ -64,30 +65,38 @@ sub update {
|
||||||
$self->SUPER::update(+{%$properties, isHidden => 1});
|
$self->SUPER::update(+{%$properties, isHidden => 1});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#------------------------------------------------
|
||||||
sub _escapeXml {
|
sub _escapeXml {
|
||||||
my $text = shift;
|
my $text = shift;
|
||||||
my %entities = ('<' => '<', '>' => '>', '"' => '"', "'" => "'");
|
return $text unless (ref $text eq "");
|
||||||
$text =~ s/([<>\"\'])/$entities{$1}/g;
|
return HTML::Entities::encode_numeric($text)
|
||||||
return $text;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#------------------------------------------------
|
||||||
sub _tlsOfAsset {
|
sub _tlsOfAsset {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $asset = shift;
|
my $asset = shift;
|
||||||
return (_escapeXml($asset->get('title')),
|
#Fix Title
|
||||||
_escapeXml($self->session->url->getSiteURL() . $asset->getUrl),
|
my $title = _escapeXml($asset->get('title'));
|
||||||
_escapeXml($asset->get('synopsis')));
|
#Fix Url
|
||||||
|
my $url = _escapeXml($self->session->url->getSiteURL() . $asset->getUrl);
|
||||||
|
#Fix Description
|
||||||
|
my $description = _escapeXml($asset->get('synopsis'));
|
||||||
|
return ($title,$url,$description);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#------------------------------------------------
|
||||||
sub isValidRssItem { 0 }
|
sub isValidRssItem { 0 }
|
||||||
|
|
||||||
|
#------------------------------------------------
|
||||||
sub displayInFolder2 { 0 }
|
sub displayInFolder2 { 0 }
|
||||||
|
|
||||||
|
#------------------------------------------------
|
||||||
sub www_view {
|
sub www_view {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
return '' unless $self->session->asset->getId eq $self->getId;
|
return '' unless $self->session->asset->getId eq $self->getId;
|
||||||
return '' unless $self->getParent->isa('WebGUI::Asset::RSSCapable');
|
return '' unless $self->getParent->isa('WebGUI::Asset::RSSCapable');
|
||||||
my $parent = $self->getParent;
|
my $parent = $self->getParent;
|
||||||
|
|
||||||
my $template = WebGUI::Asset::Template->new($self->session, $parent->get('rssCapableRssTemplateId'));
|
my $template = WebGUI::Asset::Template->new($self->session, $parent->get('rssCapableRssTemplateId'));
|
||||||
$template->prepare;
|
$template->prepare;
|
||||||
$self->session->http->setMimeType('text/xml');
|
$self->session->http->setMimeType('text/xml');
|
||||||
|
|
@ -101,7 +110,7 @@ sub www_view {
|
||||||
|
|
||||||
my @items = $parent->getRssItems;
|
my @items = $parent->getRssItems;
|
||||||
$var->{'item_loop'} = [];
|
$var->{'item_loop'} = [];
|
||||||
|
my $counter = 0;
|
||||||
foreach my $item (@items) {
|
foreach my $item (@items) {
|
||||||
my $subvar = {};
|
my $subvar = {};
|
||||||
|
|
||||||
|
|
@ -112,16 +121,14 @@ sub www_view {
|
||||||
$subvar->{guid} = $subvar->{link};
|
$subvar->{guid} = $subvar->{link};
|
||||||
$subvar->{pubDate} = _escapeXml($self->session->datetime->epochToMail($item->get('dateUpdated')));
|
$subvar->{pubDate} = _escapeXml($self->session->datetime->epochToMail($item->get('dateUpdated')));
|
||||||
} elsif (ref $item eq 'HASH') {
|
} elsif (ref $item eq 'HASH') {
|
||||||
foreach my $key (keys %$item) {
|
foreach my $key (keys %$item) {
|
||||||
### This does not do any XML escaping. A way must be found to
|
$subvar->{$key} = _escapeXml($item->{$key});
|
||||||
# recursively escape the entire data structure.
|
}
|
||||||
$subvar->{$key} = $item->{$key};
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$self->session->errorHandler->error("Don't know what to do with this RSS item: $item");
|
$self->session->errorHandler->error("Don't know what to do with this RSS item: $item");
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
$counter++;
|
||||||
push @{$var->{'item_loop'}}, $subvar;
|
push @{$var->{'item_loop'}}, $subvar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue