package WebGUI::Widget::SyndicatedContent; #------------------------------------------------------------------- # WebGUI is Copyright 2001 Plain Black Software. #------------------------------------------------------------------- # Please read the legal notices (docs/legal.txt) and the license # (docs/license.txt) that came with this distribution before using # this software. #------------------------------------------------------------------- # http://www.plainblack.com info@plainblack.com #------------------------------------------------------------------- use strict; use WebGUI::Macro; use WebGUI::Privilege; use WebGUI::Session; use WebGUI::SQL; use WebGUI::Utility; use WebGUI::Widget; #------------------------------------------------------------------- sub purge { WebGUI::SQL->write("delete from SyndicatedContent where widgetId=$_[0]",$_[1]); purgeWidget($_[0],$_[1]); } #------------------------------------------------------------------- sub widgetName { return "Syndicated Content"; } #------------------------------------------------------------------- sub www_add { my ($output); if (WebGUI::Privilege::canEditPage()) { $output = '

Add Syndicated Content

'; $output .= WebGUI::Form::hidden("widget","SyndicatedContent"); $output .= WebGUI::Form::hidden("func","addSave"); $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= '
Title'.WebGUI::Form::text("title",20,30,'Syndicated Content').'
Display the title?'.WebGUI::Form::checkbox("displayTitle",1,1).'
Description'.WebGUI::Form::textArea("description",'','','',1).'
URL to RSS File'.WebGUI::Form::text("rssUrl",20,2048).'
'.WebGUI::Form::submit("save").'
'; return $output; } else { return WebGUI::Privilege::insufficient(); } return $output; } #------------------------------------------------------------------- sub www_addSave { my ($widgetId); if (WebGUI::Privilege::canEditPage()) { $widgetId = create(); WebGUI::SQL->write("insert into SyndicatedContent set widgetId=$widgetId, rssUrl=".quote($session{form}{rssUrl}).", content='Not yet fetched.'",$session{dbh}); return ""; } else { return WebGUI::Privilege::insufficient(); } } #------------------------------------------------------------------- sub www_edit { my ($output, %data); if (WebGUI::Privilege::canEditPage()) { %data = WebGUI::SQL->quickHash("select * from widget,SyndicatedContent where widget.widgetId=$session{form}{wid}",$session{dbh}); $output = '

Edit Syndicated Content

'; $output .= WebGUI::Form::hidden("wid",$session{form}{wid}); $output .= WebGUI::Form::hidden("func","editSave"); $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= '
Title'.WebGUI::Form::text("title",20,30,$data{title}).'
Display the title?'.WebGUI::Form::checkbox("displayTitle","1",$data{displayTitle}).'
Description'.WebGUI::Form::textArea("description",$data{description},50,10,1).'
URL to RSS File'.WebGUI::Form::text("rssUrl",20,2048,$data{rssUrl}).'
'.WebGUI::Form::submit("save").'

Last Fetched'.$data{lastFetched}.'
Current Content'.$data{content}.'
'; return $output; } else { return WebGUI::Privilege::insufficient(); } } #------------------------------------------------------------------- sub www_editSave { if (WebGUI::Privilege::canEditPage()) { update(); WebGUI::SQL->write("update SyndicatedContent set rssUrl=".quote($session{form}{rssUrl})." where widgetId=$session{form}{wid}",$session{dbh}); return ""; } else { return WebGUI::Privilege::insufficient(); } } #------------------------------------------------------------------- sub www_view { my (%data, $output, $widgetId); $widgetId = shift; %data = WebGUI::SQL->quickHash("select * from widget,SyndicatedContent where widget.widgetId=$widgetId",$session{dbh}); if (defined %data) { if ($data{displayTitle} == 1) { $output = "

".$data{title}."

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

'; } $output .= $data{content}; } return $output; } 1;