diff --git a/docs/upgrades/upgrade_4.6.9-4.7.0.sql b/docs/upgrades/upgrade_4.6.9-4.7.0.sql
index 335307165..0b76213d9 100644
--- a/docs/upgrades/upgrade_4.6.9-4.7.0.sql
+++ b/docs/upgrades/upgrade_4.6.9-4.7.0.sql
@@ -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);
diff --git a/lib/WebGUI.pm b/lib/WebGUI.pm
index 0f5f1867f..8cb0ab2ba 100644
--- a/lib/WebGUI.pm
+++ b/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
"
- .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
"
- .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})
- .'
';
- }
- 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}} .= '';
- $contentHash{"template.position".${$wobject}{templatePosition}} .= '
';
- $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}} .= "
\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 = ''.$session{debug}{warning}.'
';
- $debug .= ''.$session{debug}{security}.'
';
- $debug .= ''.$session{debug}{audit}.'
';
+ $debug = ''.$session{debug}{warning}.'
';
+ $debug .= ''.$session{debug}{security}.'
';
+ $debug .= ''.$session{debug}{audit}.'
';
$debug .= '';
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 .= '| '.$section.'.'.$key.': | '.$value.' | ';
- }
+ unless (lc($key) eq "password" || lc($key) eq "identifier") {
+ $debug .= '
| '.$section.'.'.$key.': | '.$value.' | ';
+ }
}
$debug .= '
| |   |
';
}
$debug .='
';
+ }
+ 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
"
+ .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
"
+ .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})
+ .'
';
+ }
+ 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}} .= '';
+ $contentHash{"template.position".${$wobject}{templatePosition}} .= '
';
+ $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}} .= "
\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();
}
diff --git a/lib/WebGUI/Form.pm b/lib/WebGUI/Form.pm
index e74552af1..180904a98 100644
--- a/lib/WebGUI/Form.pm
+++ b/lib/WebGUI/Form.pm
@@ -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.
diff --git a/lib/WebGUI/HTMLForm.pm b/lib/WebGUI/HTMLForm.pm
index 55a316e45..69fb8f4d0 100644
--- a/lib/WebGUI/HTMLForm.pm
+++ b/lib/WebGUI/HTMLForm.pm
@@ -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 = ''.WebGUI::International::get(741).' / ';
+ }
+ $subtext .= ''
+ .WebGUI::International::get(742).'';
+ $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.
diff --git a/lib/WebGUI/Operation/Page.pm b/lib/WebGUI/Operation/Page.pm
index 7f5162a56..98dac65ad 100644
--- a/lib/WebGUI/Operation/Page.pm
+++ b/lib/WebGUI/Operation/Page.pm
@@ -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=>' '.WebGUI::International::get(107).' |
',
-uiLevel=>9
diff --git a/lib/WebGUI/Operation/Template.pm b/lib/WebGUI/Operation/Template.pm
index 2228cf171..c9553c274 100644
--- a/lib/WebGUI/Operation/Template.pm
+++ b/lib/WebGUI/Operation/Template.pm
@@ -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 .= ''.WebGUI::International::get(42).'
';
$output .= WebGUI::International::get(502).'';
$output .= '
';
+ $output .= ' '.WebGUI::International::get(45).'';
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} = "\n";
+ if ($session{form}{namespace} eq "Page") {
+ $template{template} = "\n \n | \n\n\n\n".
+ " | \n
\n
\n";
+ } else {
+ $template{template} = "
\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 .= ''.WebGUI::International::get(507).'
';
$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} = "\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} = "\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 .= ''.WebGUI::International::get(506).'
';
$output .= '';
- $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] = '| '
- .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])
.' | ';
- $row[$i] .= ''.$data[1].' |
';
+ $row[$i] .= ''.$data[1].' | ';
+ $row[$i] .= ''.$data[2].' | ';
$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 .= '';
$output .= $p->getPage($session{form}{pn});
$output .= '
';
$output .= $p->getBarTraditional($session{form}{pn});
return $output;
} else {
- return WebGUI::Privilege::adminOnly();
+ return WebGUI::Privilege::insufficient();
}
}
diff --git a/lib/WebGUI/Template.pm b/lib/WebGUI/Template.pm
index b2a8cb9d8..48ee08601 100644
--- a/lib/WebGUI/Template.pm
+++ b/lib/WebGUI/Template.pm
@@ -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;
}
diff --git a/lib/WebGUI/Wobject.pm b/lib/WebGUI/Wobject.pm
index 5e5c46ff5..d370eee1d 100644
--- a/lib/WebGUI/Wobject.pm
+++ b/lib/WebGUI/Wobject.pm
@@ -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 = 'get("wobjectId"))).'">'
+ .WebGUI::International::get(741).' / '
+ .WebGUI::International::get(742).'';
+ }
+ $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
diff --git a/lib/WebGUI/Wobject/Product.pm b/lib/WebGUI/Wobject/Product.pm
index 07059061c..32e0cbf11 100644
--- a/lib/WebGUI/Wobject/Product.pm
+++ b/lib/WebGUI/Wobject/Product.pm
@@ -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 .= ''.WebGUI::International::get(6,$namespace).'
';
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 .= '
';
- $output .= ''
- .WebGUI::International::get(56,$namespace).'
';
- 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}.'
';
- }
- $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 .= '
'.WebGUI::International::get(58,$namespace).'
';
- $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 = '
'
+ $var{brochure} = '
'
.WebGUI::International::get(13,$namespace).'';
+ $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 = '
'
+ $var{manual} = '
'
.WebGUI::International::get(14,$namespace).'';
+ $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 = '
'
+ $var{warranty} = '
'
.WebGUI::International::get(15,$namespace).'';
+ $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 = '
';
+ $var{image1} = '
';
+ $var{image1thumbnail} = '
';
+ $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 = '
';
+ $var{image2} = '
';
+ $var{image2thumbnail} = '
';
+ $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 = '
';
+ $var{image3} = '
';
+ $var{image3thumbnail} = '
';
+ $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 = '
';
- }
- $template =~ s/\^Product_Image1\;/$segment/;
- #---product image2
- $segment = "";
- if ($_[0]->get("image2")) {
- $file = WebGUI::Attachment->new($_[0]->get("image2"),$_[0]->get("wobjectId"));
- $segment = '
';
- }
- $template =~ s/\^Product_Image2\;/$segment/;
- #---product image3
- $segment = "";
- if ($_[0]->get("image3")) {
- $file = WebGUI::Attachment->new($_[0]->get("image3"),$_[0]->get("wobjectId"));
- $segment = '
';
- }
- $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 .= ''.WebGUI::International::get(34,$namespace).'';
+ $var{addFeature} = ''.WebGUI::International::get(34,$namespace).'';
}
+ $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}.'
';
+ 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 .= 'get("wobjectId")).'">'.WebGUI::International::get(55,$namespace).'';
}
+ $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}.'
';
+ 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 .= 'get("wobjectId")).'">'.WebGUI::International::get(35,$namespace).'';
}
+ $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 .= '·'.$data{name}.': '.$data{value}.' '.$data{units}.'
';
+ 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 .= 'get("wobjectId")).'">'.WebGUI::International::get(36,$namespace).'';
}
+ $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 .= '·'.$data{title}.'
';
+ push(@accessoryloop,{URL=>WebGUI::URL::gateway($data{urlizedTitle}),title=>$data{title},
+ accessory=>''.$data{title}.'',
+ 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 .= 'get("wobjectId")).'">'.WebGUI::International::get(37,$namespace).'';
- }
+ }
+ $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 .= '·'.$data{title}.'
';
+ push(@relatedloop,{URL=>WebGUI::URL::gateway($data{urlizedTitle}),title=>$data{title},
+ specification=>''.$data{title}.'',
+ 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));
}