Changed the help system to use the internationalization system directly.
This commit is contained in:
parent
2836eb1ef1
commit
d1f8f816f8
4 changed files with 94 additions and 131 deletions
|
|
@ -660,6 +660,32 @@ update international set message='Attachment' where internationalId=33 and langu
|
||||||
alter table page add column startDate int not null default 946710000;
|
alter table page add column startDate int not null default 946710000;
|
||||||
alter table page add column endDate int not null default 2082783600;
|
alter table page add column endDate int not null default 2082783600;
|
||||||
update page set styleId=-6 where styleId=-3;
|
update page set styleId=-6 where styleId=-3;
|
||||||
|
update international set message='Edit Image Group' where internationalId=545 and languageId=1;
|
||||||
|
alter table help change seeAlso seeAlso text;
|
||||||
|
alter table international change message message mediumtext;
|
||||||
|
drop table helpSeeAlso;
|
||||||
|
insert into international select (60+helpId),namespace,1,concat(object,", ",action) from help where languageId=1 and namespace<>'WebGUI';
|
||||||
|
insert into international select (70+helpId),namespace,1,body from help where languageId=1 and namespace<>'WebGUI';
|
||||||
|
insert into international select (605+helpId),namespace,1,body from help where languageId=1 and namespace='WebGUI';
|
||||||
|
insert into international select (650+helpId),namespace,1,concat(object,", ",action) from help where languageId=1 and namespace='WebGUI';
|
||||||
|
alter table help add column titleId int after languageId;
|
||||||
|
alter table help add column bodyId int after titleId;
|
||||||
|
update help set titleId=60+helpId, bodyId=70+helpId where namespace<>'WebGUI';
|
||||||
|
update help set titleId=650+helpId, bodyId=605+helpId where namespace='WebGUI';
|
||||||
|
alter table help drop column languageId;
|
||||||
|
alter table help drop column action;
|
||||||
|
alter table help drop column object;
|
||||||
|
alter table help drop column body;
|
||||||
|
delete from international where internationalId=96;
|
||||||
|
delete from international where internationalId=97;
|
||||||
|
insert into international values (642,'WebGUI',1,'Page, Add/Edit');
|
||||||
|
update help set titleId=642 where helpId=1 and namespace='WebGUI';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,92 +12,85 @@ package WebGUI::Operation::Help;
|
||||||
|
|
||||||
use Exporter;
|
use Exporter;
|
||||||
use strict;
|
use strict;
|
||||||
|
use Tie::IxHash;
|
||||||
use Tie::CPHash;
|
use Tie::CPHash;
|
||||||
use WebGUI::International;
|
use WebGUI::International;
|
||||||
use WebGUI::Session;
|
use WebGUI::Session;
|
||||||
use WebGUI::SQL;
|
use WebGUI::SQL;
|
||||||
use WebGUI::URL;
|
use WebGUI::URL;
|
||||||
|
use WebGUI::Utility;
|
||||||
|
|
||||||
our @ISA = qw(Exporter);
|
our @ISA = qw(Exporter);
|
||||||
our @EXPORT = qw(&www_viewHelp &www_viewHelpIndex);
|
our @EXPORT = qw(&www_viewHelp &www_viewHelpIndex);
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
sub _helpLink {
|
||||||
|
return '<a href="'.WebGUI::URL::page('op=viewHelp&hid='.$_[0].'&namespace='.$_[1]).'">'.$_[2].'</a>';
|
||||||
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
sub _seeAlso {
|
||||||
|
my ($item, $seeAlso, @items, $namespace, $helpId, $titleId, $output);
|
||||||
|
$seeAlso = $_[0];
|
||||||
|
$seeAlso =~ s/\n//g; #removes line feeds
|
||||||
|
$seeAlso =~ s/\r//g; #removes carriage returns
|
||||||
|
$seeAlso =~ s/ //g; #removes spaces
|
||||||
|
@items = split(/;/,$seeAlso);
|
||||||
|
foreach $item (@items) {
|
||||||
|
($helpId,$namespace) = split(/,/,$item);
|
||||||
|
($titleId) = WebGUI::SQL->quickArray("select titleId from help where helpId=$helpId
|
||||||
|
and namespace='$namespace'");
|
||||||
|
$output .= '<li>'._helpLink($helpId,$namespace,WebGUI::International::get($titleId,$namespace));
|
||||||
|
}
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
sub www_viewHelp {
|
sub www_viewHelp {
|
||||||
my ($output, %help, @data, $sth, %seeAlso, $namespace);
|
my ($output, %help, $namespace);
|
||||||
$namespace = $session{form}{namespace} || "WebGUI";
|
$namespace = $session{form}{namespace} || "WebGUI";
|
||||||
tie %help, 'Tie::CPHash';
|
tie %help, 'Tie::CPHash';
|
||||||
%help = WebGUI::SQL->quickHash("select * from help where helpId=$session{form}{hid} and namespace='$namespace' and
|
%help = WebGUI::SQL->quickHash("select * from help where helpId=$session{form}{hid} and namespace='$namespace'");
|
||||||
languageId='$session{user}{language}'");
|
$output = '<h1>'.WebGUI::International::get(93).': '.
|
||||||
if ($help{action} eq "") {
|
WebGUI::International::get($help{titleId},$help{namespace}).'</h1>';
|
||||||
%help = WebGUI::SQL->quickHash("select * from help where helpId=$session{form}{hid} and namespace='$namespace' and languageId=1");
|
$output .= WebGUI::International::get($help{bodyId},$help{namespace});
|
||||||
}
|
$output .= '<p><b>'.WebGUI::International::get(94).':<ul>';
|
||||||
$output = '<h1>'.WebGUI::International::get(93).': '.$help{action}.' '.$help{object}.'</h1>';
|
$output .= _seeAlso($help{seeAlso});
|
||||||
$output .= $help{body};
|
$output .= '<li><a href="'.WebGUI::URL::page('op=viewHelpIndex').'">'.WebGUI::International::get(95).'</a></ul>';
|
||||||
$output .= '<p><b>'.WebGUI::International::get(94).':';
|
|
||||||
$sth = WebGUI::SQL->read("select helpId, action, object, namespace from help where object='$help{object}'
|
|
||||||
and action<>'$help{action}' and languageId='$session{user}{language}' order by action");
|
|
||||||
unless ($sth->rows) {
|
|
||||||
$sth->finish;
|
|
||||||
$sth = WebGUI::SQL->read("select helpId, action, object, namespace from help where object='$help{object}'
|
|
||||||
and action<>'$help{action}' and languageId=1 order by action");
|
|
||||||
}
|
|
||||||
while (@data = $sth->array) {
|
|
||||||
$output .= ' <a href="'.WebGUI::URL::page('op=viewHelp&hid='.$data[0].'&namespace='.$data[3])
|
|
||||||
.'">'.$data[1].' '.$data[2].'</a>,';
|
|
||||||
}
|
|
||||||
$sth->finish;
|
|
||||||
$sth = WebGUI::SQL->read("select helpId, namespace from helpSeeAlso where seeAlsoId in ($help{seeAlso})");
|
|
||||||
while (@data = $sth->array) {
|
|
||||||
%seeAlso = WebGUI::SQL->quickHash("select helpId,namespace,action,object from help where helpId='$data[0]'
|
|
||||||
and namespace='$data[1]' and languageId='$session{user}{language}'");
|
|
||||||
if ($seeAlso{helpId} eq "") {
|
|
||||||
%seeAlso = WebGUI::SQL->quickHash("select helpId,namespace,action,object from help where helpId='$data[0]'
|
|
||||||
and namespace='$data[1]' and languageId=1");
|
|
||||||
}
|
|
||||||
$output .= ' <a href="'.
|
|
||||||
WebGUI::URL::page('op=viewHelp&hid='.$seeAlso{helpId}.'&namespace='.$seeAlso{namespace})
|
|
||||||
.'">'.$seeAlso{action}.' '.$seeAlso{object}.'</a>,';
|
|
||||||
}
|
|
||||||
$sth->finish;
|
|
||||||
$output .= ' <a href="'.WebGUI::URL::page('op=viewHelpIndex').'">'.WebGUI::International::get(95).'</a>';
|
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
sub www_viewHelpIndex {
|
sub www_viewHelpIndex {
|
||||||
my ($sth, @data, $output, $previous);
|
my ($sth, %help, $output, $key, %index, $title, $seeAlso, %sortedIndex, $i, $midpoint);
|
||||||
|
tie %help, 'Tie::CPHash';
|
||||||
|
tie %sortedIndex, 'Tie::IxHash';
|
||||||
$output = '<h1>'.WebGUI::International::get(95).'</h1>';
|
$output = '<h1>'.WebGUI::International::get(95).'</h1>';
|
||||||
$output .= '<table width="100%"><tr><td valign="top"><b>'.WebGUI::International::get(96).'</b><p>';
|
$sth = WebGUI::SQL->read("select helpId,namespace,titleId,seeAlso from help");
|
||||||
$sth = WebGUI::SQL->read("select helpId, action, object, namespace from help where languageId='$session{user}{language}' order by action,object");
|
while (%help = $sth->hash) {
|
||||||
unless ($sth->rows) {
|
$title = WebGUI::International::get($help{titleId},$help{namespace});
|
||||||
$sth->finish;
|
$index{$title} = _helpLink($help{helpId},$help{namespace},$title);
|
||||||
$sth = WebGUI::SQL->read("select helpId, action, object, namespace from help where languageId=1 order by action,object");
|
$seeAlso = _seeAlso($help{seeAlso});
|
||||||
}
|
if ($seeAlso ne "") {
|
||||||
while (@data = $sth->array) {
|
$index{$title} .= '<span style="font-size: 11px"><ul>'.$seeAlso.'</ul></span>';
|
||||||
if ($data[1] ne $previous) {
|
|
||||||
$output .= '<p><b>'.$data[1].'</b><br>';
|
|
||||||
$previous = $data[1];
|
|
||||||
}
|
}
|
||||||
$output .= '<li><a href="'.WebGUI::URL::page('op=viewHelp&hid='.$data[0].'&namespace='.$data[3])
|
$i++;
|
||||||
.'">'.$data[2].'</a><br>';
|
|
||||||
}
|
}
|
||||||
|
$midpoint = round($i/2);
|
||||||
$sth->finish;
|
$sth->finish;
|
||||||
$output .= '</td><td valign="top"><b>'.WebGUI::International::get(97).'</b><p>';
|
foreach $key (sort {$a cmp $b} keys %index) {
|
||||||
$sth = WebGUI::SQL->read("select helpId, object, action, namespace from help where languageId='$session{user}{language}' order by object,action");
|
$sortedIndex{$key}=$index{$key};
|
||||||
unless ($sth->rows) {
|
|
||||||
$sth->finish;
|
|
||||||
$sth = WebGUI::SQL->read("select helpId, object, action, namespace from help where languageId=1 order by object,action");
|
|
||||||
}
|
}
|
||||||
while (@data = $sth->array) {
|
$i = 0;
|
||||||
if ($data[1] ne $previous) {
|
$output .= '<table width="100%"><tr><td width="50%" valign="top" class="content">';
|
||||||
$output .= '<p><b>'.$data[1].'</b><br>';
|
foreach $key (keys %sortedIndex) {
|
||||||
$previous = $data[1];
|
if ($i == $midpoint) {
|
||||||
}
|
$output .= '</td><td width="50%" valign="top" class="content">';
|
||||||
$output .= '<li><a href="'.WebGUI::URL::page('op=viewHelp&hid='.$data[0].'&namespace='.$data[3])
|
}
|
||||||
.'">'.$data[2].'</a><br>';
|
$output .= $sortedIndex{$key}.'<p>';
|
||||||
}
|
$i++;
|
||||||
$sth->finish;
|
}
|
||||||
$output .= '</td></tr></table>';
|
$output .= '</table>';
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -314,7 +314,7 @@ sub www_editImageGroup {
|
||||||
%data = WebGUI::SQL->quickHash("select * from imageGroup where imageGroupId=$session{form}{gid}");
|
%data = WebGUI::SQL->quickHash("select * from imageGroup where imageGroupId=$session{form}{gid}");
|
||||||
}
|
}
|
||||||
%parent_data = WebGUI::SQL->quickHash("select name from imageGroup where imageGroupId=$session{form}{pid}");
|
%parent_data = WebGUI::SQL->quickHash("select name from imageGroup where imageGroupId=$session{form}{pid}");
|
||||||
$output = helpIcon(20);
|
$output = helpIcon(36);
|
||||||
$output .= '<h1>'.WebGUI::International::get(545).'</h1>';
|
$output .= '<h1>'.WebGUI::International::get(545).'</h1>';
|
||||||
$f = WebGUI::HTMLForm->new;
|
$f = WebGUI::HTMLForm->new;
|
||||||
$f->hidden("op","editImageGroupSave");
|
$f->hidden("op","editImageGroupSave");
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,6 @@ sub _submenu {
|
||||||
$output .= '<td valign="top" class="tableMenu">';
|
$output .= '<td valign="top" class="tableMenu">';
|
||||||
$output .= '<li><a href="'.WebGUI::URL::page('op=editLanguage&lid='.$session{form}{lid}).'">'.WebGUI::International::get(598).'</a>';
|
$output .= '<li><a href="'.WebGUI::URL::page('op=editLanguage&lid='.$session{form}{lid}).'">'.WebGUI::International::get(598).'</a>';
|
||||||
$output .= '<li><a href="'.WebGUI::URL::page('op=listInternationalMessages&lid='.$session{form}{lid}).'">'.WebGUI::International::get(594).'</a>';
|
$output .= '<li><a href="'.WebGUI::URL::page('op=listInternationalMessages&lid='.$session{form}{lid}).'">'.WebGUI::International::get(594).'</a>';
|
||||||
$output .= '<li><a href="'.WebGUI::URL::page('op=listHelpMessages&lid='.$session{form}{lid}).'">'.WebGUI::International::get(599).'</a>';
|
|
||||||
$output .= '<li><a href="'.WebGUI::URL::page('op=submitTranslation&lid='.$session{form}{lid}).'">'.WebGUI::International::get(593).'</a>';
|
$output .= '<li><a href="'.WebGUI::URL::page('op=submitTranslation&lid='.$session{form}{lid}).'">'.WebGUI::International::get(593).'</a>';
|
||||||
$output .= '<li><a href="'.WebGUI::URL::page('op=listLanguages').'">'.WebGUI::International::get(585).'</a>';
|
$output .= '<li><a href="'.WebGUI::URL::page('op=listLanguages').'">'.WebGUI::International::get(585).'</a>';
|
||||||
$output .= '<li><a href="'.WebGUI::URL::page().'">'.WebGUI::International::get(493).'</a>';
|
$output .= '<li><a href="'.WebGUI::URL::page().'">'.WebGUI::International::get(493).'</a>';
|
||||||
|
|
@ -78,59 +77,6 @@ sub www_deleteLanguageConfirm {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
|
||||||
sub www_editHelpMessage {
|
|
||||||
my ($output, %data, $f, $language, $action, $object);
|
|
||||||
tie %data, 'Tie::CPHash';
|
|
||||||
if (WebGUI::Privilege::isInGroup(3)) {
|
|
||||||
($language) = WebGUI::SQL->quickArray("select language from language where languageId=".$session{form}{lid});
|
|
||||||
$action = WebGUI::International::get(603);
|
|
||||||
$object = WebGUI::International::get(604);
|
|
||||||
$output = '<h1>'.WebGUI::International::get(602).'</h1>';
|
|
||||||
$f = WebGUI::HTMLForm->new;
|
|
||||||
$f->readOnly($session{form}{hid},WebGUI::International::get(600));
|
|
||||||
$f->hidden("lid",$session{form}{lid});
|
|
||||||
$f->hidden("hid",$session{form}{hid});
|
|
||||||
$f->hidden("missing",$session{form}{missing});
|
|
||||||
$f->hidden("pn",$session{form}{pn});
|
|
||||||
$f->hidden("namespace",$session{form}{namespace});
|
|
||||||
$f->hidden("op","editHelpMessageSave");
|
|
||||||
%data = WebGUI::SQL->quickHash("select action,object,body from help where helpId=".$session{form}{hid}."
|
|
||||||
and namespace='".$session{form}{namespace}."' and languageId=".$session{form}{lid});
|
|
||||||
$f->text("action",$action,$data{action});
|
|
||||||
$f->text("object",$object,$data{object});
|
|
||||||
$f->HTMLArea("body",$language,$data{body});
|
|
||||||
$f->submit;
|
|
||||||
%data = WebGUI::SQL->quickHash("select action,object,body from help where helpId=".$session{form}{hid}."
|
|
||||||
and namespace='".$session{form}{namespace}."' and languageId=1");
|
|
||||||
$f->readOnly($data{action},$action);
|
|
||||||
$f->readOnly($data{object},$object);
|
|
||||||
$f->readOnly($data{body},"English");
|
|
||||||
$output .= $f->print;
|
|
||||||
return _submenu($output);
|
|
||||||
} else {
|
|
||||||
return WebGUI::Privilege::adminOnly();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
|
||||||
sub www_editHelpMessageSave {
|
|
||||||
if (WebGUI::Privilege::isInGroup(3)) {
|
|
||||||
if ($session{form}{missing}) {
|
|
||||||
WebGUI::SQL->write("insert into help (body,action,object,namespace,languageId,helpId) values (".quote($session{form}{body}).", "
|
|
||||||
.quote($session{form}{action}).", ".quote($session{form}{object}).",".quote($session{form}{namespace}).","
|
|
||||||
.$session{form}{lid}.",".$session{form}{hid}.")");
|
|
||||||
} else {
|
|
||||||
WebGUI::SQL->write("update help set body=".quote($session{form}{body}).", action=".quote($session{form}{action}).",
|
|
||||||
object=".quote($session{form}{action})." where namespace=".quote($session{form}{namespace})."
|
|
||||||
and languageId=".$session{form}{lid}." and helpId=".$session{form}{hid});
|
|
||||||
}
|
|
||||||
return www_listHelpMessages();
|
|
||||||
} else {
|
|
||||||
return WebGUI::Privilege::adminOnly();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
sub www_editInternationalMessage {
|
sub www_editInternationalMessage {
|
||||||
my ($output, $message, $f, $language);
|
my ($output, $message, $f, $language);
|
||||||
|
|
@ -197,7 +143,6 @@ sub www_editLanguage {
|
||||||
if ($session{form}{lid} ne "new") {
|
if ($session{form}{lid} ne "new") {
|
||||||
$output .= '<ul>';
|
$output .= '<ul>';
|
||||||
$output .= '<li><a href="'.WebGUI::URL::page('op=listInternationalMessages&lid='.$session{form}{lid}).'">'.WebGUI::International::get(594).'</a>';
|
$output .= '<li><a href="'.WebGUI::URL::page('op=listInternationalMessages&lid='.$session{form}{lid}).'">'.WebGUI::International::get(594).'</a>';
|
||||||
$output .= '<li><a href="'.WebGUI::URL::page('op=listHelpMessages&lid='.$session{form}{lid}).'">'.WebGUI::International::get(599).'</a>';
|
|
||||||
$output .= '<li><a href="'.WebGUI::URL::page('op=submitLanguage&lid='.$session{form}{lid}).'">'.WebGUI::International::get(593).'</a>';
|
$output .= '<li><a href="'.WebGUI::URL::page('op=submitLanguage&lid='.$session{form}{lid}).'">'.WebGUI::International::get(593).'</a>';
|
||||||
$output .= '</ul>';
|
$output .= '</ul>';
|
||||||
}
|
}
|
||||||
|
|
@ -353,23 +298,22 @@ sub www_submitTranslation {
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
sub www_submitTranslationConfirm {
|
sub www_submitTranslationConfirm {
|
||||||
my ($sth, @data, $submission);
|
my ($sth, %data, $submission);
|
||||||
|
tie %data, 'Tie::CPHash';
|
||||||
$submission = "#language\n\n";
|
$submission = "#language\n\n";
|
||||||
|
$submission .= "delete from language where languageId=".$session{form}{lid}.";\n";
|
||||||
$sth = WebGUI::SQL->read("select * from language where languageId=".$session{form}{lid});
|
$sth = WebGUI::SQL->read("select * from language where languageId=".$session{form}{lid});
|
||||||
while (@data = $sth->array) {
|
while (%data = $sth->hash) {
|
||||||
$submission .= join("\t",@data)."\n";
|
$submission .= "insert into language (languageId,language,characterSet) values ("
|
||||||
|
.$data{languageId}.", ".quote($data{language}).", ".quote($data{characterSet}).");\n";
|
||||||
}
|
}
|
||||||
$sth->finish;
|
$sth->finish;
|
||||||
$submission .= "\n#international\n\n";
|
$submission .= "\n#international\n\n";
|
||||||
|
$submission .= "delete from international where languageId=".$session{form}{lid}.";\n";
|
||||||
$sth = WebGUI::SQL->read("select * from international where languageId=".$session{form}{lid});
|
$sth = WebGUI::SQL->read("select * from international where languageId=".$session{form}{lid});
|
||||||
while (@data = $sth->array) {
|
while (%data = $sth->hash) {
|
||||||
$submission .= join("\t",@data)."\n";
|
$submission .= "insert into international (internationalId,languageId,namespace,message) values ("
|
||||||
}
|
.$data{internationalId}.",".$data{languageId}.",".quote($data{namespace}).",".quote($data{message}).");\n";
|
||||||
$sth->finish;
|
|
||||||
$submission .= "\n#help\n\n";
|
|
||||||
$sth = WebGUI::SQL->read("select * from help where languageId=".$session{form}{lid});
|
|
||||||
while (@data = $sth->array) {
|
|
||||||
$submission .= join("\t",@data)."\n";
|
|
||||||
}
|
}
|
||||||
$sth->finish;
|
$sth->finish;
|
||||||
WebGUI::Mail::send("info\@plainblack.com","International Message Submission",$submission);
|
WebGUI::Mail::send("info\@plainblack.com","International Message Submission",$submission);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue