[AppWrap-cvs] AppWrap/Apache/AppWrap Pager.pm,1.16,1.17
Status: Beta
Brought to you by:
planetman
From: <pla...@us...> - 2002-12-26 01:31:56
|
Update of /cvsroot/appwrap/AppWrap/Apache/AppWrap In directory sc8-pr-cvs1:/tmp/cvs-serv31488 Modified Files: Pager.pm Log Message: fixed bug in even numbered 'sb' query string args; more i18n. Index: Pager.pm =================================================================== RCS file: /cvsroot/appwrap/AppWrap/Apache/AppWrap/Pager.pm,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** Pager.pm 21 Dec 2002 11:08:21 -0000 1.16 --- Pager.pm 26 Dec 2002 01:31:53 -0000 1.17 *************** *** 18,25 **** use AppWrap qw(%config); use Apache::AppWrap::Subs qw($dbh $HNL); - use Date::Format; - use Date::Parse; - use Date::Calc qw(Week_of_Year); - use Data::Dumper; use vars qw($VERSION); use Apache::Log (); --- 18,21 ---- *************** *** 27,31 **** use Apache::Constants qw(:common); ! $Apache::AppWrap::Pager::VERSION = "0.07"; # 13Dec02. Replaced "alt" attributes with "title" in <img> tags # 03Dec02. convert to my_tables table_type directive --- 23,27 ---- use Apache::Constants qw(:common); ! $Apache::AppWrap::Pager::VERSION = "0.08"; # 13Dec02. Replaced "alt" attributes with "title" in <img> tags # 03Dec02. convert to my_tables table_type directive *************** *** 62,73 **** ! my $kv = $opts->{valid_kv} || $opts->{args}{kv}; ! $kv ||= $opts->{args}{idnum}; ! # default sort order for this table ! my $sb = $opts->{args}{sb} || $args->{default_sort}; ! $sb ||= $my_tables->{$table}{default_sort} || 1; ! #print Dumper($source); ! my $r = Apache::Request->instance( Apache->request ); #$test = scalar(@$source); #$log->debug("\npaginator: source=$test."); --- 58,68 ---- ! my $kv = $opts->{valid_kv} || $opts->{args}{kv}; ! $kv ||= $opts->{args}{idnum}; ! # default sort order for this table ! my $sb = $opts->{args}{sb} || $args->{default_sort}; ! $sb ||= $my_tables->{$table}{default_sort} || 1; ! my $r = Apache::Request->instance( Apache->request ); #$test = scalar(@$source); #$log->debug("\npaginator: source=$test."); *************** *** 143,171 **** my $sb = $order * 2 - 1; $sort_hash{$sb} = fill_sort($sb, $column, $label); ! $sb = $order * 2 - 1; $sort_hash{$sb} = fill_sort($sb, $column, $label); } my $sort_by = $sort_hash{$sb}{sql}; # %args shares with downstream subs data which should ! # not be persistent between requests. my %args = ( - 'caller' => 'paginator', element => 'title', sort_hash => \%sort_hash, ); - # this is how we get display text - my $msgs = $opts->{display_text}; - $msgs ||= Apache::AppWrap::Subs::get_display_text($opts); - unless ($msgs) { - my $text = 'paginator: display_text not found in %opts.'; - $r->log_error($text); - return SERVER_ERROR; - } - $opts->{display_text} ||= $msgs; - $opts->{msgs} = $msgs; - $args{kv} = $kv if $kv; --- 138,157 ---- my $sb = $order * 2 - 1; $sort_hash{$sb} = fill_sort($sb, $column, $label); ! $sb = $order * 2; $sort_hash{$sb} = fill_sort($sb, $column, $label); } + #$test = join("\n", map {$_ . '=>' . $sort_hash{$_}{label} } sort {$a <=> $b} keys %sort_hash); + #$log->debug("\npaginator: sort_hash=\n$test."); my $sort_by = $sort_hash{$sb}{sql}; # %args shares with downstream subs data which should ! # not be persistent between requests. $args{caller} will ! # come from $opts->{phase}. my %args = ( element => 'title', sort_hash => \%sort_hash, ); $args{kv} = $kv if $kv; *************** *** 176,187 **** } ! # save title for &Webify ! $opts->{Title} = Apache::AppWrap::Subs::chk_txt($opts, \%args); # subtitles are not mandatory: some tables have none. $args{element} = 'subtitle'; $args{sb_label} = $sort_hash{$sb}{label}; # save subitle for &Webify $opts->{SubTitle} = Apache::AppWrap::Subs::chk_txt($opts, \%args); #$log->debug("\npaginator: sb=$sb, $sort_hash{$sb}{column}."); --- 162,180 ---- } ! # save title for &Webify. Upstream sub may already have ! # populated the Title element, so test for that ! unless (exists $opts->{Title}) { ! $args{element} = 'title'; ! my $title = Apache::AppWrap::Subs::chk_txt($opts, \%args); ! $opts->{Title} = $title; ! } # subtitles are not mandatory: some tables have none. + unless (exists $opts->{SubTitle}) { $args{element} = 'subtitle'; $args{sb_label} = $sort_hash{$sb}{label}; # save subitle for &Webify $opts->{SubTitle} = Apache::AppWrap::Subs::chk_txt($opts, \%args); + } #$log->debug("\npaginator: sb=$sb, $sort_hash{$sb}{column}."); *************** *** 230,236 **** # an array ref. sort { lc($b->[3][0]) cmp lc($a->[3][0]) } ! map { ! [$_, $row = $_, $column = $sort_column, eval $sort_eval] ! } @$source; } else { --- 223,229 ---- # an array ref. sort { lc($b->[3][0]) cmp lc($a->[3][0]) } ! map { ! [$_, $row = $_, $column = $sort_column, eval $sort_eval] ! } @$source; } else { *************** *** 238,242 **** @$sorted_data = map { $_->[0] } sort { lc($a->[3][0]) cmp lc($b->[3][0]) } ! map { [$_, $row = $_, $column = $sort_column, eval $sort_eval] } @$source; } # end $sb IF } # end 'indirect_sort' IF --- 231,237 ---- @$sorted_data = map { $_->[0] } sort { lc($a->[3][0]) cmp lc($b->[3][0]) } ! map { ! [$_, $row = $_, $column = $sort_column, eval $sort_eval] ! } @$source; } # end $sb IF } # end 'indirect_sort' IF *************** *** 267,271 **** #$test = scalar(@$sorted_data); #$log->debug("\npaginator: rows=$test."); ! ############## end of massive sort section #################### # Calculate which rows to grab for this page. We want to grab one --- 262,266 ---- #$test = scalar(@$sorted_data); #$log->debug("\npaginator: rows=$test."); ! ############## end of sort section #################### # Calculate which rows to grab for this page. We want to grab one *************** *** 297,307 **** } ! my $row_count = scalar(@$to_display) if $to_display; ! $opts->{row_count} = $row_count; ! ######## this is the visualization icon section ######## ! # start the table with a div so we can control it a bit. ! # This <div> actually encompasses more than a single table. ! # We could manage that better, but we are trying to hurry ! # to get the site presentable again for the next release. # get the data_header section --- 292,303 ---- } ! my $row_count = scalar(@$to_display) if $to_display; ! $opts->{row_count} = $row_count; ! ! ######## this is the data_header section ######## ! # start the table with a div so we can control it a bit. ! # This <div> actually encompasses more than a single table. ! # We could manage that better, but we are trying to hurry ! # to get the site presentable again for the next release. # get the data_header section *************** *** 310,320 **** push @rows, map $_, @$data_header; } ! push @rows, '<!-- start the table data from &paginator -->' . $HNL; ! push @rows, '<div id="pager">' . $HNL; - ############################################################ - # code works, but display not working, possible issue with browser - # compliance to standards? - ############################################################ # print the data column headings. # hash "%hh" <col> tags preceed the <tr> tags so we have to loop an --- 306,312 ---- push @rows, map $_, @$data_header; } ! push @rows, '<!-- start the table data from &paginator -->' . $HNL; ! push @rows, '<div id="pager">' . $HNL; # print the data column headings. # hash "%hh" <col> tags preceed the <tr> tags so we have to loop an *************** *** 418,422 **** $all .= '<a href="' . $config{homeurl} . $r->uri; $all .= '?sb=' . $sort{$column}; - # $all .= '<a href="' . $r->uri . '?sb=' . $sort{$column}; # this is used by Display handler, $kv won't exist for # reports --- 410,413 ---- *************** *** 551,556 **** # convert a line of all white space to a html space $value =~ s/^\s+$/\ /; ! $value =~ s!( ! )!<br />!g; $value =~ s!\n!<br />!g; $out .= $value; --- 542,547 ---- # convert a line of all white space to a html space $value =~ s/^\s+$/\ /; ! # trying to replace a newline embedded in the data ! # $value =~ s!()!<br />!g; $value =~ s!\n!<br />!g; $out .= $value; *************** *** 571,575 **** push @rows, $out; } # end of columns loop - # $opts->{table} = $table; push @rows, '</tr>' . $HNL; --- 562,565 ---- *************** *** 675,679 **** # right cell, get any data navigation icons my $nav; ! unless (exists $opts->{args}{top_summary}) { $nav = navigate($opts, $args); } --- 665,670 ---- # right cell, get any data navigation icons my $nav; ! unless (exists $opts->{args}{top_summary} || ! $my_tables->{$table}{table_type} eq 'report') { $nav = navigate($opts, $args); } *************** *** 698,720 **** ############################### sub visualize { ! my ($opts, $args) = @_; ! my $r = Apache->request; ! my $log = $r->log; ! my $my_tables = $opts->{my_tables}; ! my $table = $opts->{table}; ! my $my_columns = $opts->{my_columns}; ! my $my_defaults = $opts->{my_defaults}; ! my $msgs = $opts->{display_text}; ! # bail if visualization not enabled ! # might also check for the existence of the required CPAN modules(s) ! # and bail if not found ! return unless $my_defaults->{dv_enabled}; ! # bail if this is a tab summary, visualization useless. ! # bail if visualization would be meaningless ! return if $r->uri =~ m/focus|audit/; ! # list of visualizations. Must exist in table:my_defaults, and ! # have TRUE value. We use the name with leading 'dv_' removed. my @dv_types = grep { /^dv_/ && $my_defaults->{$_} && s/^dv_// --- 689,711 ---- ############################### sub visualize { ! my ($opts, $args) = @_; ! my $r = Apache->request; ! my $log = $r->log; ! my $my_tables = $opts->{my_tables}; ! my $table = $opts->{table}; ! my $my_columns = $opts->{my_columns}; ! my $my_defaults = $opts->{my_defaults}; ! my $msgs = $opts->{display_text}; ! # bail if visualization not enabled ! # might also check for the existence of the required CPAN modules(s) ! # and bail if not found ! return unless $my_defaults->{dv_enabled}; ! # bail if this is a tab summary, visualization useless. ! # bail if visualization would be meaningless ! return if $r->uri =~ m/focus|audit/; ! # list of visualizations. Must exist in table:my_defaults, and ! # have TRUE value. We use the name with leading 'dv_' removed. my @dv_types = grep { /^dv_/ && $my_defaults->{$_} && s/^dv_// *************** *** 734,739 **** # wrap the images in a <div> tag push @rows, ' <div class="icons">' . $HNL; - # # wrap the images in a <p> tag - # push @rows, ' <p>'; # create the links foreach my $dv (@dv_types) { --- 725,728 ---- *************** *** 788,799 **** ############################ sub navigate { ! my ($opts, $args) = @_; ! my $table = $opts->{table}; ! my $my_tables = $opts->{my_tables}; ! my $my_columns = $opts->{my_columns}; ! my $my_defaults = $opts->{my_defaults}; ! my $msgs = $opts->{display_text}; ! my $r = Apache->request; ! my $idnum = $opts->{args}{idnum}; my $sb = $opts->{args}{sb}; --- 777,788 ---- ############################ sub navigate { ! my ($opts, $args) = @_; ! my $table = $opts->{table}; ! my $my_tables = $opts->{my_tables}; ! my $my_columns = $opts->{my_columns}; ! my $my_defaults = $opts->{my_defaults}; ! my $msgs = $opts->{display_text}; ! my $r = Apache->request; ! my $idnum = $opts->{args}{idnum}; my $sb = $opts->{args}{sb}; *************** *** 809,819 **** # $args is a hash ref so that receiving subs can modify ! # values which later subs will see. ! $args->{'caller'} = 'navigate'; $args->{label} = $link_vars->{label}; $args->{sb} = $sb; $args->{current_unit} = $opts->{args}{page} || 1; - # $test = join(", ", keys %$args); - #$log->debug("\nnavigate: keys=$test"); my $rc = nav_series($opts, $args); --- 798,807 ---- # $args is a hash ref so that receiving subs can modify ! # values which later subs will see. Respect 'caller' ! # value set by upstream subs. ! $args->{'caller'} ||= 'navigate'; $args->{label} = $link_vars->{label}; $args->{sb} = $sb; $args->{current_unit} = $opts->{args}{page} || 1; my $rc = nav_series($opts, $args); *************** *** 830,834 **** } @{ $opts->{col_order} }; - my @rows; # start the <div> --- 818,821 ---- *************** *** 841,845 **** my $navigate_title = Apache::AppWrap::Subs::chk_txt($opts, $args); # add a little space to make the HTML more readable ! push @rows, ' ' . $navigate_title . $HNL; # get the sequence info. Dynamic values are embedding --- 828,832 ---- my $navigate_title = Apache::AppWrap::Subs::chk_txt($opts, $args); # add a little space to make the HTML more readable ! push @rows, ' ' . $navigate_title . $HNL if $navigate_title; # get the sequence info. Dynamic values are embedding *************** *** 849,853 **** my $sequence = Apache::AppWrap::Subs::chk_txt($opts, $args); # add a little space to make the HTML more readable ! push @rows, ' ' . $sequence . $HNL; # call the sub to populate navigation icons --- 836,840 ---- my $sequence = Apache::AppWrap::Subs::chk_txt($opts, $args); # add a little space to make the HTML more readable ! push @rows, ' ' . $sequence . $HNL if $sequence; # call the sub to populate navigation icons *************** *** 876,884 **** $args->{by_vals} = \@by_vals; my $nav_popup = nav_popup($opts, $args); ! # unless ($nav_popup ) { ! # my $msg = 'navigate: nav_popup returned undef or no data.'; ! # $r->log_error($msg); ! # return SERVER_ERROR; ! # } push @rows, map ($_, @$nav_popup); } --- 863,871 ---- $args->{by_vals} = \@by_vals; my $nav_popup = nav_popup($opts, $args); ! unless ($nav_popup || scalar(@$nav_popup)) { ! my $msg = 'navigate: nav_popup returned undef or no data.'; ! $r->log_error($msg); ! return SERVER_ERROR; ! } push @rows, map ($_, @$nav_popup); } *************** *** 886,894 **** push @rows, $text . $HNL; ! # close the <div> ! $text = '</div> <!-- end of navigate section -->'; ! push @rows, $text . $HNL; ! return \@rows; } # end &navigate --- 873,881 ---- push @rows, $text . $HNL; ! # close the <div> ! $text = '</div> <!-- end of navigate section -->'; ! push @rows, $text . $HNL; ! return \@rows; } # end &navigate *************** *** 931,935 **** my $sb = $order * 2 - 1; $sort_hash{$sb} = fill_sort($sb, $column, $label); ! $sb = $order * 2 - 1; $sort_hash{$sb} = fill_sort($sb, $column, $label); } --- 918,922 ---- my $sb = $order * 2 - 1; $sort_hash{$sb} = fill_sort($sb, $column, $label); ! $sb = $order * 2; $sort_hash{$sb} = fill_sort($sb, $column, $label); } *************** *** 961,969 **** if ($sb) { $order_by = $sort_hash{$sb}{column}; - # $order_by = $sort_hash{$sb}{column} . ' ASC'; } else { $order_by = $by; - # $order_by = $by . ' ASC'; } --- 948,954 ---- *************** *** 1031,1034 **** --- 1016,1020 ---- $rows_per ||= $my_defaults->{rows_per}; + # error check the value is available. unless ($row_count) { my $msg = 'nav_series: number id rows undefined.'; *************** *** 1047,1055 **** $args->{previous_unit} = $page - 1; } ! #$log->debug("\nnav_series: total_rows=$total_rows, row_count=$row_count, rows_per=$rows_per."); ! # to get the value of the highest row number in ! # the current data set subtract 1 from the page, ! # then multiply this value time the number of rows ! # on each page, finally add 1. my $max_current_row = $page * $rows_per + 1; if ( $total_rows >= $max_current_row ) { --- 1033,1040 ---- $args->{previous_unit} = $page - 1; } ! # to get the value of the highest row number in the ! # current data set subtract 1 from the page, then ! # multiply this value time the number of rows on each ! # page, finally add 1. my $max_current_row = $page * $rows_per + 1; if ( $total_rows >= $max_current_row ) { *************** *** 1080,1085 **** my $by = $opts->{args}{by} || 'idnum'; ! # these values are used by some of the ALT messages ! $args->{'caller'} = 'nav_icons'; my $img_dir = $config{imageurl} || $config{homeurl}; --- 1065,1071 ---- my $by = $opts->{args}{by} || 'idnum'; ! # these values are used by the ALT messages. An upstream ! # sub may have set the value. ! $args->{'caller'} ||= 'nav_icons'; my $img_dir = $config{imageurl} || $config{homeurl}; *************** *** 1091,1095 **** $img_dir .= '/' . $config{images}; ! # get the height and width of the navigation icons my $img_height = $my_defaults->{navigate_img_height}; unless ($img_height) { --- 1077,1082 ---- $img_dir .= '/' . $config{images}; ! # get the height and width of the navigation icons. They ! # must exist so test for them my $img_height = $my_defaults->{navigate_img_height}; unless ($img_height) { *************** *** 1123,1127 **** last if (! exists $opts->{args}{idnum} && $icon eq 'edit'); $args->{element} = 'alt_' . $icon; - #$log->debug("\nnavigate: icon=$icon, raw_alt=$raw_alt."); my $alt = Apache::AppWrap::Subs::chk_txt($opts, $args); my $url = $config{homeurl} . '/' . $table . '/' . $icon; --- 1110,1113 ---- *************** *** 1230,1238 **** my $selected = ''; # @values is the list of product_id to display foreach my $column (@{ $args->{by_vals} }) { - # next if $column =~ /$my_defaults->{default_picklist}/o; my $label = $my_columns->{$table}{$column}{label}; - # determine if a value is among the defaults by comparing each - # default ($_) with the current product number ($value) my $menu = ' <option'; # make this the displayed column if it is the $by value --- 1216,1223 ---- my $selected = ''; # @values is the list of product_id to display + # populate the popup menu. 'selected' is set for the + # field indicated by the value of $sb foreach my $column (@{ $args->{by_vals} }) { my $label = $my_columns->{$table}{$column}{label}; my $menu = ' <option'; # make this the displayed column if it is the $by value |