diff --git a/docs/upgrades/upgrade_3.7.0-3.8.0.sql b/docs/upgrades/upgrade_3.7.0-3.8.0.sql index e4a01d0ca..f21d72ee5 100644 --- a/docs/upgrades/upgrade_3.7.0-3.8.0.sql +++ b/docs/upgrades/upgrade_3.7.0-3.8.0.sql @@ -85,6 +85,12 @@ delete from international where internationalId=5 and namespace='Article'; update international set message='(Select \"Yes\" only if you aren\'t adding <br> manually.)' where internationalId='11' and namespace='Article' and language='English'; +insert into wobject (wobjectId, pageId, title, displayTitle, processMacros, description, dateAdded, addedBy, namespace, lastEdited, editedBy, templatePosition, sequenceNumber, startDate, endDate) select widgetId, pageId, title, displayTitle, processMacros, description, dateAdded, addedBy, namespace, lastEdited, editedBy, templatePosition, sequenceNumber, dateAdded, 1336444487 from widget where namespace='SyndicatedContent'; +delete from widget where namespace='SyndicatedContent'; +alter table SyndicatedContent change widgetId wobjectId int not null; + + + update international set message='Select \"Yes\" to change all the pages under this page to this style.' where internationalId='106' and namespace='WebGUI' and language='English'; update international set message='Select \"Yes\" to change the privileges of all pages under this page to these privileges.' where internationalId='116' and namespace='WebGUI' and language='English'; INSERT INTO international VALUES (500,'WebGUI','English','Page ID'); diff --git a/lib/WebGUI/Widget/SyndicatedContent.pm b/lib/WebGUI/Wobject/SyndicatedContent.pm similarity index 57% rename from lib/WebGUI/Widget/SyndicatedContent.pm rename to lib/WebGUI/Wobject/SyndicatedContent.pm index 3e992b398..1cb4f3936 100644 --- a/lib/WebGUI/Widget/SyndicatedContent.pm +++ b/lib/WebGUI/Wobject/SyndicatedContent.pm @@ -1,6 +1,4 @@ -package WebGUI::Widget::SyndicatedContent; - -our $namespace = "SyndicatedContent"; +package WebGUI::Wobject::SyndicatedContent; #------------------------------------------------------------------- # WebGUI is Copyright 2001-2002 Plain Black Software. @@ -15,32 +13,43 @@ our $namespace = "SyndicatedContent"; use strict; use Tie::CPHash; use WebGUI::DateTime; +use WebGUI::HTMLForm; +use WebGUI::Icon; use WebGUI::International; use WebGUI::Macro; use WebGUI::Privilege; use WebGUI::Session; -use WebGUI::Shortcut; use WebGUI::SQL; -use WebGUI::Widget; +use WebGUI::Wobject; + +our @ISA = qw(WebGUI::Wobject); +our $namespace = "SyndicatedContent"; +our $name = WebGUI::International::get(2,$namespace); #------------------------------------------------------------------- sub duplicate { - my (%data, $newWidgetId, $pageId); - tie %data, 'Tie::CPHash'; - %data = getProperties($namespace,$_[0]); - $pageId = $_[1] || $data{pageId}; - $newWidgetId = create($pageId,$namespace,$data{title},$data{displayTitle},$data{description},$data{processMacros},$data{templatePosition}); - WebGUI::SQL->write("insert into SyndicatedContent values ($newWidgetId, ".quote($data{rssUrl}).", ".quote($data{content}).", ".quote($data{lastFetched}).")"); + my ($w); + $w = $_[0]->SUPER::duplicate($_[1]); + $w = WebGUI::Wobject::Article->new({wobjectId=>$w,namespace=>$namespace}); + $w->set({ + rssUrl=>$_[0]->get("rssUrl"), + rssUrl=>$_[0]->get("content"), + rssUrl=>$_[0]->get("lastFetched") + }); } #------------------------------------------------------------------- -sub purge { - purgeWidget($_[0],$_[1],$namespace); +sub new { + my ($self, $class, $property); + $class = shift; + $property = shift; + $self = WebGUI::Wobject->new($property); + bless $self, $class; } #------------------------------------------------------------------- -sub widgetName { - return WebGUI::International::get(2,$namespace); +sub set { + $_[0]->SUPER::set($_[1], [qw(rssUrl content lastFetched)]); } #------------------------------------------------------------------- @@ -85,7 +94,7 @@ sub www_addSave { #------------------------------------------------------------------- sub www_copy { if (WebGUI::Privilege::canEditPage()) { - duplicate($session{form}{wid}); + $_[0]->duplicate; return ""; } else { return WebGUI::Privilege::insufficient(); @@ -94,30 +103,20 @@ sub www_copy { #------------------------------------------------------------------- sub www_edit { - my ($output, %data, %hash, @array); - tie %data, 'Tie::CPHash'; - tie %hash, 'Tie::IxHash'; + my ($output, $f); if (WebGUI::Privilege::canEditPage()) { - %data = getProperties($namespace,$session{form}{wid}); - $output = helpLink(1,$namespace); + $output = helpIcon(1,$namespace); $output .= '

'.WebGUI::International::get(4,$namespace).'

'; - $output .= formHeader(); - $output .= WebGUI::Form::hidden("wid",$session{form}{wid}); - $output .= WebGUI::Form::hidden("func","editSave"); - $output .= ''; - $output .= tableFormRow(WebGUI::International::get(99),WebGUI::Form::text("title",20,128,$data{title})); - $output .= tableFormRow(WebGUI::International::get(174),WebGUI::Form::checkbox("displayTitle","1",$data{displayTitle})); - $output .= tableFormRow(WebGUI::International::get(175),WebGUI::Form::checkbox("processMacros","1",$data{processMacros})); - %hash = WebGUI::Widget::getPositions(); - $array[0] = $data{templatePosition}; - $output .= tableFormRow(WebGUI::International::get(363),WebGUI::Form::selectList("templatePosition",\%hash,\@array)); - $output .= tableFormRow(WebGUI::International::get(85),WebGUI::Form::textArea("description",$data{description},50,10,1)); - $output .= tableFormRow(WebGUI::International::get(1,$namespace),WebGUI::Form::text("rssUrl",20,2048,$data{rssUrl})); - $output .= formSave(); - $output .= ''; - $output .= tableFormRow(WebGUI::International::get(5,$namespace),WebGUI::DateTime::epochToHuman($data{lastFetched},"%m/%d/%y %h:%n%p")); - $output .= tableFormRow(WebGUI::International::get(6,$namespace),$data{content}); - $output .= '

'; + $f = WebGUI::HTMLForm->new; + $f->url("rssUrl",WebGUI::International::get(1,$namespace),$_[0]->get("rssUrl")); + if ($_[0]->get("wobjectId") ne "new") { + $f->readOnly(WebGUI::DateTime::epochToHuman($_[0]->get("lastFetched"),"%z %Z"),WebGUI::International::get(5,$namespace)); + $f->readOnly($_[0]->get("content"),WebGUI::International::get(6,$namespace)); + } else { + $f->hidden("content","Not yet fetched!"); + $f->hidden("lastFetched",time()); + } + $output .= $_[0]->SUPER::www_edit($f->printRowsOnly); return $output; } else { return WebGUI::Privilege::insufficient(); @@ -126,9 +125,13 @@ sub www_edit { #------------------------------------------------------------------- sub www_editSave { + my ($property); if (WebGUI::Privilege::canEditPage()) { - update(); - WebGUI::SQL->write("update SyndicatedContent set rssUrl=".quote($session{form}{rssUrl})." where widgetId=$session{form}{wid}"); + $_[0]->SUPER::www_editSave(); + $property->{rssUrl} = $session{form}{rssUrl}; + $property->{content} = $session{form}{content} if ($session{form}{content} ne ""); + $property->{lastFetched} = $session{form}{lastFetched} if ($session{form}{lastFetched} ne ""); + $_[0]->set($property); return ""; } else { return WebGUI::Privilege::insufficient(); @@ -137,23 +140,14 @@ sub www_editSave { #------------------------------------------------------------------- sub www_view { - my (%data, $output); - tie %data, 'Tie::CPHash'; - %data = getProperties($namespace,$_[0]); - if (defined %data) { - if ($data{displayTitle} == 1) { - $output = "

".$data{title}."

"; - } - if ($data{description} ne "") { - $output .= $data{description}.'

'; - } - $output .= $data{content}; - } - if ($data{processMacros}) { - $output = WebGUI::Macro::process($output); - } + my ($output); + $output = $_[0]->displayTitle; + $output .= $_[0]->description; + $output = $_[0]->processMacros($output); + $output .= $_[0]->get("content"); return $output; } 1; + diff --git a/runHourly.pl b/runHourly.pl index a6a1b6c87..2fc884a5b 100644 --- a/runHourly.pl +++ b/runHourly.pl @@ -68,16 +68,16 @@ sub generateHTML { #------------------------------------------------------------------- sub updateSyndicatedContent { my ($sth, @data, %rss, $html); - $sth = WebGUI::SQL->read("select widget.widgetId, SyndicatedContent.rssURL, SyndicatedContent.content from widget,SyndicatedContent where widget.WidgetId=SyndicatedContent.widgetId and widget.pageId<>3",$dbh); + $sth = WebGUI::SQL->read("select wobject.wobjectId, SyndicatedContent.rssURL, SyndicatedContent.content from wobject,SyndicatedContent where wobject.wobjectId=SyndicatedContent.wobjectId and wobject.pageId<>3",$dbh); while (@data = $sth->array) { %rss = getRSS($data[1]); $html = generateHTML(%rss); if ($html ne "") { - WebGUI::SQL->write("update SyndicatedContent set content=".$dbh->quote($html).", lastFetched=".time()." where widgetId=$data[0]",$dbh); + WebGUI::SQL->write("update SyndicatedContent set content=".$dbh->quote($html).", lastFetched=".time()." where wobjectId=$data[0]",$dbh); } elsif (substr($data[2],6) ne "Unable" && substr($data[2],7) ne "Not yet") { # then just leave the existing content in place } else { - WebGUI::SQL->write("update SyndicatedContent set content='Unable to fetch content. Perhaps the RSS is improperly formated.', lastFetched=".time()." where widgetId=$data[0]",$dbh); + WebGUI::SQL->write("update SyndicatedContent set content='Unable to fetch content. Perhaps the RSS is improperly formated.', lastFetched=".time()." where wobjectId=$data[0]",$dbh); } } $sth->finish;