Fix bug in Operation/Help.pm that would infinitely recurse if a Help

entry had an ISA entry from its own namespace.
Final adjustments to Collaboration Help.
This commit is contained in:
Colin Kuskie 2006-06-18 05:52:06 +00:00
parent 000c35022b
commit 837b18d310
3 changed files with 573 additions and 297 deletions

View file

@ -203,6 +203,197 @@ our $HELP = {
'collaboration template labels' => {
title => 'collaboration template labels title',
body => 'collaboration template labels body',
variables => [
{
'name' => 'add.label'
},
{
'name' => 'addlink.label'
},
{
'name' => 'addquestion.label'
},
{
'name' => 'answer.label'
},
{
'name' => 'attachment.label'
},
{
'name' => 'by.label'
},
{
'name' => 'body.label'
},
{
'name' => 'back.label'
},
{
'name' => 'compensation.label'
},
{
'name' => 'open.label'
},
{
'name' => 'close.label'
},
{
'name' => 'closed.label'
},
{
'name' => 'critical.label'
},
{
'name' => 'minor.label'
},
{
'name' => 'cosmetic.label'
},
{
'name' => 'fatal.label'
},
{
'name' => 'severity.label'
},
{
'name' => 'date.label'
},
{
'name' => 'delete.label'
},
{
'name' => 'description.label'
},
{
'name' => 'edit.label'
},
{
'name' => 'image.label'
},
{
'name' => 'job.header.label'
},
{
'name' => 'job.title.label'
},
{
'name' => 'job.description.label'
},
{
'name' => 'job.requirements.label'
},
{
'name' => 'location.label'
},
{
'name' => 'layout.flat.label'
},
{
'name' => 'link.header.label'
},
{
'name' => 'lastReply.label'
},
{
'name' => 'lock.label'
},
{
'name' => 'layout.label'
},
{
'name' => 'message.header.label'
},
{
'name' => 'message.label'
},
{
'name' => 'next.label'
},
{
'name' => 'newWindow.label'
},
{
'name' => 'layout.nested.label'
},
{
'name' => 'previous.label'
},
{
'name' => 'post.label'
},
{
'name' => 'question.label'
},
{
'name' => 'question.header.label'
},
{
'name' => 'rating.label'
},
{
'name' => 'rate.label'
},
{
'name' => 'reply.label'
},
{
'name' => 'replies.label'
},
{
'name' => 'readmore.label'
},
{
'name' => 'responses.label'
},
{
'name' => 'search.label'
},
{
'name' => 'subject.label'
},
{
'name' => 'subscribe.label'
},
{
'name' => 'submission.header.label'
},
{
'name' => 'stick.label'
},
{
'name' => 'status.label'
},
{
'name' => 'synopsis.label'
},
{
'name' => 'thumbnail.label'
},
{
'name' => 'title.label'
},
{
'name' => 'unlock.label'
},
{
'name' => 'unstick.label'
},
{
'name' => 'unsubscribe.label'
},
{
'name' => 'url.label'
},
{
'name' => 'user.label'
},
{
'name' => 'views.label'
},
{
'name' => 'visitorName.label'
}
],
fields => [
],
related => [

View file

@ -18,7 +18,8 @@ use WebGUI::Asset::Template;
use WebGUI::Macro;
use WebGUI::Utility;
use WebGUI::TabForm;
use Storable qw/dclone/;
use Data::Dumper;
#use Storable qw/dclone/;
=head1 NAME
@ -32,6 +33,70 @@ Handles displaying WebGUI's internal help to the user as an operation.
#-------------------------------------------------------------------
=head2 _loadHelp ( $session, $helpPackage )
Safely load's the Help file for the requested helpPackage if it hasn't
been already and logs errors during the load.
=cut
sub _loadHelp {
my $session = shift;
my $helpPackage = shift;
return $helpPackage::HELP if defined $helpPackage::HELP; ##Already loaded
my $load = sprintf 'use %-s; $%-s::HELP', $helpPackage, $helpPackage;
my $help = eval($load);
if ($@) {
$session->errorHandler->error("Help failed to compile: $helpPackage. ".$@);
return {};
}
return $help;
}
#-------------------------------------------------------------------
=head2 _process ( $session, $cmd, $key )
Do all post processing for an entry in a freshly loaded help file.
Resolve the related key, add a default isa key if it is missing,
and set the __PROCESSED flag to prevent processing entries twice.
=cut
sub _process {
my ($session, $helpEntry, $key) = @_;
return if exists($helpEntry->{__PROCESSED}) and $helpEntry->{__PROCESSED};
$helpEntry->{related} = [ _related($session, $helpEntry->{related}) ];
##Add an ISA link unless it already exists.
##This simplifies handling later.
unless (exists $helpEntry->{isa} and ref $helpEntry->{isa} eq 'ARRAY') {
$helpEntry->{isa} = [];
}
unless (exists $helpEntry->{__PROCESSED}) {
$helpEntry->{__PROCESSED} = 0;
}
foreach my $isa ( @{ $helpEntry->{isa} } ) {
my $oCmd = "WebGUI::Help::".$isa->{namespace};
my $other = _loadHelp($session, $oCmd);
my $otherHelp = $other->{ $isa->{tag} };
_process($session, $otherHelp, $isa->{tag});
my $add = $otherHelp->{fields};
@{$helpEntry->{fields}} = (@{$helpEntry->{fields}}, @{$add});
$add = $otherHelp->{related};
@{$helpEntry->{related}} = (@{ $helpEntry->{related} }, @{ $add });
$add = $otherHelp->{variables};
foreach my $row (@{$add}) {
push(@{$helpEntry->{variables}}, {
name=> $row->{name},
description => $row->{description},
namespace => $row->{namespace} || $isa->{namespace}
});
}
}
}
#-------------------------------------------------------------------
=head2 _load ( $session, $namespace )
Safely load's the Help file for the requested namespace and logs errors
@ -43,38 +108,9 @@ sub _load {
my $session = shift;
my $namespace = shift;
my $cmd = "WebGUI::Help::".$namespace;
my $load = sprintf 'use %-s; $%-s::HELP;', $cmd, $cmd;
my $hash = eval($load);
if ($@) {
$session->errorHandler->error("Help failed to compile: $namespace. ".$@);
return {};
}
local $Storable::Deparse = 1;
local $Storable::Eval = 1;
my $help = dclone($hash);
my $help = _loadHelp($session, $cmd);
foreach my $tag (keys %{ $help }) {
$help->{$tag}{related} = [ _related($session, $help->{$tag}{related}) ];
##Add an ISA link unless it already exists.
##This simplifies handling later.
unless (exists $help->{$tag}{isa} and ref $help->{$tag}{isa} eq 'ARRAY') {
$help->{$tag}{isa} = [];
}
foreach my $isa ( @{ $help->{$tag}{isa} } ) {
my $other = _load($session, $isa->{namespace});
my $otherHelp = $other->{ $isa->{tag} };
my $add = $otherHelp->{fields};
@{$help->{$tag}{fields}} = (@{$help->{$tag}{fields}}, @{$add});
$add = $otherHelp->{related};
@{$help->{$tag}{related}} = (@{ $help->{$tag}{related} }, @{ $add });
$add = $otherHelp->{variables};
foreach my $row (@{$add}) {
push(@{$help->{$tag}{variables}}, {
name=> $row->{name},
description => $row->{description},
namespace => $row->{namespace} || $isa->{namespace}
});
}
}
_process($session, $help->{$tag}, $tag);
}
return $help;
}

View file

@ -696,277 +696,326 @@ our $I18N = {
lastUpdated => 1111520746,
},
'word' => {
context => q|Helper phrase for autogenerated documentation for labels|,
message => q|The word|,
lastUpdated => 1111533791,
},
'add.label' => {
message => q|The word "Add".|,
lastUpdated => 1150169037,
},
'phrase' => {
context => q|Helper phrase for autogenerated documentation for labels|,
message => q|The phrase|,
lastUpdated => 1111533788,
},
'addlink.label' => {
message => q|The phrase "Add a link".|,
lastUpdated => 1150169037,
},
'addquestion.label' => {
message => q|The phrase "Add a question".|,
lastUpdated => 1150169037,
},
'answer.label' => {
message => q|The word "Answer".|,
lastUpdated => 1150169037,
},
'attachment.label' => {
message => q|The word "Attachment".|,
lastUpdated => 1150169037,
},
'by.label' => {
message => q|The word "By".|,
lastUpdated => 1150169037,
},
'body.label' => {
message => q|The word "Body".|,
lastUpdated => 1150169037,
},
'back.label' => {
message => q|The word "Back".|,
lastUpdated => 1150169037,
},
'compensation.label' => {
message => q|The word "Compensation".|,
lastUpdated => 1150169037,
},
'open.label' => {
message => q|The word "Open".|,
lastUpdated => 1150169037,
},
'close.label' => {
message => q|The word "Close".|,
lastUpdated => 1150169037,
},
'closed.label' => {
message => q|The word "Closed".|,
lastUpdated => 1150169037,
},
'critical.label' => {
message => q|The word "Critical (mostly not working)".|,
lastUpdated => 1150169037,
},
'minor.label' => {
message => q|The word "Minor (annoying, but not harmful)".|,
lastUpdated => 1150169037,
},
'cosmetic.label' => {
message => q|The word "Cosmetic (misspelling, formatting problems)".|,
lastUpdated => 1150169037,
},
'fatal.label' => {
message => q|The word "Fatal (can't continue until this is resolved)".|,
lastUpdated => 1150169037,
},
'severity.label' => {
message => q|The word "Severity".|,
lastUpdated => 1150169037,
},
'date.label' => {
message => q|The word "Date".|,
lastUpdated => 1150169037,
},
'delete.label' => {
message => q|The word "Delete".|,
lastUpdated => 1150169037,
},
'description.label' => {
message => q|The word "Description".|,
lastUpdated => 1150169037,
},
'edit.label' => {
message => q|The word "Edit".|,
lastUpdated => 1150169037,
},
'image.label' => {
message => q|The word "Image".|,
lastUpdated => 1150169037,
},
'job.header.label' => {
message => q|The phrase "Edit Job Posting".|,
lastUpdated => 1150169037,
},
'job.title.label' => {
message => q|The phrase "Job Title".|,
lastUpdated => 1150169037,
},
'job.description.label' => {
message => q|The phrase "Job Description".|,
lastUpdated => 1150169037,
},
'job.requirements.label' => {
message => q|The phrase "Job Requirements".|,
lastUpdated => 1150169037,
},
'location.label' => {
message => q|The word "Location".|,
lastUpdated => 1150169037,
},
'layout.flat.label' => {
message => q|The word "Flat".|,
lastUpdated => 1150169037,
},
'link.header.label' => {
message => q|The phrase "Edit Link".|,
lastUpdated => 1150169037,
},
'lastReply.label' => {
message => q|The phrase "Last Reply".|,
lastUpdated => 1150169037,
},
'lock.label' => {
message => q|The word "Lock".|,
lastUpdated => 1150169037,
},
'layout.label' => {
message => q|The word "Layout".|,
lastUpdated => 1150169037,
},
'message.header.label' => {
message => q|The phrase "Edit Message".|,
lastUpdated => 1150169037,
},
'message.label' => {
message => q|The word "Message".|,
lastUpdated => 1150169037,
},
'next.label' => {
message => q|The word "Next".|,
lastUpdated => 1150169037,
},
'newWindow.label' => {
message => q|The phrase "Open in new window?".|,
lastUpdated => 1150169037,
},
'layout.nested.label' => {
message => q|The word "Nested".|,
lastUpdated => 1150169037,
},
'previous.label' => {
message => q|The word "Previous".|,
lastUpdated => 1150169037,
},
'post.label' => {
message => q|The word "Post".|,
lastUpdated => 1150169037,
},
'question.label' => {
message => q|The word "Question".|,
lastUpdated => 1150169037,
},
'question.header.label' => {
message => q|The phrase "Edit Question".|,
lastUpdated => 1150169037,
},
'rating.label' => {
message => q|The word "Rating".|,
lastUpdated => 1150169037,
},
'rate.label' => {
message => q|The word "Rate".|,
lastUpdated => 1150169037,
},
'reply.label' => {
message => q|The word "Reply".|,
lastUpdated => 1150169037,
},
'replies.label' => {
message => q|The word "Replies".|,
lastUpdated => 1150169037,
},
'readmore.label' => {
message => q|The phrase "Read More".|,
lastUpdated => 1150169037,
},
'responses.label' => {
message => q|The word "Responses".|,
lastUpdated => 1150169037,
},
'search.label' => {
message => q|The word "Search".|,
lastUpdated => 1150169037,
},
'subject.label' => {
message => q|The word "Subject".|,
lastUpdated => 1150169038,
},
'subscribe.label' => {
message => q|The word "Subscribe".|,
lastUpdated => 1150169038,
},
'submission.header.label' => {
message => q|The phrase "Edit Submission".|,
lastUpdated => 1150169038,
},
'stick.label' => {
message => q|The phrase "Make Sticky".|,
lastUpdated => 1150169038,
},
'status.label' => {
message => q|The word "Status".|,
lastUpdated => 1150169038,
},
'synopsis.label' => {
message => q|The word "Summary".|,
lastUpdated => 1150169038,
},
'thumbnail.label' => {
message => q|The word "Thumbnail".|,
lastUpdated => 1150169038,
},
'title.label' => {
message => q|The word "Title".|,
lastUpdated => 1150169038,
},
'unlock.label' => {
message => q|The word "Unlock".|,
lastUpdated => 1150169038,
},
'unstick.label' => {
message => q|The word "Unstick".|,
lastUpdated => 1150169038,
},
'unsubscribe.label' => {
message => q|The word "Unsubscribe".|,
lastUpdated => 1150169038,
},
'url.label' => {
message => q|The word "URL".|,
lastUpdated => 1150169038,
},
'user.label' => {
message => q|The word "User".|,
lastUpdated => 1150169038,
},
'views.label' => {
message => q|The word "Views".|,
lastUpdated => 1150169038,
},
'visitorName.label' => {
message => q|The phrase "Visitor Name".|,
lastUpdated => 1150169038,
},
'collaboration template labels body' => {
context => q|Note to translators, this text is largely autogenerated. Please just translate the paragraph at the beginning of the message and leave the rest.|,
message => q|<p>These labels are available in the templates of several Assets and Wobjects, but all of them may not be useful. Please consult the template documentation for the Asset or Wobject to see which are used.
</p>
<p><b>add.label</b><br />
^International("word","Asset_Collaboration"); "^International("add","Asset_Collaboration");".
</p>
<p><b>addlink.label</b><br />
^International("phrase","Asset_Collaboration"); "^International("addlink","Asset_Collaboration");".
</p>
<p><b>addquestion.label</b><br />
^International("phrase","Asset_Collaboration"); "^International("addquestion","Asset_Collaboration");".
</p>
<p><b>answer.label</b><br />
^International("word","Asset_Collaboration"); "^International("answer","Asset_Collaboration");".
</p>
<p><b>attachment.label</b><br />
^International("word","Asset_Collaboration"); "^International("attachment","Asset_Collaboration");".
</p>
<p><b>by.label</b><br />
^International("word","Asset_Collaboration"); "^International("by","Asset_Collaboration");".
</p>
<p><b>body.label</b><br />
^International("word","Asset_Collaboration"); "^International("body","Asset_Collaboration");".
</p>
<p><b>back.label</b><br />
^International("word","Asset_Collaboration"); "^International("back","Asset_Collaboration");".
</p>
<p><b>compensation.label</b><br />
^International("word","Asset_Collaboration"); "^International("compensation","Asset_Collaboration");".
</p>
<p><b>open.label</b><br />
^International("word","Asset_Collaboration"); "^International("open","Asset_Collaboration");".
</p>
<p><b>close.label</b><br />
^International("word","Asset_Collaboration"); "^International("close","Asset_Collaboration");".
</p>
<p><b>closed.label</b><br />
^International("word","Asset_Collaboration"); "^International("closed","Asset_Collaboration");".
</p>
<p><b>critical.label</b><br />
^International("word","Asset_Collaboration"); "^International("critical","Asset_Collaboration");".
</p>
<p><b>minor.label</b><br />
^International("word","Asset_Collaboration"); "^International("minor","Asset_Collaboration");".
</p>
<p><b>cosmetic.label</b><br />
^International("word","Asset_Collaboration"); "^International("cosmetic","Asset_Collaboration");".
</p>
<p><b>fatal.label</b><br />
^International("word","Asset_Collaboration"); "^International("fatal","Asset_Collaboration");".
</p>
<p><b>severity.label</b><br />
^International("word","Asset_Collaboration"); "^International("severity","Asset_Collaboration");".
</p>
<p><b>date.label</b><br />
^International("word","Asset_Collaboration"); "^International("date","Asset_Collaboration");".
</p>
<p><b>delete.label</b><br />
^International("word","Asset_Collaboration"); "^International("delete","Asset_Collaboration");".
</p>
<p><b>description.label</b><br />
^International("word","Asset_Collaboration"); "^International("description","Asset_Collaboration");".
</p>
<p><b>edit.label</b><br />
^International("word","Asset_Collaboration"); "^International("edit","Asset_Collaboration");".
</p>
<p><b>image.label</b><br />
^International("word","Asset_Collaboration"); "^International("image","Asset_Collaboration");".
</p>
<p><b>job.header.label</b><br />
^International("phrase","Asset_Collaboration"); "^International("edit job","Asset_Collaboration");".
</p>
<p><b>job.title.label</b><br />
^International("phrase","Asset_Collaboration"); "^International("job title","Asset_Collaboration");".
</p>
<p><b>job.description.label</b><br />
^International("phrase","Asset_Collaboration"); "^International("job description","Asset_Collaboration");".
</p>
<p><b>job.requirements.label</b><br />
^International("phrase","Asset_Collaboration"); "^International("job requirements","Asset_Collaboration");".
</p>
<p><b>location.label</b><br />
^International("word","Asset_Collaboration"); "^International("location","Asset_Collaboration");".
</p>
<p><b>layout.flat.label</b><br />
^International("word","Asset_Collaboration"); "^International("flatLayout","Asset_Collaboration");".
</p>
<p><b>link.header.label</b><br />
^International("phrase","Asset_Collaboration"); "^International("edit link","Asset_Collaboration");".
</p>
<p><b>lastReply.label</b><br />
^International("phrase","Asset_Collaboration"); "^International("lastReply","Asset_Collaboration");".
</p>
<p><b>lock.label</b><br />
^International("word","Asset_Collaboration"); "^International("lock","Asset_Collaboration");".
</p>
<p><b>layout.label</b><br />
^International("word","Asset_Collaboration"); "^International("layout","Asset_Collaboration");".
</p>
<p><b>message.header.label</b><br />
^International("phrase","Asset_Collaboration"); "^International("edit message","Asset_Collaboration");".
</p>
<p><b>message.label</b><br />
^International("word","Asset_Collaboration"); "^International("message","Asset_Collaboration");".
</p>
<p><b>next.label</b><br />
^International("word","Asset_Collaboration"); "^International("next","Asset_Collaboration");".
</p>
<p><b>newWindow.label</b><br />
^International("phrase","Asset_Collaboration"); "^International("new window","Asset_Collaboration");".
</p>
<p><b>layout.nested.label</b><br />
^International("word","Asset_Collaboration"); "^International("nested","Asset_Collaboration");".
</p>
<p><b>previous.label</b><br />
^International("word","Asset_Collaboration"); "^International("previous","Asset_Collaboration");".
</p>
<p><b>post.label</b><br />
^International("word","Asset_Collaboration"); "^International("post","Asset_Collaboration");".
</p>
<p><b>question.label</b><br />
^International("word","Asset_Collaboration"); "^International("question","Asset_Collaboration");".
</p>
<p><b>question.header.label</b><br />
^International("phrase","Asset_Collaboration"); "^International("edit question","Asset_Collaboration");".
</p>
<p><b>rating.label</b><br />
^International("word","Asset_Collaboration"); "^International("rating","Asset_Collaboration");".
</p>
<p><b>rate.label</b><br />
^International("word","Asset_Collaboration"); "^International("rate","Asset_Collaboration");".
</p>
<p><b>reply.label</b><br />
^International("word","Asset_Collaboration"); "^International("reply","Asset_Collaboration");".
</p>
<p><b>replies.label</b><br />
^International("word","Asset_Collaboration"); "^International("replies","Asset_Collaboration");".
</p>
<p><b>readmore.label</b><br />
^International("phrase","Asset_Collaboration"); "^International("read more","Asset_Collaboration");".
</p>
<p><b>responses.label</b><br />
^International("word","Asset_Collaboration"); "^International("responses","Asset_Collaboration");".
</p>
<p><b>search.label</b><br />
^International("word","Asset_Collaboration"); "^International("search","Asset_Collaboration");".
</p>
<p><b>subject.label</b><br />
^International("word","Asset_Collaboration"); "^International("subject","Asset_Collaboration");".
</p>
<p><b>subscribe.label</b><br />
^International("word","Asset_Collaboration"); "^International("subscribe","Asset_Collaboration");".
</p>
<p><b>submission.header.label</b><br />
^International("phrase","Asset_Collaboration"); "^International("edit submission","Asset_Collaboration");".
</p>
<p><b>stick.label</b><br />
^International("phrase","Asset_Collaboration"); "^International("sticky","Asset_Collaboration");".
</p>
<p><b>status.label</b><br />
^International("word","Asset_Collaboration"); "^International("status","Asset_Collaboration");".
</p>
<p><b>synopsis.label</b><br />
^International("word","Asset_Collaboration"); "^International("synopsis","Asset_Collaboration");".
</p>
<p><b>thumbnail.label</b><br />
^International("word","Asset_Collaboration"); "^International("thumbnail","Asset_Collaboration");".
</p>
<p><b>title.label</b><br />
^International("word","Asset_Collaboration"); "^International("title","Asset_Collaboration");".
</p>
<p><b>unlock.label</b><br />
^International("word","Asset_Collaboration"); "^International("unlock","Asset_Collaboration");".
</p>
<p><b>unstick.label</b><br />
^International("word","Asset_Collaboration"); "^International("unstick","Asset_Collaboration");".
</p>
<p><b>unsubscribe.label</b><br />
^International("word","Asset_Collaboration"); "^International("unsubscribe","Asset_Collaboration");".
</p>
<p><b>url.label</b><br />
^International("word","Asset_Collaboration"); "^International("url","Asset_Collaboration");".
</p>
<p><b>user.label</b><br />
^International("word","Asset_Collaboration"); "^International("user","Asset_Collaboration");".
</p>
<p><b>views.label</b><br />
^International("word","Asset_Collaboration"); "^International("views","Asset_Collaboration");".
</p>
<p><b>visitorName.label</b><br />
^International("phrase","Asset_Collaboration"); "^International("visitor","Asset_Collaboration");".
</p>
|,
lastUpdated => 1146153770
lastUpdated => 1150169127
},
'collaboration add/edit title' => {