Changed default behavior to return nothing instead of the macro tag when no

matching collateral is found.
This commit is contained in:
Alan Ritari 2003-12-29 20:35:52 +00:00
parent e8c305d919
commit 47015a8b26
6 changed files with 37 additions and 16 deletions

View file

@ -18,8 +18,14 @@ use WebGUI::Session;
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub process { sub process {
my @param = WebGUI::Macro::getParams($_[0]); my @param = WebGUI::Macro::getParams($_[0]);
my $collateral = WebGUI::Collateral->find($param[0]); if (my $collateral = WebGUI::Collateral->find($param[0])) {
return '<a href="'.$collateral->getURL.'"><img src="'.$collateral->getIcon.'" align="middle" border="0" /> '.$collateral->get("name").'</a>'; return '<a href="' . $collateral->getURL .
'"><img src="' . $collateral->getIcon .
'" align="middle" border="0" /> ' .
$collateral->get("name") . '</a>';
} else {
return undef;
}
} }
1; 1;

View file

@ -28,8 +28,11 @@ sub process {
} }
my @images = WebGUI::SQL->buildArray("select collateralId from collateral my @images = WebGUI::SQL->buildArray("select collateralId from collateral
where collateralType='image' and collateralFolderId=".$collateralFolderId); where collateralType='image' and collateralFolderId=".$collateralFolderId);
my $collateral = WebGUI::Collateral->new($images[rand($#images+1)]); if (my $collateral = WebGUI::Collateral->new($images[rand($#images+1)])) {
return '<img src="'.$collateral->getURL.'" '.$collateral->get("parameters").' />'; return '<img src="'.$collateral->getURL.'" '.$collateral->get("parameters").' />';
} else {
return undef;
}
} }

View file

@ -28,8 +28,11 @@ sub process {
} }
my @snippets = WebGUI::SQL->buildArray("select collateralId from collateral my @snippets = WebGUI::SQL->buildArray("select collateralId from collateral
where collateralType='snippet' and collateralFolderId=".$collateralFolderId); where collateralType='snippet' and collateralFolderId=".$collateralFolderId);
my $collateral = WebGUI::Collateral->new($snippets[rand($#snippets+1)]); if (my $collateral = WebGUI::Collateral->new($snippets[rand($#snippets+1)])) {
return $collateral->get("parameters"); return $collateral->get("parameters");
} else {
return undef;
}
} }

View file

@ -20,8 +20,11 @@ use WebGUI::Session;
sub process { sub process {
my (@param, $temp); my (@param, $temp);
@param = WebGUI::Macro::getParams($_[0]); @param = WebGUI::Macro::getParams($_[0]);
my $collateral = WebGUI::Collateral->find($param[0]); if (my $collateral = WebGUI::Collateral->find($param[0])) {
return $collateral->get("parameters"); return $collateral->get("parameters");
} else {
return undef;
}
} }

View file

@ -18,8 +18,11 @@ use WebGUI::Session;
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub process { sub process {
my @param = WebGUI::Macro::getParams($_[0]); my @param = WebGUI::Macro::getParams($_[0]);
my $collateral = WebGUI::Collateral->find($param[0]); if (my $collateral = WebGUI::Collateral->find($param[0])) {
return $collateral->getThumbnail; return $collateral->getThumbnail;
} else {
return undef;
}
} }

View file

@ -18,12 +18,15 @@ use WebGUI::Session;
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub process { sub process {
my @param = WebGUI::Macro::getParams($_[0]); my @param = WebGUI::Macro::getParams($_[0]);
my $collateral = WebGUI::Collateral->find($param[0]); if (my $collateral = WebGUI::Collateral->find($param[0])) {
my $output = '<a href="'.$collateral->getURL.'"'; my $output = '<a href="'.$collateral->getURL.'"';
$output .= ' target="_blank"' if ($param[1]); $output .= ' target="_blank"' if ($param[1]);
$output .= '><img src="'.$collateral->getThumbnail. $output .= '><img src="' . $collateral->getThumbnail;
'" border="0"></a><br><b>'.$param[0].'</b><p>'; $output .= '" border="0"></a><br><b>'.$param[0].'</b><p>';
return $output; return $output;
} else {
return undef;
}
} }