WebGUI 2.6.0 release

This commit is contained in:
JT Smith 2001-12-17 00:03:00 +00:00
parent 00aec56a04
commit c0463670e8
12 changed files with 800 additions and 83 deletions

View file

@ -41,7 +41,7 @@ sub process {
foreach $file (@files) {
if ($file ne "." && $file ne ".." && $file =~ /\.pm/) {
$file =~ s/\.pm//;
$cmd = "require WebGUI::Macro::".$file;
$cmd = "use WebGUI::Macro::".$file;
eval($cmd);
$cmd = "WebGUI::Macro::".$file."::process";
$output = &$cmd($output);

View file

@ -0,0 +1,64 @@
package WebGUI::Macro::FlexMenu;
#-------------------------------------------------------------------
# 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;
#-------------------------------------------------------------------
sub _replacement {
my ($temp, @param);
@param = WebGUI::Macro::getParams($_[0]);
$temp = '<span class="verticalMenu">';
$temp .= _reversePageTree($session{page}{pageId});
$temp .= '</span>';
return $temp;
}
#-------------------------------------------------------------------
sub _reversePageTree {
my ($sth, @data, $output, $parentId);
($parentId) = WebGUI::SQL->quickArray("select parentId from page where pageId='$_[0]'",$session{dbh});
$sth = WebGUI::SQL->read("select pageId,parentId,title,urlizedTitle from page where parentId=$_[0] order by sequenceNumber",$session{dbh});
while (@data = $sth->array) {
if (WebGUI::Privilege::canViewPage($data[0])) {
if ($_[1] == $data[0]) {
$output .= '<span class="selectedMenuItem">';
}
$output .= '<a class="verticalMenu" href="'.$session{env}{SCRIPT_NAME}.'/'.$data[3].'">'.$data[2].'</a><br>';
if ($_[1] == $data[0]) {
$output .= '</span>';
}
if ($_[1] == $data[0] && $_[2] ne "") {
$output .= '<table cellpadding=0 cellspacing=0 border=0 class="verticalMenu"><tr><td>&nbsp;&nbsp;&nbsp;</td><td>'.$_[2].'</td></tr></table>';
}
}
}
$sth->finish;
if ($parentId > 0) {
$output = _reversePageTree($parentId,$_[0],$output);
}
return $output;
}
#-------------------------------------------------------------------
sub process {
my ($output,$temp);
$output = $_[0];
#$output =~ s/\^FlexMenu\((.*?)\)\;/_replacement($1)/ge;
$output =~ s/\^FlexMenu\;/_replacement()/ge;
return $output;
}
1;

View file

@ -65,14 +65,14 @@ sub www_search {
$row[$i] = '<li><a href="'.$session{ENV}{SCRIPT_NAME}.'/'.$page{urlizedTitle}.'">'.$page{title}.'</a>';
$i++;
}
if ($row[0] ne "") {
($dataRows, $prevNextBar) = paginate(20,$session{page}{url}.'?op=search',\@row);
$output .= WebGUI::International::get(365).'<p><ul>';
$output .= $dataRows;
$output .= '</ul>'.$prevNextBar;
} else {
$output .= WebGUI::International::get(366);
}
}
if ($row[0] ne "") {
($dataRows, $prevNextBar) = paginate(20,$session{page}{url}.'?op=search',\@row);
$output .= WebGUI::International::get(365).'<p><ol>';
$output .= $dataRows;
$output .= '</ol>'.$prevNextBar;
} else {
$output .= WebGUI::International::get(366);
}
}
return $output;

View file

@ -15,6 +15,33 @@ use Tie::IxHash;
use WebGUI::ErrorHandler;
use WebGUI::Session;
#-------------------------------------------------------------------
sub loadTemplates {
my ($templateDir, @files, $file, $use, @template, $i);
if ($^O =~ /Win/i) {
$templateDir = "\\lib\\WebGUI\\Template";
} else {
$templateDir = "/lib/WebGUI/Template";
}
opendir (DIR,$session{config}{webguiRoot}.$templateDir) or WebGUI::ErrorHandler::fatalError("Can't open template directory!");
@files = readdir(DIR);
foreach $file (@files) {
if ($file ne "." && $file ne ".." && $file =~ /\.pm/) {
$file =~ s/\.pm//;
$template[$i] = $file;
$use = "require WebGUI::Template::".$template[$i];
eval($use);
if ($@) {
WebGUI::ErrorHandler::fatalError("Template load failed: ".$@);
}
$i++;
}
}
closedir(DIR);
return @template;
}
#-------------------------------------------------------------------
sub calculatePositions {
my (%positions, $string);
@ -29,34 +56,22 @@ sub calculatePositions {
#-------------------------------------------------------------------
sub getList {
my (@files, $file, $namespace, $cmd, %list, $templateDir);
if ($^O =~ /Win/i) {
$templateDir = "\\lib\\WebGUI\\Template";
} else {
$templateDir = "/lib/WebGUI/Template";
}
opendir (DIR,$session{config}{webguiRoot}.$templateDir) or WebGUI::ErrorHandler::fatalError("Can't open template directory!");
@files = readdir(DIR);
foreach $file (@files) {
if ($file ne "." && $file ne ".." && $file =~ /\.pm/) {
$file =~ s/\.pm//;
$cmd = "require WebGUI::Template::".$file;
eval($cmd);
$cmd = "WebGUI::Template::".$file."::namespace";
$namespace = $$cmd;
$cmd = "WebGUI::Template::".$file."::name";
$list{$namespace} = &$cmd();
}
my (@templates, $cmd, $template, $namespace, %list);
@templates = loadTemplates();
foreach $template (@templates) {
#$cmd = "WebGUI::Template::".$template."::namespace";
#$namespace = $$cmd;
$cmd = "WebGUI::Template::".$template."::name";
$list{$template} = &$cmd();
}
closedir(DIR);
return %list;
return %list;
}
#-------------------------------------------------------------------
sub getPositions {
my ($cmd, %hash);
tie %hash, "Tie::IxHash";
$cmd = "require WebGUI::Template::".$_[0];
$cmd = "use WebGUI::Template::".$_[0];
eval($cmd);
$cmd = "WebGUI::Template::".$_[0]."::getPositions";
%hash = &$cmd;

162
lib/WebGUI/Widget/Item.pm Normal file
View file

@ -0,0 +1,162 @@
package WebGUI::Widget::Item;
our $namespace = "Item";
#-------------------------------------------------------------------
# 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::Form;
use WebGUI::International;
use WebGUI::Privilege;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::Utility;
use WebGUI::Widget;
#-------------------------------------------------------------------
sub purge {
WebGUI::SQL->write("delete from Item where widgetId=$_[0]",$_[1]);
purgeWidget($_[0],$_[1]);
}
#-------------------------------------------------------------------
sub widgetName {
return "Item";
}
#-------------------------------------------------------------------
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>Add '.widgetName().'</h1>';
$output .= '<form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
$output .= WebGUI::Form::hidden("widget","Item");
$output .= WebGUI::Form::hidden("func","addSave");
$output .= '<table>';
$output .= '<tr><td class="formDescription">'.WebGUI::International::get(99).'</td><td>'.WebGUI::Form::text("title",20,30,widgetName()).'</td></tr>';
$output .= '<tr><td class="formDescription">'.WebGUI::International::get(175).'</td><td>'.WebGUI::Form::checkbox("processMacros",1,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",'').'</td></tr>';
$output .= '<tr><td class="formDescription">'.WebGUI::International::get(1,$namespace).'</td><td>'.WebGUI::Form::text("linkURL",20,2048).'</td></tr>';
$output .= '<tr><td class="formDescription">'.WebGUI::International::get(2,$namespace).'</td><td>'.WebGUI::Form::file("attachment").'</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, $attachment);
if (WebGUI::Privilege::canEditPage()) {
$widgetId = create();
$attachment = saveAttachment("attachment",$widgetId);
WebGUI::SQL->write("insert into Item values ($widgetId, ".quote($session{form}{description}).", ".quote($session{form}{linkURL}).", ".quote($attachment).")",$session{dbh});
return "";
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_deleteAttachment {
if (WebGUI::Privilege::canEditPage()) {
WebGUI::SQL->write("update Item set attachment='' where widgetId=$session{form}{wid}",$session{dbh});
return www_edit();
} 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,Item where widget.widgetId=Item.widgetId and widget.widgetId=$session{form}{wid}",$session{dbh});
$output .= '<h1>Edit '.widgetName().'</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,30,$data{title}).'</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}).'</td></tr>';
$output .= '<tr><td class="formDescription">'.WebGUI::International::get(1,$namespace).'</td><td>'.WebGUI::Form::text("linkURL",20,2048,$data{linkURL}).'</td></tr>';
if ($data{attachment} ne "") {
$output .= '<tr><td class="formDescription">'.WebGUI::International::get(2,$namespace).'</td><td><a href="'.$session{page}{url}.'?func=deleteAttachment&wid='.$session{form}{wid}.'">'.WebGUI::International::get(3,$namespace).'</a></td></tr>';
} else {
$output .= '<tr><td class="formDescription">'.WebGUI::International::get(2,$namespace).'</td><td>'.WebGUI::Form::file("attachment").'</td></tr>';
}
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
$output .= '</table></form>';
return $output;
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_editSave {
my ($attachment);
if (WebGUI::Privilege::canEditPage()) {
update();
$attachment = saveAttachment("attachment",$session{form}{wid});
if ($attachment ne "") {
$attachment = ', attachment='.quote($attachment);
}
WebGUI::SQL->write("update Item set description=".quote($session{form}{description}).", linkURL=".quote($session{form}{linkURL}).$attachment." where widgetId=$session{form}{wid}",$session{dbh});
return "";
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_view {
my (%data, @test, $output, $widgetId);
tie %data, 'Tie::CPHash';
$widgetId = shift;
%data = WebGUI::SQL->quickHash("select * from widget,Item where widget.widgetId='$widgetId' and widget.WidgetId=Item.widgetId",$session{dbh});
if (defined %data) {
if ($data{linkURL} ne "") {
$output .= '<a href="'.$data{linkURL}.'"><span class="itemTitle">'.$data{title}.'</span></a>';
} else {
$output .= '<span class="itemTitle">'.$data{title}.'</span>';
}
if ($data{attachment} ne "") {
$output .= ' - <a href="'.$session{setting}{attachmentDirectoryWeb}.'/'.$widgetId.'/'.$data{attachment}.'"><img src="'.$session{setting}{lib}.'/smallAttachment.gif" border=0 alt="Download Attachment"></a>';
}
if ($data{description} ne "") {
$output .= ' - '.$data{description};
}
}
return $output;
}
1;

View file

@ -291,11 +291,11 @@ sub www_view {
}
$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}.'<b><a href="'.$link[1].'"';
$output .= $indent.$data{bullet}.'<a href="'.$link[1].'"';
if ($link[3]) {
$output .= ' target="_blank"';
}
$output .= '>'.$link[0].'</a></b>';
$output .= '><span class="linkTitle">'.$link[0].'</span></a>';
if ($link[2] ne "") {
$output .= ' - '.$link[2];
}