From c197ded0a9c9c87bd7330f68eab139d8c8e3fade Mon Sep 17 00:00:00 2001 From: Roy Johnson Date: Thu, 2 Nov 2006 20:17:47 +0000 Subject: [PATCH] Added feature to the Syndicated Content Wobject that allows the use of macros in the RSS URL property --- docs/changelog/7.x.x.txt | 2 ++ docs/upgrades/upgrade_7.1.4-7.2.0.pl | 8 ++++++ lib/WebGUI/Asset/Wobject/SyndicatedContent.pm | 26 +++++++++++++++++-- .../i18n/English/Asset_SyndicatedContent.pm | 8 ++++++ 4 files changed, 42 insertions(+), 2 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 71031338d..285a56266 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -15,6 +15,8 @@ - Test: Added t/lib/WebGUI/PseudoRequest, which is a mostly functional Apache::Request object replacement. It doesn't do everything, but it does enough to test Session/Http.pm, except for cookies. + - Added an option to the Syndicated Content Wobject that allows use of macros + inside the RSS Url property. 7.1.4 - Template variables in the main Survey Template were out of date in the diff --git a/docs/upgrades/upgrade_7.1.4-7.2.0.pl b/docs/upgrades/upgrade_7.1.4-7.2.0.pl index f2aecab36..9970942f8 100644 --- a/docs/upgrades/upgrade_7.1.4-7.2.0.pl +++ b/docs/upgrades/upgrade_7.1.4-7.2.0.pl @@ -22,9 +22,17 @@ my $session = start(); # this line required commerceSalesTax($session); createDictionaryStorage($session); +addRssUrlMacroProcessing($session); finish($session); # this line required +#-------------------------------------------------- +sub addRssUrlMacroProcessing { + my $session = shift; + print "\tAdding option to process macros in a Syndicated Content RSS Url.\n" unless ($quiet); + $session->db->write("alter table SyndicatedContent add column processMacroInRssUrl int(11) default 0"); + +} ##------------------------------------------------- sub commerceSalesTax { diff --git a/lib/WebGUI/Asset/Wobject/SyndicatedContent.pm b/lib/WebGUI/Asset/Wobject/SyndicatedContent.pm index 5dd1fb185..ceb2cd38f 100644 --- a/lib/WebGUI/Asset/Wobject/SyndicatedContent.pm +++ b/lib/WebGUI/Asset/Wobject/SyndicatedContent.pm @@ -20,6 +20,7 @@ use WebGUI::HTMLForm; use WebGUI::HTML; use WebGUI::International; use WebGUI::Asset::Wobject; +use WebGUI::Macro; use XML::RSSLite; use XML::RSS::Creator; use LWP::UserAgent; @@ -89,7 +90,7 @@ sub _getMaxHeadlines { #------------------------------------------------------------------- sub _getValidatedUrls { my $self = shift; - my @urls = split(/\s+/,$self->get('rssUrl')); + my @urls = split(/\s+/,$self->getRssUrl); my @validatedUrls = (); foreach my $url (@urls) { push(@validatedUrls, $url) if ($url =~ m/^http/); @@ -140,6 +141,13 @@ sub definition { label=>$i18n->get(1), hoverHelp=>$i18n->get('1 description') }, + processMacroInRssUrl=>{ + tab=>"properties", + defaultValue=>0, + fieldType=>'yesNo', + label=>$i18n->get('process macros in rss url'), + hoverHelp=>$i18n->get('process macros in rss url description'), + }, maxHeadlines=>{ tab=>"properties", fieldType=>'integer', @@ -504,7 +512,7 @@ sub _get_items { # - aggregate: $items # - aggregate2 (2006-08-26): [$items, \@rss_feeds] - my $key=join(':',('aggregate2', $displayMode,$hasTermsRegex,$maxHeadlines,$self->get('rssUrl'))); + my $key=join(':',('aggregate2', $displayMode,$hasTermsRegex,$maxHeadlines,$self->getRssUrl)); my $cache = WebGUI::Cache->new($self->session,$key, 'RSS'); my $cached = Storable::thaw($cache->get()); @@ -649,6 +657,20 @@ sub view { } +#------------------------------------------------------------------- +=head2 getRssUrl + +Get the RSS URL and process macros if we're supposed to. + +=cut + +sub getRssUrl { + my $self = shift; + my $value = $self->get("rssUrl"); + WebGUI::Macro::process($self->session,\$value) if $self->get("processMacroInRssUrl"); + return $value; +} + #------------------------------------------------------------------- =head2 getContentLastModified ( ) diff --git a/lib/WebGUI/i18n/English/Asset_SyndicatedContent.pm b/lib/WebGUI/i18n/English/Asset_SyndicatedContent.pm index 5a52c9805..6abac1ecd 100644 --- a/lib/WebGUI/i18n/English/Asset_SyndicatedContent.pm +++ b/lib/WebGUI/i18n/English/Asset_SyndicatedContent.pm @@ -1,6 +1,14 @@ package WebGUI::i18n::English::Asset_SyndicatedContent; our $I18N = { + 'process macros in rss url' => { + message => q|Process Macros in RSS URLs|, + lastUpdated => 0 + }, + 'process macros in rss url description' => { + message => q|Setting this to yes will allow you to use macros in your urls|, + lastUpdated => 0 + }, 'cache timeout' => { message => q|Cache Timeout|, lastUpdated => 0