package WebGUI::Widget::LinkList;
our $namespace = "LinkList";
#-------------------------------------------------------------------
# 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::International;
use WebGUI::Macro;
use WebGUI::Privilege;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::Utility;
use WebGUI::Widget;
#-------------------------------------------------------------------
sub _reorderLinks {
my ($sth, $i, $lid);
$sth = WebGUI::SQL->read("select linkId from LinkList_link where widgetId=$_[0] order by sequenceNumber",$session{dbh});
while (($lid) = $sth->array) {
WebGUI::SQL->write("update LinkList_link set sequenceNumber='$i' where linkId=$lid",$session{dbh});
$i++;
}
$sth->finish;
}
#-------------------------------------------------------------------
sub purge {
WebGUI::SQL->write("delete from LinkList where widgetId=$_[0]",$_[1]);
WebGUI::SQL->write("delete from LinkList_link where widgetId=$_[0]",$_[1]);
purgeWidget($_[0],$_[1]);
}
#-------------------------------------------------------------------
sub widgetName {
return WebGUI::International::get(214);
}
#-------------------------------------------------------------------
sub www_add {
my ($output, %hash);
tie %hash, 'Tie::IxHash';
if (WebGUI::Privilege::canEditPage()) {
$output = '
';
$output .= '
'; $output .= '
'; return $output; } else { return WebGUI::Privilege::insufficient(); } } #------------------------------------------------------------------- sub www_deleteLinkConfirm { my ($output); if (WebGUI::Privilege::canEditPage()) { WebGUI::SQL->write("delete from LinkList_link where linkId=$session{form}{lid}",$session{dbh}); _reorderLinks($session{form}{wid}); return www_edit(); } else { return WebGUI::Privilege::insufficient(); } } #------------------------------------------------------------------- sub www_edit { my ($output, %hash, @array, %data, @link, $sth); tie %data, 'Tie::CPHash'; tie %hash, 'Tie::IxHash'; if (WebGUI::Privilege::canEditPage()) { %data = WebGUI::SQL->quickHash("select * from widget,LinkList where widget.widgetId=$session{form}{wid} and widget.widgetId=LinkList.widgetId",$session{dbh}); $output = '
';
$output .= ''.WebGUI::International::get(221).'
'; $output .= '
';
}
for ($i=0;$i<$data{indent};$i++) {
$indent .= " ";
}
for ($i=0;$i<$data{lineSpacing};$i++) {
$lineSpacing .= "
";
}
$sth = WebGUI::SQL->read("select name, url, description, newWindow from LinkList_link where widgetId='$widgetId' order by sequenceNumber",$session{dbh});
while (@link = $sth->array) {
$output .= $indent.$data{bullet}.'';
if ($link[2] ne "") {
$output .= ' - '.$link[2];
}
$output .= $lineSpacing;
}
$sth->finish;
if ($data{processMacros}) {
$output = WebGUI::Macro::process($output);
}
}
return $output;
}
1;