[AppWrap-cvs] AppWrap/Apache/AppWrap Focus.pm,1.10,1.11
Status: Beta
Brought to you by:
planetman
From: <pla...@us...> - 2002-12-30 09:34:02
|
Update of /cvsroot/appwrap/AppWrap/Apache/AppWrap In directory sc8-pr-cvs1:/tmp/cvs-serv13945 Modified Files: Focus.pm Log Message: Completed i18n on related subroutines Index: Focus.pm =================================================================== RCS file: /cvsroot/appwrap/AppWrap/Apache/AppWrap/Focus.pm,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Focus.pm 26 Dec 2002 01:35:47 -0000 1.10 --- Focus.pm 30 Dec 2002 09:33:57 -0000 1.11 *************** *** 17,21 **** use vars qw($VERSION); ! $Apache::AppWrap::Focus::VERSION = '0.06'; # 13Dec02. Sub'd out &nav_popup; added prepare_cached DBI calls # 11Dec02. 1i18n; navigate_img_(height|width) directives added --- 17,22 ---- use vars qw($VERSION); ! $Apache::AppWrap::Focus::VERSION = '0.07'; ! # 26Dec02. Completed i18n on subs # 13Dec02. Sub'd out &nav_popup; added prepare_cached DBI calls # 11Dec02. 1i18n; navigate_img_(height|width) directives added *************** *** 80,84 **** $opts->{SubTitle} = $subtitle; - # get the data_header section my $dh = Apache::AppWrap::Pager::data_header($opts, \%args); --- 81,84 ---- *************** *** 163,189 **** $menu_func ||= $my_defaults->{func_focus}; $menu_func ||= $my_defaults->{func_default}; ! ! # call functions if defined. Functions return array of to ! # data wrapped in <td> tags ! if ($menu_func) { ! my @subs = split(/\s*;\s*/, $menu_func ); ! foreach my $sub (@subs) { ! $log->debug("\nFocus: eval_sub=$sub"); ! my $ref = eval $sub; ! if ($ref && scalar(@$ref)) { ! push @{ $opts->{menuitems} }, join("", @$ref); ! } ! } ! } ! push @{ $opts->{Rows} }, join("", @rows); ! # comply with HEAD request ! if ($r->header_only) { ! $r->send_http_header; ! return OK; ! } ! Apache::AppWrap::Subs::Webify($opts); ! return OK; } # end handler --- 163,189 ---- $menu_func ||= $my_defaults->{func_focus}; $menu_func ||= $my_defaults->{func_default}; ! ! # call functions if defined. Functions return array of to ! # data wrapped in <td> tags ! if ($menu_func) { ! my @subs = split(/\s*;\s*/, $menu_func ); ! foreach my $sub (@subs) { ! my $ref = eval $sub; ! if ($ref && scalar(@$ref)) { ! my $result = join("", @$ref); ! push @{ $opts->{menuitems} }, join("", @$ref); ! } ! } ! } ! push @{ $opts->{Rows} }, join("", @rows); ! # comply with HEAD request ! if ($r->header_only) { ! $r->send_http_header; ! return OK; ! } ! Apache::AppWrap::Subs::Webify($opts); ! return OK; } # end handler *************** *** 208,212 **** my $log = Apache->request->log; ! $log->debug("\nfocus_stats2: here."); # list distict db entries for this control except if # control = (idnum|date). We make these 2 exceptions --- 208,216 ---- my $log = Apache->request->log; ! my %args = ( ! table => $table, ! 'caller' => 'focus_stats2', ! element => 'table_heading', ! ); # list distict db entries for this control except if # control = (idnum|date). We make these 2 exceptions *************** *** 221,256 **** my $label = $my_columns->{$table}{$column}{label}; push @rows, '<table>' . $HNL; ! # my $text = ' <tr><th>' . $label; ! # $text .= '</th><th>Count</th></tr>'; ! my %args = ( ! 'caller' => 'focus_stats2', ! element => 'table_heading', ! label => $label, ! ); ! my $show = ' '; my $text = Apache::AppWrap::Subs::chk_txt($opts, \%args); ! $show .= $text if $text; ! push @rows, $show . $HNL; ! ! # my $text = '<tr><th>' . $args->{label} . '</th><th>Count</th></tr>'; ! # push @rows, $text . $HNL; ! my $sql = qq{SeLecT disTInct($by),MAX(idnum),COUNT($by)}; ! $sql .= qq{ FROM $table GROUP BY $by}; my $sth = $dbh->prepare_cached($sql); ! my $rc = $sth-execute(); ! # make a link (idnum & $by) for each distinct db entry while (my $row = $sth->fetchrow_hashref) { # Handle the varied column inputs by processing with the ! # func_focus subroutine in my_columns. This is a bit ugly ! # now so needs work. But it functions correctly. my ($ary, $val); # get the func_focus sub ! my $func_focus; ! if ($my_columns->{$table}{$column}{func_focus}) { ! $func_focus = $my_columns->{$table}{$column}{func_focus}; ! } ! # if it exists, run it. if not, use the input value directly if ($func_focus) { $ary = eval $func_focus; --- 225,249 ---- my $label = $my_columns->{$table}{$column}{label}; push @rows, '<table>' . $HNL; ! $args{label} = $label, ! #$log->debug("\nfocus_stats2: before chk_txt."); my $text = Apache::AppWrap::Subs::chk_txt($opts, \%args); ! push @rows, ' ' . $text . $HNL if $text; ! my $sql = qq{ ! SeLecT disTInct($by), MAX(idnum) AS max_id, COUNT($by) as qty FROM $table GROUP BY $by ! }; my $sth = $dbh->prepare_cached($sql); ! my $rc = $sth->execute(); ! ! # set the element for data rows # make a link (idnum & $by) for each distinct db entry while (my $row = $sth->fetchrow_hashref) { # Handle the varied column inputs by processing with the ! # func_focus subroutine in my_columns. my ($ary, $val); # get the func_focus sub ! my $func_focus = $my_columns->{$table}{$column}{func_focus}; ! ! # if a sub exists, eval it, otherwise show the data if ($func_focus) { $ary = eval $func_focus; *************** *** 262,279 **** $val = $row->{$column}; } ! # could be some newlines in the data, so delete them $val =~ s/\n/<br \/>/g if $val; ! $result = html_blank($val); ! # this hash element key is a messy string with the ! # column embedded. ! my $count = 'COUNT(' . $by . ')'; ! # now fromat the html output ! my $stat = ' <tr><td class="first"><a href="/' . $table; ! $stat .= '/focus?idnum=' . $row->{'MAX(idnum)'} . '&by='; ! $stat .= $by . '">' . $result . '</a></td><td>'; ! $stat .= $row->{$count} . '</td></tr>' . $HNL; ! push @rows, $stat; } # close the WHILE ! push @rows, '</table>' . $HNL; } # close the IF return \@rows; --- 255,270 ---- $val = $row->{$column}; } ! #$log->debug("\nfocus_stats2: val=$val."); ! # could be some newlines in the data, so replace $val =~ s/\n/<br \/>/g if $val; ! ! # now format the html output ! my $text = '<tr><td class="first">'; ! $text .= qq{<a href="/$table/focus?idnum=$row->{max_id}}; ! $text .= '&by=' . $by . '">' . $val . '</a></td>'; ! $text .= '<td>' . $row->{qty} . '</td></tr>'; ! push @rows, ' ' . $text . $HNL; } # close the WHILE ! push @rows, ' </table>' . $HNL; } # close the IF return \@rows; *************** *** 295,303 **** my $my_columns = $opts->{my_columns}; my (@rows, @fields); ! ### color coded links ! my $link_vars = cclinks($opts); my $label = $link_vars->{label}; # push the header # get count of distinct entries in each sortable field --- 286,299 ---- my $my_columns = $opts->{my_columns}; my (@rows, @fields); + my $log = Apache->request->log; ! # color coded links ! my $link_vars = Apache::AppWrap::Subs::cclinks($opts); my $label = $link_vars->{label}; + my %args = ( + 'caller' => 'focus_stats1', + ); + #$log->debug("\nfocus_stats1."); # push the header # get count of distinct entries in each sortable field *************** *** 309,325 **** my $i = $sth->rows; $sth->finish; if ($by eq 'idnum') { ! my $text = ' <p class="bodyheader">' . $label; ! $text .= ' records.</p>' . $HNL; ! push @rows, $text; ! next; } ! my $unit = ' value'; ! $i > 1 ? $unit .= 's</p>' : $unit .= '</p>'; ! my $label = $my_columns->{$table}{$by}{label}; ! push @rows, ' <p>' . $i . ' unique '; ! push @rows, $label . $unit . $HNL; } - ### return \@rows; } # end &focus_stats1 --- 305,331 ---- my $i = $sth->rows; $sth->finish; + + # get the correct unit + if ($i > 1) { + $args{element} = 'values'; + $args{unit} = Apache::AppWrap::Subs::chk_txt($opts, \%args); + } + else { + $args{element} = 'value'; + $args{unit} = Apache::AppWrap::Subs::chk_txt($opts, \%args); + } + if ($by eq 'idnum') { ! $args{element} = 'table_heading'; } ! else { ! $args{element} = 'row_data'; ! } ! ! $args{count} = $i; ! $args{label} = $my_columns->{$table}{$by}{label}; ! my $text = Apache::AppWrap::Subs::chk_txt($opts, \%args); ! push @rows, ' ' . $text . $HNL if $text; } return \@rows; } # end &focus_stats1 |