various patches added

This commit is contained in:
JT Smith 2004-07-12 04:45:38 +00:00
parent 2e791c9dd5
commit c0bf7e46f0
16 changed files with 136 additions and 108 deletions

View file

@ -16,6 +16,7 @@ package WebGUI::Form;
use strict;
use HTTP::BrowserDetect;
use Tie::IxHash;
use WebGUI::DateTime;
use WebGUI::International;
use WebGUI::Session;
@ -1314,6 +1315,10 @@ If you want to add anything special to this form element like javascript actions
'onChange="this.form.submit()"'
=item sortByValue
A boolean value for whether or not the values in the options hash should be sorted.
=back
=cut
@ -1322,20 +1327,30 @@ sub selectList {
my ($output, $key, $item, $size, $multiple);
$size = $_[0]->{size} || 1;
$multiple = ' multiple="1"' if ($_[0]->{multiple});
$output = '<select name="'.$_[0]->{name}.'" size="'.$size.'" '.$_[0]->{extras}.$multiple.'>';
foreach $key (keys %{$_[0]->{options}}) {
$output .= '<option value="'.$key.'"';
foreach $item (@{$_[0]->{value}}) {
if ($item eq $key) {
$output .= ' selected="1"';
}
}
$output .= '>'.${$_[0]->{options}}{$key}.'</option>';
$output = '<select name="'.$_[0]->{name}.'" size="'.$size.'" '.$_[0]->{extras}.$multiple.'>';
my %options;
if ($_[0]->{sortByValue}) {
tie %options, 'Tie::IxHash';
foreach my $optionKey (sort {"\L${$_[0]->{options}}{$a}" cmp "\L${$_[0]->{options}}{$b}" } keys %{$_[0]->{options}}) {
$options{$optionKey} = ${$_[0]->{options}}{$optionKey};
}
} else {
%options = %{$_[0]->{options}};
}
foreach $key (keys %options) {
$output .= '<option value="'.$key.'"';
foreach $item (@{$_[0]->{value}}) {
if ($item eq $key) {
$output .= ' selected="1"';
}
}
$output .= '>'.${$_[0]->{options}}{$key}.'</option>';
}
$output .= '</select>';
return $output;
}
#-------------------------------------------------------------------
=head2 submit ( hashRef )

View file

@ -1834,6 +1834,10 @@ Extra text to describe this form element or to provide special instructions.
The UI level for this field. See the WebGUI developer's site for details. Defaults to "0".
=item sortByValue
A boolean value for whether the values in the options hash should be sorted.
=back
=cut
@ -1841,8 +1845,8 @@ The UI level for this field. See the WebGUI developer's site for details. Defaul
sub selectList {
my ($output);
my ($self, @p) = @_;
my ($name, $options, $label, $value, $size, $multiple, $extras, $subtext, $uiLevel) =
rearrange([qw(name options label value size multiple extras subtext uiLevel)], @p);
my ($name, $options, $label, $value, $size, $multiple, $extras, $subtext, $uiLevel, $sortByValue) =
rearrange([qw(name options label value size multiple extras subtext uiLevel sortByValue)], @p);
if (_uiLevelChecksOut($uiLevel)) {
$output = WebGUI::Form::selectList({
"name"=>$name,
@ -1850,7 +1854,8 @@ sub selectList {
"value"=>$value,
"multiple"=>$multiple,
"size"=>$size,
"extras"=>$extras
"extras"=>$extras,
"sortByValue"=>$sortByValue
});
$output .= _subtext($subtext);
$output = $self->_tableFormRow($label,$output);

View file

@ -23,21 +23,8 @@ sub process {
if (WebGUI::Grouping::isInGroup(12)) {
my %var;
my @param = WebGUI::Macro::getParams($_[0]);
my $templateId = 1; ##Set default template in the namespace
##1 param means use my template with default text
my ($turnOff, $turnOn) = (WebGUI::International::get(517),WebGUI::International::get(516));
if (@param == 1) {
$templateId = WebGUI::Template::getIdByName($param[0],"Macro/AdminToggle");
}
##2 params means use my text with the default template
elsif (@param == 2) {
($turnOff, $turnOn) = @param;
}
##3 or more params means use my text and template, other args ignored
elsif (@param >= 3) {
($turnOff, $turnOn) = @param[1,2];
$templateId = WebGUI::Template::getIdByName($param[0],"Macro/AdminToggle");
}
my $turnOn = $param[0] || WebGUI::International::get(516);
my $turnOff = $param[1] || WebGUI::International::get(517);
if ($session{var}{adminOn}) {
$var{'toggle.url'} = WebGUI::URL::page('op=switchOffAdmin');
$var{'toggle.text'} = $turnOff;
@ -45,8 +32,7 @@ sub process {
$var{'toggle.url'} = WebGUI::URL::page('op=switchOnAdmin');
$var{'toggle.text'} = $turnOn;
}
$templateId = 1 if $templateId == 0;
return WebGUI::Template::process($templateId,"Macro/AdminToggle",\%var);
return WebGUI::Template::process(WebGUI::Template::getIdByName($param[2],"Macro/AdminToggle"),"Macro/AdminToggle",\%var);
}
return "";
}

View file

@ -24,20 +24,8 @@ sub process {
if (WebGUI::Page::canEdit() && WebGUI::Grouping::isInGroup(12)) {
my %var;
my @param = WebGUI::Macro::getParams($_[0]);
my $templateId = 1; ##Set default template in the namespace
my ($turnOff, $turnOn) = (WebGUI::International::get(517),WebGUI::International::get(516));
##1 param means use my template with default text
if (@param == 1) {
$templateId = WebGUI::Template::getIdByName($param[0],"Macro/EditableToggle");
}
##2 params means use my text with the default template
elsif (@param == 2) {
($turnOff, $turnOn) = @param;
}
##3 or more params means use my text and template, other args ignored
elsif (@param >= 3) {
($turnOff, $turnOn) = @param[1,2];
}
my $turnOn = $param[0] || WebGUI::International::get(516);
my $turnOff = $param[1] || WebGUI::International::get(517);
if ($session{var}{adminOn}) {
$var{'toggle.url'} = WebGUI::URL::page('op=switchOffAdmin');
$var{'toggle.text'} = $turnOff;
@ -45,8 +33,7 @@ sub process {
$var{'toggle.url'} = WebGUI::URL::page('op=switchOnAdmin');
$var{'toggle.text'} = $turnOn;
}
$templateId = 1 if $templateId == 0;
return WebGUI::Template::process($templateId,"Macro/EditableToggle",\%var);
return WebGUI::Template::process(WebGUI::Template::getIdByName($param[2],"Macro/EditableToggle"),"Macro/EditableToggle",\%var);
}
return "";
}

View file

@ -14,24 +14,18 @@ use strict;
use WebGUI::Collateral;
use WebGUI::Macro;
use WebGUI::Session;
use WebGUI::Template;
#-------------------------------------------------------------------
sub process {
my @param = WebGUI::Macro::getParams($_[0]);
if (my $collateral = WebGUI::Collateral->find($param[0])) {
# include default icon unless a second param
if ( ! $param[1] ) {
return '<a href="' . $collateral->getURL .
'"><img src="' . $collateral->getIcon .
'" align="middle" border="0" /> ' .
$collateral->get("name") . '</a>';
# second param was flag, so no accompanying image
} else {
return '<a href="' . $collateral->getURL .
'">' . $collateral->get("name") . '</a>';
}
$var{'file.url'} = $collateral->getURL;
$var{'file.icon'} = $collateral->getIcon;
$var{'file.name'} = $param[0];
$var{'file.size'} = $collateral->getSize;
$var{'file.thumbnail'} = $collateral->getThumbnail;
return WebGUI::Template::process(WebGUI::Template::getIdByName($param[1],"Macro/File"),"Macro/File", \%var);
} else {
return undef;
}

View file

@ -15,6 +15,7 @@ use WebGUI::Group;
use WebGUI::Grouping;
use WebGUI::Macro;
use WebGUI::Session;
use WebGUI::Template;
use WebGUI::URL;
#-------------------------------------------------------------------
@ -25,7 +26,10 @@ sub process {
return "" if ($g->groupId eq "");
return "" unless ($g->autoAdd);
return "" if (WebGUI::Grouping::isInGroup($g->groupId));
return '<a href="'.WebGUI::URL::page("op=autoAddToGroup&groupId=".$g->groupId).'">'.$param[1].'</a>';
my %var = ();
$var{'group.url'} = WebGUI::URL::page("op=autoAddToGroup&groupId=".$g->groupId);
$var{'group.text'} = $param[1];
return WebGUI::Template::process(WebGUI::Template::getIdByName($param[2],"Macro/GroupAdd"), "Macro/GroupAdd", \%var);
}

View file

@ -15,6 +15,7 @@ use WebGUI::Group;
use WebGUI::Grouping;
use WebGUI::Macro;
use WebGUI::Session;
use WebGUI::Template;
use WebGUI::URL;
#-------------------------------------------------------------------
@ -25,7 +26,10 @@ sub process {
return "" if ($g->groupId eq "");
return "" unless ($g->autoDelete);
return "" unless (WebGUI::Grouping::isInGroup($g->groupId));
return '<a href="'.WebGUI::URL::page("op=autoDeleteFromGroup&groupId=".$g->groupId).'">'.$param[1].'</a>';
my %var = ();
$var{'group.url'} = WebGUI::URL::page("op=autoDeleteFromGroup&groupId=".$g->groupId);
$var{'group.text'} = $param[1];
return WebGUI::Template::process(WebGUI::Template::getIdByName($param[2],"Macro/GroupDelete"),"Macro/GroupDelete", \%var);
}

View file

@ -27,13 +27,14 @@ sub process {
}
$temp = WebGUI::URL::gateway($temp);
if ($param[0] ne "linkonly") {
$temp = '<a class="homeLink" href="'.$temp.'">';
if ($param[0] ne "") {
$temp .= $param[0];
} else {
$temp .= WebGUI::International::get(47);
}
$temp .= '</a>';
my %var;
$var{'homelink.url'} = WebGUI::URL::gateway($temp);
if ($param[0] ne "") {
$var{'homeLink.text'} = $param[0];
} else {
$var{'homeLink.text'} = WebGUI::International::get(47);
}
$temp = WebGUI::Template::process(WebGUI::Template::getIdByName($param[1],"Macro/H_homeLink"), "Macro/H_homeLink", \%var);
}
return $temp;
}

View file

@ -14,26 +14,25 @@ use strict;
use WebGUI::International;
use WebGUI::Macro;
use WebGUI::Session;
use WebGUI::Template;
use WebGUI::URL;
#-------------------------------------------------------------------
sub process {
my (@param, $temp, $login, $logout);
@param = WebGUI::Macro::getParams($_[0]);
if ($session{user}{userId} == 1) {
if ($param[0] eq "linkonly") {
return WebGUI::URL::page('op=displayLogin');
}
$login = $param[0] || WebGUI::International::get(716);
$temp = '<a class="loginToggleLink" href="'.WebGUI::URL::page('op=displayLogin').'">'.$login.'</a>';
} else {
if ($param[0] eq "linkonly") {
return WebGUI::URL::page('op=logout');
}
$logout = $param[1] || WebGUI::International::get(717);
$temp = '<a class="loginToggleLink" href="'.WebGUI::URL::page('op=logout').'">'.$logout.'</a>';
}
return $temp;
my @param = WebGUI::Macro::getParams($_[0]);
my $login = $param[0] || WebGUI::International::get(716);
my $logout = $param[1] || WebGUI::International::get(717);
my %var;
if ($session{user}{userId} == 1) {
return WebGUI::URL::page("op=displayLogin") if ($param[0] eq "linkonly");
$var{'toggle.url'} = WebGUI::URL::page('op=displayLogin');
$var{'toggle.text'} = $login;
} else {
return WebGUI::URL::page("op=logout") if ($param[0] eq "linkonly");
$var{'toggle.url'} = WebGUI::URL::page('op=logout');
$var{'toggle.text'} = $logout;
}
return WebGUI::Template::process(WebGUI::Template::getIdByName($param[3],"Macro/LoginToggle"), "Macro/LoginToggle", \%var);
}

View file

@ -21,18 +21,10 @@ use WebGUI::URL;
sub process {
my %var;
my @param = WebGUI::Macro::getParams($_[0]);
return WebGUI::URL::page("op=displayAccount") if ($param[0] eq "linkonly");
$var{'account.url'} = WebGUI::URL::page('op=displayAccount');
my $templateId = 1; ##Set default template in the namespace
$var{'account.text'} = WebGUI::International::get(46);
if (@param == 1) {
$var{'account.text'} = $param[0] if $param[0];
}
elsif (@param == 2) {
$var{'account.text'} = $param[0] if $param[0];
$templateId = WebGUI::Template::getIdByName($param[1],"Macro/a_account");
$templateId = 1 if $templateId == 0;
}
return WebGUI::Template::process($templateId,"Macro/a_account",\%var);
$var{'account.text'} = $param[0] || WebGUI::International::get(46);
return WebGUI::Template::process(WebGUI::Template::getIdByName($param[1],"Macro/a_account"),"Macro/a_account",\%var);
}

View file

@ -15,6 +15,7 @@ use WebGUI::International;
use WebGUI::Macro;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::Template;
use WebGUI::URL;
use WebGUI::Utility;
@ -28,19 +29,20 @@ sub process {
}
$temp = WebGUI::URL::append($session{env}{REQUEST_URI},$append);
if ($param[1] ne "") {
($styleId) = WebGUI::SQL->quickArray("select styleId from style where name=".quote($param[1]),WebGUI::SQL->getSlave);
($styleId) = WebGUI::Template::getIdByName($param[1],"style");
if ($styleId != 0) {
$temp = WebGUI::URL::append($temp,'styleId='.$styleId);
}
}
if ($param[0] ne "linkonly") {
$temp = '<a class="makePrintableLink" href="'.$temp.'">';
if ($param[0] ne "") {
$temp .= $param[0];
} else {
$temp .= WebGUI::International::get(53);
}
$temp .= '</a>';
my %var;
$var{'printable.url'} = $temp;
if ($param[0] ne "") {
$var{'printable.text'} = $param[0];
} else {
$var{'printable.text'} = WebGUI::International::get(53);
}
$temp = WebGUI::Template::process(WebGUI::Template::getByName($param[2],"Macro/r_printable"), "Macro/r_printable", \%var);
}
return $temp;
}