# HG changeset patch # User devi # Date 1141323211 -7200 # Node ID 62001c1e3295c5ebfa098efe21a7421362dd4162 # Parent 385499ec544aee4ce33c8bf29d45c1bfd4a3d03a Доделан вызов окна редактирования журнала. + исправлен баг с unicode diff -r 385499ec544a -r 62001c1e3295 l3-cgi --- a/l3-cgi Thu Mar 02 00:06:54 2006 +0200 +++ b/l3-cgi Thu Mar 02 20:13:31 2006 +0200 @@ -13,7 +13,7 @@ my %filter; -for my $key (qw(login_from local_session_id)) { +for my $key (qw(login_from local_session_id action)) { $filter{$key} = param($key) if param($key); $filter{$key} = $ENV{$key} if defined $ENV{$key}; } diff -r 385499ec544a -r 62001c1e3295 l3-frontend --- a/l3-frontend Thu Mar 02 00:06:54 2006 +0200 +++ b/l3-frontend Thu Mar 02 20:13:31 2006 +0200 @@ -11,7 +11,10 @@ our %Args_Description; our $Mywi_Socket; our %Sessions; + our %filter; +our $filter_url; +sub init_filter; our %Files; @@ -43,7 +46,9 @@ sub print_all_txt; sub print_all_html; +sub print_edit_all_html; sub print_command_lines_html; +sub print_command_lines_txt; sub print_files_html; sub print_stat_html; sub print_header_html; @@ -59,16 +64,34 @@ init_config(); $Config{frontend_ico_path}=$Config{frontend_css}; $Config{frontend_ico_path}=~s@/[^/]*$@@; + init_filter(); open_mywi_socket(); load_command_lines_from_xml($Config{"backend_datafile"}); load_sessions_from_xml($Config{"backend_datafile"}); sort_command_lines; process_command_lines; - print_all_txt($Config{"output"}); + if (defined($filter{action}) && $filter{action} eq "edit") { + print_edit_all_html($Config{"output"}); + } + else { + print_all_html($Config{"output"}); + } close_mywi_socket; } +sub init_filter +{ + if ($Config{filter}) { + # Инициализация фильтра + for (split /&/,$Config{filter}) { + my ($var, $val) = split /=/; + $filter{$var} = $val || ""; + } + } + $filter_url = join ("&", map("$_=$filter{$_}", keys %filter)); +} + # extract_from_cline # In: $what = commands | args @@ -237,6 +260,7 @@ open (CLASS, $datafile) or die "Can't open file with xml lablog ",$datafile,"\n"; local $/; + binmode CLASS, ":utf8"; $data = ; close(CLASS); @@ -253,9 +277,10 @@ { my $datafile = $_[0]; - open (CLASS, $datafile) + open (CLASS, $datafile) or die "Can't open file with xml lablog ",$datafile,"\n"; local $/; + binmode CLASS, ":utf8"; my $data = ; close(CLASS); @@ -301,11 +326,20 @@ sub process_command_lines { + +COMMAND_LINE_PROCESSING: for my $i (@Command_Lines_Index) { my $cl = \$Command_Lines[$i]; next if !$cl; + for my $filter_key (keys %filter) { + next COMMAND_LINE_PROCESSING + if defined($$cl->{local_session_id}) + && defined($Sessions{$$cl->{local_session_id}}->{$filter_key}) + && $Sessions{$$cl->{local_session_id}}->{$filter_key} ne $filter{$filter_key}; + } + $$cl->{id} = $$cl->{"time"}; $$cl->{err} ||=0; @@ -461,13 +495,6 @@ my @known_commands; - if ($Config{filter}) { - # Инициализация фильтра - for (split /&/,$Config{filter}) { - my ($var, $val) = split /=/; - $filter{$var} = $val || ""; - } - } $Stat{LastCommand} ||= 0; $Stat{TotalCommands} ||= 0; @@ -615,10 +642,12 @@ # Session change if ( $last_session ne $cl->{"local_session_id"}) { - my $tty = $cl->{"tty"}; - $this_day_result .= "
" + my $tty; + if (defined $Sessions{$cl->{"local_session_id"}}->{"tty"}) { + $this_day_result .= ""; + } $last_session=$cl->{"local_session_id"}; } @@ -817,7 +846,7 @@ # In: $_[0] output_filename # Out: -sub print_all_txt +sub print_command_lines_txt { my $output_filename=$_[0]; @@ -985,40 +1014,86 @@ $result .= $this_day_result; } + return $result; - my $SetCursorPosition_JS = <" + ."" + ."" + ."$title" + ."" ."" ."" + ."

Журнал лабораторных работ. Правка

" + ."
" ."" + ."
" + ."
" + ."

Внимательно правим, потом сохраняем

" + ."

Строки, начинающиеся символами #l3: можно трогать, только если точно знаешь, что делаешь

" ."" - ."" - ; + .""; + + if ($output_filename eq "-") { + print $result; } else { open(OUT, ">", $output_filename) or die "Can't open $output_filename for writing\n"; - print OUT "
$result
"; + binmode ":utf8"; + print OUT "$result"; + close(OUT); + } +} + +############# +# print_all_txt +# +# Вывести страницу с текстовым представлением журнала для редактирования +# +# In: $_[0] output_filename +# Out: + +sub print_all_txt +{ + my $result; + + $result = print_command_lines_txt; + + $result =~ s/>/>/g; + $result =~ s/</:utf8", $output_filename) + or die "Can't open $output_filename for writing\n"; + print OUT "$result"; close(OUT); } } @@ -1052,16 +1127,17 @@ $result.= "

Журнал

" . $command_lines; $result.= "

Файлы

" . $files_section if $files_section; - $result.= "

Статистика

" . print_stat; + $result.= "

Статистика

" . print_stat_html; $result.= "

Справка

" . $Html_Help . "
"; $result.= "

О программе

". $Html_About. "
"; $result.= print_footer_html; if ($output_filename eq "-") { + binmode STDOUT, ":utf8"; print $result; } else { - open(OUT, ">", $output_filename) + open(OUT, ">:utf8", $output_filename) or die "Can't open $output_filename for writing\n"; print OUT $result; close(OUT); @@ -1140,7 +1216,10 @@ -

Журнал лабораторных работ

+ +

Журнал лабораторных работ

HEADER if ( $course_student || $course_trainer @@ -1334,7 +1413,12 @@ . "" . "
".$Files{$file}->{content}."
"; } - return "
".collapse_list(\@toc)."
".$result; + if ($result) { + return "
".collapse_list(\@toc)."
".$result; + } + else { + return ""; + } } @@ -1665,6 +1749,21 @@ } JS +$SetCursorPosition_JS = < { "query" => "http://www.google.com/search?q=" , "icon" => "$Config{frontend_google_ico}" }, diff -r 385499ec544a -r 62001c1e3295 l3config.pm --- a/l3config.pm Thu Mar 02 00:06:54 2006 +0200 +++ b/l3config.pm Thu Mar 02 20:13:31 2006 +0200 @@ -1,6 +1,6 @@ - package l3config; +use utf8; use Exporter; use vars qw(@ISA @EXPORT $VERSION); use Getopt::Long; @@ -163,5 +163,8 @@ read_config_file(\%file_config, $User_Config_File); GetOptions(\%argv_config, map "$_=s", keys %Config); %Config = (%Config, %file_config, %argv_config); + for my $key (keys %Config) { + utf8::decode($Config{$key}); + } }