[AppWrap-cvs] AppWrap/Apache/AppWrap Chart_Counts.pm,1.7,1.8 Doorknob.pm,1.14,1.15 Pager.pm,1.19,1.2
Status: Beta
Brought to you by:
planetman
From: <pla...@us...> - 2003-01-19 23:29:27
|
Update of /cvsroot/appwrap/AppWrap/Apache/AppWrap In directory sc8-pr-cvs1:/tmp/cvs-serv15183 Modified Files: Chart_Counts.pm Doorknob.pm Pager.pm Subs.pm Log Message: i18n Index: Chart_Counts.pm =================================================================== RCS file: /cvsroot/appwrap/AppWrap/Apache/AppWrap/Chart_Counts.pm,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Chart_Counts.pm 9 Dec 2002 10:05:43 -0000 1.7 --- Chart_Counts.pm 19 Jan 2003 23:29:24 -0000 1.8 *************** *** 24,120 **** use vars qw($VERSION); ! $Apache::AppWrap::Chart_Counts::VERSION = '0.04'; ############################ # 08Dec02. CSS, warnings pragma. # 12Nov02. handle HEAD requests ############################ ! sub handler { ! my $r = Apache::Request->instance( Apache->request ); ! my $opts = $r->pnotes('opts'); ! my $table = $opts->{table}; ! my $my_tables = $opts->{my_tables}; ! my $my_columns = $opts->{my_columns}; ! my $my_defaults = $opts->{my_defaults}; ! my $log = $r->log; ! my $test; ! my %args; ! # get the arguments ! my $date_field = $opts->{args}{date_field}; ! my $where = $opts->{args}{where}; ! $args{start_date} = $opts->{args}{start_date}; ! $args{end_date} = $opts->{args}{end_date}; ! $args{interval} = $opts->{args}{interval}; ! $args{interval} ||= $my_tables->{$table}{chartcount_default_interval}; ! $args{interval} ||= $my_defaults->{chartcount_default_interval}; ! $args{interval} ||= 'week'; ! # get the db data ! my $select; ! $date_field ? ($select = $date_field) : ($select = 'created_date'); ! $select .= ' AS date_field'; ! my $from = $table; ! my $ref = Apache::AppWrap::Subs::sqlSelectHashRef($select, $from, $where); - # slotify the data by the specified period - my $src = Apache::AppWrap::Subs::slotify($opts, $ref, \%args); ! # x axis label ! $args{x_label} = 'Date added'; ! # skip label display on x axis ! # my $x_count = scalar(keys %$src); ! my $x_count = scalar(@{$src->[0]}); ! $args{x_label_skip} = int($x_count / 2.5); ! #$log->debug("\n x_label_skip=$args{x_label_skip}"); ! # y axis label ! $args{y_label} = 'number of adds on this date'; ! # chart title ! my $label = $my_tables->{$table}{label}; ! $args{chart_title} = 'Count of ' . $label . ' entries by '; ! $args{chart_title} .= $args{interval}; ! # maximum value ! # $src->[0] is x labels, [1] is x values ! # $args{y_max} = $src; ! # chart title ! # $args{y_tick}; ! # my ($out, @x, @y); ! # foreach my $interval (sort {$a <=> $b} keys %$src) { ! # my $date = &Date::Format::time2str("%d-%h-%y", $interval); ! # push @x, $date; ! # push @y, scalar(@{ $src->{$interval} }); ! ## push @y, $counts{$int}; ! # } ! # push @$out, \@x; ! # push @$out, \@y; ! ! # return $out; ! # save source data for other subs ! $opts->{source_dataset} = $src; - # my $check = &graph( $opts, $out, \%args); - my $check = graph( $opts, $src, \%args); - # error unless check - # end of former &counts_body ! my $link_vars = Apache::AppWrap::Subs::cclinks($opts); ! # $opts->{Title} = 'Calendar of ' . $link_vars->{label}; ! # $opts->{Rows} = \@rows; ! # comply with HEAD request ! if ($r->header_only) { ! $r->send_http_header; ! return OK; ! } ! Apache::AppWrap::Subs::Webify($opts); ! return OK; } # end handler --- 24,123 ---- use vars qw($VERSION); ! $Apache::AppWrap::Chart_Counts::VERSION = '0.05'; ############################ # 08Dec02. CSS, warnings pragma. # 12Nov02. handle HEAD requests ############################ + sub handler { + my $r = Apache::Request->instance( Apache->request ); + my $opts = $r->pnotes('opts'); + my $table = $opts->{table}; + my $my_tables = $opts->{my_tables}; + my $my_columns = $opts->{my_columns}; + my $my_defaults = $opts->{my_defaults}; + my $log = $r->log; + my $test; + my %args; + # get the arguments + my $date_field = $opts->{args}{date_field}; + my $where = $opts->{args}{where}; + $args{start_date} = $opts->{args}{start_date}; + $args{end_date} = $opts->{args}{end_date}; ! $args{interval} = $opts->{args}{interval}; ! $args{interval} ||= $my_tables->{$table}{chartcount_default_interval}; ! $args{interval} ||= $my_defaults->{chartcount_default_interval}; ! unless ($args{interval}) { ! my $msg = 'Chart_Counts::handler: directive table:my_defaults'; ! $msg .= ' chartcount_default_interval" defined.'; ! $r->log_error($msg); ! return SERVER_ERROR; ! } ! # get the db data. the select wants fields having ! # date-type values. ! my $select; ! $date_field ? ($select = $date_field) : ($select = 'created_date'); ! $select .= ' AS date_field'; ! my $from = $table; ! my $ref = Apache::AppWrap::Subs::sqlSelectHashRef($select, $from); ! # slotify orders the data by number of table records per the ! # specified period ! my $src = Apache::AppWrap::Subs::slotify($opts, $ref, \%args); ! # x axis label ! $args{element} = 'x_label'; ! $args{x_label} = Apache::AppWrap::Subs::get_txt($opts, \%args); ! # skip label display on x axis ! my $x_count = scalar(@{$src->[0]}); ! $args{x_label_skip} = int($x_count / 2.5); ! #$log->debug("\n x_label_skip=$args{x_label_skip}"); ! # y axis label ! $args{element} = 'y_label'; ! $args{y_label} = Apache::AppWrap::Subs::get_txt($opts, \%args); ! # chart title ! $args{label} = $my_tables->{$table}{label}; ! $args{element} = 'title'; ! $args{title} = Apache::AppWrap::Subs::get_txt($opts, \%args); + # maximum value + # $src->[0] is x labels, [1] is x values + # $args{y_max} = $src; + # chart title + # $args{y_tick}; ! # my ($out, @x, @y); ! # foreach my $interval (sort {$a <=> $b} keys %$src) { ! # my $date = &Date::Format::time2str("%d-%h-%y", $interval); ! # push @x, $date; ! # push @y, scalar(@{ $src->{$interval} }); ! ## push @y, $counts{$int}; ! # } ! # push @$out, \@x; ! # push @$out, \@y; ! ! # return $out; + # save source data for other subs + $opts->{source_dataset} = $src; ! my $check = graph( $opts, $src, \%args); ! # error unless check ! # comply with HEAD request ! if ($r->header_only) { ! $r->send_http_header; ! return OK; ! } ! Apache::AppWrap::Subs::Webify($opts); ! return OK; } # end handler *************** *** 125,168 **** ############################### sub graph { ! my ($opts, $data, $args) = @_; ! my $r = Apache::Request->instance( Apache->request ); ! my $log = $r->log; ! # store output in @rows; ! my @rows; ! # store data and other optional info in %args; ! ##### defined chart info ##### ! # x axis label ! my $x_label = $args->{x_label} || 'Date'; ! # y axis label ! my $y_label = $args->{y_label} || 'Y Label'; ! # chart title ! my $chart_title = $args->{chart_title} || 'Some simple Chart'; ! my $graph = GD::Graph::bars->new(600, 450); ! # my $graph = GD::Graph::lines->new; ! # these get set for all tables, all charts ! $graph->set( ! x_label => $x_label, ! y_label => $y_label, ! title => $chart_title, ! ); ! $graph->set(y_tick_number => $args->{y_tick_number}) if $args->{y_tick_number}; ! $graph->set(x_label_skip => $args->{x_label_skip}) if $args->{x_label_skip}; ! $graph->set(y_label_skip => $args->{y_label_skip}) if $args->{y_label_skip}; ! $graph->set(y_max_value => $args->{y_max_value}) if $args->{y_max_value}; ! # $graph->set(x_tick_length => $args->{x_tick_length}) if $args->{x_tick_length}; ! # get a temporary filehandle to write the image to. ! # bug out if we don't get a graph object ! unless ($graph->plot($data)) { ! $r->warn($graph->error); ! return SERVER_ERROR; ! }; # truly lame implementation. Need to be able to hold the ! # image in memory until we print it. But cannot do that yet. my $fh = Apache::File->new; #$log->debug("\ngraph(): image path = $tempfile."); --- 128,198 ---- ############################### sub graph { ! my ($opts, $data, $args) = @_; ! my $r = Apache::Request->instance( Apache->request ); ! my $log = $r->log; ! # store output in @rows; ! my @rows; ! # store data and other optional info in %args; ! ##### defined chart info ##### ! # x axis label ! my $x_label = $args->{x_label}; ! unless ($x_label) { ! my $msg = 'Chart_Counts::Chart: caller passed no x_label value'; ! $r->log_error($msg); ! return SERVER_ERROR; ! } ! # y axis label ! my $y_label = $args->{y_label}; ! unless ($y_label) { ! my $msg = 'Chart_Counts::Chart: caller passed no y_label value'; ! $r->log_error($msg); ! return SERVER_ERROR; ! } ! # chart title ! my $title = $args->{title}; ! unless ($title) { ! my $msg = 'Chart_Counts::Chart: caller passed no title value'; ! $r->log_error($msg); ! return SERVER_ERROR; ! } ! my $graph = GD::Graph::bars->new(600, 450); ! # my $graph = GD::Graph::lines->new; ! # these get set for all tables, all charts ! $graph->set( ! x_label => $x_label, ! y_label => $y_label, ! title => $title, ! ); ! if ($args->{y_tick_number}) { ! $graph->set(y_tick_number => $args->{y_tick_number}); ! } ! if ($args->{x_label_skip}) { ! $graph->set(x_label_skip => $args->{x_label_skip}); ! } ! if ($args->{y_label_skip}) { ! $graph->set(y_label_skip => $args->{y_label_skip}); ! } ! if ($args->{y_max_value}) { ! $graph->set(y_max_value => $args->{y_max_value}); ! } ! if ($args->{x_tick_length}) { ! $graph->set(x_tick_length => $args->{x_tick_length}); ! } ! ! # get a temporary filehandle to write the image to. ! # bug out if we don't get a graph object ! unless ($graph->plot($data)) { ! $r->log_error($graph->error); ! return SERVER_ERROR; ! }; # truly lame implementation. Need to be able to hold the ! # image in memory until we print it. But don't know how ! # to do that yet. my $fh = Apache::File->new; #$log->debug("\ngraph(): image path = $tempfile."); *************** *** 176,186 **** $fh->close; - push @rows, '<h2>This is from Apache::AppWrap::Subs::graph</h2>'; - my $test = scalar(@rows); #$log->debug("\n $test rows detected."); ! ######################## ! $opts->{Image} = $file; # this works # binmode STDOUT; --- 206,214 ---- $fh->close; my $test = scalar(@rows); #$log->debug("\n $test rows detected."); ! ######################## ! $opts->{Image} = $file; # this works # binmode STDOUT; *************** *** 190,194 **** # &Apache::AppWrap::Subs::Webify($opts); ! return 1; # return \@rows; # return OK; --- 218,222 ---- # &Apache::AppWrap::Subs::Webify($opts); ! return 1; # return \@rows; # return OK; *************** *** 202,217 **** ############################### sub localtime_rerange { ! my $time = shift; ! my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($time); ! $sec += 1; ! $min += 1; ! $hour += 1; ! $mday += 1; ! $mon += 1; ! $year += 1900; ! $wday += 1; ! $yday += 1; ! return ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst); } --- 230,245 ---- ############################### sub localtime_rerange { ! my $time = shift; ! my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($time); ! $sec += 1; ! $min += 1; ! $hour += 1; ! $mday += 1; ! $mon += 1; ! $year += 1900; ! $wday += 1; ! $yday += 1; ! return ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst); } Index: Doorknob.pm =================================================================== RCS file: /cvsroot/appwrap/AppWrap/Apache/AppWrap/Doorknob.pm,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Doorknob.pm 14 Jan 2003 08:35:23 -0000 1.14 --- Doorknob.pm 19 Jan 2003 23:29:24 -0000 1.15 *************** *** 260,264 **** $my_tables->{$table}{table_type} eq 'script'; unless ($directive) { - # unless (exists $my_tables->{$table}{$dir}) { my $msg = 'Doorknob: Directive my_tables->{'; $msg .= $table . '}{' . $dir . '} not defined.'; --- 260,263 ---- Index: Pager.pm =================================================================== RCS file: /cvsroot/appwrap/AppWrap/Apache/AppWrap/Pager.pm,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** Pager.pm 14 Jan 2003 08:35:23 -0000 1.19 --- Pager.pm 19 Jan 2003 23:29:24 -0000 1.20 *************** *** 728,738 **** $args->{'caller'} = 'visualize'; ! $args->{element} = 'visualize_title'; ! my $visualize_title = Apache::AppWrap::Subs::get_txt($opts, $args); ! # add a little space to make the HTML more readable ! push @rows, ' ' . $visualize_title . $HNL; # wrap the images in a <div> tag push @rows, ' <div class="icons">' . $HNL; # create the links foreach my $dv (@dv_types) { --- 728,740 ---- $args->{'caller'} = 'visualize'; ! $args->{element} = 'title'; ! my $visualize = Apache::AppWrap::Subs::get_txt($opts, $args); ! my $text = '<h2>' . $visualize . '</h2>'; # add a little space to make the HTML more readable ! push @rows, ' ' . $text . $HNL; ! # wrap the images in a <div> tag push @rows, ' <div class="icons">' . $HNL; + # create the links foreach my $dv (@dv_types) { *************** *** 746,751 **** --- 748,755 ---- # get ALT msg to display + $args->{'caller'} = $dv; $args->{element} = $dv . '_alt'; my $alt = Apache::AppWrap::Subs::get_txt($opts, $args); + # get img height + width my $height = $my_defaults->{ $dv . '_img_height'}; *************** *** 758,761 **** --- 762,766 ---- $img .= '" width="' . $width . '" />'; # the url + my $link = '/' . $table . '/' . $dv; # check for query string args *************** *** 765,774 **** my $atag = '<a href="' . $link . '">' . $img . '</a>'; # set up output ! push @rows, $atag; } # close the <div> image tag ! push @rows, $HNL; ! my $text = '</div> <!-- end of icons div -->'; ! push @rows, $text . $HNL; $text = '</div> <!-- end of visualize div -->'; push @rows, $text . $HNL; --- 770,778 ---- my $atag = '<a href="' . $link . '">' . $img . '</a>'; # set up output ! push @rows, ' ' . $atag . $HNL; } # close the <div> image tag ! $text = '</div> <!-- end of icons div -->'; ! push @rows, ' ' . $text . $HNL; $text = '</div> <!-- end of visualize div -->'; push @rows, $text . $HNL; *************** *** 808,814 **** # $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; --- 812,817 ---- # $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; *************** *** 834,850 **** push @rows, '<div id="navigate">' . $HNL; ! # give us a heading ! $args->{element} = 'navigate_title'; my $navigate_title = Apache::AppWrap::Subs::get_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 ! # in the 'navigate_sequence' value in my_text. ! $text = $msgs->{navigate_sequence}; ! $args->{element} = 'navigate_sequence'; my $sequence = Apache::AppWrap::Subs::get_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 --- 837,855 ---- push @rows, '<div id="navigate">' . $HNL; ! # give us a heading. 'caller' set above to 'navigate' ! $args->{element} = 'title'; my $navigate_title = Apache::AppWrap::Subs::get_txt($opts, $args); # add a little space to make the HTML more readable ! $text = '<h2>' . $navigate_title . '</h2>'; ! push @rows, ' ' . $text . $HNL if $navigate_title; # get the sequence info. Dynamic values are embedding ! # in the 'sequence' value in my_text. ! $text = $msgs->{sequence}; ! $args->{element} = 'sequence'; my $sequence = Apache::AppWrap::Subs::get_txt($opts, $args); # add a little space to make the HTML more readable ! $text = '<h3>' . $sequence . '</h3>'; ! push @rows, ' ' . $text . $HNL if $sequence; # call the sub to populate navigation icons Index: Subs.pm =================================================================== RCS file: /cvsroot/appwrap/AppWrap/Apache/AppWrap/Subs.pm,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** Subs.pm 14 Jan 2003 08:35:23 -0000 1.36 --- Subs.pm 19 Jan 2003 23:29:24 -0000 1.37 *************** *** 1512,1528 **** ######################################################## sub Webify { ! my $opts = shift; ! my $r = Apache::Request->instance(Apache->request); ! my $my_tables = $opts->{my_tables}; ! my $table = $opts->{table}; ! my $my_defaults = $opts->{my_defaults}; ! my $cookie = $opts->{cookie}; ! my $log = $r->log; ! # store all output, in order, in @output ! my @output; ! # Initial header info ! # these lines disable caching # $r->header_out('Pragma'=>'No-cache'); # $r->header_out('Cache-control'=>'No-cache'); --- 1512,1530 ---- ######################################################## sub Webify { ! my $opts = shift; ! my $r = Apache::Request->instance(Apache->request); ! my $my_tables = $opts->{my_tables}; ! my $table = $opts->{table}; ! my $my_defaults = $opts->{my_defaults}; ! my $cookie = $opts->{cookie}; ! my $log = $r->log; ! # use this toi pass values to get_txt() ! my %args; ! # store all output, in order, in @output ! my @output; ! # Initial header info ! # these lines disable caching # $r->header_out('Pragma'=>'No-cache'); # $r->header_out('Cache-control'=>'No-cache'); *************** *** 1531,1544 **** #$log->debug("\nGraph: $t1"); ! # set up outgoing header. ! $r->content_type('text/html'); ! $r->header_out('Set-cookie' => $cookie) if $cookie; ! $r->send_http_header; ! my $default_title = $my_defaults->{title} || 'AppWrap'; ! my $screen_title = $default_title; ! if ($opts->{ScreenTitle}) { ! $screen_title = $opts->{ScreenTitle} . ' - ' . $default_title; ! } # images could come from a remote server, so check for that --- 1533,1546 ---- #$log->debug("\nGraph: $t1"); ! # set up outgoing header. ! $r->content_type('text/html'); ! $r->header_out('Set-cookie' => $cookie) if $cookie; ! $r->send_http_header; ! my $default_title = $my_defaults->{title} || 'AppWrap'; ! my $screen_title = $default_title; ! if ($opts->{ScreenTitle}) { ! $screen_title = $opts->{ScreenTitle} . ' - ' . $default_title; ! } # images could come from a remote server, so check for that *************** *** 1573,1577 **** $header .= '" />' . $HNL; ! # link to the stylesheet my $stylesheet = $opts->{args}{StyleSheet}; $stylesheet ||= $my_defaults->{stylesheet_name}; --- 1575,1579 ---- $header .= '" />' . $HNL; ! # link to the stylesheet my $stylesheet = $opts->{args}{StyleSheet}; $stylesheet ||= $my_defaults->{stylesheet_name}; *************** *** 1629,1650 **** my $logo = $my_defaults->{logo_img} || 'AppWrap_logo.gif'; my $splash = '/' . $config{images} . '/' . $logo; ! my $logo_alt = $my_defaults->{logo_alt} || $my_defaults->{title}; ! my $link = ' <a href="'; $link .= $my_defaults->{homepage} . '">'; $link .= '<img src="' . $splash . '"'; $link .= ' height="' . $my_defaults->{logo_height} . '"'; $link .= ' width="' . $my_defaults->{logo_width} . '"'; ! $link .= ' title="' . $logo_alt . '" /></a>'; ! push @header, $link . $HNL; push @header, '</div>' . $HNL; ! # now print the header table ! push @output, join("", @header); ! # start a table for the tabs, links and motd. ! my @ui; ! # run &tab_bar before starting the table so that we have the width ! # of all the tabs ! my $tab_bar = tab_bar($opts); #$log->debug("\nWebify: $tab_bar"); --- 1631,1664 ---- my $logo = $my_defaults->{logo_img} || 'AppWrap_logo.gif'; my $splash = '/' . $config{images} . '/' . $logo; ! ! # get a title/ALT message for the logo ! $args{'caller'} = 'webify'; ! $args{element} = 'logo_title'; ! my $logo_title = get_txt($opts, \%args); ! unless ($logo_title) { ! my $msg = qq{Webify: "logo_title" does not exist}; ! $msg .= ' for caller="Webify" in table:my_text.'; ! $r->warn($msg); ! } ! ! my $link = '<a href="'; $link .= $my_defaults->{homepage} . '">'; $link .= '<img src="' . $splash . '"'; $link .= ' height="' . $my_defaults->{logo_height} . '"'; $link .= ' width="' . $my_defaults->{logo_width} . '"'; ! $link .= ' title="' . $logo_title . '"' if $logo_title; ! $link .= ' /></a>'; ! push @header, ' ' . $link . $HNL; ! # close out the logo div push @header, '</div>' . $HNL; ! # now print the header table ! push @output, join("", @header); ! # start a table for the tabs, links and motd. ! my @ui; ! # run &tab_bar before starting the table so that we have the width ! # of all the tabs ! my $tab_bar = tab_bar($opts); #$log->debug("\nWebify: $tab_bar"); *************** *** 1662,1679 **** # page titles, start with header file ! # Setup the div for the vertical bar on the left side ! push @output, '<!-- Start the leftvbar div -->' . $HNL; ! push @output, '<div id="leftvbar">' . $HNL; ! # This creates the links on the left side of the screen ! if (exists($opts->{menuitems}) ) { ! push @output, join("", @{ $opts->{menuitems} }); ! } # add a link to search. Get the displayed text from table my_text ! my %args = ( ! 'caller' => 'search', ! element => 'title', ! ); my $text = get_txt($opts, \%args); my $search = '<a id="search" href="/search">'; --- 1676,1691 ---- # page titles, start with header file ! # Setup the div for the vertical bar on the left side ! push @output, '<!-- Start the leftvbar div -->' . $HNL; ! push @output, '<div id="leftvbar">' . $HNL; ! # This creates the links on the left side of the screen ! if (exists($opts->{menuitems}) ) { ! push @output, join("", @{ $opts->{menuitems} }); ! } # add a link to search. Get the displayed text from table my_text ! $args{'caller'} = 'search'; ! $args{element} = 'title'; my $text = get_txt($opts, \%args); my $search = '<a id="search" href="/search">'; *************** *** 2506,2576 **** ############################ sub top_menu { ! my $opts = shift; ! my $my_tables = $opts->{my_tables}; ! my $table = $opts->{table}; ! $table = $opts->{args}{top_summary} if $table eq 'summary'; ! ! # title in left side ! $opts->{vbar_title} = 'Other Tables in this Family'; ! ! # show family members and record count only. Start by determining ! # parent table, then get siblings, then record counts, then display. ! my $r = Apache::Request->new(Apache->request); ! my $log = $r->log; #my $test; #$log->debug("\ntop_menu: valid_tables=$table"); ! # get parent table ! my $parent_table = $my_tables->{$table}{parent}; ! # determine the key_type ! my $kt = $my_tables->{$parent_table}{key_type}; ! # now get all valid tables ! my (@valid_tables, @rents); ! foreach (keys %$my_tables) { ! next unless $_; ! # skip tables under development ! next if $my_tables->{$_}{beta}; ! next unless $my_tables->{$_}{key_type}; ! next unless $my_tables->{$_}{parent}; ! next unless $my_tables->{$_}{menu_order}; ! # store a list of valid tables, which will generate no ! # 'uninitialized value' errors ! push @valid_tables, $_; ! } ! # get siblings or children ! my @ordered_sibs = ! sort { $my_tables->{$a}{menu_order} <=> $my_tables->{$b}{menu_order} } ! grep {$my_tables->{$_}{parent} eq $parent_table } @valid_tables; ! # make parent table first in the list if it is, in fact, a table ! # Now get the qty records for each table ! my %counts; ! foreach my $kid (@ordered_sibs) { ! # set up query to count number of entries for each key_type ! my $select = 'COUNT(*)'; ! my $ref = sqlSelectArrayRef($select, $kid); ! $counts{$kid} = $ref->[0][0]; ! } # end FOREACH ! ! my @rows; # store values temporarily ! push @rows, '<p class="topicheader">Related Tables</p>'; ! foreach my $kid (@ordered_sibs) { ! next unless $kid; ! # don't display if no records ! next unless exists $counts{$kid}; ! next if $my_tables->{$kid}{beta}; ! # put the url in the returned array. ! my $link_vars = cclinks( $opts, (table=>$kid) ); ! my $label = $link_vars->{label}; ! # get the plurals count right ! $label .= sprintf " (%d record%s)", $counts{$kid}, ($counts{$kid} == 1) ? '' : "s"; ! push @rows, '<p>' . $label . '</p>' . $HNL; ! } ! return \@rows; } # end &top_menu --- 2518,2606 ---- ############################ sub top_menu { ! my $opts = shift; ! my $my_tables = $opts->{my_tables}; ! my $table = $opts->{table}; ! $table = $opts->{args}{top_summary} if $table eq 'summary'; ! # show family members and record count only. Start by determining ! # parent table, then get siblings, then record counts, then display. ! my $r = Apache::Request->new(Apache->request); ! my $log = $r->log; #my $test; #$log->debug("\ntop_menu: valid_tables=$table"); ! # get parent table ! my $parent_table = $my_tables->{$table}{parent}; ! # determine the key_type ! my $kt = $my_tables->{$parent_table}{key_type}; ! # now get all valid tables ! my (@valid_tables, @rents); ! foreach (keys %$my_tables) { ! next unless $_; ! # skip tables under development ! next if $my_tables->{$_}{beta}; ! next unless $my_tables->{$_}{key_type}; ! next unless $my_tables->{$_}{parent}; ! next unless $my_tables->{$_}{menu_order}; ! # store a list of valid tables, which will generate no ! # 'uninitialized value' errors ! push @valid_tables, $_; ! } ! # get siblings or children ! my @ordered_sibs = sort { ! $my_tables->{$a}{menu_order} <=> $my_tables->{$b}{menu_order} ! } ! grep { ! $my_tables->{$_}{parent} eq $parent_table ! } @valid_tables; ! # make parent table first in the list if it is, in fact, a table ! # Now get the qty records for each table ! my %counts; ! foreach my $kid (@ordered_sibs) { ! # set up query to count number of entries for each key_type ! my $select = 'COUNT(*)'; ! my $ref = sqlSelectArrayRef($select, $kid); ! $counts{$kid} = $ref->[0][0]; ! } # end FOREACH ! ! # store values temporarily ! my @rows; ! # pass values to get_txt() ! my %args; ! $args{'caller'} = 'top_menu'; ! $args{element} = 'title'; ! my $text = get_txt($opts, \%args); ! push @rows, qq{ <p class="topicheader">$text</p>} . $HNL; ! ! $args{element} = 'records'; ! my $records = get_txt($opts, \%args); ! ! $args{element} = 'record'; ! my $record = get_txt($opts, \%args); ! ! # loop through each related table and display the ! # table name and number of records ! foreach my $kid (@ordered_sibs) { ! next unless $kid; ! # don't display if no records ! next unless exists $counts{$kid}; ! next if $my_tables->{$kid}{beta}; ! ! # put the url in the returned array. ! my $link_vars = cclinks( $opts, (table=>$kid) ); ! ! # get the plurals count right ! my $plural = ($counts{$kid} == 1) ? $record : $records; ! ! $text = '<p>' . $link_vars->{label} . ' ('; ! $text .= $counts{$kid} . ' ' . $plural . ')</p>'; ! push @rows, ' ' . $text . $HNL; ! } ! return \@rows; } # end &top_menu *************** *** 2856,2872 **** push @hdr_links, $alink; } - # use this to space the links in a pretty way. Although this is a - # blunt instrument, 'tis better than naught. If there are more - # than 5 links, OR if motd is not enabled. Would be better to - # measure the length of the link string, comparing that to the - # width of the displayed tabs, rather than counting the links - my $sp; - if (scalar(@link_order) > 5 || $my_defaults->{enable_motd}) { - $sp = ' '; - } - else { - $sp = ' '; - } - push @links, join("", @hdr_links); } # end IF --- 2886,2889 ---- *************** *** 2877,2884 **** push @links, '</div>' . $HNL; } ! # whitespace for pretty printing HTML ! push @rows, ' ' . join("", @links) . $HNL; ! push @rows, '</div>' . $HNL; return \@rows; } # end tab_bar --- 2894,2904 ---- push @links, '</div>' . $HNL; } ! # wrap anchor tags in a paragraph tag for alignment and ! # so that a full page of crumbs will wrap around (eg, ! # admin tab) ! push @rows, ' <p>' . join("", @links) . '</p>' . $HNL; ! # close the div ! push @rows, '</div> <!-- close the crumbs div -->' . $HNL; return \@rows; } # end tab_bar *************** *** 4458,4477 **** if ($tablename eq $table && $caller eq $phase) { $value = $my_text->{$table}{$phase}{$admin}; - # my $value = $my_text->{$table}{$phase}{$admin}; } elsif ($tablename eq 'DEFAULT' && $caller eq $phase) { ! # value same for all tables $value = $my_text->{DEFAULT}{$phase}{$admin}; - # $value ||= $my_text->{DEFAULT}{$phase}{$admin}; } elsif ($tablename eq $table && $caller eq 'DEFAULT') { ! # value same for all phases of this table $value = $my_text->{$table}{DEFAULT}{$admin}; - # $value ||= $my_text->{$table}{DEFAULT}{$admin}; } else { ! # value same for all phases of all tables (eg, ALT) $value = $my_text->{DEFAULT}{DEFAULT}{$admin}; - # $value ||= $my_text->{DEFAULT}{DEFAULT}{$admin}; } $msgs{$admin} = $value; --- 4478,4493 ---- if ($tablename eq $table && $caller eq $phase) { $value = $my_text->{$table}{$phase}{$admin}; } elsif ($tablename eq 'DEFAULT' && $caller eq $phase) { ! # value same for all tables $value = $my_text->{DEFAULT}{$phase}{$admin}; } elsif ($tablename eq $table && $caller eq 'DEFAULT') { ! # value same for all phases of this table $value = $my_text->{$table}{DEFAULT}{$admin}; } else { ! # value same for all phases of all tables (eg, ALT) $value = $my_text->{DEFAULT}{DEFAULT}{$admin}; } $msgs{$admin} = $value; |