Formatting and general code cleanup to reduce redundancy and increase readability.
This commit is contained in:
parent
d309be32f5
commit
65de90cbb5
17 changed files with 910 additions and 1103 deletions
|
|
@ -59,130 +59,114 @@ sub set {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deleteLink {
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
return $_[0]->confirm(WebGUI::International::get(9,$namespace),
|
||||
WebGUI::URL::page('func=deleteLinkConfirm&wid='.$session{form}{wid}.'&lid='.$session{form}{lid}));
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
return WebGUI::Privilege::insufficient() unless (WebGUI::Privilege::canEditPage());
|
||||
return $_[0]->confirm(WebGUI::International::get(9,$namespace),
|
||||
WebGUI::URL::page('func=deleteLinkConfirm&wid='.$session{form}{wid}.'&lid='.$session{form}{lid}));
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deleteLinkConfirm {
|
||||
my ($output);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
$_[0]->deleteCollateral("LinkList_link","linkId",$session{form}{lid});
|
||||
$_[0]->reorderCollateral("LinkList_link","linkId");
|
||||
return "";
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
return WebGUI::Privilege::insufficient() unless (WebGUI::Privilege::canEditPage());
|
||||
$_[0]->deleteCollateral("LinkList_link","linkId",$session{form}{lid});
|
||||
$_[0]->reorderCollateral("LinkList_link","linkId");
|
||||
return "";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_edit {
|
||||
return WebGUI::Privilege::insufficient() unless (WebGUI::Privilege::canEditPage());
|
||||
my ($proceed, $f, $output, $indent, $lineSpacing, $bullet);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
if ($_[0]->get("wobjectId") eq "new") {
|
||||
$proceed = 1;
|
||||
}
|
||||
$bullet = $_[0]->get("bullet") || '·';
|
||||
$lineSpacing = $_[0]->get("lineSpacing") || 1;
|
||||
$indent = $_[0]->get("indent") || 5;
|
||||
$output = helpIcon(1,$namespace);
|
||||
$output .= '<h1>'.WebGUI::International::get(10,$namespace).'</h1>';
|
||||
$f = WebGUI::HTMLForm->new;
|
||||
$f->integer("indent",WebGUI::International::get(1,$namespace),$indent);
|
||||
$f->integer("lineSpacing",WebGUI::International::get(2,$namespace),$lineSpacing);
|
||||
$f->text("bullet",WebGUI::International::get(4,$namespace),$bullet);
|
||||
$f->yesNo("proceed",WebGUI::International::get(5,$namespace),$proceed);
|
||||
$output .= $_[0]->SUPER::www_edit($f->printRowsOnly);
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
if ($_[0]->get("wobjectId") eq "new") {
|
||||
$proceed = 1;
|
||||
}
|
||||
$bullet = $_[0]->get("bullet") || '·';
|
||||
$lineSpacing = $_[0]->get("lineSpacing") || 1;
|
||||
$indent = $_[0]->get("indent") || 5;
|
||||
$output = helpIcon(1,$namespace);
|
||||
$output .= '<h1>'.WebGUI::International::get(10,$namespace).'</h1>';
|
||||
$f = WebGUI::HTMLForm->new;
|
||||
$f->integer("indent",WebGUI::International::get(1,$namespace),$indent);
|
||||
$f->integer("lineSpacing",WebGUI::International::get(2,$namespace),$lineSpacing);
|
||||
$f->text("bullet",WebGUI::International::get(4,$namespace),$bullet);
|
||||
$f->yesNo("proceed",WebGUI::International::get(5,$namespace),$proceed);
|
||||
$output .= $_[0]->SUPER::www_edit($f->printRowsOnly);
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editSave {
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
$_[0]->SUPER::www_editSave();
|
||||
$_[0]->set({
|
||||
indent=>$session{form}{indent},
|
||||
bullet=>$session{form}{bullet},
|
||||
lineSpacing=>$session{form}{lineSpacing}
|
||||
});
|
||||
if ($session{form}{proceed}) {
|
||||
$_[0]->www_editLink();
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
return WebGUI::Privilege::insufficient() unless (WebGUI::Privilege::canEditPage());
|
||||
$_[0]->SUPER::www_editSave();
|
||||
$_[0]->set({
|
||||
indent=>$session{form}{indent},
|
||||
bullet=>$session{form}{bullet},
|
||||
lineSpacing=>$session{form}{lineSpacing}
|
||||
});
|
||||
if ($session{form}{proceed}) {
|
||||
$_[0]->www_editLink();
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editLink {
|
||||
return WebGUI::Privilege::insufficient() unless (WebGUI::Privilege::canEditPage());
|
||||
my ($output, %link, $f, $linkId, $newWindow);
|
||||
tie %link, 'Tie::CPHash';
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
$linkId = $session{form}{lid} || "new";
|
||||
%link = WebGUI::SQL->quickHash("select * from LinkList_link where linkId='$session{form}{lid}'");
|
||||
if ($linkId eq "new") {
|
||||
$newWindow = 1;
|
||||
} else {
|
||||
$newWindow = $link{newWindow};
|
||||
}
|
||||
$output = helpIcon(2,$namespace);
|
||||
$output .= '<h1>'.WebGUI::International::get(12,$namespace).'</h1>';
|
||||
$f = WebGUI::HTMLForm->new;
|
||||
$f->hidden("wid",$_[0]->get("wobjectId"));
|
||||
$f->hidden("lid",$linkId);
|
||||
$f->hidden("func","editLinkSave");
|
||||
$f->text("name",WebGUI::International::get(99),$link{name});
|
||||
$f->url("url",WebGUI::International::get(8,$namespace),$link{url});
|
||||
$f->yesNo("newWindow",WebGUI::International::get(3,$namespace),$newWindow);
|
||||
$f->textarea("description",WebGUI::International::get(85),$link{description});
|
||||
$f->yesNo("proceed",WebGUI::International::get(5,$namespace));
|
||||
$f->submit;
|
||||
$output .= $f->print;
|
||||
return $output;
|
||||
$linkId = $session{form}{lid} || "new";
|
||||
%link = WebGUI::SQL->quickHash("select * from LinkList_link where linkId='$session{form}{lid}'");
|
||||
if ($linkId eq "new") {
|
||||
$newWindow = 1;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
$newWindow = $link{newWindow};
|
||||
}
|
||||
$output = helpIcon(2,$namespace);
|
||||
$output .= '<h1>'.WebGUI::International::get(12,$namespace).'</h1>';
|
||||
$f = WebGUI::HTMLForm->new;
|
||||
$f->hidden("wid",$_[0]->get("wobjectId"));
|
||||
$f->hidden("lid",$linkId);
|
||||
$f->hidden("func","editLinkSave");
|
||||
$f->text("name",WebGUI::International::get(99),$link{name});
|
||||
$f->url("url",WebGUI::International::get(8,$namespace),$link{url});
|
||||
$f->yesNo("newWindow",WebGUI::International::get(3,$namespace),$newWindow);
|
||||
$f->textarea("description",WebGUI::International::get(85),$link{description});
|
||||
$f->yesNo("proceed",WebGUI::International::get(5,$namespace));
|
||||
$f->submit;
|
||||
$output .= $f->print;
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editLinkSave {
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
$_[0]->setCollateral("LinkList_link", "linkId", {
|
||||
linkId => $session{form}{lid},
|
||||
description => $session{form}{description},
|
||||
newWindow => $session{form}{newWindow},
|
||||
url => $session{form}{url},
|
||||
name => $session{form}{name}
|
||||
});
|
||||
if ($session{form}{proceed}) {
|
||||
$session{form}{lid} = "new";
|
||||
$_[0]->www_editLink();
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
return WebGUI::Privilege::insufficient() unless (WebGUI::Privilege::canEditPage());
|
||||
$_[0]->setCollateral("LinkList_link", "linkId", {
|
||||
linkId => $session{form}{lid},
|
||||
description => $session{form}{description},
|
||||
newWindow => $session{form}{newWindow},
|
||||
url => $session{form}{url},
|
||||
name => $session{form}{name}
|
||||
});
|
||||
if ($session{form}{proceed}) {
|
||||
$session{form}{lid} = "new";
|
||||
return $_[0]->www_editLink();
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_moveLinkDown {
|
||||
return WebGUI::Privilege::insufficient() unless (WebGUI::Privilege::canEditPage());
|
||||
$_[0]->moveCollateralDown("LinkList_link","linkId",$session{form}{lid});
|
||||
return "";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_moveLinkUp {
|
||||
return WebGUI::Privilege::insufficient() unless (WebGUI::Privilege::canEditPage());
|
||||
$_[0]->moveCollateralUp("LinkList_link","linkId",$session{form}{lid});
|
||||
return "";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue