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 endDate int not null default 2082783600;
|
||||
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 strict;
|
||||
use Tie::IxHash;
|
||||
use Tie::CPHash;
|
||||
use WebGUI::International;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
use WebGUI::URL;
|
||||
use WebGUI::Utility;
|
||||
|
||||
our @ISA = qw(Exporter);
|
||||
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 {
|
||||
my ($output, %help, @data, $sth, %seeAlso, $namespace);
|
||||
my ($output, %help, $namespace);
|
||||
$namespace = $session{form}{namespace} || "WebGUI";
|
||||
tie %help, 'Tie::CPHash';
|
||||
%help = WebGUI::SQL->quickHash("select * from help where helpId=$session{form}{hid} and namespace='$namespace' and
|
||||
languageId='$session{user}{language}'");
|
||||
if ($help{action} eq "") {
|
||||
%help = WebGUI::SQL->quickHash("select * from help where helpId=$session{form}{hid} and namespace='$namespace' and languageId=1");
|
||||
}
|
||||
$output = '<h1>'.WebGUI::International::get(93).': '.$help{action}.' '.$help{object}.'</h1>';
|
||||
$output .= $help{body};
|
||||
$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>';
|
||||
%help = WebGUI::SQL->quickHash("select * from help where helpId=$session{form}{hid} and namespace='$namespace'");
|
||||
$output = '<h1>'.WebGUI::International::get(93).': '.
|
||||
WebGUI::International::get($help{titleId},$help{namespace}).'</h1>';
|
||||
$output .= WebGUI::International::get($help{bodyId},$help{namespace});
|
||||
$output .= '<p><b>'.WebGUI::International::get(94).':<ul>';
|
||||
$output .= _seeAlso($help{seeAlso});
|
||||
$output .= '<li><a href="'.WebGUI::URL::page('op=viewHelpIndex').'">'.WebGUI::International::get(95).'</a></ul>';
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
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 .= '<table width="100%"><tr><td valign="top"><b>'.WebGUI::International::get(96).'</b><p>';
|
||||
$sth = WebGUI::SQL->read("select helpId, action, object, namespace from help where languageId='$session{user}{language}' order by action,object");
|
||||
unless ($sth->rows) {
|
||||
$sth->finish;
|
||||
$sth = WebGUI::SQL->read("select helpId, action, object, namespace from help where languageId=1 order by action,object");
|
||||
}
|
||||
while (@data = $sth->array) {
|
||||
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])
|
||||
.'">'.$data[2].'</a><br>';
|
||||
$sth = WebGUI::SQL->read("select helpId,namespace,titleId,seeAlso from help");
|
||||
while (%help = $sth->hash) {
|
||||
$title = WebGUI::International::get($help{titleId},$help{namespace});
|
||||
$index{$title} = _helpLink($help{helpId},$help{namespace},$title);
|
||||
$seeAlso = _seeAlso($help{seeAlso});
|
||||
if ($seeAlso ne "") {
|
||||
$index{$title} .= '<span style="font-size: 11px"><ul>'.$seeAlso.'</ul></span>';
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$midpoint = round($i/2);
|
||||
$sth->finish;
|
||||
$output .= '</td><td valign="top"><b>'.WebGUI::International::get(97).'</b><p>';
|
||||
$sth = WebGUI::SQL->read("select helpId, object, action, namespace from help where languageId='$session{user}{language}' order by object,action");
|
||||
unless ($sth->rows) {
|
||||
$sth->finish;
|
||||
$sth = WebGUI::SQL->read("select helpId, object, action, namespace from help where languageId=1 order by object,action");
|
||||
foreach $key (sort {$a cmp $b} keys %index) {
|
||||
$sortedIndex{$key}=$index{$key};
|
||||
}
|
||||
while (@data = $sth->array) {
|
||||
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])
|
||||
.'">'.$data[2].'</a><br>';
|
||||
}
|
||||
$sth->finish;
|
||||
$output .= '</td></tr></table>';
|
||||
$i = 0;
|
||||
$output .= '<table width="100%"><tr><td width="50%" valign="top" class="content">';
|
||||
foreach $key (keys %sortedIndex) {
|
||||
if ($i == $midpoint) {
|
||||
$output .= '</td><td width="50%" valign="top" class="content">';
|
||||
}
|
||||
$output .= $sortedIndex{$key}.'<p>';
|
||||
$i++;
|
||||
}
|
||||
$output .= '</table>';
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -314,7 +314,7 @@ sub www_editImageGroup {
|
|||
%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}");
|
||||
$output = helpIcon(20);
|
||||
$output = helpIcon(36);
|
||||
$output .= '<h1>'.WebGUI::International::get(545).'</h1>';
|
||||
$f = WebGUI::HTMLForm->new;
|
||||
$f->hidden("op","editImageGroupSave");
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ sub _submenu {
|
|||
$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=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=listLanguages').'">'.WebGUI::International::get(585).'</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 {
|
||||
my ($output, $message, $f, $language);
|
||||
|
|
@ -197,7 +143,6 @@ sub www_editLanguage {
|
|||
if ($session{form}{lid} ne "new") {
|
||||
$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=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 .= '</ul>';
|
||||
}
|
||||
|
|
@ -353,23 +298,22 @@ sub www_submitTranslation {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_submitTranslationConfirm {
|
||||
my ($sth, @data, $submission);
|
||||
my ($sth, %data, $submission);
|
||||
tie %data, 'Tie::CPHash';
|
||||
$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});
|
||||
while (@data = $sth->array) {
|
||||
$submission .= join("\t",@data)."\n";
|
||||
while (%data = $sth->hash) {
|
||||
$submission .= "insert into language (languageId,language,characterSet) values ("
|
||||
.$data{languageId}.", ".quote($data{language}).", ".quote($data{characterSet}).");\n";
|
||||
}
|
||||
$sth->finish;
|
||||
$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});
|
||||
while (@data = $sth->array) {
|
||||
$submission .= join("\t",@data)."\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";
|
||||
while (%data = $sth->hash) {
|
||||
$submission .= "insert into international (internationalId,languageId,namespace,message) values ("
|
||||
.$data{internationalId}.",".$data{languageId}.",".quote($data{namespace}).",".quote($data{message}).");\n";
|
||||
}
|
||||
$sth->finish;
|
||||
WebGUI::Mail::send("info\@plainblack.com","International Message Submission",$submission);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue