Adding templates.
This commit is contained in:
parent
fc1e0eb763
commit
2b09ea9f64
9 changed files with 471 additions and 381 deletions
|
|
@ -76,6 +76,11 @@ alter table Product_feature change productFeatureId Product_featureId int not nu
|
|||
alter table Product_specification change productSpecificationId Product_specificationId int not null;
|
||||
update wobject set templatePosition=templatePosition+1;
|
||||
alter table template add column namespace varchar(35) not null default 'Page';
|
||||
delete from international where languageId=1 and namespace='WebGUI' and internationalId=363;
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (363,1,'WebGUI','Page Template Position', 1034736999);
|
||||
alter table Product change Product_templateId templateId int not null default 1;
|
||||
alter table template drop primary key;
|
||||
alter table template add primary key (templateId,namespace);
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
367
lib/WebGUI.pm
367
lib/WebGUI.pm
|
|
@ -22,152 +22,17 @@ use WebGUI::Session;
|
|||
use WebGUI::SQL;
|
||||
use WebGUI::Style;
|
||||
use WebGUI::Template;
|
||||
use WebGUI::URL;
|
||||
use WebGUI::Utility;
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub page {
|
||||
my ($debug, %contentHash, $w, $cmd, $pageEdit, $wobject, $wobjectOutput, $extra, $originalWobject, $proxyWobjectId,
|
||||
$sth, $httpHeader, $content, $operationOutput, $adminBar, $template, %hash, $canEdit);
|
||||
WebGUI::Session::open($_[0],$_[1]);
|
||||
$template = 1;
|
||||
if (exists $session{form}{op}) {
|
||||
if ($session{form}{op} =~ /^[A-Za-z]+$/) {
|
||||
$cmd = "WebGUI::Operation::www_".$session{form}{op};
|
||||
$operationOutput = eval($cmd);
|
||||
WebGUI::ErrorHandler::security("call a non-existent operation: $session{form}{op}.") if($@);
|
||||
} else {
|
||||
WebGUI::ErrorHandler::security("execute an invalid operation: ".$session{form}{op});
|
||||
}
|
||||
}
|
||||
if (exists $session{form}{func} && exists $session{form}{wid}) {
|
||||
if ($session{form}{func} =~ /^[A-Za-z]+$/) {
|
||||
if ($session{form}{wid} eq "new") {
|
||||
$wobject = {wobjectId=>"new",namespace=>$session{form}{namespace},pageId=>$session{page}{pageId}};
|
||||
} else {
|
||||
$wobject = WebGUI::SQL->quickHashRef("select * from wobject where wobjectId="
|
||||
.$session{form}{wid});
|
||||
if (${$wobject}{namespace} eq "") {
|
||||
WebGUI::ErrorHandler::warn("Wobject [$session{form}{wid}] appears to be missing or "
|
||||
."corrupt, but was requested "
|
||||
."by $session{user}{username} [$session{user}{userId}].");
|
||||
$wobject = ();
|
||||
} else {
|
||||
$extra = WebGUI::SQL->quickHashRef("select * from ${$wobject}{namespace}
|
||||
where wobjectId=${$wobject}{wobjectId}");
|
||||
tie %hash, 'Tie::CPHash';
|
||||
%hash = (%{$wobject},%{$extra});
|
||||
$wobject = \%hash;
|
||||
}
|
||||
}
|
||||
if ($wobject) {
|
||||
if (${$wobject}{pageId} != $session{page}{pageId}) {
|
||||
($proxyWobjectId) = WebGUI::SQL->quickArray("select wobject.wobjectId from
|
||||
wobject,WobjectProxy
|
||||
where wobject.wobjectId=WobjectProxy.wobjectId
|
||||
and wobject.pageId=".$session{page}{pageId}."
|
||||
and WobjectProxy.proxiedWobjectId=".${$wobject}{wobjectId});
|
||||
${$wobject}{_WobjectProxy} = $proxyWobjectId;
|
||||
}
|
||||
unless (${$wobject}{pageId} == $session{page}{pageId} || ${$wobject}{pageId} == 2 || ${$wobject}{_WobjectProxy} ne "") {
|
||||
$wobjectOutput .= WebGUI::International::get(417);
|
||||
WebGUI::ErrorHandler::security("access wobject [".$session{form}{wid}."] on page '"
|
||||
.$session{page}{title}."' [".$session{page}{pageId}."].");
|
||||
} else {
|
||||
if (WebGUI::Privilege::canViewPage()) {
|
||||
$cmd = "WebGUI::Wobject::".${$wobject}{namespace};
|
||||
$w = eval{$cmd->new($wobject)};
|
||||
WebGUI::ErrorHandler::fatalError("Couldn't instanciate wobject: ${$wobject}{namespace}. Root Cause: ".$@) if($@);
|
||||
$cmd = "www_".$session{form}{func};
|
||||
$wobjectOutput = eval{$w->$cmd};
|
||||
WebGUI::ErrorHandler::fatalError("Wobject runtime error: ${$wobject}{namespace} / $session{form}{func}. Root cause: ".$@) if($@);
|
||||
} else {
|
||||
$wobjectOutput = WebGUI::Privilege::noAccess();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
WebGUI::ErrorHandler::security("execute an invalid function on wobject "
|
||||
.$session{form}{wid}.": ".$session{form}{func});
|
||||
}
|
||||
}
|
||||
if ($session{header}{mimetype} ne "text/html") {
|
||||
$httpHeader = WebGUI::Session::httpHeader();
|
||||
WebGUI::Session::close();
|
||||
return $httpHeader.$operationOutput.$wobjectOutput;
|
||||
} elsif ($operationOutput ne "") {
|
||||
$contentHash{"template.position".1} = $operationOutput;
|
||||
} elsif ($wobjectOutput ne "") {
|
||||
$contentHash{"template.position".1} = $wobjectOutput;
|
||||
} elsif ($session{page}{redirectURL}) {
|
||||
$session{header}{redirect} = WebGUI::Session::httpRedirect($session{page}{redirectURL})
|
||||
} else {
|
||||
if (WebGUI::Privilege::canViewPage()) {
|
||||
if ($session{var}{adminOn}) {
|
||||
$canEdit = WebGUI::Privilege::canEditPage();
|
||||
if ($canEdit) {
|
||||
$pageEdit = "\n<br>"
|
||||
.pageIcon()
|
||||
.deleteIcon('op=deletePage')
|
||||
.editIcon('op=editPage')
|
||||
.moveUpIcon('op=movePageUp')
|
||||
.moveDownIcon('op=movePageDown')
|
||||
.cutIcon('op=cutPage')
|
||||
."\n";
|
||||
}
|
||||
}
|
||||
$sth = WebGUI::SQL->read("select * from wobject where pageId=$session{page}{pageId} order by sequenceNumber, wobjectId");
|
||||
while ($wobject = $sth->hashRef) {
|
||||
if ($session{var}{adminOn} && $canEdit) {
|
||||
$contentHash{"template.position".${$wobject}{templatePosition}} .= "\n<hr>"
|
||||
.wobjectIcon()
|
||||
.deleteIcon('func=delete&wid='.${$wobject}{wobjectId})
|
||||
.editIcon('func=edit&wid='.${$wobject}{wobjectId})
|
||||
.moveUpIcon('func=moveUp&wid='.${$wobject}{wobjectId})
|
||||
.moveDownIcon('func=moveDown&wid='.${$wobject}{wobjectId})
|
||||
.moveTopIcon('func=moveTop&wid='.${$wobject}{wobjectId})
|
||||
.moveBottomIcon('func=moveBottom&wid='.${$wobject}{wobjectId})
|
||||
.cutIcon('func=cut&wid='.${$wobject}{wobjectId})
|
||||
.copyIcon('func=copy&wid='.${$wobject}{wobjectId})
|
||||
.'<br>';
|
||||
}
|
||||
if (${$wobject}{namespace} eq "WobjectProxy") {
|
||||
$originalWobject = $wobject;
|
||||
($wobject) = WebGUI::SQL->quickArray("select proxiedWobjectId from WobjectProxy where wobjectId=".${$wobject}{wobjectId});
|
||||
$wobject = WebGUI::SQL->quickHashRef("select * from wobject where wobject.wobjectId=".$wobject);
|
||||
if (${$wobject}{namespace} eq "") {
|
||||
$wobject = $originalWobject;
|
||||
} else {
|
||||
${$wobject}{templatePosition} = ${$originalWobject}{templatePosition};
|
||||
${$wobject}{_WobjectProxy} = ${$originalWobject}{wobjectId};
|
||||
}
|
||||
}
|
||||
my $sql = "select * from ".$wobject->{namespace}." where wobjectId=".$wobject->{wobjectId};
|
||||
$extra = WebGUI::SQL->quickHashRef("select * from ".$wobject->{namespace}." where wobjectId=".$wobject->{wobjectId});
|
||||
tie %hash, 'Tie::CPHash';
|
||||
%hash = (%{$wobject},%{$extra});
|
||||
$wobject = \%hash;
|
||||
$cmd = "WebGUI::Wobject::".${$wobject}{namespace};
|
||||
$w = eval{$cmd->new($wobject)};
|
||||
WebGUI::ErrorHandler::fatalError("Couldn't instanciate wobject: ${$wobject}{namespace}. Root cause: ".$@) if($@);
|
||||
if ($w->inDateRange) {
|
||||
$contentHash{"template.position".${$wobject}{templatePosition}} .= '<div class="wobject'.${$wobject}{namespace}.'" id="wobjectId'.${$wobject}{wobjectId}.'">';
|
||||
$contentHash{"template.position".${$wobject}{templatePosition}} .= '<a name="'.${$wobject}{wobjectId}.'"></a>';
|
||||
$contentHash{"template.position".${$wobject}{templatePosition}} .= eval{$w->www_view};
|
||||
WebGUI::ErrorHandler::fatalError("Wobject runtime error: ${$wobject}{namespace}. Root cause: ".$@) if($@);
|
||||
$contentHash{"template.position".${$wobject}{templatePosition}} .= "</div>\n\n";
|
||||
}
|
||||
}
|
||||
$sth->finish;
|
||||
$template = $session{page}{templateId};
|
||||
} else {
|
||||
$contentHash{"template.position".1} = WebGUI::Privilege::noAccess();
|
||||
}
|
||||
}
|
||||
#-------------------------------------------------------------------
|
||||
sub _generateDebug {
|
||||
my ($debug);
|
||||
if ($session{setting}{showDebug} || ($session{form}{debug}==1 && WebGUI::Privilege::isInGroup(3))) {
|
||||
$debug = '<div style="background-color: #ffdddd;color: #000000;">'.$session{debug}{warning}.'</div>';
|
||||
$debug .= '<div style="background-color: #800000;color: #ffffff;">'.$session{debug}{security}.'</div>';
|
||||
$debug .= '<div style="background-color: #ffffdd;color: #000000;">'.$session{debug}{audit}.'</div>';
|
||||
$debug = '<div style="background-color: #ffdddd;color: #000000;">'.$session{debug}{warning}.'</div>';
|
||||
$debug .= '<div style="background-color: #800000;color: #ffffff;">'.$session{debug}{security}.'</div>';
|
||||
$debug .= '<div style="background-color: #ffffdd;color: #000000;">'.$session{debug}{audit}.'</div>';
|
||||
$debug .= '<table bgcolor="#ffffff" style="color: #000000; font-size: 10pt; font-family: helvetica;">';
|
||||
while (my ($section, $hash) = each %session) {
|
||||
while (my ($key, $value) = each %$hash) {
|
||||
|
|
@ -176,32 +41,216 @@ sub page {
|
|||
} elsif (ref $value eq 'HASH') {
|
||||
$value = '{'.join(', ',map {"$_ => $value->{$_}"} keys %$value).'}';
|
||||
}
|
||||
unless (lc($key) eq "password" || lc($key) eq "identifier") {
|
||||
$debug .= '<tr><td align="right"><b>'.$section.'.'.$key.':</b></td><td>'.$value.'</td>';
|
||||
}
|
||||
unless (lc($key) eq "password" || lc($key) eq "identifier") {
|
||||
$debug .= '<tr><td align="right"><b>'.$section.'.'.$key.':</b></td><td>'.$value.'</td>';
|
||||
}
|
||||
}
|
||||
$debug .= '<tr height=10><td> </td><td> </td></tr>';
|
||||
}
|
||||
$debug .='</table>';
|
||||
}
|
||||
return $debug;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub _generatePage {
|
||||
my ($canEdit, $pageEdit, $sth, $wobject, %contentHash, $originalWobject, $sql, $extra, %hash, $cmd, $w, $template);
|
||||
if (WebGUI::Privilege::canViewPage()) {
|
||||
if ($session{var}{adminOn}) {
|
||||
$canEdit = WebGUI::Privilege::canEditPage();
|
||||
if ($canEdit) {
|
||||
$pageEdit = "\n<br>"
|
||||
.pageIcon()
|
||||
.deleteIcon('op=deletePage')
|
||||
.editIcon('op=editPage')
|
||||
.moveUpIcon('op=movePageUp')
|
||||
.moveDownIcon('op=movePageDown')
|
||||
.cutIcon('op=cutPage')
|
||||
."\n";
|
||||
}
|
||||
}
|
||||
$sth = WebGUI::SQL->read("select * from wobject where pageId=$session{page}{pageId}
|
||||
order by sequenceNumber, wobjectId");
|
||||
while ($wobject = $sth->hashRef) {
|
||||
if ($session{var}{adminOn} && $canEdit) {
|
||||
$contentHash{"template.position".${$wobject}{templatePosition}} .= "\n<hr>"
|
||||
.wobjectIcon()
|
||||
.deleteIcon('func=delete&wid='.${$wobject}{wobjectId})
|
||||
.editIcon('func=edit&wid='.${$wobject}{wobjectId})
|
||||
.moveUpIcon('func=moveUp&wid='.${$wobject}{wobjectId})
|
||||
.moveDownIcon('func=moveDown&wid='.${$wobject}{wobjectId})
|
||||
.moveTopIcon('func=moveTop&wid='.${$wobject}{wobjectId})
|
||||
.moveBottomIcon('func=moveBottom&wid='.${$wobject}{wobjectId})
|
||||
.cutIcon('func=cut&wid='.${$wobject}{wobjectId})
|
||||
.copyIcon('func=copy&wid='.${$wobject}{wobjectId})
|
||||
.'<br>';
|
||||
}
|
||||
if (${$wobject}{namespace} eq "WobjectProxy") {
|
||||
$originalWobject = $wobject;
|
||||
($wobject) = WebGUI::SQL->quickArray("select proxiedWobjectId from WobjectProxy
|
||||
where wobjectId=".${$wobject}{wobjectId});
|
||||
$wobject = WebGUI::SQL->quickHashRef("select * from wobject where wobject.wobjectId=".$wobject);
|
||||
if (${$wobject}{namespace} eq "") {
|
||||
$wobject = $originalWobject;
|
||||
} else {
|
||||
${$wobject}{templatePosition} = ${$originalWobject}{templatePosition};
|
||||
${$wobject}{_WobjectProxy} = ${$originalWobject}{wobjectId};
|
||||
}
|
||||
}
|
||||
my $sql = "select * from ".$wobject->{namespace}." where wobjectId=".$wobject->{wobjectId};
|
||||
$extra = WebGUI::SQL->quickHashRef("select * from ".$wobject->{namespace}."
|
||||
where wobjectId=".$wobject->{wobjectId});
|
||||
tie %hash, 'Tie::CPHash';
|
||||
%hash = (%{$wobject},%{$extra});
|
||||
$wobject = \%hash;
|
||||
$cmd = "WebGUI::Wobject::".${$wobject}{namespace};
|
||||
$w = eval{$cmd->new($wobject)};
|
||||
WebGUI::ErrorHandler::fatalError("Couldn't instanciate wobject: ${$wobject}{namespace}. Root cause: ".$@) if($@);
|
||||
if ($w->inDateRange) {
|
||||
$contentHash{"template.position".${$wobject}{templatePosition}} .= '<div class="wobject'
|
||||
.${$wobject}{namespace}.'" id="wobjectId'.${$wobject}{wobjectId}.'">';
|
||||
$contentHash{"template.position".${$wobject}{templatePosition}} .= '<a name="'
|
||||
.${$wobject}{wobjectId}.'"></a>';
|
||||
$contentHash{"template.position".${$wobject}{templatePosition}} .= eval{$w->www_view};
|
||||
WebGUI::ErrorHandler::fatalError("Wobject runtime error: ${$wobject}{namespace}. Root cause: ".$@) if($@);
|
||||
$contentHash{"template.position".${$wobject}{templatePosition}} .= "</div>\n\n";
|
||||
}
|
||||
}
|
||||
$sth->finish;
|
||||
$template = $session{page}{templateId};
|
||||
} else {
|
||||
$contentHash{"template.position".1} = WebGUI::Privilege::noAccess();
|
||||
}
|
||||
return (\%contentHash,$template,$pageEdit);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub _processAction {
|
||||
my ($urlString, %form, $pair, @pairs, @param);
|
||||
$urlString = WebGUI::URL::unescape($_[0]);
|
||||
@pairs = split(/\&/,$urlString);
|
||||
foreach $pair (@pairs) {
|
||||
@param = split(/\=/,$pair);
|
||||
$form{$param[0]} = $param[1];
|
||||
}
|
||||
if ($session{header}{redirect} ne "") {
|
||||
$httpHeader = $session{header}{redirect};
|
||||
$session{form} = \%form;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub _processFunctions {
|
||||
my ($wobject, $extra, %hash, $output, $proxyWobjectId, $cmd, $w);
|
||||
if (exists $session{form}{func} && exists $session{form}{wid}) {
|
||||
if ($session{form}{func} =~ /^[A-Za-z]+$/) {
|
||||
if ($session{form}{wid} eq "new") {
|
||||
$wobject = {wobjectId=>"new",namespace=>$session{form}{namespace},pageId=>$session{page}{pageId}};
|
||||
} else {
|
||||
$wobject = WebGUI::SQL->quickHashRef("select * from wobject where wobjectId="
|
||||
.$session{form}{wid});
|
||||
if (${$wobject}{namespace} eq "") {
|
||||
WebGUI::ErrorHandler::warn("Wobject [$session{form}{wid}] appears to be missing or "
|
||||
."corrupt, but was requested "
|
||||
."by $session{user}{username} [$session{user}{userId}].");
|
||||
$wobject = ();
|
||||
} else {
|
||||
$extra = WebGUI::SQL->quickHashRef("select * from ${$wobject}{namespace}
|
||||
where wobjectId=${$wobject}{wobjectId}");
|
||||
tie %hash, 'Tie::CPHash';
|
||||
%hash = (%{$wobject},%{$extra});
|
||||
$wobject = \%hash;
|
||||
}
|
||||
}
|
||||
if ($wobject) {
|
||||
if (${$wobject}{pageId} != $session{page}{pageId}) {
|
||||
($proxyWobjectId) = WebGUI::SQL->quickArray("select wobject.wobjectId from
|
||||
wobject,WobjectProxy
|
||||
where wobject.wobjectId=WobjectProxy.wobjectId
|
||||
and wobject.pageId=".$session{page}{pageId}."
|
||||
and WobjectProxy.proxiedWobjectId=".${$wobject}{wobjectId});
|
||||
${$wobject}{_WobjectProxy} = $proxyWobjectId;
|
||||
}
|
||||
unless (${$wobject}{pageId} == $session{page}{pageId} || ${$wobject}{pageId} == 2 || ${$wobject}{_WobjectProxy} ne "") {
|
||||
$output .= WebGUI::International::get(417);
|
||||
WebGUI::ErrorHandler::security("access wobject [".$session{form}{wid}."] on page '"
|
||||
.$session{page}{title}."' [".$session{page}{pageId}."].");
|
||||
} else {
|
||||
if (WebGUI::Privilege::canViewPage()) {
|
||||
$cmd = "WebGUI::Wobject::".${$wobject}{namespace};
|
||||
$w = eval{$cmd->new($wobject)};
|
||||
WebGUI::ErrorHandler::fatalError("Couldn't instanciate wobject: ${$wobject}{namespace}. Root Cause: ".$@) if($@);
|
||||
$cmd = "www_".$session{form}{func};
|
||||
$output = eval{$w->$cmd};
|
||||
WebGUI::ErrorHandler::fatalError("Wobject runtime error: ${$wobject}{namespace} / $session{form}{func}. Root cause: ".$@) if($@);
|
||||
} else {
|
||||
$output = WebGUI::Privilege::noAccess();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
WebGUI::ErrorHandler::security("execute an invalid function on wobject "
|
||||
.$session{form}{wid}.": ".$session{form}{func});
|
||||
}
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub _processOperations {
|
||||
my ($cmd, $output);
|
||||
if (exists $session{form}{op}) {
|
||||
if ($session{form}{op} =~ /^[A-Za-z]+$/) {
|
||||
$cmd = "WebGUI::Operation::www_".$session{form}{op};
|
||||
$output = eval($cmd);
|
||||
WebGUI::ErrorHandler::security("call a non-existent operation: $session{form}{op}.") if($@);
|
||||
} else {
|
||||
WebGUI::ErrorHandler::security("execute an invalid operation: ".$session{form}{op});
|
||||
}
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub page {
|
||||
my ($positions, $wobjectOutput, $pageEdit, $httpHeader, $content, $operationOutput, $template);
|
||||
WebGUI::Session::open($_[0],$_[1]);
|
||||
$operationOutput = _processOperations();
|
||||
$wobjectOutput = _processFunctions();
|
||||
if ($operationOutput eq "" && $wobjectOutput eq "" && $session{form}{action2} ne "") {
|
||||
_processAction($session{form}{action2});
|
||||
$operationOutput = _processOperations();
|
||||
$wobjectOutput = _processFunctions();
|
||||
}
|
||||
if ($session{header}{mimetype} ne "text/html") {
|
||||
$httpHeader = WebGUI::Session::httpHeader();
|
||||
WebGUI::Session::close();
|
||||
return $httpHeader.$operationOutput.$wobjectOutput;
|
||||
} elsif ($session{page}{redirectURL}) {
|
||||
$httpHeader = WebGUI::Session::httpRedirect($session{page}{redirectURL});
|
||||
WebGUI::Session::close();
|
||||
return $httpHeader;
|
||||
} elsif ($session{header}{redirect} ne "") {
|
||||
$httpHeader = $session{header}{redirect};
|
||||
WebGUI::Session::close();
|
||||
return $httpHeader;
|
||||
} elsif ($operationOutput ne "") {
|
||||
$positions->{"template.position".1} = $operationOutput;
|
||||
} elsif ($wobjectOutput ne "") {
|
||||
$positions->{"template.position".1} = $wobjectOutput;
|
||||
} else {
|
||||
$httpHeader = WebGUI::Session::httpHeader();
|
||||
$content = WebGUI::Template::process(
|
||||
WebGUI::Macro::process(
|
||||
WebGUI::Style::get(
|
||||
$pageEdit
|
||||
.WebGUI::Template::get($template)
|
||||
)
|
||||
),
|
||||
\%contentHash
|
||||
);
|
||||
WebGUI::Session::close();
|
||||
return $httpHeader.$adminBar.$content.$debug;
|
||||
($positions, $template, $pageEdit) = _generatePage();
|
||||
}
|
||||
$httpHeader = WebGUI::Session::httpHeader();
|
||||
$content = WebGUI::Template::process(
|
||||
WebGUI::Macro::process(
|
||||
WebGUI::Style::get(
|
||||
$pageEdit
|
||||
.WebGUI::Template::get($template)
|
||||
)
|
||||
),
|
||||
$positions
|
||||
);
|
||||
WebGUI::Session::close();
|
||||
return $httpHeader.$content._generateDebug();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ use WebGUI::URL;
|
|||
WebGUI::Form::radioList({name="dayOfWeek", options=>\%days});
|
||||
WebGUI::Form::selectList({name=>"dayOfWeek", options=>\%days, value=>\@array"});
|
||||
WebGUI::Form::submit;
|
||||
WebGUI::Form::template({name=>"templateId"});
|
||||
WebGUI::Form::text({name=>"firstName"});
|
||||
WebGUI::Form::textarea({name=>"emailMessage"});
|
||||
WebGUI::Form::url({name=>"homepage"});
|
||||
|
|
@ -395,9 +396,9 @@ sub formHeader {
|
|||
|
||||
The name field for this form element.
|
||||
|
||||
=item value
|
||||
=item groupId
|
||||
|
||||
The default value(s) for this form element. This should be passed
|
||||
The selected group id(s) for this form element. This should be passed
|
||||
as an array reference. Defaults to "7" (Everyone).
|
||||
|
||||
=item size
|
||||
|
|
@ -420,7 +421,7 @@ sub formHeader {
|
|||
|
||||
sub group {
|
||||
my (%hash, $value);
|
||||
$value = $_[0]->{value};
|
||||
$value = $_[0]->{groupId};
|
||||
if ($$value[0] eq "") { #doing long form otherwise arrayRef didn't work
|
||||
$value = [7];
|
||||
}
|
||||
|
|
@ -967,6 +968,39 @@ sub submit {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 template ( hashRef )
|
||||
|
||||
Returns a select list of templates.
|
||||
|
||||
=item name
|
||||
|
||||
The name field for this form element.
|
||||
|
||||
=item value
|
||||
|
||||
The unique identifier for the selected template. Defaults to "1".
|
||||
|
||||
=item namespace
|
||||
|
||||
The namespace for the list of templates to return. If this is
|
||||
omitted, all templates will be displayed.
|
||||
|
||||
=cut
|
||||
|
||||
sub template {
|
||||
my ($templates, $templateId, $where);
|
||||
$templateId = $_[0]->{value} || 1;
|
||||
$templates = WebGUI::SQL->buildHashRef("select templateId,name from template where namespace="
|
||||
.quote($_[0]->{namespace})." order by name");
|
||||
return selectList({
|
||||
name=>$_[0]->{name},
|
||||
options=>$templates,
|
||||
value=>[$templateId]
|
||||
});
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 text ( hashRef )
|
||||
|
||||
Returns a text input field.
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ use WebGUI::SQL;
|
|||
$f->readOnly("34","Page ID");
|
||||
$f->select("dayOfWeek",\%days,"Which day?");
|
||||
$f->submit;
|
||||
$f->template("templateId","Page Template");
|
||||
$f->text("firstName", "First Name");
|
||||
$f->textarea("emailMessage","Email Message");
|
||||
$f->url("homepage","Home Page");
|
||||
|
|
@ -606,7 +607,7 @@ sub group {
|
|||
$output = WebGUI::Form::hiddenList({
|
||||
name=>$name,
|
||||
options=>$hashRef,
|
||||
value=>$value
|
||||
groupId=>$value
|
||||
});
|
||||
}
|
||||
$self->{_data} .= $output;
|
||||
|
|
@ -1425,6 +1426,41 @@ sub submit {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 template ( name [, value, label, namespace, return, extras, uiLevel ] )
|
||||
|
||||
=cut
|
||||
|
||||
sub template {
|
||||
my ($output, $subtext);
|
||||
my ($self, @p) = @_;
|
||||
my ($name, $value, $label, $namespace, $afterEdit, $extras, $uiLevel) =
|
||||
rearrange([name, value, label, namespace, afterEdit, extras, uiLevel], @p);
|
||||
if (_uiLevelChecksOut($uiLevel)) {
|
||||
if ($afterEdit) {
|
||||
$subtext = '<a href="'.WebGUI::URL::page("op=editTemplate&tid=".$value."&afterEdit="
|
||||
.WebGUI::URL::escape($afterEdit)).'">'.WebGUI::International::get(741).'</a> / ';
|
||||
}
|
||||
$subtext .= '<a href="'.WebGUI::URL::page("op=listTemplates&namespace=$namespace").'">'
|
||||
.WebGUI::International::get(742).'</a>';
|
||||
$output = WebGUI::Form::template({
|
||||
name=>$name,
|
||||
value=>$value,
|
||||
namespace=>$namespace,
|
||||
extras=>$extras
|
||||
});
|
||||
$output .= _subtext($subtext);
|
||||
$output = $self->_tableFormRow($label,$output);
|
||||
} else {
|
||||
$output = WebGUI::Form::hidden({
|
||||
name=>$name,
|
||||
value=>$value
|
||||
});
|
||||
}
|
||||
$self->{_data} .= $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 text ( name [ label, value, maxlength, extras, subtext, size, uiLevel ] )
|
||||
|
||||
Adds a text row to this form.
|
||||
|
|
|
|||
|
|
@ -196,11 +196,6 @@ sub www_editPage {
|
|||
-value=>$page{redirectURL},
|
||||
-uiLevel=>8
|
||||
);
|
||||
$f->readOnly(
|
||||
-value=>WebGUI::Template::select($page{templateId}),
|
||||
-label=>WebGUI::International::get(356),
|
||||
-uiLevel=>5
|
||||
);
|
||||
$f->textarea(
|
||||
-name=>"synopsis",
|
||||
-label=>WebGUI::International::get(412),
|
||||
|
|
@ -237,6 +232,11 @@ sub www_editPage {
|
|||
-subtext=>' '.WebGUI::International::get(106),
|
||||
-uiLevel=>9
|
||||
);
|
||||
$f->readOnly(
|
||||
-value=>WebGUI::Template::select($page{templateId}),
|
||||
-label=>WebGUI::International::get(356),
|
||||
-uiLevel=>5
|
||||
);
|
||||
$f->raw(
|
||||
-value=>'<tr><td colspan=2><hr size=1><b>'.WebGUI::International::get(107).'</b></td></tr>',
|
||||
-uiLevel=>9
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ use WebGUI::Paginator;
|
|||
use WebGUI::Privilege;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
use WebGUI::Template;
|
||||
use WebGUI::URL;
|
||||
use WebGUI::Utility;
|
||||
|
||||
|
|
@ -32,8 +33,10 @@ sub www_copyTemplate {
|
|||
my (%template);
|
||||
if (WebGUI::Privilege::isInGroup($session{setting}{templateManagersGroup})) {
|
||||
%template = WebGUI::SQL->quickHash("select * from template where templateId=$session{form}{tid}");
|
||||
WebGUI::SQL->write("insert into template (templateId,name,template) values (".getNextId("templateId").",
|
||||
".quote('Copy of '.$template{name}).", ".quote($template{template}).")");
|
||||
WebGUI::SQL->write("insert into template (templateId,name,template,namespace)
|
||||
values (".getNextId("templateId").",
|
||||
".quote('Copy of '.$template{name}).", ".quote($template{template}).",
|
||||
".quote($template{namespace}).")");
|
||||
return www_listTemplates();
|
||||
} else {
|
||||
return WebGUI::Privilege::adminOnly();
|
||||
|
|
@ -50,10 +53,11 @@ sub www_deleteTemplate {
|
|||
$output .= '<h1>'.WebGUI::International::get(42).'</h1>';
|
||||
$output .= WebGUI::International::get(502).'<p>';
|
||||
$output .= '<div align="center"><a href="'.
|
||||
WebGUI::URL::page('op=deleteTemplateConfirm&tid='.$session{form}{tid})
|
||||
WebGUI::URL::page('op=deleteTemplateConfirm&tid='.$session{form}{tid}.'&namespace='
|
||||
.$session{form}{namespace})
|
||||
.'">'.WebGUI::International::get(44).'</a>';
|
||||
$output .= ' <a href="'.WebGUI::URL::page('op=listTemplates').
|
||||
'">'.WebGUI::International::get(45).'</a></div>';
|
||||
$output .= ' <a href="'.WebGUI::URL::page('op=listTemplates&namespace='
|
||||
.$session{form}{namespace}).'">'.WebGUI::International::get(45).'</a></div>';
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::adminOnly();
|
||||
|
|
@ -66,13 +70,16 @@ sub www_deleteTemplateConfirm {
|
|||
if ($session{form}{tid} < 1000 && $session{form}{tid} > 1000) {
|
||||
return WebGUI::Privilege::vitalComponent();
|
||||
} elsif (WebGUI::Privilege::isInGroup($session{setting}{templateManagersGroup})) {
|
||||
$a = WebGUI::SQL->read("select * from page where templateId=".$session{form}{tid});
|
||||
while (($pageId) = $a->array) {
|
||||
WebGUI::SQL->write("update wobject set templatePosition=1 where pageId=$pageId");
|
||||
if ($session{form}{namespace} eq "Page") {
|
||||
$a = WebGUI::SQL->read("select * from page where templateId=".$session{form}{tid});
|
||||
while (($pageId) = $a->array) {
|
||||
WebGUI::SQL->write("update wobject set templatePosition=1 where pageId=$pageId");
|
||||
}
|
||||
$a->finish;
|
||||
WebGUI::SQL->write("update page set templateId=2 where templateId=".$session{form}{tid});
|
||||
}
|
||||
$a->finish;
|
||||
WebGUI::SQL->write("delete from template where templateId=".$session{form}{tid});
|
||||
WebGUI::SQL->write("update page set templateId=2 where templateId=".$session{form}{tid});
|
||||
WebGUI::SQL->write("delete from template where templateId=".$session{form}{tid}
|
||||
." and namespace=".quote($session{form}{namespace}));
|
||||
return www_listTemplates();
|
||||
} else {
|
||||
return WebGUI::Privilege::adminOnly();
|
||||
|
|
@ -85,14 +92,22 @@ sub www_editTemplate {
|
|||
tie %template, 'Tie::CPHash';
|
||||
if (WebGUI::Privilege::isInGroup($session{setting}{templateManagersGroup})) {
|
||||
if ($session{form}{tid} eq "new") {
|
||||
$template{template} = "<table>\n <tr>\n <td>\n\n<tmpl_var template.position1>\n\n </td>\n </tr>\n</table>\n";
|
||||
if ($session{form}{namespace} eq "Page") {
|
||||
$template{template} = "<table>\n <tr>\n <td>\n\n<tmpl_var template.position1>\n\n".
|
||||
"</td>\n </tr>\n</table>\n";
|
||||
} else {
|
||||
$template{template} = "<h1><tmpl_var title></h1>\n\n";
|
||||
}
|
||||
} else {
|
||||
%template = WebGUI::SQL->quickHash("select * from template where templateId=$session{form}{tid}");
|
||||
%template = WebGUI::SQL->quickHash("select * from template where templateId=$session{form}{tid} and
|
||||
namespace=".quote($session{form}{namespace}));
|
||||
}
|
||||
$output .= helpIcon(34);
|
||||
$output .= '<h1>'.WebGUI::International::get(507).'</h1>';
|
||||
$f = WebGUI::HTMLForm->new;
|
||||
$f->hidden("op","editTemplateSave");
|
||||
$f->hidden("afterEdit",$session{form}{afterEdit});
|
||||
$f->hidden("namespace",$session{form}{namespace});
|
||||
$f->hidden("tid",$session{form}{tid});
|
||||
$f->readOnly($session{form}{tid},WebGUI::International::get(503));
|
||||
$f->text("name",WebGUI::International::get(528),$template{name});
|
||||
|
|
@ -100,7 +115,7 @@ sub www_editTemplate {
|
|||
$f->submit;
|
||||
$output .= $f->print;
|
||||
} else {
|
||||
$output = WebGUI::Privilege::adminOnly();
|
||||
$output = WebGUI::Privilege::insufficient();
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
|
@ -109,45 +124,54 @@ sub www_editTemplate {
|
|||
sub www_editTemplateSave {
|
||||
if (WebGUI::Privilege::isInGroup($session{setting}{templateManagersGroup})) {
|
||||
if ($session{form}{tid} eq "new") {
|
||||
$session{form}{tid} = getNextId("templateId");
|
||||
WebGUI::SQL->write("insert into template (templateId) values ($session{form}{tid})");
|
||||
($session{form}{tid}) = WebGUI::SQL->quickArray("select max(internationalId)
|
||||
from international where templateId=".$session{form}{tid}."
|
||||
and namespace=".quote($session{form}{namespace}));
|
||||
$session{form}{tid}++;
|
||||
WebGUI::SQL->write("insert into template (templateId,namespace) values
|
||||
($session{form}{tid}, ".quote($session{form}{namespace}).")");
|
||||
}
|
||||
$session{form}{template} = "<table>\n <tr>\n <td>\n\n^0;\n\n </td>\n </tr>\n</table>\n" if ($session{form}{template} eq "");
|
||||
WebGUI::SQL->write("update template set name=".quote($session{form}{name}).", template=".quote($session{form}{template})."
|
||||
if ($session{form}{template} eq "" && $session{form}{namespace} eq "Page") {
|
||||
$session{form}{template} = "<table>\n<tr>\n<td>\n\n<tmpl_var template.position1>\n\n</td>\n </tr>\n</table>\n";
|
||||
}
|
||||
WebGUI::SQL->write("update template set name=".quote($session{form}{name}).",
|
||||
template=".quote($session{form}{template})."
|
||||
where templateId=".$session{form}{tid});
|
||||
return www_listTemplates();
|
||||
} else {
|
||||
return WebGUI::Privilege::adminOnly();
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_listTemplates {
|
||||
my ($output, $sth, @data, @row, $i, $p);
|
||||
my ($output, $sth, @data, @row, $i, $p, $where);
|
||||
if (WebGUI::Privilege::isInGroup($session{setting}{templateManagersGroup})) {
|
||||
$where = "where namespace=".quote($session{form}{namespace}) if ($session{form}{namespace});
|
||||
$output = helpIcon(33);
|
||||
$output .= '<h1>'.WebGUI::International::get(506).'</h1>';
|
||||
$output .= '<div align="center"><a href="'.WebGUI::URL::page('op=editTemplate&tid=new').
|
||||
'">'.WebGUI::International::get(505).'</a><p/></div>';
|
||||
$sth = WebGUI::SQL->read("select templateId,name from template order by name");
|
||||
$sth = WebGUI::SQL->read("select templateId,name,namespace from template $where order by namespace,name");
|
||||
while (@data = $sth->array) {
|
||||
$row[$i] = '<tr><td valign="top" class="tableData">'
|
||||
.deleteIcon('op=deleteTemplate&tid='.$data[0])
|
||||
.editIcon('op=editTemplate&tid='.$data[0])
|
||||
.copyIcon('op=copyTemplate&tid='.$data[0])
|
||||
.deleteIcon('op=deleteTemplate&tid='.$data[0].'&namespace='.$data[2])
|
||||
.editIcon('op=editTemplate&tid='.$data[0].'&namespace='.$data[2])
|
||||
.copyIcon('op=copyTemplate&tid='.$data[0].'&namespace='.$data[2])
|
||||
.'</td>';
|
||||
$row[$i] .= '<td valign="top" class="tableData">'.$data[1].'</td></tr>';
|
||||
$row[$i] .= '<td valign="top" class="tableData">'.$data[1].'</td>';
|
||||
$row[$i] .= '<td valign="top" class="tableData">'.$data[2].'</td></tr>';
|
||||
$i++;
|
||||
}
|
||||
$sth->finish;
|
||||
$p = WebGUI::Paginator->new(WebGUI::URL::page('op=listTemplates'),\@row);
|
||||
$p = WebGUI::Paginator->new(WebGUI::URL::page('op=listTemplates&namespace='.$session{form}{namespace}),\@row);
|
||||
$output .= '<table border=1 cellpadding=5 cellspacing=0 align="center">';
|
||||
$output .= $p->getPage($session{form}{pn});
|
||||
$output .= '</table>';
|
||||
$output .= $p->getBarTraditional($session{form}{pn});
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::adminOnly();
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ sub _newPositionFormat {
|
|||
#-------------------------------------------------------------------
|
||||
sub countPositions {
|
||||
my ($template, $i);
|
||||
($template) = WebGUI::SQL->quickArray("select template from template where templateId=".$_[0]);
|
||||
$template = get($_[0]);
|
||||
$i = 1;
|
||||
while ($template =~ m/template\.position$i/) {
|
||||
$i++;
|
||||
|
|
@ -48,7 +48,10 @@ sub draw {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub get {
|
||||
my ($template) = WebGUI::SQL->quickArray("select template from template where templateId=".$_[0]);
|
||||
my $templateId = $_[0] || 1;
|
||||
my $namespace = $_[1] || "Page";
|
||||
my ($template) = WebGUI::SQL->quickArray("select template from template
|
||||
where templateId=".$templateId." and namespace=".quote($namespace));
|
||||
$template =~ s/\^(\d+)\;/_newPositionFormat($1)/eg; #compatibility with old-style templates
|
||||
return $template;
|
||||
}
|
||||
|
|
@ -57,7 +60,7 @@ sub get {
|
|||
sub getList {
|
||||
my (%list);
|
||||
tie %list, 'Tie::IxHash';
|
||||
%list = WebGUI::SQL->buildHash("select templateId,name from template order by name");
|
||||
%list = WebGUI::SQL->buildHash("select templateId,name from template where namespace='Page' order by name");
|
||||
return \%list;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ use WebGUI::Template;
|
|||
use WebGUI::URL;
|
||||
use WebGUI::Utility;
|
||||
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::Wobject
|
||||
|
|
@ -451,13 +452,13 @@ sub moveCollateralUp {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 new ( hashRef )
|
||||
=head2 new ( properties )
|
||||
|
||||
Constructor.
|
||||
|
||||
NOTE: This method should never need to be overridden or extended.
|
||||
|
||||
=item hashRef
|
||||
=item properties
|
||||
|
||||
A hash reference containing at minimum "wobjectId" and "namespace"
|
||||
and wobjectId may be set to "new" if you're creating a new
|
||||
|
|
@ -472,7 +473,7 @@ sub moveCollateralUp {
|
|||
=cut
|
||||
|
||||
sub new {
|
||||
bless {_property => $_[1] }, $_[0];
|
||||
bless {_property => $_[1]}, $_[0];
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -722,6 +723,37 @@ sub setCollateral {
|
|||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 templateProperties
|
||||
|
||||
Returns a list of template properties.
|
||||
|
||||
=cut
|
||||
|
||||
sub templateProperties {
|
||||
my ($f, $templates, $templateId, $subtext);
|
||||
$templateId = $_[0]->get("templateId") || 1;
|
||||
if ($_[0]->get("wobjectId") ne "new" && $session{user}{uiLevel} >= 5) {
|
||||
$subtext = '<a href="'.WebGUI::URL::page("op=editTemplate&tid=".$templateId."&return="
|
||||
.WebGUI::URL::escape("func=edit&wid=".$_[0]->get("wobjectId"))).'">'
|
||||
.WebGUI::International::get(741).'</a> / <a href="'.WebGUI::URL::page("op=listTemplates").'">'
|
||||
.WebGUI::International::get(742).'</a>';
|
||||
}
|
||||
$templates = WebGUI::SQL->buildHashRef("select templateId,name from template where namespace="
|
||||
.quote($_[0]->get("namespace"))." order by name");
|
||||
$f = WebGUI::HTMLForm->new;
|
||||
$f->select(
|
||||
-name=>"templateId",
|
||||
-options=>$templates,
|
||||
-label=>WebGUI::International::get(740),
|
||||
-value=>[$templateId],
|
||||
-uiLevel=>1,
|
||||
-subtext=>$subtext
|
||||
);
|
||||
return $f->printRowsOnly;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 uiLevel
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ our @ISA = qw(WebGUI::Wobject);
|
|||
our $namespace = "Product";
|
||||
our $name = WebGUI::International::get(1,$namespace);
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub duplicate {
|
||||
my ($w, $file, %data, $newId, $sth);
|
||||
|
|
@ -180,17 +179,6 @@ sub www_addRelatedSave {
|
|||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_copyTemplate {
|
||||
return WebGUI::Privilege::insufficient() unless (WebGUI::Privilege::canEditPage());
|
||||
my (%data);
|
||||
tie %data, 'Tie::CPHash';
|
||||
%data = WebGUI::SQL->quickHash("select * from Product_template where Product_templateId=".$session{form}{tid});
|
||||
WebGUI::SQL->write("insert into Product_template values (".getNextId("Product_templateId").","
|
||||
.quote("Copy of ".$data{name}).",".quote($data{template}).")");
|
||||
return $_[0]->www_edit();
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deleteAccessory {
|
||||
return $_[0]->confirm(
|
||||
|
|
@ -271,36 +259,25 @@ sub www_deleteSpecificationConfirm {
|
|||
return "";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deleteTemplate {
|
||||
return $_[0]->confirm(
|
||||
WebGUI::International::get(57,$namespace),
|
||||
WebGUI::URL::page('func=deleteTemplateConfirm&wid='.$_[0]->get("wobjectId").'&tid='.$session{form}{tid}),
|
||||
'',
|
||||
($session{form}{tid} < 1000)
|
||||
);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deleteTemplateConfirm {
|
||||
return WebGUI::Privilege::insufficient() unless (WebGUI::Privilege::canEditPage());
|
||||
$_[0]->deleteCollateral("Product_template","Product_templateId",$session{form}{tid});
|
||||
WebGUI::SQL->write("update Product set Product_templateId=1 where Product_templateId=$session{form}{tid}");
|
||||
return $_[0]->www_edit();
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_edit {
|
||||
return WebGUI::Privilege::insufficient() unless (WebGUI::Privilege::canEditPage());
|
||||
my ($f, $output, $proceed, %data, $sth, $templates, $template);
|
||||
my ($f, $output, $template);
|
||||
$output = helpIcon(1,$namespace);
|
||||
$output .= '<h1>'.WebGUI::International::get(6,$namespace).'</h1>';
|
||||
if ($_[0]->get("wobjectId") eq "new") {
|
||||
$template = 1;
|
||||
} else {
|
||||
$template = $_[0]->get("Product_templateId");
|
||||
$template = $_[0]->get("templateId");
|
||||
}
|
||||
$f = WebGUI::HTMLForm->new;
|
||||
$f->template(
|
||||
-name=>"templateId",
|
||||
-value=>$template,
|
||||
-namespace=>$namespace,
|
||||
-label=>WebGUI::International::get(61,$namespace),
|
||||
-afterEdit=>'func=edit&wid='.$_[0]->get("wobjectId")
|
||||
);
|
||||
$f->text("price",WebGUI::International::get(10,$namespace),$_[0]->get("price"));
|
||||
$f->text("productNumber",WebGUI::International::get(11,$namespace),$_[0]->get("productNumber"));
|
||||
$f->raw($_[0]->fileProperty("image1",7));
|
||||
|
|
@ -309,23 +286,7 @@ sub www_edit {
|
|||
$f->raw($_[0]->fileProperty("brochure",13));
|
||||
$f->raw($_[0]->fileProperty("manual",14));
|
||||
$f->raw($_[0]->fileProperty("warranty",15));
|
||||
$templates = WebGUI::SQL->buildHashRef("select Product_templateId,name from Product_template order by name");
|
||||
$f->select("Product_templateId",$templates,WebGUI::International::get(61,$namespace),[$template]);
|
||||
$output .= $_[0]->SUPER::www_edit($f->printRowsOnly);
|
||||
unless ($_[0]->get("wobjectId") eq "new") {
|
||||
$output .= '<hr size="1" /><p>';
|
||||
$output .= '<a href="'.WebGUI::URL::page('func=editTemplate&tid=new&wid='.$_[0]->get("wobjectId")).'">'
|
||||
.WebGUI::International::get(56,$namespace).'</a><p>';
|
||||
tie %data, 'Tie::CPHash';
|
||||
$sth = WebGUI::SQL->read("select Product_templateId,name from Product_template order by name");
|
||||
while (%data = $sth->hash) {
|
||||
$output .= deleteIcon('func=deleteTemplate&wid='.$_[0]->get("wobjectId").'&tid='.$data{Product_templateId})
|
||||
.editIcon('func=editTemplate&wid='.$_[0]->get("wobjectId").'&tid='.$data{Product_templateId})
|
||||
.copyIcon('func=copyTemplate&wid='.$_[0]->get("wobjectId").'&tid='.$data{Product_templateId})
|
||||
.' '.$data{name}.'<br>';
|
||||
}
|
||||
$sth->finish;
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
|
@ -352,7 +313,7 @@ sub www_editSave {
|
|||
$file = WebGUI::Attachment->new("",$_[0]->get("wobjectId"));
|
||||
$file->save("warranty");
|
||||
$property{warranty}=$file->getFilename("warranty") if ($file->getFilename("warranty") ne "");
|
||||
$property{Product_templateId}=$session{form}{Product_templateId};
|
||||
$property{templateId}=$session{form}{templateId};
|
||||
$property{price}=$session{form}{price};
|
||||
$property{productNumber}=$session{form}{productNumber};
|
||||
$_[0]->SUPER::www_editSave(\%property);
|
||||
|
|
@ -470,35 +431,6 @@ sub www_editSpecificationSave {
|
|||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editTemplate {
|
||||
return WebGUI::Privilege::insufficient() unless (WebGUI::Privilege::canEditPage());
|
||||
my ($output, $data, $f);
|
||||
$data = $_[0]->getCollateral("Product_template","Product_templateId",$session{form}{tid});
|
||||
$output = helpIcon(7,$namespace);
|
||||
$output .= '<h1>'.WebGUI::International::get(58,$namespace).'</h1>';
|
||||
$f = WebGUI::HTMLForm->new;
|
||||
$f->hidden("wid",$_[0]->get("wobjectId"));
|
||||
$f->hidden("tid",$data->{Product_templateId});
|
||||
$f->hidden("func","editTemplateSave");
|
||||
$f->text("name",WebGUI::International::get(59,$namespace),$data->{name});
|
||||
$f->HTMLArea("template",WebGUI::International::get(60,$namespace),$data->{template},'','','',($session{setting}{textAreaRows}+10));
|
||||
$f->submit;
|
||||
$output .= $f->print;
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editTemplateSave {
|
||||
return WebGUI::Privilege::insufficient() unless (WebGUI::Privilege::canEditPage());
|
||||
$_[0]->setCollateral("Product_template", "Product_templateId", {
|
||||
Product_templateId => $session{form}{tid},
|
||||
name => $session{form}{name},
|
||||
template => $session{form}{template}
|
||||
}, 0, 0);
|
||||
return $_[0]->www_edit();
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_moveAccessoryDown {
|
||||
return WebGUI::Privilege::insufficient() unless (WebGUI::Privilege::canEditPage());
|
||||
|
|
@ -571,183 +503,158 @@ sub www_moveSpecificationUp {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_view {
|
||||
my ($output, %data, $sth, $file, $segment, $template);
|
||||
my ($output, %data, $sth, $file, $segment, $template, %var, @featureloop, @benefitloop, @specificationloop,
|
||||
@accessoryloop, @relatedloop);
|
||||
tie %data, 'Tie::CPHash';
|
||||
$output = $_[0]->displayTitle;
|
||||
($template) = WebGUI::SQL->quickArray("select template from Product_template where Product_templateId=".$_[0]->get("Product_templateId"));
|
||||
#---product title
|
||||
$segment = $_[0]->get("title");
|
||||
$template =~ s/\^Product_Title\;/$segment/;
|
||||
#---product description
|
||||
$segment = $_[0]->description;
|
||||
$template =~ s/\^Product_Description\;/$segment/;
|
||||
#---product price
|
||||
$segment = $_[0]->get("price");
|
||||
$template =~ s/\^Product_Price\;/$segment/;
|
||||
#---product number
|
||||
$segment = $_[0]->get("productNumber");
|
||||
$template =~ s/\^Product_Number\;/$segment/;
|
||||
#---product brochure
|
||||
$segment = "";
|
||||
#---brochure
|
||||
if ($_[0]->get("brochure")) {
|
||||
$file = WebGUI::Attachment->new($_[0]->get("brochure"),$_[0]->get("wobjectId"));
|
||||
$segment = '<a href="'.$file->getURL.'"><img src="'.$file->getIcon.'" border=0 align="absmiddle"> '
|
||||
$var{brochure} = '<a href="'.$file->getURL.'"><img src="'.$file->getIcon.'" border=0 align="absmiddle"> '
|
||||
.WebGUI::International::get(13,$namespace).'</a>';
|
||||
$var{brochureURL} = $file->getURL;
|
||||
}
|
||||
$template =~ s/\^Product_Brochure\;/$segment/;
|
||||
#---product manual
|
||||
$segment = "";
|
||||
#---manual
|
||||
if ($_[0]->get("manual")) {
|
||||
$file = WebGUI::Attachment->new($_[0]->get("manual"),$_[0]->get("wobjectId"));
|
||||
$segment = '<a href="'.$file->getURL.'"><img src="'.$file->getIcon.'" border=0 align="absmiddle"> '
|
||||
$var{manual} = '<a href="'.$file->getURL.'"><img src="'.$file->getIcon.'" border=0 align="absmiddle"> '
|
||||
.WebGUI::International::get(14,$namespace).'</a>';
|
||||
$var{manualURL} = $file->getURL;
|
||||
}
|
||||
$template =~ s/\^Product_Manual\;/$segment/;
|
||||
#---product warranty
|
||||
$segment = "";
|
||||
#---warranty
|
||||
if ($_[0]->get("warranty")) {
|
||||
$file = WebGUI::Attachment->new($_[0]->get("warranty"),$_[0]->get("wobjectId"));
|
||||
$segment = '<a href="'.$file->getURL.'"><img src="'.$file->getIcon.'" border=0 align="absmiddle"> '
|
||||
$var{warranty} = '<a href="'.$file->getURL.'"><img src="'.$file->getIcon.'" border=0 align="absmiddle"> '
|
||||
.WebGUI::International::get(15,$namespace).'</a>';
|
||||
$var{warrantyURL} = $file->getURL;
|
||||
}
|
||||
$template =~ s/\^Product_Warranty\;/$segment/;
|
||||
#---product thumbnail1
|
||||
$segment = "";
|
||||
#---image1
|
||||
if ($_[0]->get("image1")) {
|
||||
$file = WebGUI::Attachment->new($_[0]->get("image1"),$_[0]->get("wobjectId"));
|
||||
$segment = '<a href="'.$file->getURL.'"><img src="'.$file->getThumbnail.'" border=0></a>';
|
||||
$var{image1} = '<img src="'.$file->getURL.'" border=0>';
|
||||
$var{image1thumbnail} = '<a href="'.$file->getURL.'"><img src="'.$file->getThumbnail.'" border=0></a>';
|
||||
$var{image1url} = $file->getURL;
|
||||
}
|
||||
$template =~ s/\^Product_Thumbnail1\;/$segment/;
|
||||
#---product thumbnail2
|
||||
$segment = "";
|
||||
#---image2
|
||||
if ($_[0]->get("image2")) {
|
||||
$file = WebGUI::Attachment->new($_[0]->get("image2"),$_[0]->get("wobjectId"));
|
||||
$segment = '<a href="'.$file->getURL.'"><img src="'.$file->getThumbnail.'" border=0></a>';
|
||||
$var{image2} = '<img src="'.$file->getURL.'" border=0>';
|
||||
$var{image2thumbnail} = '<a href="'.$file->getURL.'"><img src="'.$file->getThumbnail.'" border=0></a>';
|
||||
$var{image2url} = $file->getURL;
|
||||
}
|
||||
$template =~ s/\^Product_Thumbnail2\;/$segment/;
|
||||
#---product thumbnail3
|
||||
$segment = "";
|
||||
#---image3
|
||||
if ($_[0]->get("image3")) {
|
||||
$file = WebGUI::Attachment->new($_[0]->get("image3"),$_[0]->get("wobjectId"));
|
||||
$segment = '<a href="'.$file->getURL.'"><img src="'.$file->getThumbnail.'" border=0></a>';
|
||||
$var{image3} = '<img src="'.$file->getURL.'" border=0>';
|
||||
$var{image3thumbnail} = '<a href="'.$file->getURL.'"><img src="'.$file->getThumbnail.'" border=0></a>';
|
||||
$var{image3url} = $file->getURL;
|
||||
}
|
||||
$template =~ s/\^Product_Thumbnail3\;/$segment/;
|
||||
#---product image1
|
||||
$segment = "";
|
||||
if ($_[0]->get("image1")) {
|
||||
$file = WebGUI::Attachment->new($_[0]->get("image1"),$_[0]->get("wobjectId"));
|
||||
$segment = '<img src="'.$file->getURL.'" border=0>';
|
||||
}
|
||||
$template =~ s/\^Product_Image1\;/$segment/;
|
||||
#---product image2
|
||||
$segment = "";
|
||||
if ($_[0]->get("image2")) {
|
||||
$file = WebGUI::Attachment->new($_[0]->get("image2"),$_[0]->get("wobjectId"));
|
||||
$segment = '<img src="'.$file->getURL.'" border=0>';
|
||||
}
|
||||
$template =~ s/\^Product_Image2\;/$segment/;
|
||||
#---product image3
|
||||
$segment = "";
|
||||
if ($_[0]->get("image3")) {
|
||||
$file = WebGUI::Attachment->new($_[0]->get("image3"),$_[0]->get("wobjectId"));
|
||||
$segment = '<img src="'.$file->getURL.'" border=0>';
|
||||
}
|
||||
$template =~ s/\^Product_Image3\;/$segment/;
|
||||
#---product features
|
||||
$segment = "";
|
||||
$sth = WebGUI::SQL->read("select feature,Product_featureId from Product_feature where wobjectId=".$_[0]->get("wobjectId")." order by sequenceNumber");
|
||||
|
||||
#---features
|
||||
if ($session{var}{adminOn}) {
|
||||
$segment .= '<a href="'.WebGUI::URL::page('func=editFeature&fid=new&wid='
|
||||
.$_[0]->get("wobjectId")).'">'.WebGUI::International::get(34,$namespace).'</a><p/>';
|
||||
$var{addFeature} = '<a href="'.WebGUI::URL::page('func=editFeature&fid=new&wid='
|
||||
.$_[0]->get("wobjectId")).'">'.WebGUI::International::get(34,$namespace).'</a>';
|
||||
}
|
||||
$sth = WebGUI::SQL->read("select feature,Product_featureId from Product_feature where wobjectId="
|
||||
.$_[0]->get("wobjectId")." order by sequenceNumber");
|
||||
while (%data = $sth->hash) {
|
||||
if ($session{var}{adminOn}) {
|
||||
$segment .= deleteIcon('func=deleteFeature&wid='.$_[0]->get("wobjectId").'&fid='.$data{Product_featureId})
|
||||
$segment = deleteIcon('func=deleteFeature&wid='.$_[0]->get("wobjectId").'&fid='.$data{Product_featureId})
|
||||
.editIcon('func=editFeature&wid='.$_[0]->get("wobjectId").'&fid='.$data{Product_featureId})
|
||||
.moveUpIcon('func=moveFeatureUp&wid='.$_[0]->get("wobjectId").'&fid='.$data{Product_featureId})
|
||||
.moveDownIcon('func=moveFeatureDown&wid='.$_[0]->get("wobjectId").'&fid='.$data{Product_featureId});
|
||||
}
|
||||
$segment .= '·'.$data{feature}.'<br>';
|
||||
push(@featureloop,{feature=>$data{feature},featureId=>$data{Product_featureId},controls=>$segment});
|
||||
}
|
||||
$sth->finish;
|
||||
$template =~ s/\^Product_Features\;/$segment/;
|
||||
#---product benefits
|
||||
$segment = "";
|
||||
$sth = WebGUI::SQL->read("select benefit,Product_benefitId from Product_benefit where wobjectId=".$_[0]->get("wobjectId")." order by sequenceNumber");
|
||||
$var{feature_loop} = \@featureloop;
|
||||
|
||||
#---benefits
|
||||
if ($session{var}{adminOn}) {
|
||||
$segment .= '<a href="'.WebGUI::URL::page('func=editBenefit&fid=new&wid='
|
||||
$var{addBenefit} = '<a href="'.WebGUI::URL::page('func=editBenefit&fid=new&wid='
|
||||
.$_[0]->get("wobjectId")).'">'.WebGUI::International::get(55,$namespace).'</a><p/>';
|
||||
}
|
||||
$sth = WebGUI::SQL->read("select benefit,Product_benefitId from Product_benefit where wobjectId="
|
||||
.$_[0]->get("wobjectId")." order by sequenceNumber");
|
||||
while (%data = $sth->hash) {
|
||||
if ($session{var}{adminOn}) {
|
||||
$segment .= deleteIcon('func=deleteBenefit&wid='.$_[0]->get("wobjectId").'&bid='.$data{Product_benefitId})
|
||||
$segment = deleteIcon('func=deleteBenefit&wid='.$_[0]->get("wobjectId").'&bid='.$data{Product_benefitId})
|
||||
.editIcon('func=editBenefit&wid='.$_[0]->get("wobjectId").'&bid='.$data{Product_benefitId})
|
||||
.moveUpIcon('func=moveBenefitUp&wid='.$_[0]->get("wobjectId").'&bid='.$data{Product_benefitId})
|
||||
.moveDownIcon('func=moveBenefitDown&wid='.$_[0]->get("wobjectId").'&bid='.$data{Product_benefitId});
|
||||
}
|
||||
$segment.= '·'.$data{benefit}.'<br>';
|
||||
push(@benefitloop,{benefit=>$data{benefit},benefitId=>$data{Product_benefitId},controls=>$segment});
|
||||
}
|
||||
$sth->finish;
|
||||
$template =~ s/\^Product_Benefits\;/$segment/;
|
||||
#---product specifications
|
||||
$segment = "";
|
||||
$sth = WebGUI::SQL->read("select name,value,units,Product_specificationId from Product_specification
|
||||
where wobjectId=".$_[0]->get("wobjectId")." order by sequenceNumber");
|
||||
$var{benefit_loop} = \@benefitloop;
|
||||
|
||||
#---specifications
|
||||
if ($session{var}{adminOn}) {
|
||||
$segment .= '<a href="'.WebGUI::URL::page('func=editSpecification&sid=new&wid='
|
||||
$var{addSpecification} = '<a href="'.WebGUI::URL::page('func=editSpecification&sid=new&wid='
|
||||
.$_[0]->get("wobjectId")).'">'.WebGUI::International::get(35,$namespace).'</a><p/>';
|
||||
}
|
||||
$sth = WebGUI::SQL->read("select name,value,units,Product_specificationId from Product_specification
|
||||
where wobjectId=".$_[0]->get("wobjectId")." order by sequenceNumber");
|
||||
while (%data = $sth->hash) {
|
||||
if ($session{var}{adminOn}) {
|
||||
$segment .= deleteIcon('func=deleteSpecification&wid='.$_[0]->get("wobjectId").'&sid='.$data{Product_specificationId})
|
||||
$segment = deleteIcon('func=deleteSpecification&wid='.$_[0]->get("wobjectId").'&sid='.$data{Product_specificationId})
|
||||
.editIcon('func=editSpecification&wid='.$_[0]->get("wobjectId").'&sid='.$data{Product_specificationId})
|
||||
.moveUpIcon('func=moveSpecificationUp&wid='.$_[0]->get("wobjectId").'&sid='.$data{Product_specificationId})
|
||||
.moveDownIcon('func=moveSpecificationDown&wid='.$_[0]->get("wobjectId").'&sid='.$data{Product_specificationId});
|
||||
}
|
||||
$segment .= '·<b>'.$data{name}.':</b> '.$data{value}.' '.$data{units}.'<br>';
|
||||
push(@specificationloop,{specificationId=>$data{Product_specificationId},
|
||||
controls=>$segment,specification=>$data{value},units=>$data{units},label=>$data{name}});
|
||||
}
|
||||
$sth->finish;
|
||||
$template =~ s/\^Product_Specifications\;/$segment/;
|
||||
#---product accessories
|
||||
$segment = "";
|
||||
$sth = WebGUI::SQL->read("select wobject.title,page.urlizedTitle,Product_accessory.accessoryWobjectId from Product_accessory,wobject,page
|
||||
where Product_accessory.wobjectId=".$_[0]->get("wobjectId")."
|
||||
and Product_accessory.accessoryWobjectId=wobject.wobjectId and wobject.pageId=page.pageId order by Product_accessory.sequenceNumber");
|
||||
$var{specification_loop} = \@specificationloop;
|
||||
|
||||
#---accessories
|
||||
if ($session{var}{adminOn}) {
|
||||
$segment .= '<a href="'.WebGUI::URL::page('func=addAccessory&wid='
|
||||
$var{addaccessory} = '<a href="'.WebGUI::URL::page('func=addAccessory&wid='
|
||||
.$_[0]->get("wobjectId")).'">'.WebGUI::International::get(36,$namespace).'</a><p/>';
|
||||
}
|
||||
$sth = WebGUI::SQL->read("select wobject.title,page.urlizedTitle,Product_accessory.accessoryWobjectId
|
||||
from Product_accessory,wobject,page
|
||||
where Product_accessory.wobjectId=".$_[0]->get("wobjectId")."
|
||||
and Product_accessory.accessoryWobjectId=wobject.wobjectId
|
||||
and wobject.pageId=page.pageId order by Product_accessory.sequenceNumber");
|
||||
while (%data = $sth->hash) {
|
||||
if ($session{var}{adminOn}) {
|
||||
$segment .= deleteIcon('func=deleteAccessory&wid='.$_[0]->get("wobjectId").'&aid='.$data{accessoryWobjectId})
|
||||
$segment = deleteIcon('func=deleteAccessory&wid='.$_[0]->get("wobjectId").'&aid='.$data{accessoryWobjectId})
|
||||
.moveUpIcon('func=moveAccessoryUp&wid='.$_[0]->get("wobjectId").'&aid='.$data{accessoryWobjectId})
|
||||
.moveDownIcon('func=moveAccessoryDown&wid='.$_[0]->get("wobjectId").'&aid='.$data{accessoryWobjectId});
|
||||
}
|
||||
$segment .= '·<a href="'.WebGUI::URL::gateway($data{urlizedTitle}).'">'.$data{title}.'</a><br>';
|
||||
push(@accessoryloop,{URL=>WebGUI::URL::gateway($data{urlizedTitle}),title=>$data{title},
|
||||
accessory=>'<a href="'.WebGUI::URL::gateway($data{urlizedTitle}).'">'.$data{title}.'</a>',
|
||||
controls=>$segment});
|
||||
}
|
||||
$sth->finish;
|
||||
$template =~ s/\^Product_Accessories\;/$segment/;
|
||||
#---product related
|
||||
$segment = "";
|
||||
$sth = WebGUI::SQL->read("select wobject.title,page.urlizedTitle,Product_related.relatedWobjectId from Product_related,wobject,page
|
||||
where Product_related.wobjectId=".$_[0]->get("wobjectId")."
|
||||
and Product_related.relatedWobjectId=wobject.wobjectId and wobject.pageId=page.pageId order by Product_related.sequenceNumber");
|
||||
$var{accessory_loop} = \@accessoryloop;
|
||||
|
||||
#---related
|
||||
if ($session{var}{adminOn}) {
|
||||
$segment .= '<a href="'.WebGUI::URL::page('func=addRelated&wid='
|
||||
$var{addrelatedproduct} = '<a href="'.WebGUI::URL::page('func=addRelated&wid='
|
||||
.$_[0]->get("wobjectId")).'">'.WebGUI::International::get(37,$namespace).'</a><p/>';
|
||||
}
|
||||
}
|
||||
$sth = WebGUI::SQL->read("select wobject.title,page.urlizedTitle,Product_related.relatedWobjectId
|
||||
from Product_related,wobject,page
|
||||
where Product_related.wobjectId=".$_[0]->get("wobjectId")."
|
||||
and Product_related.relatedWobjectId=wobject.wobjectId
|
||||
and wobject.pageId=page.pageId order by Product_related.sequenceNumber");
|
||||
while (%data = $sth->hash) {
|
||||
if ($session{var}{adminOn}) {
|
||||
$segment .= deleteIcon('func=deleteRelated&wid='.$_[0]->get("wobjectId").'&rid='.$data{relatedWobjectId})
|
||||
$segment = deleteIcon('func=deleteRelated&wid='.$_[0]->get("wobjectId").'&rid='.$data{relatedWobjectId})
|
||||
.moveUpIcon('func=moveRelatedUp&wid='.$_[0]->get("wobjectId").'&rid='.$data{relatedWobjectId})
|
||||
.moveDownIcon('func=moveRelatedDown&wid='.$_[0]->get("wobjectId").'&rid='.$data{relatedWobjectId});
|
||||
}
|
||||
$segment .= '·<a href="'.WebGUI::URL::gateway($data{urlizedTitle}).'">'.$data{title}.'</a><br>';
|
||||
push(@relatedloop,{URL=>WebGUI::URL::gateway($data{urlizedTitle}),title=>$data{title},
|
||||
specification=>'<a href="'.WebGUI::URL::gateway($data{urlizedTitle}).'">'.$data{title}.'</a>',
|
||||
controls=>$segment});
|
||||
}
|
||||
$sth->finish;
|
||||
$template =~ s/\^Product_Related\;/$segment/;
|
||||
$output .= $template;
|
||||
return $_[0]->processMacros($output);
|
||||
$var{relatedproduct_loop} = \@relatedloop;
|
||||
return $_[0]->processMacros($_[0]->processTemplate($_[0]->get("templateId"),\%var));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue