141 lines
7.2 KiB
Perl
141 lines
7.2 KiB
Perl
package WebGUI::Widget::SyndicatedContent;
|
|
|
|
our $namespace = "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 Tie::CPHash;
|
|
use WebGUI::DateTime;
|
|
use WebGUI::International;
|
|
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 WebGUI::International::get(271);
|
|
}
|
|
|
|
#-------------------------------------------------------------------
|
|
sub www_add {
|
|
my ($output, %hash);
|
|
tie %hash, 'Tie::IxHash';
|
|
if (WebGUI::Privilege::canEditPage()) {
|
|
$output = '<a href="'.$session{page}{url}.'?op=viewHelp&hid=1&namespace='.$namespace.'"><img src="'.$session{setting}{lib}.'/help.gif" border="0" align="right"></a>';
|
|
$output .= '<h1>'.WebGUI::International::get(272).'</h1>';
|
|
$output .= '<form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
|
|
$output .= WebGUI::Form::hidden("widget",$namespace);
|
|
$output .= WebGUI::Form::hidden("func","addSave");
|
|
$output .= '<table>';
|
|
$output .= '<tr><td class="formDescription">'.WebGUI::International::get(99).'</td><td>'.WebGUI::Form::text("title",20,128,'Syndicated Content').'</td></tr>';
|
|
$output .= '<tr><td class="formDescription">'.WebGUI::International::get(174).'</td><td>'.WebGUI::Form::checkbox("displayTitle",1).'</td></tr>';
|
|
$output .= '<tr><td class="formDescription">'.WebGUI::International::get(175).'</td><td>'.WebGUI::Form::checkbox("processMacros",1).'</td></tr>';
|
|
%hash = WebGUI::Widget::getPositions();
|
|
$output .= '<tr><td class="formDescription">'.WebGUI::International::get(363).'</td><td>'.WebGUI::Form::selectList("position",\%hash).'</td></tr>';
|
|
$output .= '<tr><td class="formDescription">'.WebGUI::International::get(85).'</td><td>'.WebGUI::Form::textArea("description",'','','',1).'</td></tr>';
|
|
$output .= '<tr><td class="formDescription">'.WebGUI::International::get(273).'</td><td>'.WebGUI::Form::text("rssUrl",20,2048).'</td></tr>';
|
|
$output .= '<tr><td></td><td>'.WebGUI::Form::submit(WebGUI::International::get(62)).'</td></tr>';
|
|
$output .= '</table></form>';
|
|
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 values ($widgetId, ".quote($session{form}{rssUrl}).", 'Not yet fetched.', '".time()."')",$session{dbh});
|
|
return "";
|
|
} else {
|
|
return WebGUI::Privilege::insufficient();
|
|
}
|
|
}
|
|
|
|
#-------------------------------------------------------------------
|
|
sub www_edit {
|
|
my ($output, %data, %hash, @array);
|
|
tie %data, 'Tie::CPHash';
|
|
tie %hash, 'Tie::IxHash';
|
|
if (WebGUI::Privilege::canEditPage()) {
|
|
%data = WebGUI::SQL->quickHash("select * from widget,SyndicatedContent where widget.widgetId=$session{form}{wid}",$session{dbh});
|
|
$output = '<a href="'.$session{page}{url}.'?op=viewHelp&hid=1&namespace='.$namespace.'"><img src="'.$session{setting}{lib}.'/help.gif" border="0" align="right"></a>';
|
|
$output .= '<h1>'.WebGUI::International::get(274).'</h1>';
|
|
$output .= '<form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
|
|
$output .= WebGUI::Form::hidden("wid",$session{form}{wid});
|
|
$output .= WebGUI::Form::hidden("func","editSave");
|
|
$output .= '<table>';
|
|
$output .= '<tr><td class="formDescription">'.WebGUI::International::get(99).'</td><td>'.WebGUI::Form::text("title",20,128,$data{title}).'</td></tr>';
|
|
$output .= '<tr><td class="formDescription">'.WebGUI::International::get(174).'</td><td>'.WebGUI::Form::checkbox("displayTitle","1",$data{displayTitle}).'</td></tr>';
|
|
$output .= '<tr><td class="formDescription">'.WebGUI::International::get(175).'</td><td>'.WebGUI::Form::checkbox("processMacros","1",$data{processMacros}).'</td></tr>';
|
|
%hash = WebGUI::Widget::getPositions();
|
|
$array[0] = $data{position};
|
|
$output .= '<tr><td class="formDescription">'.WebGUI::International::get(363).'</td><td>'.WebGUI::Form::selectList("position",\%hash,\@array).'</td></tr>';
|
|
$output .= '<tr><td class="formDescription">'.WebGUI::International::get(85).'</td><td>'.WebGUI::Form::textArea("description",$data{description},50,10,1).'</td></tr>';
|
|
$output .= '<tr><td class="formDescription">'.WebGUI::International::get(273).'</td><td>'.WebGUI::Form::text("rssUrl",20,2048,$data{rssUrl}).'</td></tr>';
|
|
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
|
|
$output .= '<tr><td><br></td></tr>';
|
|
$output .= '<tr><td class="formDescription">'.WebGUI::International::get(275).'</td><td>'.WebGUI::DateTime::epochToHuman($data{lastFetched},"%m/%d/%y %h:%n%p").'</td></tr>';
|
|
$output .= '<tr><td class="formDescription">'.WebGUI::International::get(276).'</td><td>'.$data{content}.'</td></tr>';
|
|
$output .= '</table></form>';
|
|
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);
|
|
tie %data, 'Tie::CPHash';
|
|
$widgetId = shift;
|
|
%data = WebGUI::SQL->quickHash("select * from widget,SyndicatedContent where widget.widgetId=SyndicatedContent.widgetId and widget.widgetId=$widgetId",$session{dbh});
|
|
if (defined %data) {
|
|
if ($data{displayTitle} == 1) {
|
|
$output = "<h1>".$data{title}."</h1>";
|
|
}
|
|
if ($data{description} ne "") {
|
|
$output .= $data{description}.'<p>';
|
|
}
|
|
$output .= $data{content};
|
|
}
|
|
if ($data{processMacros}) {
|
|
$output = WebGUI::Macro::process($output);
|
|
}
|
|
return $output;
|
|
}
|
|
|
|
|
|
1;
|