diff --git a/docs/upgrades/upgrade_4.2.0-4.3.0.sql b/docs/upgrades/upgrade_4.2.0-4.3.0.sql index 8ff86c812..571bfcdab 100644 --- a/docs/upgrades/upgrade_4.2.0-4.3.0.sql +++ b/docs/upgrades/upgrade_4.2.0-4.3.0.sql @@ -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'; + + + + + + diff --git a/lib/WebGUI/Operation/Help.pm b/lib/WebGUI/Operation/Help.pm index 9157d0d91..947e18daa 100644 --- a/lib/WebGUI/Operation/Help.pm +++ b/lib/WebGUI/Operation/Help.pm @@ -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 ''.$_[2].''; +} + +#------------------------------------------------------------------- +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 .= '
  • '._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 = '

    '.WebGUI::International::get(93).': '.$help{action}.' '.$help{object}.'

    '; - $output .= $help{body}; - $output .= '

    '.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 .= ' '.$data[1].' '.$data[2].','; - } - $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 .= ' '.$seeAlso{action}.' '.$seeAlso{object}.','; - } - $sth->finish; - $output .= ' '.WebGUI::International::get(95).''; + %help = WebGUI::SQL->quickHash("select * from help where helpId=$session{form}{hid} and namespace='$namespace'"); + $output = '

    '.WebGUI::International::get(93).': '. + WebGUI::International::get($help{titleId},$help{namespace}).'

    '; + $output .= WebGUI::International::get($help{bodyId},$help{namespace}); + $output .= '

    '.WebGUI::International::get(94).':

    '; 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 = '

    '.WebGUI::International::get(95).'

    '; - $output .= '
    '.WebGUI::International::get(96).'

    '; - $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 .= '

    '.$data[1].'
    '; - $previous = $data[1]; - } - $output .= '

  • '.$data[2].'
    '; + $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} .= '
      '.$seeAlso.'
    '; + } + $i++; } + $midpoint = round($i/2); $sth->finish; - $output .= '
  • '.WebGUI::International::get(97).'

    '; - $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 .= '

    '.$data[1].'
    '; - $previous = $data[1]; - } - $output .= '

  • '.$data[2].'
    '; - } - $sth->finish; - $output .= '
  • '; + $i = 0; + $output .= '
    '; + foreach $key (keys %sortedIndex) { + if ($i == $midpoint) { + $output .= ''; + } + $output .= $sortedIndex{$key}.'

    '; + $i++; + } + $output .= '

    '; return $output; } diff --git a/lib/WebGUI/Operation/Image.pm b/lib/WebGUI/Operation/Image.pm index c33d90b43..1ff814040 100644 --- a/lib/WebGUI/Operation/Image.pm +++ b/lib/WebGUI/Operation/Image.pm @@ -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 .= '

    '.WebGUI::International::get(545).'

    '; $f = WebGUI::HTMLForm->new; $f->hidden("op","editImageGroupSave"); diff --git a/lib/WebGUI/Operation/International.pm b/lib/WebGUI/Operation/International.pm index b616b020f..4eb60fb6c 100644 --- a/lib/WebGUI/Operation/International.pm +++ b/lib/WebGUI/Operation/International.pm @@ -36,7 +36,6 @@ sub _submenu { $output .= ''; $output .= '
  • '.WebGUI::International::get(598).''; $output .= '
  • '.WebGUI::International::get(594).''; - $output .= '
  • '.WebGUI::International::get(599).''; $output .= '
  • '.WebGUI::International::get(593).''; $output .= '
  • '.WebGUI::International::get(585).''; $output .= '
  • '.WebGUI::International::get(493).''; @@ -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 = '

    '.WebGUI::International::get(602).'

    '; - $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 .= ''; } @@ -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);