appwrap-cvs Mailing List for AppWrap web frontend to workgroup data (Page 2)
Status: Beta
Brought to you by:
planetman
You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(30) |
Oct
(27) |
Nov
(86) |
Dec
(65) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(12) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
(2) |
Dec
|
From: <pla...@us...> - 2002-12-21 11:10:39
|
Update of /cvsroot/appwrap/AppWrap/includes In directory sc8-pr-cvs1:/tmp/cvs-serv16960 Modified Files: AppWrap.css Log Message: changes related to recoding of Pager and Focus Index: AppWrap.css =================================================================== RCS file: /cvsroot/appwrap/AppWrap/includes/AppWrap.css,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** AppWrap.css 10 Dec 2002 10:15:26 -0000 1.6 --- AppWrap.css 21 Dec 2002 11:10:36 -0000 1.7 *************** *** 6,10 **** margin: 0.5em 0.5em; } ! div#logo { } div#motdarea { float: right; width: 52%; z-index: 10; } /* "tabbar" is a class as there may be more than one of 'em */ --- 6,14 ---- margin: 0.5em 0.5em; } ! img { ! border: none; ! } ! div#logo { ! } div#motdarea { float: right; width: 52%; z-index: 10; } /* "tabbar" is a class as there may be more than one of 'em */ *************** *** 20,24 **** color: #000; background: #fff; } ! div.tabbar img { display: inline; padding: 0 0 0 0; } div#crumbs { width: 100%; --- 24,31 ---- color: #000; background: #fff; } ! div.tabbar img { ! display: inline; ! padding: 0 0 0 0; ! } div#crumbs { width: 100%; *************** *** 85,95 **** margin: 0.2em 0em; } - div#mainleft { margin: 0 38% 0 24%; padding: 0 0 0 1em; } - div#mainright { - float: right; - margin: 0; - padding: 0 0 0 1em; - width: 36%; - } p#title { color: #000000; --- 92,95 ---- *************** *** 107,125 **** margin-left: 26%; } ! div#seqnav { float: right; ! width: 35%; ! text-align: right; ! margin: -1em 0 0 0; padding: 0 0 0 0; } ! div#seqnav h1 { ! font-size: 12pt; font-family: arial; text-align: center; ! margin: 1em 0em 1em; } div#noteleft { ! border: 1px red dotted; float: right; width: 30%; --- 107,177 ---- margin-left: 26%; } ! div#mainleft { margin: 0 38% 0 24%; padding: 0 0 0 1em; } ! div#mainright { float: right; ! margin: 0; ! padding: 0 0 0 1em; ! width: 36%; ! } ! div#dataheader { ! clear: right; ! height: 3.5em; ! margin: 1em 0 0 26%; ! } ! div#dataheader h2 { ! font-family: arial; ! text-align: center; ! padding: 0; ! margin: 0 0; ! } ! div#dataheader img { padding: 0 0 0 0; + display: inline; } ! div#dataheader p { ! text-align: center; ! padding: 0 0 -3em 0; ! } ! div#visualize { ! float: left; ! width: 30%; ! } ! div#visualize p { ! padding: 0 0 0 0; ! margin: 1.4em 0 0 0; ! } ! div#navigate { ! float: right; ! width: 30%; ! padding: 0 0 0 0; ! margin: 0 0 0 0; ! /* border: 3px blue dotted; */ ! } ! div.icons { ! text-align: center; ! padding: -0.2em 0; ! margin: 0.4em 0 -0.2em 0; ! /* border: 1px red solid; */ ! } ! div.icons a { ! padding: 0 0 -0.2em 0; ! margin: 0 0 -0.2em 0; ! } ! div.icons img { ! padding: -0.2em -0.02em; ! margin: 0 -0.2em; ! } ! div#navigate h3 { ! font-size: 10pt; font-family: arial; + font-weight: normal; text-align: center; ! padding: 0.2em 0; ! margin: 0 0 -0.2em; ! /* border: 1px blue solid; */ } + div#navigate form { display: inline; } div#noteleft { ! /* border: 1px red dotted */; float: right; width: 30%; *************** *** 127,131 **** } div#notecenter { ! border: 1px red dotted; float: right; width: 30%; --- 179,183 ---- } div#notecenter { ! /* border: 1px red dotted; */ float: right; width: 30%; *************** *** 139,143 **** div#pager table { width: 100%; ! /* border: 1px solid #aaa; */ } div#pager tr.odd { --- 191,198 ---- div#pager table { width: 100%; ! border: 1px solid #aaa; ! } ! div#pager td { ! border: 1px solid #aaa; } div#pager tr.odd { |
From: <pla...@us...> - 2002-12-21 11:09:28
|
Update of /cvsroot/appwrap/AppWrap/Apache/AppWrap In directory sc8-pr-cvs1:/tmp/cvs-serv16690 Modified Files: Focus.pm Log Message: recoded for clarity and performance, i18n, CSS, DB query caching. Moved several subs to Pager.pm Index: Focus.pm =================================================================== RCS file: /cvsroot/appwrap/AppWrap/Apache/AppWrap/Focus.pm,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Focus.pm 9 Dec 2002 10:11:59 -0000 1.8 --- Focus.pm 21 Dec 2002 11:09:25 -0000 1.9 *************** *** 18,21 **** --- 18,24 ---- 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 + # to my_defaults # 04Dec02. CSS repairs to &seq_nav. # 02Dec02. CSS repairs. *************** *** 29,34 **** my $opts = $r->pnotes('opts'); ! my $log = $r->log; ! my $test; my $table = $opts->{table}; --- 32,37 ---- my $opts = $r->pnotes('opts'); ! my $log = $r->log; ! my $test; my $table = $opts->{table}; *************** *** 43,85 **** #my $t1 = join(",", keys %{ $opts->{args} }); #$log->debug("\nFocus: idnum=$idnum, table=$table, args=$t1"); ! # its important that we have an idnum, so drop an informative ! # if we don't ! $test = $r->header_in('referer'); ! unless ($idnum) { ! $r->log_error("Focus: no idnum. URI=\"$test\""); ! return SERVER_ERROR; ! } ! my $select = '*'; ! my $from = $table; ! my $where = 'idnum=' . $idnum; ! my $ref = Apache::AppWrap::Subs::sqlSelectHashRef($select, $from, $where); ! my $row = $ref->[0]; my $kt = $my_tables->{$table}{key_type}; my $kv = $opts->{valid_kv} || $opts->{args}{idnum}; ! # assign messages for alt tags. This allows subs to be called ! # by &display, &focus and by &list, while retaining context ! # sensitivity. ! $opts->{msgs} = make_focus_msgs($opts); ! # other instructions to &seq_nav. ! my $uplink = $my_exceptions->{$table}{focus}{uplink}; ! $opts->{uplink} = eval $uplink if $uplink; ! my $edit_link = $my_exceptions->{$table}{focus}{edit_link}; ! $opts->{edit_link} = eval $edit_link if $edit_link; ! # show the sequential index that allows user to browse thew data ! # by my_columns->page_display columns ! my $sequence_bar = seq_nav($opts); ! foreach (@{ $sequence_bar }) { ! push @rows, $_; ! } ! # start the <div> tag so CSS can be used. ! push @rows, '<div id="pager">' . $HNL; ! push @rows, ' <table valign="top" border="1">'; # loop through each column and act on it as instructed by --- 46,99 ---- #my $t1 = join(",", keys %{ $opts->{args} }); #$log->debug("\nFocus: idnum=$idnum, table=$table, args=$t1"); ! # its important that we have an idnum, so drop an informative ! # if we don't ! unless ($idnum) { ! my $uri = $r->as_string; ! my $msg = qq{Focus: no idnum. URI="$uri."}; ! $r->log_error($msg); ! return SERVER_ERROR; ! } ! my $sql = qq{SeLEcT * FrOm $table WHERE idnum=?}; ! my $sth = $dbh->prepare($sql); ! $sth->execute($idnum); ! # should only return a single row; we only want the first ! my $row = $sth->fetchrow_hashref(); ! $sth->finish; my $kt = $my_tables->{$table}{key_type}; my $kv = $opts->{valid_kv} || $opts->{args}{idnum}; ! # the args hash passes (mostly) message info ! my %args; ! # assign messages for alt tags. this is how we get display text ! my $msgs = $opts->{display_text}; ! $msgs ||= Apache::AppWrap::Subs::get_display_text($opts); ! $opts->{display_text} ||= $msgs; ! my $title = eval $msgs->{title} if $msgs->{title}; ! # this may be a fudge to regret later ! $title ||= $opts->{Title}; ! unless ($title) { ! $r->log_error("Pager: no title eval'd: $msgs->{title}"); ! return SERVER_ERROR; ! } ! $opts->{Title} = $title; ! # subtitles are not mandatory: some tables have none. ! my $subtitle = eval $msgs->{subtitle} if $msgs->{subtitle}; ! $subtitle ||= $opts->{SubTitle}; ! $opts->{SubTitle} = $subtitle if $subtitle; ! # get the data_header section ! my $dh = Apache::AppWrap::Pager::data_header($opts, \%args); ! if ($dh and scalar(@$dh)) { ! push @rows, map {$_} @$dh; ! } ! ! # start the <div> tag so CSS can be used. ! push @rows, '<div id="pager">' . $HNL; ! push @rows, ' <table>'; # loop through each column and act on it as instructed by *************** *** 93,99 **** my $val; # first construct the row headings ! my $display = $HNL . ' <tr valign="top"><th'; ! $display .= ' class="' . $link_vars->{cell_class} . '"' if $link_vars->{cell_class}; ! $display .= '>' . $label . '</th><td class="advice">' . $description . '</td>'; push @rows, $display; --- 107,116 ---- my $val; # first construct the row headings ! my $display = $HNL . ' <tr valign="top"><th'; ! if (exists $link_vars->{cell_class}) { ! $display .= ' class="' . $link_vars->{cell_class} . '"'; ! } ! $display .= '>' . $label . '</th><td class="advice">'; ! $display .= $description . '</td>'; push @rows, $display; *************** *** 110,114 **** # turn off Perl warnings cause tests for zero cause -w noise. { ! no warnings qw(numeric); if ($func_focus) { $ary = eval $func_focus; --- 127,131 ---- # turn off Perl warnings cause tests for zero cause -w noise. { ! no warnings qw(numeric uninitialized); if ($func_focus) { $ary = eval $func_focus; *************** *** 142,163 **** } # close Perl warnings block } ! push @rows, $HNL . ' </table>' . $HNL; # That's all the tabular data, so close the </div> push @rows, $HNL . '</div>' . $HNL; - # do titles. Normally would do this at the start of the sub. But we needed to - # query the db to get the contact name, so we waited. - my $contact; - my $title = $my_exceptions->{$table}{focus}{title}; - $opts->{Title} = eval $title if $title; - - # set the page title. - $title ||= $link_vars->{label}; - $opts->{SubTitle} ||= $title; - - my $subtitle = $my_exceptions->{$table}{focus}{subtitle}; - $opts->{Title} = eval $subtitle if $subtitle; - $opts->{Title} ||= 'Focus on Idnum ' . $idnum; - # do links on the left side. Same rationale for doing here # if a function specified in the db, use it, else do the default --- 159,166 ---- } # close Perl warnings block } ! push @rows, $HNL . ' </table>' . $HNL; # That's all the tabular data, so close the </div> push @rows, $HNL . '</div>' . $HNL; # do links on the left side. Same rationale for doing here # if a function specified in the db, use it, else do the default *************** *** 167,171 **** $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 ); --- 170,175 ---- $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 ); *************** *** 178,182 **** } } - push @{ $opts->{Rows} }, join("", @rows); --- 182,185 ---- *************** *** 192,636 **** - ############################ - # my $ref = &seq_nav (\%opts) The displayed item is called an 'id' - # and is uniquely identified by an 'idnum' in the db. A control option - # is a way to search the db, such as contact, date, city, etc. These - # are user selectable to puruse the data along different dimensions. - # 09 Oct 01. "read_only' directive add, edit icons displaying - # 24 Jan 01. adjustments for my_tables changes - ############################ - sub seq_nav { - my $opts = shift; - my $table = $opts->{table}; - my $my_exceptions = $opts->{my_exceptions}; - my $my_tables = $opts->{my_tables}; - my $my_columns = $opts->{my_columns}; - my $my_defaults = $opts->{my_defaults}; - my $idnum = $opts->{args}{idnum}; - # idnum may have been passed with leading zeros, so strip them off - $idnum =~ s/^0+//; - my $sb = $opts->{args}{sb} || $my_tables->{$table}{default_sort} || 1; - my $page = $opts->{args}{page} || 0; - my $kv = $opts->{valid_kv}; - my $alt; - my $rows_per = $opts->{rows_per} ||= $my_defaults->{rows_per}; - my $image_dir = $config{homeurl} . '/' . $config{images}; - - ############################ - # my %out = id_browser($opts); - # my %ids = $out{ids}; - # my %sdi = reverse %ids; - # my $this_id = $out{this_id}; - # my $division = $out{division}; - # my $calc_page = $out{calc_page}; - # $page ||= $out{page}; - # my $kv_esc = $out{kv_esc}; - # my $by = $out{by}; - # my @by = @{ $out{by_array} }; - # my $qty_tr_by = $out{qty_tr_by}; - ############################ - - # get the sort hash. This is used to map different values. - my $i = 1; - my %sort_hash; - foreach my $column (@{ $opts->{page_display} }) { - $sort_hash{$i++} = Apache::AppWrap::Pager::fill_sort_new ($i,$column,$my_columns->{$table}{$column}{label}); - $sort_hash{$i++} = Apache::AppWrap::Pager::fill_sort_new ($i,$column,$my_columns->{$table}{$column}{label}); - } - my $log = Apache->request->log; - #$log->debug("\nseq_nav: idnum=$idnum"); - - # default display sequence. Use param('by') if set. Else - # derive it from param('sb') - my $by = $opts->{args}{by} || $sort_hash{$sb}{by}; - $by =~ s/^by //; - $opts->{args}{by} = $by; - - # get the sort column for the db dip - my $order_by; - $sb ? $order_by = $sort_hash{$sb}{column} . ' ASC' : $order_by = $by . ' ASC'; - - # get the list of control options. This is used to populate the - # popup menu. - my @by = grep { $my_columns->{$table}{$_}{page_sort} } @{ $opts->{col_order} }; - - my ($select,$from,$where,$other); - # define this, next and previous id - # first, query for values in this id - # $select = '*'; - # $from = $table; - # $where = 'idnum=' . $idnum; - my $sql_this_id = "SELECT * FROM $table WHERE idnum=$idnum"; - my $sth = $dbh->prepare($sql_this_id); - $sth->execute(); - my $data_this_id = $sth->fetchrow_hashref; - - # next, having the data, we can determine the value of the control - my $by_value = $data_this_id->{$by}; - # while we have the data for this id might as well get the key_type - my $kt = $my_tables->{$table}{key_type}; - $kv = $data_this_id->{$kt} unless ($kv && $kt); - # $kv = $data_this_id->{$kt} unless $kv; - my $kv_esc = Apache::Util::escape_uri( $kv ) if $kv; - - # then, to get the prev and next idnum we need to query to get - # them all for this 'by' control. Quote the 'by' value - my $by_value_q = $dbh->quote($by_value); - my $sql_all_id = "SELECT idnum FROM $table ORDER BY $order_by"; - if ($by eq 'idnum') { - $sql_this_id = "SELECT idnum FROM $table ORDER BY $order_by"; - } - else { - $sql_all_id = "SELECT idnum FROM $table WHERE $by=$by_value_q ORDER BY $by ASC"; - } - - my $data_all_id = $dbh->selectall_arrayref($sql_all_id); - my $qty_tr_by = scalar(@$data_all_id); - # get a hash of the idnums - my %ids; - $i = 1; - foreach my $row (@{ $data_all_id }) { - $ids{$i++} = $row->[0]; - } - - # reverse the hash to easily get the id from the idnum - my %sdi = reverse %ids; - my $this_id = $sdi{$idnum}; - my $division = ($this_id / $rows_per); - my $calc_page = sprintf("%u", $division); - $page ||= $calc_page; - - # ----------------------------------------------------------------- - # ---- define all the icons, their links and the alt tags ---- - # ----------------------------------------------------------------- - # the alt message can come from the calling function (via the - # appropriate entry in table my_exceptions) or via the default. This - # makes it less intensive to create a new application - don't - # have to define so many messages! - # get the information for the new icon, which creates a new id - # only show new icon if allowed - my $label = $my_tables->{$table}{label}; - my ($alt_new, $new_link, $temp); - unless ($opts->{read_only}) { - $alt_new = eval $opts->{msgs}{alt_new}; - $new_link = ' <a href="/'; - $new_link .= $table if $table; - $new_link .= '/add"><img src="'; - $new_link .= $image_dir; - $new_link .= '/new.gif" alt="'; - $new_link .= $alt_new if $alt_new; - $new_link .= '" width="21" height="17" border="0" /></a>'; - } - - # get the information for the edit icon, which edits this id - my $edit_link; - unless ($opts->{read_only}) { - my $alt_edit = eval $opts->{msgs}{alt_edit}; - # set the link; the rest is the same regardless - $edit_link = $opts->{edit_link}; - $edit_link ||= '<a href="/' . $table . '/edit?idnum=' . $idnum . '">'; - $edit_link .= '<img src="' . $image_dir . '/edit.gif" width="21" height="17"'; - $edit_link .= 'alt="' . $alt_edit . '" border="0" /></a>'; - } - - # get the information for the up icon, which returns to the previous - # paginated display - my $alt_uplink = eval $opts->{msgs}{alt_uplink}; - $temp = '<a href="/'; - $temp .= $table if $table; - $temp .= '/display?kv='; - $temp .= $kv_esc if $kv_esc; - $temp .= '&sb='; - $temp .= $sb if $sb; - $temp .= '">'; - my $uplink = $opts->{uplink} || $temp; - $uplink .= '<img src="' . $image_dir . '/up.gif" width="21" height="17"'; - $uplink .= ' alt="' . $alt_uplink . '" border="0" /></a>'; - - # define the next and previous links - # First build the previous icon - my ($prev_id, $prev_link); - $prev_id = $this_id - 1; - if ($prev_id && exists $ids{$prev_id}) { - my $prev_idnum = $ids{$prev_id}; - my $alt_prev = eval $opts->{msgs}{alt_previous}; - $prev_link = '<a href="/'; - $prev_link .= $table if $table; - $prev_link .= '/focus?idnum='; - $prev_link .= $prev_idnum if $prev_idnum; - $prev_link .= '&by='; - $prev_link .= $by if $by; - $prev_link .= '">'; - $prev_link .= '<img src="' . $image_dir . '/previous.gif" width="21" height="17"'; - $prev_link .= ' alt="' . $alt_prev . '" border="0" /></a>'; - } - # and if one doesn't - else { - my $alt_no_prev = eval $opts->{msgs}{alt_no_previous}; - $prev_link = '<img src="' . $image_dir . '/greyprevious.gif" width="21" height="17"'; - $prev_link .= ' alt="' . $alt_no_prev . '" border="0" /></a>'; - - } - - # build the next icon for an existing link - my ($next_id, $next_link); - $next_id = $this_id + 1; - if ($next_id && exists $ids{$next_id}) { - my $next_idnum = $ids{$next_id}; - my $alt_next = eval $opts->{msgs}{alt_next}; - $next_link = '<a href="/'; - $next_link .= $table if $table; - $next_link .= '/focus?idnum='; - $next_link .= $next_idnum if $next_idnum; - $next_link .= '&by='; - $next_link .= $by if $by; - $next_link .= '">'; - $next_link .= '<img src="' . $image_dir . '/next.gif" width="21" height="17"'; - $next_link .= ' alt="' . $alt_next . '" border="0" /></a>'; - - } - # and the next icon for a non-existing link - else { - my $alt_no_next = eval $opts->{msgs}{alt_no_next}; - my $next_idnum = ''; - $next_link = '<img src="' . $image_dir; - $next_link .= '/greynext.gif" '; - $next_link .= 'alt="' . $alt_no_next . '" border="0" />'; - } - - # get the sequence info - my $sequence = ' <b>'; - $sequence .= $this_id if $this_id; - $sequence .= '</b> of <b>'; - $sequence .= $qty_tr_by if $qty_tr_by; - $sequence .= '</b> ' . $HNL; - - # create the popup menu - my $menu = ' <select name="by">' . $HNL; - my $selected = ''; - # @values is the list of product_id to display - foreach my $value (@by) { - next if $value =~ /$my_defaults->{default_picklist}/o; - # determine if a value is among the defaults by comparing each - # default ($_) with the current product number ($value) - $menu .= ' <option value="' . $value . '">'; - $menu .= $value . '</option>' . $HNL; - } - # this plugs in the default value - $menu .= ' <option selected="1" value="' . $by . '">'; - $menu .= $by . '</option>' . $HNL; - $menu .= ' </select>' . $HNL; - - # not sure about this, but if this form is used the following - # URL must have the idnum, so let's save it here as a hidden - # field. When only sent as a query string arg it might be - # getting scraped off by POST2GET - $menu .= ' <input type="hidden" name="idnum"'; - $menu .= ' value="' . $idnum . '" />' . $HNL; - - $menu .= ' <input type="submit" name="submit" value="Go" />' . $HNL; - # ------ END of icon and link definition. Now disply 'em ------------- - - my @rows; - # start the <div> - my $text = '<!-- right float, so <div>s must be in rev order -->'; - push @rows, $text . $HNL; - push @rows, '<div id="seqnav">' . $HNL; - - # give us a heading - push @rows, ' <h1>Sequential Navigation</h1>' . $HNL; - # start the table and row and add the links - - $text = ' <form name="Sequence" action="/' . $table; - $text .= '/focus?idnum=' . $idnum . '" method="POST"'; - $text .= ' enctype="application/x-www-form-urlencoded">'; - push @rows, $text . $HNL; - - push @rows, - $new_link, # link to new id - $edit_link, # link to edit this id - $uplink, # link to app listing for this kv - $prev_link, # link to previous id - $next_link, - $sequence, - $menu; - - push @rows, ' </form>' . $HNL; - - # close the <div> - push @rows, '</div>' . $HNL; - $text = '<!-- end of seq-nav section -->'; - push @rows, $text . $HNL; - - return \@rows; - } # end &seq_nav - - - ############################ - # my $ref = &id_browser (\%opts) - # This sub is called during AppWrap phase "Focus". It determines how to sort the dataset, the number of table records in the selected dataset, and the numer of the current record in the selected dataset - - # The item is called an 'id' - # and is uniquely identified by an 'idnum' in the db. A control option - # is a way to search the db, such as contact, date, city, etc. These - # are user selectable to peruse the data along different dimensions. - # 05Dec02. Created from &seq_nav - ############################ - sub id_browser { - my $opts = shift; - my $table = $opts->{table}; - my $my_exceptions = $opts->{my_exceptions}; - my $my_tables = $opts->{my_tables}; - my $my_columns = $opts->{my_columns}; - my $my_defaults = $opts->{my_defaults}; - my $idnum = $opts->{args}{idnum}; - # idnum may have been passed with leading zeros, so strip them off - $idnum =~ s/^0+//; - my $sb = $opts->{args}{sb} || $my_tables->{$table}{default_sort} || 1; - my $page = $opts->{args}{page} || 0; - my $kv = $opts->{valid_kv}; - my $alt; - my $rows_per = $opts->{rows_per} ||= $my_defaults->{rows_per}; - my $image_dir = $config{homeurl} . '/' . $config{images}; - - my $log = Apache->request->log; - my $test; - - # store the output in a hash - my %out; - # get the sort hash. This is used to map different values. - my $i = 1; - my %sort_hash; - foreach my $column (@{ $opts->{page_display} }) { - $sort_hash{$i++} = Apache::AppWrap::Pager::fill_sort_new ($i,$column,$my_columns->{$table}{$column}{label}); - $sort_hash{$i++} = Apache::AppWrap::Pager::fill_sort_new ($i,$column,$my_columns->{$table}{$column}{label}); - } - #$log->debug("\nseq_nav: idnum=$idnum"); - - # default display sequence. Use param('by') if set. Else - # derive it from param('sb') - my $by = $opts->{args}{by} || $sort_hash{$sb}{by}; - $by =~ s/^by //; - $opts->{args}{by} = $by; - - # get the sort column for the db dip - my $order_by; - $sb ? $order_by = $sort_hash{$sb}{column} . ' ASC' : $order_by = $by . ' ASC'; - - # get the list of control options. This is used to populate the - # popup menu. - my @by = grep { - $my_columns->{$table}{$_}{page_sort} - } @{ $opts->{col_order} }; - #$test = join(", ", @by); - #$log->debug("id_browser: by=$test"); - - my ($select,$from,$where,$other); - # define this, next and previous id - # first, query for values in this id - # $select = '*'; - # $from = $table; - # $where = 'idnum=' . $idnum; - my $sql_this_id = "SELECT * FROM $table WHERE idnum=$idnum"; - my $sth = $dbh->prepare($sql_this_id); - $sth->execute(); - my $data_this_id = $sth->fetchrow_hashref; - - # next, having the data, we can determine the value of the control - my $by_value = $data_this_id->{$by}; - # while we have the data for this id might as well get the key_type - my $kt = $my_tables->{$table}{key_type}; - $kv = $data_this_id->{$kt} unless ($kv && $kt); - # $kv = $data_this_id->{$kt} unless $kv; - my $kv_esc = Apache::Util::escape_uri( $kv ) if $kv; - - # then, to get the prev and next idnum we need to query to get - # them all for this 'by' control. Quote the 'by' value - my $by_value_q = $dbh->quote($by_value); - my $sql_all_id = "SELECT idnum FROM $table ORDER BY $order_by"; - if ($by eq 'idnum') { - $sql_this_id = "SELECT idnum FROM $table ORDER BY $order_by"; - } - else { - $sql_all_id = "SELECT idnum FROM $table WHERE $by=$by_value_q ORDER BY $by ASC"; - } - - my $data_all_id = $dbh->selectall_arrayref($sql_all_id); - my $qty_tr_by = scalar(@$data_all_id); - # get a hash of the idnums - my %ids; - $i = 1; - foreach my $row (@{ $data_all_id }) { - $ids{$i++} = $row->[0]; - } - - $test = join(", ", keys %ids); - $log->debug("id_browser: test=$test"); - $log->debug("id_browser: idnum=$idnum, this_id=$ids{$idnum}, rows_per=$rows_per"); - # reverse the hash to easily get the id from the idnum - $out{ids} = %ids; - $out{this_id} = $ids{$idnum}; - $out{division} = ($out{this_id} / $rows_per); - $out{calc_page} = sprintf("%u", $out{division}); - $out{page} = $page || $out{calc_page}; - $out{kv_esc} = $kv_esc; - $out{by} = $by; - $out{by_array} = @by; - $out{qty_tr_by} = $qty_tr_by; - - return %out; - } # end &id_browser - - - ################################### - ## Usage: \%msgs = &make_focus_msgs(\%opts); - # returns a ref to a hash of messages to display on pages - # 14 May 01. Deleted this $kv from alt_new. - ################################### - sub make_focus_msgs { - my $opts = shift; - my $table = $opts->{table}; - my $kt = $opts->{my_tables}{$table}{key_type}; - my $kv = $opts->{valid_kv}; - my $idnum = $opts->{idnum}; - my $project_id = $opts->{project_id}; - my $my_exceptions = $opts->{my_exceptions}; - - # assign messages for alt tags. This allows subs to be called by - # &display, &focus and by &list, while retaining context sensitivity. - my %msgs; - my @alt_msgs; - foreach (keys %{ $my_exceptions->{$table}{focus} }) { - $msgs{$_} = $my_exceptions->{$table}{focus}{$_} if $_ =~ /^alt_/; - } - - # '$label' is defined where the msgs are eval'd - if ($kv) { - $msgs{alt_new} ||= '\'Create a new \' . $label . \' record\''; - $msgs{alt_edit} ||= '\'Edit this \' . $kv . \' \' . $label . \' record, idnum \' . $idnum'; - $msgs{alt_uplink} ||= '\'Return to the \' . $kv . \' \' . $label . \' listing\''; - $msgs{alt_previous} ||= '\'Previous \' . $label . \' record is idnum \' . $prev_idnum'; - $msgs{alt_no_previous} ||= '\'This is the first \' . $label . \' record in this series\''; - $msgs{alt_next} ||= '\'Next \' . $label . \' record is idnum \' . $next_idnum'; - $msgs{alt_no_next} ||= '\'This is the last \' . $label . \' record in this series\''; - } - else { # this is the case for 'key_type' = 'project_id' - $msgs{alt_new} ||= '\'Create a new \' . $label . \' record\''; - $msgs{alt_edit} ||= '\'Edit this \' . $label . \' record, idnum \' . $idnum'; - $msgs{alt_uplink} ||= '\'Return to the \' . $label . \' listing\''; - $msgs{alt_previous} ||= '\'Previous \' . $label . \' record is idnum \' . $prev_idnum'; - $msgs{alt_no_previous} ||= '\'This is the first \' . $label . \' record in this series\''; - $msgs{alt_next} ||= '\'Next \' . $label . \' record is idnum \' . $next_idnum'; - $msgs{alt_no_next} ||= '\'This is the last \' . $label . \' record in this series\''; - } - return \%msgs; - } - - - - - 1; - __END__ --- 195,199 ---- |
From: <pla...@us...> - 2002-12-21 11:08:24
|
Update of /cvsroot/appwrap/AppWrap/Apache/AppWrap In directory sc8-pr-cvs1:/tmp/cvs-serv16485 Modified Files: Pager.pm Log Message: recoded for clarity and performance, many changes for i18n, CSS. DB query caching Index: Pager.pm =================================================================== RCS file: /cvsroot/appwrap/AppWrap/Apache/AppWrap/Pager.pm,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Pager.pm 10 Dec 2002 07:14:40 -0000 1.15 --- Pager.pm 21 Dec 2002 11:08:21 -0000 1.16 *************** *** 28,31 **** --- 28,32 ---- $Apache::AppWrap::Pager::VERSION = "0.07"; + # 13Dec02. Replaced "alt" attributes with "title" in <img> tags # 03Dec02. convert to my_tables table_type directive # 22Nov02. Changed $kt_label definition to silence warnings *************** *** 45,55 **** # reference to a hash of configuration data, and a ref to an array of # hash refs of source data. [...1760 lines suppressed...] --- 1388,1406 ---- Displays a set of icons to simplify navigating through many "pages" (screenfuls) of data, and for adding data to tables and for editing existing data. ! =item fill_sort() Returns a reference to a hash having various elements used to create the hyperlinks in column headings for sorting. + + =item nav_series() + + Returns an array reference to data indicating the number of pages in the selected dataset, the current page number, and the unit for display, either 'idnum' or 'page'. This is required to support both table paging and browsing from the same subroutine. + + =item nav_icons() + + Returns an array reference to data for displaying the images required for paging through the given dataset. "Alt" messages come from table:my_text for the user's desired language. AppWrap actually uses the "title' attribute to display ALT message text, because this is better supported by more browsers. + + =item nav_form() + + Returns an array reference to data containing an HTML form which enables the user to browse the data in various dimensions. Dimensions are enabled by having the 'page_display' directive set in table my_columns for a given table and field. =back |
From: <pla...@us...> - 2002-12-21 11:06:55
|
Update of /cvsroot/appwrap/AppWrap/Apache/AppWrap In directory sc8-pr-cvs1:/tmp/cvs-serv15921 Modified Files: Subs.pm Log Message: i18n; CSS; many changes related to Focus and Pager recoding Index: Subs.pm =================================================================== RCS file: /cvsroot/appwrap/AppWrap/Apache/AppWrap/Subs.pm,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** Subs.pm 10 Dec 2002 07:16:46 -0000 1.32 --- Subs.pm 21 Dec 2002 11:06:51 -0000 1.33 *************** *** 31,35 **** use File::Spec (); ! $Apache::AppWrap::Subs::VERSION = "0.55"; ###### --- 31,35 ---- use File::Spec (); ! $Apache::AppWrap::Subs::VERSION = "0.56"; [...1263 lines suppressed...] + my $raw_text = $msgs->{$element}; + unless ($raw_text) { + $text = $caller . 'Display element "' . $element; + $text .= '" not found in table:my_text.'; + $r->log_error($text); + return; + } + + # we have an element, so eval and test it + my $out = eval $raw_text; + if ($@) { + $text = $caller . 'Display element "' . $element; + $text .= '" errored on eval of "' . $raw_text . '".'; + $r->log_error($text); + return; + } + return $out; + } # end chk_txt |
From: <pla...@us...> - 2002-12-21 11:04:28
|
Update of /cvsroot/appwrap/AppWrap/Apache/AppWrap In directory sc8-pr-cvs1:/tmp/cvs-serv15681 Modified Files: Doorknob.pm Log Message: Error check for directives in meta_data tables; addd my_defaults->VERBOSE directive Index: Doorknob.pm =================================================================== RCS file: /cvsroot/appwrap/AppWrap/Apache/AppWrap/Doorknob.pm,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Doorknob.pm 5 Dec 2002 04:05:44 -0000 1.11 --- Doorknob.pm 21 Dec 2002 11:04:26 -0000 1.12 *************** *** 7,18 **** # ################################################################# ! # 05Dec02. Cleaned up code whilst fixing phase-caching bug ! # 13Nov02. Warnings for uninitialized block ! # 06Nov02. Removed call to Subs::get_my_text, because in this phase of the Apache lifecycle we might not know the language ! # 05Nov02. Stubbed in initial language-independence code require Exporter; require DynaLoader; our @ISA = qw(Exporter DynaLoader); our @EXPORT = qw( @EXPORT_OK ); --- 7,22 ---- # ################################################################# ! #15Dec02. Error check for required meta_data tables and directives ! #05Dec02. Cleaned up code whilst fixing phase-caching bug ! #13Nov02. Warnings for uninitialized block ! #06Nov02. Removed call to Subs::get_my_text, because in this phase of the Apache lifecycle we might not know the language ! #05Nov02. Stubbed in initial language-independence code require Exporter; require DynaLoader; + use strict; + use warnings qw(redefine); + our @ISA = qw(Exporter DynaLoader); our @EXPORT = qw( @EXPORT_OK ); *************** *** 20,27 **** use vars qw($VERSION); ! our $VERSION = '0.04'; ! ! use strict; ! use warnings; use Apache::Constants qw(:common REDIRECT); --- 24,28 ---- use vars qw($VERSION); ! our $VERSION = '0.05'; use Apache::Constants qw(:common REDIRECT); *************** *** 79,82 **** --- 80,92 ---- $opts{my_defaults} = Apache::AppWrap::Subs::get_my_defaults(); + # enforce some rules for tables. These are directives + # which must be defined + my $rc = check_directives(\%opts); + unless ($rc) { + my $msg = 'Doorknob: problem running &check_directives'; + $r->log_error($msg); + return SERVER_ERROR; + } + # append table label to window title $opts{ScreenTitle} = $my_tables->{$table}{label}; *************** *** 207,210 **** --- 217,281 ---- return OK; } + + + ############################### + # $rc = check_directives(\%opts) + # Enforce the existence of required directives + # in table:my_tables + ############################### + sub check_directives { + my $opts = shift; + my $my_defaults = $opts->{my_defaults}; + my $my_tables = $opts->{my_tables}; + my $table = $opts->{table}; + my $r = Apache->request; + my $uri = $r->uri; + + # these meta_data tables are required, and their absence + # would error down the line. Let's stop that buck here. + my @reqd = qw(my_defaults my_tables my_columns); + + # these are the desirable my_tables directives + my @my_tables_dirs = qw(table_type label menu_order menu_tab); + + # these are the desirable my_tables directives + my @desired = qw(description ); + + # these are the required meta_data tables + foreach my $reqd_tab (@reqd) { + my $dir = $opts->{$reqd_tab}; + unless ($dir) { + my $msg = 'Doorknob: table ' . $reqd_tab . ' not defined.'; + $msg .= ' It is required.'; + $r->log_error($msg); + return SERVER_ERROR; + } + } + # these are the required my_tables directives + foreach my $dir (@my_tables_dirs) { + unless (exists $my_tables->{$table}{$dir}) { + my $msg = 'Doorknob: Directive my_tables->{'; + $msg .= $table . '}{' . $dir . '} not defined.'; + $msg .= ' It is required. Add this directive and'; + $msg .= ' retry the URL ' . $uri; + $r->log_error($msg); + return SERVER_ERROR; + } + } + return 1 unless $my_defaults->{VERBOSE}; + # these are the desirable directives + foreach my $dir (@desired) { + unless (exists $my_tables->{$table}{$dir}) { + my $msg = 'Doorknob: Directive my_tables->{'; + $msg .= $table . '}{' . $dir . '} not defined.'; + $msg .= ' Assigning an appropriate value is'; + $msg .= ' helpful to users. However it is not required.'; + $r->log_error($msg); + } + } + return 1; + } # end &check_directives + + 1; |
From: <pla...@us...> - 2002-12-21 11:03:12
|
Update of /cvsroot/appwrap/AppWrap/Apache/AppWrap In directory sc8-pr-cvs1:/tmp/cvs-serv15362 Modified Files: DBILogConfig.pm Log Message: cached DB reads/writes; used placeholders to improve cache hit-rate and security Index: DBILogConfig.pm =================================================================== RCS file: /cvsroot/appwrap/AppWrap/Apache/AppWrap/DBILogConfig.pm,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** DBILogConfig.pm 10 Dec 2002 07:08:33 -0000 1.12 --- DBILogConfig.pm 21 Dec 2002 11:03:06 -0000 1.13 *************** *** 18,23 **** ! $Apache::AppWrap::DBILogConfig::VERSION = "0.10"; ##### # 07Dec02 Cache DB statements. # 16Nov02 handle HEAD requests correctly. --- 18,24 ---- ! $Apache::AppWrap::DBILogConfig::VERSION = "0.11"; ##### + # 17Dec02 Jumble case of InSeRt statement to flag it as cached # 07Dec02 Cache DB statements. # 16Nov02 handle HEAD requests correctly. *************** *** 114,118 **** if ($r->bytes_sent) { my $today = str2time( time2str("%d-%h-%y", time() ) ); ! my $sql = 'UPDATE dailystats SET bytes=bytes+' . $r->bytes_sent; $sql .= ' WHERE stats_date=?'; $log->debug("\n\&DBILogConfig: statement=$sql") if $debug; --- 115,119 ---- if ($r->bytes_sent) { my $today = str2time( time2str("%d-%h-%y", time() ) ); ! my $sql = 'uPdaTE dailystats SET bytes=bytes+' . $r->bytes_sent; $sql .= ' WHERE stats_date=?'; $log->debug("\n\&DBILogConfig: statement=$sql") if $debug; *************** *** 203,207 **** # this is the SQL statement ! my $sql = "INSERT INTO $table ($field_str) VALUES ($bind_str)"; $log->debug("\nDBILogConfig: statement=$sql") if $debug; # do the SQL --- 204,208 ---- # this is the SQL statement ! my $sql = "InSeRt iNTo $table ($field_str) VALUES ($bind_str)"; $log->debug("\nDBILogConfig: statement=$sql") if $debug; # do the SQL |
From: <pla...@us...> - 2002-12-21 11:02:23
|
Update of /cvsroot/appwrap/AppWrap/Apache/AppWrap In directory sc8-pr-cvs1:/tmp/cvs-serv15183 Modified Files: Counter.pm Log Message: cached DB reads/writes; used placeholders to improve cache hit-rate and security Index: Counter.pm =================================================================== RCS file: /cvsroot/appwrap/AppWrap/Apache/AppWrap/Counter.pm,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Counter.pm 8 Dec 2002 02:28:53 -0000 1.10 --- Counter.pm 21 Dec 2002 11:02:19 -0000 1.11 *************** *** 18,23 **** use vars qw($VERSION); ! $Apache::AppWrap::Counter::VERSION = '0.12'; # 07Dec02. ignore backslash escapes in $config{rootdir} # 16Nov02. Don't record download on HEAD requests --- 18,24 ---- use vars qw($VERSION); ! $Apache::AppWrap::Counter::VERSION = '0.13'; + # 17Dec02. Cache all db queries and inserts # 07Dec02. ignore backslash escapes in $config{rootdir} # 16Nov02. Don't record download on HEAD requests *************** *** 49,54 **** # register all site hits in '/'. We specifically allow this # even for HEAD requests ! my $sql = "UPDATE counts SET hits=hits+1 WHERE location='/'"; ! my $rc = $dbh->do($sql); $r->log_error("Counter couldn't update counts") unless $rc; return DECLINED if $uri eq '/'; --- 50,58 ---- # register all site hits in '/'. We specifically allow this # even for HEAD requests ! # my $sql = "UPDATE counts SET hits=hits+1 WHERE location='/'"; ! my $sql = "UpdaTE counts SET hits=hits+1 WHERE location=?"; ! my $sth = $dbh->prepare_cached($sql); ! my $rc = $sth->execute('/'); ! # my $rc = $dbh->do($sql); $r->log_error("Counter couldn't update counts") unless $rc; return DECLINED if $uri eq '/'; *************** *** 58,70 **** if ($uri =~ '/download' && $r->method !~ /head/i) { my $today = &str2time( &time2str("%d-%h-%y", time() ) ); ! my $sql = 'UPDATE dailystats SET downloads=downloads+1'; $sql .= ' WHERE stats_date=?'; - # $sql .= ' WHERE stats_date=' . $today; # see if this speeds things any my $sth = $dbh->prepare_cached($sql); ! $rc = $sth->execute( $dbh->quote($today) ); - # $rc = $dbh->do($sql); unless ($rc) { $r->log_error("Counter couldn't update dailystats->download"); --- 62,73 ---- if ($uri =~ '/download' && $r->method !~ /head/i) { my $today = &str2time( &time2str("%d-%h-%y", time() ) ); ! my $sql = 'updaTE dailystats SET downloads=downloads+1'; $sql .= ' WHERE stats_date=?'; # see if this speeds things any my $sth = $dbh->prepare_cached($sql); ! $rc = $sth->execute($today); ! # $rc = $sth->execute( $dbh->quote($today) ); unless ($rc) { $r->log_error("Counter couldn't update dailystats->download"); *************** *** 85,96 **** # also register app specific hits in the appropriate app $uri =~ s#^(/\w+)\/.*$#$1#; ! $sql = 'UPDATE counts SET hits=hits+1 WHERE location=?'; ! # $sql = 'UPDATE counts SET hits=hits+1 WHERE location=' . $uri; ! my $sth = $dbh->prepare_cached($sql); $rc = $sth->execute($uri); ! # $rc = $dbh->do($sql); ! my $msg = 'Apache::Counter couldn\'t update counts->'; ! $msg .= $uri; ! $r->log_error($msg) unless $rc; return DECLINED; --- 88,99 ---- # also register app specific hits in the appropriate app $uri =~ s#^(/\w+)\/.*$#$1#; ! $sql = 'UpdaTE counts SET hits=hits+1 WHERE location=?'; ! $sth = $dbh->prepare_cached($sql); $rc = $sth->execute($uri); ! unless ($rc) { ! my $msg = q{SQLERRORL Apache::Counter couldnt update}; ! $msg .= qq{counts->$uri}; ! $r->log_error($msg) ! } return DECLINED; *************** *** 133,137 **** } # if we got here there already is a today entry, so update the value ! my $sql = 'UPDATE dailystats SET views=views+1'; $sql .= ' WHERE stats_date=?'; my $sth = $dbh->prepare_cached($sql); --- 136,140 ---- } # if we got here there already is a today entry, so update the value ! my $sql = 'upDATe dailystats SET views=views+1'; $sql .= ' WHERE stats_date=?'; my $sth = $dbh->prepare_cached($sql); |
From: <pla...@us...> - 2002-12-21 11:01:54
|
Update of /cvsroot/appwrap/AppWrap/Apache/AppWrap In directory sc8-pr-cvs1:/tmp/cvs-serv15020 Modified Files: Calendar.pm Log Message: i18n; CSS; cached DB reads/writes Index: Calendar.pm =================================================================== RCS file: /cvsroot/appwrap/AppWrap/Apache/AppWrap/Calendar.pm,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Calendar.pm 9 Dec 2002 10:04:32 -0000 1.8 --- Calendar.pm 21 Dec 2002 11:01:48 -0000 1.9 *************** *** 21,29 **** use Apache::Util (); ! use Apache::AppWrap::Subs qw($HNL); use vars qw($VERSION); ! $Apache::AppWrap::Calendar::VERSION = '0.09'; ############################ # 08Dec02. i18n, Perl warnings # 07Dec02. i18n --- 21,30 ---- use Apache::Util (); ! use Apache::AppWrap::Subs qw($dbh $HNL); use vars qw($VERSION); ! $Apache::AppWrap::Calendar::VERSION = '0.10'; ############################ + # 18Dec02. corrected how title is sourced from table:my_text # 08Dec02. i18n, Perl warnings # 07Dec02. i18n *************** *** 48,64 **** my $col_order = $opts->{col_order}; - my $msgs = $opts->{display_text}; - $msgs ||= Apache::AppWrap::Subs::get_display_text($opts); - $opts->{display_text} ||= $msgs; - # titles want to see these vars defined my $link_vars = Apache::AppWrap::Subs::cclinks($opts); ! ! my $title = eval $msgs->{title} if $msgs->{title}; ! unless ($title) { ! $r->log_error("Calendar: no title eval'd: $msgs->{title}"); ! return SERVER_ERROR; ! } ! $opts->{Title} = $title; my $log = $r->log; --- 49,57 ---- my $col_order = $opts->{col_order}; # titles want to see these vars defined my $link_vars = Apache::AppWrap::Subs::cclinks($opts); ! $args{element} = 'title'; ! $args{label} = $link_vars->{label}, ! $opts->{Title} = Apache::AppWrap::Subs::chk_txt($opts, \%args); my $log = $r->log; *************** *** 74,78 **** # now add the previous month link content ! my $url = '/' . $table . '/calendar?month=' . $m->{previous_month_end_epoch}; $url .= '&calendar=' . $query_args if $query_args; # label is full month and year --- 67,72 ---- # now add the previous month link content ! my $url = '/' . $table . '/calendar?month='; ! $url .= $m->{previous_month_end_epoch}; $url .= '&calendar=' . $query_args if $query_args; # label is full month and year *************** *** 89,128 **** my $next_link = '<a href="' . $url . '">' . $label . '</a>'; ! # Add a div for CSS ! push @rows, '<div id="pager">' . $HNL; ! # now we can push these links out to @rows in a table ! push @rows, ' <table width="95%" border="0">' . $HNL . ' <tr valign="bottom">'; ! push @rows, '<td align="left">' . $prev_link . '</td>'; ! push @rows, '<td align="right">' . $next_link . '</td>'; ! push @rows, '<tr>' . $HNL . ' </table>' . $HNL; ! # show a form of check boxes. The sub expects an array ref called ! # $defaults of columns already checked, and $columns, of all ! # possible columns ! my $defaults; ! @$defaults = split(/,/, $opts->{args}{calendar}) if $opts->{args}{calendar}; ! my $columns; ! # this isn't a very good test ! @$columns = grep { $_ =~ /^date$/ || $_ =~ /_date$/ } @$col_order; ! $defaults ||= $columns; my $start = $m->{previous_month_end_epoch}; my $end = $m->{next_month_start_epoch}; ! my $select = join(",", @$defaults); ! $select .= ',idnum'; ! my $kt = $my_tables->{$table}{key_type}; # add the key_type field to the query for later labels. So now # the query includes the idnum, the value in the "key_type" # field, and all fields of type "date". ! $select .= ',' . $kt unless $kt eq 'idnum'; ! my $from = $table; ! # limit select statement to data only in the desired month. ! my $where = join(" OR ", map {$_ . '>' . $start } @$defaults); ! $where .= ' AND ' . join(" OR ", map {$_ . '<' . $end } @$defaults); - my $ref = Apache::AppWrap::Subs::sqlSelectHashRef($select,$from,$where); # $ref is an array of hash refs of the form $row->{col_name} = $date, # one hash element for each date type field in the table. --- 83,168 ---- my $next_link = '<a href="' . $url . '">' . $label . '</a>'; ! # Add a div for CSS ! push @rows, '<div id="pager">' . $HNL; ! # now display links for previous and next months above ! # the Calaendar. Push links defined above to @rows in a table ! push @rows, ' <table>' . $HNL; ! push @rows, ' <tr valign="bottom">' . $HNL; ! push @rows, ' <td align="left">' . $prev_link . '</td>'; ! push @rows, ' <td align="right">' . $next_link . '</td>'; ! push @rows, ' </tr>' . $HNL; ! push @rows, ' </table>' . $HNL; ! # show an HTML form of check boxes. The sub expects an array ! # ref called defaults of columns already checked, and $columns, ! # of all possible columns. We overload a single query-string ! # argument with the name of all date-type columns, separated ! # by commas. ! my $defaults; ! if (exists $opts->{args}{calendar}) { ! @$defaults = split(/,/, $opts->{args}{calendar}); ! } ! my $columns; ! # get all the date-type columns from the table ! foreach my $column (@$col_order) { ! if ($column =~ /^date/ || $column =~ /_date$/) { ! push @$columns, $column; ! } ! } ! # if no query-string args use the columns from the table ! $defaults ||= $columns; my $start = $m->{previous_month_end_epoch}; my $end = $m->{next_month_start_epoch}; ! # add the idnum to the select component. The idnum is used ! # to create hyperlinks to the relevant data record. ! my $select = join(", ", @$defaults); ! $select .= ', idnum'; ! # add the key_type field to the query for later labels. So now # the query includes the idnum, the value in the "key_type" # field, and all fields of type "date". ! my $kt = $my_tables->{$table}{key_type}; ! $select .= ', ' . $kt unless $kt eq 'idnum'; + my $from = $table; + + # limit select statement to data only in the desired month. + # do this by specifying that each field value is 'GT' than + # the end of the previous month, and that each field + # value is 'LT' the end of the next month. + + # first, loop to identify the matched fields and to store + # the bind values. Field values will be processed as all + # which are greater than the end of the previous month, + # and then all which are less than the current month. + my (@starts, @ends, @bind_vals); + foreach my $field (@$defaults) { + push @starts, $field . '>?'; + push @bind_vals, $start; + } + foreach my $field (@$defaults) { + push @ends, $field . '<?'; + push @bind_vals, $end; + } + + my $where = '(' . join(" OR ", @starts) if scalar(@starts); + unless ($where) { + my $text = q{Calendar: no 'WHERE' values found. How}; + $text .= q{ is this possible?}; + $r->log_error($text); + return SERVER_ERROR; + } + $where .= ') AND ('; + $where .= join(" OR ", @ends); + $where .= ')'; + my $sql = qq{SeleCT $select frOm $table WHERE}; + $sql .= qq{ $where}; + #$log->debug("\nCalendar: sql=$sql."); + my $sth = $dbh->prepare_cached($sql); + my $rc = $sth->execute(@bind_vals); # $ref is an array of hash refs of the form $row->{col_name} = $date, # one hash element for each date type field in the table. *************** *** 146,150 **** # loop loop over entire dataset. Each row has an 'idnum' key and one # or more date type column keys. ! foreach my $row (@$ref) { my $idnum = $row->{idnum}; my $kv = $row->{$kt}; --- 186,193 ---- # loop loop over entire dataset. Each row has an 'idnum' key and one # or more date type column keys. ! my $ref; ! while (my $row = $sth->fetchrow_hashref) { ! push @$ref, $row; ! # foreach my $row (@$ref) { my $idnum = $row->{idnum}; my $kv = $row->{$kt}; *************** *** 164,168 **** next unless $date_value; my $label = eval $eval_func; - # if ($@); $label .= ' ' . $my_columns->{$table}{$col_name}{label}; push @{ $date_data{$date_value} }, {url => $url, label => $label}; --- 207,210 ---- *************** *** 308,311 **** --- 350,356 ---- # HTML::Entities is pretty verbose, apparently uselessly so. { + # this fails to quiets warnings from html::Element + # no warnings; + # but this works; local $ = 0; $out = $c->as_HTML(); |
From: <pla...@us...> - 2002-12-21 11:01:16
|
Update of /cvsroot/appwrap/AppWrap/Apache/AppWrap In directory sc8-pr-cvs1:/tmp/cvs-serv14872 Modified Files: Audit.pm Log Message: 20Dec02 Apache/AppWrap/Audit i18n; CSS; cached DB reads/writes Index: Audit.pm =================================================================== RCS file: /cvsroot/appwrap/AppWrap/Apache/AppWrap/Audit.pm,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Audit.pm 7 Dec 2002 01:48:14 -0000 1.6 --- Audit.pm 21 Dec 2002 11:01:08 -0000 1.7 *************** *** 19,23 **** use vars qw($VERSION); ! $Apache::AppWrap::Audit::VERSION = '0.05'; ############################ --- 19,23 ---- use vars qw($VERSION); ! $Apache::AppWrap::Audit::VERSION = '0.06'; ############################ *************** *** 35,67 **** my $my_columns = $opts->{my_columns}; my $my_defaults = $opts->{my_defaults}; ! ! #$log->debug("\nAudit: idnum=$idnum, table=$table"); ! my $msgs = $opts->{display_text}; ! $msgs ||= Apache::AppWrap::Subs::get_display_text($opts); ! $opts->{display_text} ||= $msgs; ! $opts->{msgs} = $msgs; # titles want to see these vars defined my $link_vars = Apache::AppWrap::Subs::cclinks($opts); ! my $link = '<a href="' . $config{homeurl} . '/'; ! $link .= $table . '/focus?idnum=' . $idnum . '">'; ! $link .= $idnum . '</a>'; ! ! my $title = eval $msgs->{title} if $msgs->{title}; ! unless ($title) { ! $r->log_error("Audit: no title eval'd: $msgs->{title}"); ! return SERVER_ERROR; ! } ! $opts->{Title} = $title; ! my $log = $r->log; ! ! my $subtitle = eval $msgs->{subtitle} if $msgs->{subtitle}; ! unless ($subtitle) { ! $r->log_error("Audit: no subtitle eval'd: $msgs->{subtitle}"); ! return SERVER_ERROR; ! } ! # app color, app name, col name ! $opts->{SubTitle} = $subtitle; # order to display columns --- 35,50 ---- my $my_columns = $opts->{my_columns}; my $my_defaults = $opts->{my_defaults}; ! my $log = $r->log; # titles want to see these vars defined my $link_vars = Apache::AppWrap::Subs::cclinks($opts); ! my %args; ! $args{element} = 'title'; ! $args{label} = $link_vars->{label}, ! $opts->{Title} = Apache::AppWrap::Subs::chk_txt($opts, \%args); + $args{element} = 'subtitle'; + $args{idnum} = $idnum; + $opts->{SubTitle} = Apache::AppWrap::Subs::chk_txt($opts, \%args); # order to display columns *************** *** 85,90 **** # get current record from source table ! my $where = 'idnum=' . $idnum; ! my $ref = Apache::AppWrap::Subs::sqlSelectHashRef ('*', $table, $where); # @final is the combined data structure my @final; --- 68,78 ---- # get current record from source table ! # my $where = 'idnum=' . $idnum; ! # my $ref = Apache::AppWrap::Subs::sqlSelectHashRef ('*', $table, $where); ! my $sql = qq{SeleCT * frOm $table WHERE idnum=?}; ! my $sth = $dbh->prepare_cached($sql); ! $sth->execute($idnum); ! ! # @final is the combined data structure my @final; *************** *** 93,98 **** # should be code to flag any columns that changed. my %converts; ! foreach my $row ( @$ref) { foreach my $column (keys %$row) { # set the column for downstream processing funcs $opts->{column} = $column; --- 81,90 ---- # should be code to flag any columns that changed. my %converts; ! my $ref; ! while (my $row = $sth->fetchrow_hashref) { ! # foreach my $row ( @$ref) { foreach my $column (keys %$row) { + # keep this to be used later + push @$ref, $row; # set the column for downstream processing funcs $opts->{column} = $column; *************** *** 162,173 **** # here is the mark for the same field in the previous row ! $final[-1]->{$column} .= chr($my_defaults->{history_flag}); # here is the ghost" style for this field in (and subsequent ) row ! $this_row{$column} = '<span class="history">' . $result . '</span>'; } else { ! # if here, this column had no history entry, meaning the column didn't change, so copy previous entry ! $test = $row->{$column}; #$log->debug("\nAudit: row=$row, col=$column, row->{column}=$test"); $this_row{$column} = $final[-1]->{$column}; --- 154,166 ---- # here is the mark for the same field in the previous row ! $final[-1]->{$column} .= chr($my_defaults->{history_flag}); # here is the ghost" style for this field in (and subsequent ) row ! $this_row{$column} = '<span class="history">' . $result . '</span>'; } else { ! # if here, this column had no history entry, meaning ! # the column didn't change, so copy previous entry ! #$test = $row->{$column}; #$log->debug("\nAudit: row=$row, col=$column, row->{column}=$test"); $this_row{$column} = $final[-1]->{$column}; *************** *** 187,191 **** push @rows, '<div id="pager">' . $HNL; push @rows, ' <table>' . $HNL . ' <tr>'; - ## push @rows, ' <table border="1">' . $HNL . ' <tr valign="bottom">'; foreach my $column (@$col_order) { next if $column eq 'idnum'; --- 180,183 ---- *************** *** 207,214 **** #$log->debug("\nAudit: col=$column, row->{column}=$out"); { # -w off - ## local $ = 0; no warnings qw(numeric uninitialized); if ($out) { ! push @rows, '<td>' . $out . '</td>' if $out; } elsif ($out == 0 && $out eq '0') { --- 199,205 ---- #$log->debug("\nAudit: col=$column, row->{column}=$out"); { # -w off no warnings qw(numeric uninitialized); if ($out) { ! push @rows, '<td>' . $out . '</td>'; } elsif ($out == 0 && $out eq '0') { *************** *** 225,229 **** } # end row loop push @rows, ' </table>' . $HNL; ! push @rows, '</div>' . $HNL; ######## left side links (vbar phase) ######### --- 216,221 ---- } # end row loop push @rows, ' </table>' . $HNL; ! my $text = '</div> <!-- end of pager div -->'; ! push @rows, $text . $HNL; ######## left side links (vbar phase) ######### *************** *** 231,241 **** $menu_func ||= $my_defaults->{func_audit}; $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(";", $menu_func ); foreach (@subs) { my $ref = eval $_; ! push @{ $opts->{menuitems} }, join("", @$ref) if $ref && scalar(@$ref); ! } } --- 223,235 ---- $menu_func ||= $my_defaults->{func_audit}; $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 (@subs) { my $ref = eval $_; ! if ($ref && scalar(@$ref)) { ! push @{ $opts->{menuitems} }, join("", @$ref); ! } } } |
From: <pla...@us...> - 2002-12-10 12:04:58
|
Update of /cvsroot/appwrap/AppWrap/Apache/AppWrap In directory sc8-pr-cvs1:/tmp/cvs-serv17358 Modified Files: GetPage.pm Log Message: CSS for chapter display. Index: GetPage.pm =================================================================== RCS file: /cvsroot/appwrap/AppWrap/Apache/AppWrap/GetPage.pm,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** GetPage.pm 1 Dec 2002 01:05:06 -0000 1.8 --- GetPage.pm 10 Dec 2002 12:04:53 -0000 1.9 *************** *** 129,132 **** --- 129,133 ---- } } + push @rows, '<div id="pager">' . $HNL; # wrap the data in table tags push @rows, '<table><tr><td>' . $chpt_data; *************** *** 137,140 **** --- 138,142 ---- push @rows, '<!-- prev/next navigation links -->' . "\n", $nav; + push @rows, '</div>' . $HNL; } # end 'chpt' |
From: <pla...@us...> - 2002-12-10 10:20:59
|
Update of /cvsroot/appwrap/AppWrap In directory sc8-pr-cvs1:/tmp/cvs-serv15387 Modified Files: AppWrap.pm.template Log Message: Updated for release 0.09 Index: AppWrap.pm.template =================================================================== RCS file: /cvsroot/appwrap/AppWrap/AppWrap.pm.template,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** AppWrap.pm.template 29 Nov 2002 13:40:54 -0000 1.2 --- AppWrap.pm.template 10 Dec 2002 10:20:56 -0000 1.3 *************** *** 14,18 **** our @EXPORT_OK = qw(%config); ! our $VERSION = '0.08'; =head1 NAME --- 14,18 ---- our @EXPORT_OK = qw(%config); ! our $VERSION = '0.09'; =head1 NAME *************** *** 228,233 **** =item * All text displayed onscreen is stored in the DB, rather than hard-coded, for iternationalization. With release 0.07 this effort has begun. - - =item * Replace HTML table-based presentation and layout with Cascading Style Sheets. =item * Notification via email, SMS, IM, etc when a table or record of ointerest changes --- 228,231 ---- |
From: <pla...@us...> - 2002-12-10 10:16:30
|
Update of /cvsroot/appwrap/AppWrap/Apache In directory sc8-pr-cvs1:/tmp/cvs-serv13700 Modified Files: AppWrap.pm Log Message: Updated for release 0.09 Index: AppWrap.pm =================================================================== RCS file: /cvsroot/appwrap/AppWrap/Apache/AppWrap.pm,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** AppWrap.pm 22 Nov 2002 10:09:43 -0000 1.9 --- AppWrap.pm 10 Dec 2002 10:16:28 -0000 1.10 *************** *** 16,20 **** our @EXPORT = qw( @EXPORT_OK ); ! our $VERSION = '0.07'; 1; --- 16,20 ---- our @EXPORT = qw( @EXPORT_OK ); ! our $VERSION = '0.09'; 1; |
From: <pla...@us...> - 2002-12-10 10:15:30
|
Update of /cvsroot/appwrap/AppWrap/includes In directory sc8-pr-cvs1:/tmp/cvs-serv13270 Modified Files: AppWrap.css Log Message: final tinkering Index: AppWrap.css =================================================================== RCS file: /cvsroot/appwrap/AppWrap/includes/AppWrap.css,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** AppWrap.css 9 Dec 2002 10:13:26 -0000 1.5 --- AppWrap.css 10 Dec 2002 10:15:26 -0000 1.6 *************** *** 149,152 **** --- 149,158 ---- vertical-align: top; } + div#buttons { + text-align: center; + } + div#buttons form { + display: inline; + } div#navfoot { color: #000000; |
From: <pla...@us...> - 2002-12-10 07:16:49
|
Update of /cvsroot/appwrap/AppWrap/Apache/AppWrap In directory sc8-pr-cvs1:/tmp/cvs-serv19902 Modified Files: Subs.pm Log Message: perl warnings, CSS, cache SQL prepare statements Index: Subs.pm =================================================================== RCS file: /cvsroot/appwrap/AppWrap/Apache/AppWrap/Subs.pm,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** Subs.pm 7 Dec 2002 02:08:29 -0000 1.31 --- Subs.pm 10 Dec 2002 07:16:46 -0000 1.32 *************** *** 31,37 **** use File::Spec (); ! $Apache::AppWrap::Subs::VERSION = "0.54"; ###### # 06Dec02. Webify AppWrap "skinning" code to set stylesheet on the fly # 02Dec02. (several) convert to my_tables table_type directive --- 31,38 ---- use File::Spec (); ! $Apache::AppWrap::Subs::VERSION = "0.55"; ###### + # 09Dec02. get_history,favorites cached DB queries # 06Dec02. Webify AppWrap "skinning" code to set stylesheet on the fly # 02Dec02. (several) convert to my_tables table_type directive *************** *** 639,644 **** $sql .= ' ' . $other if $other; ! my $sth = $dbh->prepare($sql); ! $sth->execute; my $rows; --- 640,653 ---- $sql .= ' ' . $other if $other; ! # my $sth = $dbh->prepare($sql); ! my $sth; ! # cache standard, frequently-used queries ! unless ($where || $other) { ! $sth = $dbh->prepare_cached($sql); ! } ! else { ! $sth = $dbh->prepare($sql); ! } ! $sth->execute; my $rows; *************** *** 1175,1178 **** --- 1184,1188 ---- my $my_tables = $opts->{my_tables}; my $my_defaults = $opts->{my_defaults}; + my $r = Apache->request; my $table = $opts->{table}; *************** *** 1187,1191 **** my $cutoff = time - $duration; $select = 'h.tablename,h.col_name,h.row_num,h.history_date,h.prev_value'; ! $from = 'history AS h'; # trying to clean up historical tracking. By including a cutoff we # wanted to reduce Server mmory consumption (ie, size of history --- 1197,1201 ---- my $cutoff = time - $duration; $select = 'h.tablename,h.col_name,h.row_num,h.history_date,h.prev_value'; ! # $from = 'history AS h'; # trying to clean up historical tracking. By including a cutoff we # wanted to reduce Server mmory consumption (ie, size of history *************** *** 1193,1206 **** $where = 'h.history_date>' . $cutoff; $other = ''; # regionalization should be done in the calling sub, not in this # generic data retrieval sub if ($region) { ! $from .= ',projects AS p,contacts AS c,regions AS r'; ! $where .= ' AND h.row_num=p.idnum AND p.contact=c.idnum'; ! $where .= ' AND c.country=r.country AND r.region=' . $region_q; } ! # get the data ! my $ref = sqlSelectArrayRef( $select,$from,$where,$other); my $history; # shove into an array --- 1203,1232 ---- $where = 'h.history_date>' . $cutoff; $other = ''; + my @bind_vals; + push @bind_vals, $cutoff; # regionalization should be done in the calling sub, not in this # generic data retrieval sub + # define the SQL statement + my $sql = 'SELECT ' . $select . ' FROM history AS h'; + $sql .= ',projects AS p,contacts AS c,regions AS r' if $region; + $sql .= ' WHERE h.history_date>?'; if ($region) { ! $sql .= ' AND h.row_num=p.idnum AND p.contact=c.idnum'; ! $where .= ' AND c.country=r.country AND r.region=?'; ! push @bind_vals, $region; } ! # prepare the query ! my $sth = $dbh->prepare_cached($sql); ! # execute ! my $rc = $sth->execute(@bind_vals); ! ! # error check ! unless ($rc) { ! my $msg = 'SQLERROR. Subs::get_history: "' . $sql . '"'; ! $r->log_error($msg); ! } ! my $ref = $sth->fetchall_arrayref; ! my $history; # shove into an array *************** *** 1757,1763 **** $imgfile .= '/' . $image; ! my $text = '<img src="' . $imgfile . '" height="300"'; ! $text .= ' width="400" alt="my image" />' . $HNL; push @output, $text; } else { --- 1783,1797 ---- $imgfile .= '/' . $image; ! push @output, '<div id="pager">' . $HNL; ! ! my $text = '<img src="' . $imgfile; ! # my $text = '<img src="' . $imgfile . '" height="auto"'; ! # my $text = '<img src="' . $imgfile . '" height="300"'; ! $text .= '" alt="my image" />' . $HNL; ! # $text .= ' width="auto" alt="my image" />' . $HNL; ! # $text .= ' width="400" alt="my image" />' . $HNL; push @output, $text; + + push @output, '</div>' . $HNL; } else { *************** *** 3338,3373 **** # 23 Aug 01. Created. ############################### ! sub write_stats { ! my $now = time(); ! # convert "now" to an integer date, then get number of ! # seconds from that integdate ! my $today_str = time2str("%d-%h-%y", $now); ! my $today = str2time($today_str); ! my $r = Apache->request; ! my $log = $r->log; ! # we moved &write_stats() processing into a PerlChildInit ! # handler. As the first ophase of the request we no longer ! # know how many bytes will be in the response. Need to do ! # that towards the end of the request loop ! my $bytes_sent = $r->bytes_sent; ! ! my $rc; ! # check for a "today" entry in dailystats ! my $ref = sqlSelectArrayRef('MAX(stats_date)', 'dailystats'); ! unless ($ref->[0][0] == $today) { ! # $dbh->do returns rows effected, or undef on error ! $rc = $dbh->do("INSERT INTO dailystats (stats_date) VALUES ($today)"); ! # we won't log this as an error because it normally should fail ! $r->log_error("\&write_stats couldn't insert into dailystats $today_str") unless $rc; ! return $rc ? 0 : 1; ! } ! # if we got here there already is a today entry, so update the value ! # my $sql = "UPDATE dailystats SET views=views+1, bytes=bytes+$bytes_sent WHERE stats_date=$today"; ! my $sql = 'UPDATE dailystats SET views=views+1'; ! $sql .= " WHERE stats_date=$today"; ! $rc = $dbh->do($sql); ! $r->log_error("\&write_stats couldn't update dailystats") unless $rc; ! return $rc ? 0 : 1; ! } # end &write_stats; --- 3372,3413 ---- # 23 Aug 01. Created. ############################### ! #sub write_stats { ! # my $now = time(); ! # # convert "now" to an integer date, then get number of ! # # seconds from that integdate ! # my $today_str = time2str("%d-%h-%y", $now); ! # my $today = str2time($today_str); ! # my $r = Apache->request; ! # my $log = $r->log; ! # # we moved &write_stats() processing into a PerlChildInit ! # # handler. As the first ophase of the request we no longer ! # # know how many bytes will be in the response. Need to do ! # # that towards the end of the request loop ! # my $bytes_sent = $r->bytes_sent; ! # ! # my $rc; ! # # check for a "today" entry in dailystats ! # my $ref = sqlSelectArrayRef('MAX(stats_date)', 'dailystats'); ! # unless ($ref->[0][0] == $today) { ! # # $dbh->do returns rows effected, or undef on error ! # my $sql = 'INSERT INTO dailystats (stats_date) VALUES (?)'; ! # my $sth = $dbh->prepare_cached($sql); ! # $rc = $sth->execute($today); ! ## $rc = $dbh->do("INSERT INTO dailystats (stats_date) VALUES ($today)"); ! # # we won't log this as an error because it normally should fail ! # $r->log_error("\&write_stats couldn't insert into dailystats $today_str") unless $rc; ! # return $rc ? 0 : 1; ! # } ! # # if we got here there already is a today entry, so update the value ! ## my $sql = "UPDATE dailystats SET views=views+1, bytes=bytes+$bytes_sent WHERE stats_date=$today"; ! # my $sql = 'UPDATE dailystats SET views=views+1'; ! # $sql .= ' WHERE stats_date=?'; ! # my $sth = $dbh->prepare_cached($sql); ! # $rc = $sth->execute($today); ! ## $sql .= " WHERE stats_date=$today"; ! ## $rc = $dbh->do($sql); ! # $r->log_error("\&write_stats couldn't update dailystats") unless $rc; ! # return $rc ? 0 : 1; ! #} # end &write_stats; *************** *** 3459,3463 **** return unless $user; # list of URL endings to exclude hardcoded here ! my @hard_excludes = qw/modify verify confirm display focus audit summary/; # list of URL starters to exclude found in table:my_defaults my $exclude_ends = join("|", @hard_excludes); --- 3499,3505 ---- return unless $user; # list of URL endings to exclude hardcoded here ! my @hard_excludes = qw( ! modify verify confirm display focus audit summary ! ); # list of URL starters to exclude found in table:my_defaults my $exclude_ends = join("|", @hard_excludes); *************** *** 3469,3492 **** # get qty of links to show my $limit = $my_defaults->{favorites_qty}; # get user name # create SQU guery elements my $select = 'urlpath, count(*) as qty'; ! my $from = 'accesses'; ! # skip modify & confirm ! my $user_q = $dbh->quote ($user ); ! my $where = 'user=' . $user_q; # exclude modify and confirm URL. 'modify', 'verify' and 'confirm' # out of context can have unpredictable results, and audit', # 'display', and 'focus' are only valid with query string args # (we'll figure that out later.) ! # $where .= ' AND urlpath NOT REGEXP "(modify|confirm|verify)$"'; ! # $where .= ' AND urlpath NOT REGEXP "(audit|focus|display|summary)$"'; ! $where .= ' AND urlpath NOT REGEXP "(' . $exclude_ends . ')$"'; ! $where .= ' AND urlpath NOT REGEXP "^/(' . $exclude . ')"'; ! my $other = 'GROUP BY urlpath ORDER BY qty DESC LIMIT ' . $limit; # do the query #$log->debug("\nfavorites: ready to query"); - my $ref = sqlSelectHashRef($select, $from, $where, $other); - #$log->debug("\nfavorites: finished query"); # loop to create each link my @rows; --- 3511,3567 ---- # get qty of links to show my $limit = $my_defaults->{favorites_qty}; + unless ($limit) { + my $msg = 'DBILogConfig: favorites_qty must be set in'; + $msg .= ' table:my_defaults'; + $r->log_error($msg); + return SERVER_ERROR; + } + # arbitrarily set the max number of favorites to display + $limit = 10 if $limit > 10; + # get user name # create SQU guery elements my $select = 'urlpath, count(*) as qty'; ! ! my $logtable = $r->dir_config('DBILogConfig_table'); ! $logtable ||= $my_defaults->{DBILogConfig_table}; ! unless ($logtable) { ! my $msg = 'DBILogConfig: Logging table not defined'; ! $r->log_error($msg); ! return SERVER_ERROR; ! } ! # exclude modify and confirm URL. 'modify', 'verify' and 'confirm' # out of context can have unpredictable results, and audit', # 'display', and 'focus' are only valid with query string args # (we'll figure that out later.) ! ! # define the SQL statement ! my $sql = 'SELECT urlpath, count(*) AS qty FROM ' . $logtable; ! $sql .= ' WHERE user=?'; ! $sql .= ' AND urlpath NOT REGEXP "(' . $exclude_ends . ')$"'; ! $sql .= ' AND urlpath NOT REGEXP "^/(' . $exclude . ')"'; ! $sql .= 'GROUP BY urlpath ORDER BY qty DESC LIMIT 10'; ! ! # prepare the query ! my $sth = $dbh->prepare_cached($sql); ! # execute ! my $rc = $sth->execute($user); ! # error check ! unless ($rc) { ! my $msg = 'SQLERROR. DBILogConfig: "' . $sql . '"'; ! $r->log_error($msg); ! } ! my $ref; ! my $i = 0; ! while (my $row = $sth->fetchrow_hashref) { ! push @$ref, { %$row }; ! last if $i++ == $limit ! } ! $sth->finish; ! ! #### #### # do the query #$log->debug("\nfavorites: ready to query"); # loop to create each link my @rows; *************** *** 3497,3500 **** --- 3572,3576 ---- push @rows, $text . $HNL; #$log->debug("\nfavorites: start html loop"); + # favorites to display foreach my $row (@$ref) { my $url = $row->{urlpath}; *************** *** 3503,3506 **** --- 3579,3583 ---- my $link = '<a href="' . $url . '">'; $link .= $url . '</a>'; + push @rows, ' <tr><td class="first">' . $link . '</td>'; push @rows, '<td>' . $qty . '</td></tr>' . $HNL; |
From: <pla...@us...> - 2002-12-10 07:14:44
|
Update of /cvsroot/appwrap/AppWrap/Apache/AppWrap In directory sc8-pr-cvs1:/tmp/cvs-serv19570 Modified Files: Pager.pm Log Message: perl warnings, code cleanup Index: Pager.pm =================================================================== RCS file: /cvsroot/appwrap/AppWrap/Apache/AppWrap/Pager.pm,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Pager.pm 8 Dec 2002 02:42:57 -0000 1.14 --- Pager.pm 10 Dec 2002 07:14:40 -0000 1.15 *************** *** 152,155 **** --- 152,157 ---- my $title = eval $msgs->{title} if $msgs->{title}; + # this may be a fudge to regret later + $title ||= $opts->{Title}; unless ($title) { $r->log_error("Pager: no title eval'd: $msgs->{title}"); *************** *** 158,168 **** $opts->{Title} = $title; my $subtitle = eval $msgs->{subtitle} if $msgs->{subtitle}; ! unless ($subtitle) { ! $r->log_error("Pager: no subtitle eval'd: $msgs->{subtitle}"); ! return SERVER_ERROR; ! } ! # app color, app name, col name ! $opts->{SubTitle} = $subtitle; # sort the provided data according to the selected sort order --- 160,167 ---- $opts->{Title} = $title; + # subtitles are not mandatory: some tables have none. my $subtitle = eval $msgs->{subtitle} if $msgs->{subtitle}; ! $subtitle ||= $opts->{SubTitle}; ! $opts->{SubTitle} = $subtitle if $subtitle; # sort the provided data according to the selected sort order |
From: <pla...@us...> - 2002-12-10 07:12:53
|
Update of /cvsroot/appwrap/AppWrap/Apache/AppWrap In directory sc8-pr-cvs1:/tmp/cvs-serv19203 Modified Files: Generate_form.pm Log Message: CSS, warnings, general code cleanup Index: Generate_form.pm =================================================================== RCS file: /cvsroot/appwrap/AppWrap/Apache/AppWrap/Generate_form.pm,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Generate_form.pm 22 Nov 2002 10:05:56 -0000 1.6 --- Generate_form.pm 10 Dec 2002 07:12:49 -0000 1.7 *************** *** 8,11 **** --- 8,13 ---- use strict; + use warnings; + no warnings qw(redefine); use CGI::Carp qw(fatalsToBrowser); use DBI; *************** *** 21,26 **** use vars qw($VERSION); ! $Apache::AppWrap::Generate_form::VERSION = '0.05'; ! # 03 Nov 02. Missing semi-colon, apparently unimoportant, replaced. --- 23,29 ---- use vars qw($VERSION); ! $Apache::AppWrap::Generate_form::VERSION = '0.06'; ! # 09Dec02. CSS, general code cleanup. ! # 03Nov02. Missing semi-colon, apparently unimportant, replaced. *************** *** 43,47 **** # determine key_type and key_value (if any) my $kt = $my_tables->{$table}{key_type}; ! $opts->{valid_kv} = &Apache::AppWrap::Subs::valid_kv($opts); my $kv = $opts->{valid_kv}; --- 46,50 ---- # determine key_type and key_value (if any) my $kt = $my_tables->{$table}{key_type}; ! $opts->{valid_kv} = Apache::AppWrap::Subs::valid_kv($opts); my $kv = $opts->{valid_kv}; *************** *** 49,53 **** # set titles ! my $link_vars = &Apache::AppWrap::Subs::cclinks( $opts); my $label = $link_vars->{label}; --- 52,56 ---- # set titles ! my $link_vars = Apache::AppWrap::Subs::cclinks( $opts); my $label = $link_vars->{label}; *************** *** 70,74 **** $from = $table; $where = 'idnum=' . $idnum; ! $ref = &Apache::AppWrap::Subs::sqlSelectHashRef( $select, $from, $where ); # set titles --- 73,77 ---- $from = $table; $where = 'idnum=' . $idnum; ! $ref = Apache::AppWrap::Subs::sqlSelectHashRef( $select, $from, $where ); # set titles *************** *** 95,99 **** # call functions if defined. Functions return array of to data wrapped in <td> tags if ($menu_func) { ! my @subs = split(";", $menu_func ); foreach (@subs) { my $ref = eval $_; --- 98,102 ---- # 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 (@subs) { my $ref = eval $_; *************** *** 101,117 **** } } # manually set the url to redirect to my $url = '/' . $table . '/verify'; ! my $start_form = ' <form method="POST" action="' . $url; ! $start_form .= '" enctype="application/x-www-form-urlencoded">'; ! push @rows, $start_form; ! # set the idnum and key_values param if available ! push @rows, $HNL . ' <input type="hidden" name="idnum" value="' . $idnum . '" />' if $idnum; ! if ($kv && $kt && $kt ne 'idnum') { ! push @rows, $HNL . ' <input type="hidden" name="' . $kt . '" value="' . $kv . '" />'; ! } my $birthplace = $opts->{args}{birthplace}; --- 104,129 ---- } } + # start the <div> + push @rows, '<div id="pager">' . $HNL; # manually set the url to redirect to my $url = '/' . $table . '/verify'; ! my $start_form = ' <form method="POST" action="' . $url; ! $start_form .= '" enctype="application/x-www-form-urlencoded">'; ! push @rows, $start_form . $HNL; ! my $text; ! # set the idnum and key_values param if available ! if ($idnum) { ! $text = ' <input type="hidden" name="idnum" value="'; ! $text .= $idnum . '" />' if $idnum; ! push @rows, $text . $HNL; ! } ! if ($kv && $kt && $kt ne 'idnum') { ! $text = ' <input type="hidden" name="' . $kt; ! $text .= '" value="' . $kv . '" />'; ! push @rows, $text . $HNL; ! } my $birthplace = $opts->{args}{birthplace}; *************** *** 124,147 **** #$log->debug("\nGenerate_form: birthplace=$birthplace"); ! push @rows, $HNL . ' <input type="hidden" name="birthplace" value="' . $birthplace . '" />'; ! # pass this edit_flag to set whether to INSERT or UPDATE db. ! push @rows, $HNL . ' <input type="hidden" name="edit_flag" value="1" />' if $opts->{args}{edit_flag}; ! # show a ''Verify' button ! push @rows, $HNL . ' <p align="center"><input type="submit" name=".submit"'; ! push @rows, ' value="Verify" /></p>' . $HNL . ' <table border="1">'; my ($column, $default, $val); ! # loop thru each column to display form fields and default values, if any my @col_order = @{ $opts->{col_order} }; { # -w off ! local $ = 0; foreach $column (@col_order) { ! # these columns are handled exceptionally, so don't process them here for all tables next if $column eq 'idnum'; next if $column eq 'email'; next if $column eq 'created_date'; ! # we skip some fields. Skip the key_type field if the key value is set. next if $kv && $column eq $kt; --- 136,170 ---- #$log->debug("\nGenerate_form: birthplace=$birthplace"); ! $text = ' <input type="hidden" name="birthplace" value="'; ! $text .= $birthplace . '" />'; ! push @rows, $text . $HNL; ! # pass this edit_flag to set whether to INSERT or UPDATE db. ! if ($opts->{args}{edit_flag}) { ! $text = ' <input type="hidden" name="edit_flag" value="1" />'; ! push @rows, $text . $HNL; ! } ! # show a ''Verify' button ! $text = ' <p align="center"><input type="submit" name=".submit"'; ! $text .= ' value="Verify" /></p>'; ! push @rows, $text . $HNL; ! push @rows, ' <table border="1">' . $HNL; my ($column, $default, $val); ! # loop thru each column to display form fields and default ! # values, if any my @col_order = @{ $opts->{col_order} }; { # -w off ! no warnings qw(uninitialized numeric); ! # local $ = 0; foreach $column (@col_order) { ! # these columns are handled exceptionally, so don't ! # process them here for all tables next if $column eq 'idnum'; next if $column eq 'email'; next if $column eq 'created_date'; ! # we skip some fields. Skip the key_type field if the ! # key value is set. next if $kv && $column eq $kt; *************** *** 149,153 **** $opts->{column} = $column; ! # if this is an edit, get the fields from the DB. However, always override them with the %args hash my $default; if ($opts->{args}{$column}) { --- 172,177 ---- $opts->{column} = $column; ! # if this is an edit, get the fields from the DB. ! # However, always override them with the %args hash my $default; if ($opts->{args}{$column}) { *************** *** 164,168 **** # flag fields which are required ! my $label = &Apache::AppWrap::Subs::mark_required ($opts, $column); # display the label and the description --- 188,192 ---- # flag fields which are required ! my $label = Apache::AppWrap::Subs::mark_required ($opts, $column); # display the label and the description *************** *** 170,178 **** my $text = eval $help if $help; $text ||= ' '; ! my $display = $HNL . ' <tr valign="top">'; $display .= '<th'; ! $display .= ' class="' . $link_vars->{cell_class} . '"' if $link_vars->{cell_class}; ! $display .= '>' . $label . '</th><td class="advice">' . $text . '</td>'; ! push @rows, $display; # Run the external function. All external functions are required --- 194,205 ---- my $text = eval $help if $help; $text ||= ' '; ! my $display = ' <tr valign="top">'; $display .= '<th'; ! if (exists $link_vars->{cell_class}) { ! $display .= ' class="' . $link_vars->{cell_class} . '"'; ! } ! $display .= '>' . $label . '</th>'; ! $display .= '<td class="advice">' . $text . '</td>'; ! push @rows, $display . $HNL; # Run the external function. All external functions are required *************** *** 185,189 **** $val = join("", @$func_ref) if $func_ref && scalar(@$func_ref); $val ||= ' '; ! push @rows, '<td>' . $val . '</td></tr>'; next; } --- 212,216 ---- $val = join("", @$func_ref) if $func_ref && scalar(@$func_ref); $val ||= ' '; ! push @rows, ' <td>' . $val . '</td></tr>' . $HNL; next; } *************** *** 192,196 **** # NOT zero (RE [\w\d]+) elsif ($default) { ! push @rows, '<td>' . $default . '</td></tr>'; next; } --- 219,223 ---- # NOT zero (RE [\w\d]+) elsif ($default) { ! push @rows, ' <td>' . $default . '</td></tr>' . $HNL; next; } *************** *** 198,220 **** elsif ($default == 0 && $default eq '0') { # could be blank or null string ! push @rows, '<td>0</td></tr>'; next; } # case d) no function, and value of $default is blank else { ! push @rows, '<td> </td></tr>'; next; } } # end column treatment } # -w on ! # close table and show another 'Verify' button for convenience on long forms ! my $out = $HNL . ' </table>' . $HNL . ' <p>Fields marked with ' . $my_defaults->{reqd_flag}; ! $out .= ' require input.</p>' . $HNL . ' <p align="center">'; ! $out .= '<input type="submit" name=".submit" value="Verify" /></p>' . $HNL; ! $out .= ' </form>' . $HNL; ! push @rows, $out; $opts->{Rows} = \@rows; ! &Apache::AppWrap::Subs::Webify($opts); return OK; } # end handler --- 225,256 ---- elsif ($default == 0 && $default eq '0') { # could be blank or null string ! push @rows, ' <td>0</td></tr>' . $HNL; next; } # case d) no function, and value of $default is blank else { ! push @rows, ' <td> </td></tr>' . $HNL; next; } } # end column treatment } # -w on ! # close table and show another 'Verify' button for ! # convenience on long forms ! $text = $HNL . ' </table>'; ! push @rows, $text . $HNL; ! $text = ' <p>Fields marked with ' . $my_defaults->{reqd_flag}; ! $text .= ' require input.</p>'; ! push @rows, $text . $HNL; ! $text = ' <p align="center">'; ! $text .= '<input type="submit" name=".submit" value="Verify"'; ! $text .= ' /></p>' . $HNL; ! $text .= ' </form>' . $HNL; ! push @rows, $text; ! ! # close the <div> ! push @rows, '</div>' . $HNL; $opts->{Rows} = \@rows; ! Apache::AppWrap::Subs::Webify($opts); return OK; } # end handler *************** *** 239,243 **** $from = $table; $where = 'idnum=' . $idnum; ! my $ref = &Apache::AppWrap::Subs::sqlSelectHashRef( $select, $from, $where ); my $col_order = $opts->{col_order}; --- 275,279 ---- $from = $table; $where = 'idnum=' . $idnum; ! my $ref = Apache::AppWrap::Subs::sqlSelectHashRef( $select, $from, $where ); my $col_order = $opts->{col_order}; *************** *** 254,258 **** } ! my $link_vars = &Apache::AppWrap::Subs::cclinks( $opts); my $label = $link_vars->{label}; # set titles --- 290,294 ---- } ! my $link_vars = Apache::AppWrap::Subs::cclinks( $opts); my $label = $link_vars->{label}; # set titles |
From: <pla...@us...> - 2002-12-10 07:12:10
|
Update of /cvsroot/appwrap/AppWrap/Apache/AppWrap In directory sc8-pr-cvs1:/tmp/cvs-serv19013 Modified Files: Confirm.pm Log Message: cache history table INSERT, check return status Index: Confirm.pm =================================================================== RCS file: /cvsroot/appwrap/AppWrap/Apache/AppWrap/Confirm.pm,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Confirm.pm 22 Nov 2002 10:05:56 -0000 1.8 --- Confirm.pm 10 Dec 2002 07:12:05 -0000 1.9 *************** *** 19,27 **** use vars qw($VERSION); ! $Apache::AppWrap::Confirm::VERSION = '0.03'; #ToDo # - the db write operation might be simplifiable if DBI bind vars # were used. Then it would not be necessary to determine # numeric/alpha-ness. DBI handles that transparently. --- 19,29 ---- use vars qw($VERSION); ! $Apache::AppWrap::Confirm::VERSION = '0.04'; #ToDo # - the db write operation might be simplifiable if DBI bind vars # were used. Then it would not be necessary to determine # numeric/alpha-ness. DBI handles that transparently. + # 10Dec02. cache history table INSERT, check return status + # 14May01. Removed 'created_date' field. *************** *** 50,54 **** my $idnum_q = $dbh->quote($idnum); ! # have to delete these here so they don't pollute the loop that follows delete $opts->{args}{idnum}; delete $opts->{args}{edit_flag}; --- 52,56 ---- my $idnum_q = $dbh->quote($idnum); ! # delete these here so they don't pollute the loop that follows delete $opts->{args}{idnum}; delete $opts->{args}{edit_flag}; *************** *** 60,64 **** { # -w off ! no warnings; # this loop will prepare CGI parameters values for input to # the db. The result should be value ready to input. This --- 62,66 ---- { # -w off ! no warnings qw(uninitialized numeric); # this loop will prepare CGI parameters values for input to # the db. The result should be value ready to input. This *************** *** 77,85 **** $val_q = $dbh->quote( $temp ); } ! # maybe this should be a simple "else", or need a case for '0' ! # (zero) if ($val) { # don't quote integer data types, otherwise quote ! if (&Apache::AppWrap::Subs::isMysqlNumber($table, $column)) { $val_q = $val; } --- 79,86 ---- $val_q = $dbh->quote( $temp ); } ! # a simple "else", or need a case for '0' (zero)? if ($val) { # don't quote integer data types, otherwise quote ! if (Apache::AppWrap::Subs::isMysqlNumber($table, $column)) { $val_q = $val; } *************** *** 111,115 **** # allows a transition during which both techniques exist. my $email = $r->pnotes('authed_email'); - # my $email = $r->pnotes('authed_email') || $r->connection->user; push @update, 'email=' . $dbh->quote( $email ); push @insert_fields, 'email'; --- 112,115 ---- *************** *** 137,141 **** # write changed fields to history table history( $opts, $opts->{args} ); - # &Apache::AppWrap::Subs::history( $opts, $opts->{args} ); $dbh->do($sql); # } --- 137,140 ---- *************** *** 249,260 **** ################ # record row change info in the history table. ! # usage: &history ($opts,\%params) # from %opts we get the table and idnum (row_num) that is being changed # %params is a hash ref of all cgi params - # 14 May 01. Removed 'created_date' field. ################ sub history { my ($opts, $params) = @_; my $table = $opts->{table}; # should always be set if {edit_flag} is set, which is how we got # here anyway --- 248,260 ---- ################ # record row change info in the history table. ! # usage: &history ($opts,\%params) # from %opts we get the table and idnum (row_num) that is being changed # %params is a hash ref of all cgi params ################ sub history { my ($opts, $params) = @_; my $table = $opts->{table}; + my $r = Apache->request; + my $log = $r->log; # should always be set if {edit_flag} is set, which is how we got # here anyway *************** *** 266,274 **** my $date = time(); # get the row that is being changed ! my $ref = &Apache::AppWrap::Subs::sqlSelectHashRef($select,$from,$where,$other); # look at each row, but should be only one my $field_list = 'tablename,col_name,row_num,prev_value,history_date'; ! # this could probably skip a loop as it will only ever be a single row. ! # my $row = $ref->[0]; foreach my $row (@$ref) { foreach my $column (keys %$row) { --- 266,273 ---- my $date = time(); # get the row that is being changed ! my $ref = Apache::AppWrap::Subs::sqlSelectHashRef($select,$from,$where,$other); # look at each row, but should be only one my $field_list = 'tablename,col_name,row_num,prev_value,history_date'; ! # this might skip a loop as it will only ever be a single row. foreach my $row (@$ref) { foreach my $column (keys %$row) { *************** *** 277,291 **** # some apps modify idnum with a leading zero, which isn't a real # change. ! # other apps shouldn't allow users to edit idnums. next if $column eq 'idnum'; ! # 'created_date' should never change in table:history next if $column eq 'created_date'; ! # test each field from the source against the param, skip unless ! # a delta next if $row->{$column} eq $params->{$column}; my $table_q = $dbh->quote( $table ); my $column_q = $dbh->quote( $column ); my $prev_value = $dbh->quote( $row->{$column} ); ! $dbh->do("INSERT INTO history ($field_list) VALUES ($table_q,$column_q,$idnum,$prev_value,$date)"); } } --- 276,302 ---- # some apps modify idnum with a leading zero, which isn't a real # change. ! # other apps don't allow users to edit idnums. next if $column eq 'idnum'; ! # 'created_date' will never change in table:history next if $column eq 'created_date'; ! # test each field from the source against the param, skip ! # if no delta next if $row->{$column} eq $params->{$column}; + #$log->debug("history: now: \n$row->{$column}, \n$params->{$column}"); + # quote field values for the DB my $table_q = $dbh->quote( $table ); my $column_q = $dbh->quote( $column ); my $prev_value = $dbh->quote( $row->{$column} ); ! my $sql = 'INSERT INTO history (tablename, col_name,'; ! $sql .= ' row_num,prev_value,history_date) VALUES (?,?,?,?,?)'; ! my $sth = $dbh->prepare_cached($sql); ! my $rc = $sth->execute($table_q,$column_q,$idnum,$prev_value,$date); ! # check the execute for errors ! unless ($rc) { ! my $msg = 'SQLERROR. &Confirm::history erred when'; ! $msg .= ' writing to history table: "' . $sql . '"'; ! $r->log_error($msg); ! } ! # $dbh->do("INSERT INTO history ($field_list) VALUES ($table_q,$column_q,$idnum,$prev_value,$date)"); } } |
From: <pla...@us...> - 2002-12-10 07:11:45
|
Update of /cvsroot/appwrap/AppWrap/Apache/AppWrap In directory sc8-pr-cvs1:/tmp/cvs-serv18924 Modified Files: Verify.pm Log Message: CSS, warnings pragma Index: Verify.pm =================================================================== RCS file: /cvsroot/appwrap/AppWrap/Apache/AppWrap/Verify.pm,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Verify.pm 20 Oct 2002 05:44:14 -0000 1.4 --- Verify.pm 10 Dec 2002 07:11:40 -0000 1.5 *************** *** 8,11 **** --- 8,13 ---- use strict; + use warnings; + use CGI::Carp qw(fatalsToBrowser); *************** *** 17,21 **** use vars qw($VERSION); ! $Apache::AppWrap::Verify::VERSION = '0.02'; --- 19,23 ---- use vars qw($VERSION); ! $Apache::AppWrap::Verify::VERSION = '0.03'; *************** *** 40,53 **** my $log = $r->log; - # $opts->{valid_kv} = &Apache::AppWrap::Subs::valid_kv($opts); - # my $kv = $opts->{valid_kv}; - my ($column, $ref); # if we got here all reqd fields were input - # my $kv = $opts->{valid_kv} || $opts->{args}{idnum}; - # my $kt = $my_tables->{$table}{key_type}; # for title and link information ! my $link_vars = &Apache::AppWrap::Subs::cclinks( $opts); ######## left side links (vbar phase) ######### --- 42,50 ---- my $log = $r->log; my ($column, $ref); # if we got here all reqd fields were input # for title and link information ! my $link_vars = Apache::AppWrap::Subs::cclinks( $opts); ######## left side links (vbar phase) ######### *************** *** 55,63 **** $menu_func ||= $my_defaults->{func_verify}; $menu_func ||= $my_defaults->{func_default}; ! # call functions if defined. Functions return array of to data wrapped in <td> tags if ($menu_func) { ! foreach ( split(";", $menu_func ) ) { ! my $ref = eval $_; ! push @{ $opts->{menuitems} }, join("", @$ref) if $ref && scalar(@$ref); } } --- 52,63 ---- $menu_func ||= $my_defaults->{func_verify}; $menu_func ||= $my_defaults->{func_default}; ! # call functions if defined. Functions return array of to ! # data wrapped in <td> tags if ($menu_func) { ! foreach ( split(/\s*;\s*/, $menu_func ) ) { ! my $ref = eval $_; ! if ($ref && scalar(@$ref)) { ! push @{ $opts->{menuitems} }, join("", @$ref); ! } } } *************** *** 65,103 **** my %temp; - push @rows, ' <table align="center">' . $HNL; - push @rows, ' <tr valign="bottom">' . $HNL; ############ button creating loop ############## ! # not elegant code, but we want 2 separate forms: one for the confirm ! # button, with it's associated URL, and one for the Modify button and it's URL ! foreach my $button (qw/confirm modify/) { ! # start the form ! my $out = ' <td align="center">' . $HNL; ! $out .= ' <form method="POST" action="' . $url . $button; ! $out .= '" enctype="application/x-www-form-urlencoded">' . $HNL; ! $out .= ' <input type="submit" name=".submit" value="'; ! $out .= ucfirst($button) . '">' . $HNL; ! push @rows, $out; ! my $birthplace = $opts->{args}{birthplace}; ! $out = ' <input type="hidden" name="birthplace" value="'; ! $out .= $birthplace . '" />' . $HNL; #$log->debug("\nVerify: birthplace=$birthplace"); ! push @rows, $out; ! # catch the idnum if present ! if ( $idnum ) { ! my $text = ' <input type="hidden" name="idnum" value="'; ! $text .= $idnum . '" />' . $HNL; ! push @rows, $text; ! } ! # catch the 'edit_flag' flag which may have been set by &generate_form if ( $opts->{args}{edit_flag} ) { ! my $text = ' <input type="hidden" name="edit_flag"'; ! $text .= ' value="1" />' . $HNL; push @rows, $text; } # what would it take to delete use of %temp in this bit? ! # also, if we store the hidden fields in the table we can eliminate one loop foreach $column (@$col_order) { # skip these columns for &verify --- 65,105 ---- my %temp; ############ button creating loop ############## ! # not elegant code, but we want 2 separate forms: one for ! # the confirm button, with it's associated URL, and one ! # for the Modify button and it's URL ! my $out = ' <div id="buttons">' . $HNL; ! push @rows, $out; ! foreach my $button (qw/confirm modify/) { ! # start the form ! $out .= ' <form method="POST" action="' . $url . $button; ! $out .= '" enctype="application/x-www-form-urlencoded">'; ! $out .= ' <input type="submit" name=".submit" value="'; ! $out .= ucfirst($button) . '">'; ! push @rows, $out; ! my $birthplace = $opts->{args}{birthplace}; ! $out = ' <input type="hidden" name="birthplace" value="'; ! $out .= $birthplace . '" />'; #$log->debug("\nVerify: birthplace=$birthplace"); ! push @rows, $out; ! # catch the idnum if present ! if ( $idnum ) { ! my $text = ' <input type="hidden" name="idnum" value="'; ! $text .= $idnum . '" />'; ! push @rows, $text; ! } ! # catch the 'edit_flag' flag which may have been set by ! # &generate_form if ( $opts->{args}{edit_flag} ) { ! my $text = ' <input type="hidden" name="edit_flag"'; ! $text .= ' value="1" />'; push @rows, $text; } # what would it take to delete use of %temp in this bit? ! # also, if we store the hidden fields in the table we can ! # eliminate one loop foreach $column (@$col_order) { # skip these columns for &verify *************** *** 105,160 **** $temp{$column} = $opts->{args}{$column}; ! # unrequired fields with a picklist might retain the default value, so delete it. ! $temp{$column} = '' if $temp{$column} && $temp{$column} =~ $my_defaults->{default_picklist}; ! # $temp{$column} = Apache::Util::escape_html($temp{$column}) if $temp{$column}; # try to catch a zero value { # -w off ! local $ = 0; # non-zero numbers and text #$log->debug("\nVerify: col=$column, val=$temp{$column}"); if ($temp{$column}) { ! my $out = ' <input type="hidden" name="' . $column; ! $out .= '" value="' . Apache::Util::escape_uri($temp{$column}) . '" />' . $HNL; ! # $out .= '" value="' . $temp{$column} . '" />' . $HNL; push @rows, $out; } # zero values elsif ($temp{$column} == 0 && $temp{$column} eq '0') { ! my $out = ' <input type="hidden" name="' . $column; ! $out .= '" value="0" />' . $HNL; push @rows, $out; } # blanks else { ! my $out = ' <input type="hidden" name="' . $column; ! $out .= '" value="" />' . $HNL; push @rows, $out; } } # -w off } # end of FOREACH of hidden fields ! push @rows, ' </form>' . $HNL . ' </td>' . $HNL; } # this ends the button creating loop ######################################## ! push @rows, ' </tr>' . $HNL . ' </table>' . $HNL; ! push @rows, ' <table width="100%" border="1" cellpadding="7">'; { # -w off ! local $ = 0; # startloop to display field values foreach $column (@$col_order) { # add column labels # set the column to be used by called subs $opts->{column} = $column; ! # skip 'idnum', 'email' and 'created_date' because user is not allowed to ! # influence these next if $column eq 'idnum' || $column eq 'email' || $column eq 'created_date'; ! # show the label ! my $display = $HNL . ' <tr valign="top"><th'; ! $display .= ' class="' . $link_vars->{cell_class} . '"' if $link_vars->{cell_class}; ! $display .= '>' . $my_columns->{$table}{$column}{label} . '</th>'; ! push @rows, $display; ! # call a function if defined. Function uses $temp{$column} to get cgi input my $val; my $func = $my_columns->{$table}{$column}{func_verify}; --- 107,174 ---- $temp{$column} = $opts->{args}{$column}; ! # unrequired fields with a picklist might retain the ! # default value, so delete it. ! if (exists $temp{$column}) { ! if ($temp{$column} =~ $my_defaults->{default_picklist}) { ! $temp{$column} = ''; ! } ! } # try to catch a zero value { # -w off ! no warnings qw(numeric uninitialized); # non-zero numbers and text #$log->debug("\nVerify: col=$column, val=$temp{$column}"); if ($temp{$column}) { ! my $out = ' <input type="hidden" name="' . $column; ! $out .= '" value="' . Apache::Util::escape_uri($temp{$column}); ! $out .= '" />'; push @rows, $out; } # zero values elsif ($temp{$column} == 0 && $temp{$column} eq '0') { ! my $out = ' <input type="hidden" name="' . $column; ! $out .= '" value="0" />'; push @rows, $out; } # blanks else { ! my $out = ' <input type="hidden" name="' . $column; ! $out .= '" value="" />'; push @rows, $out; } } # -w off } # end of FOREACH of hidden fields ! push @rows, ' </form>'; } # this ends the button creating loop ######################################## ! # close out the <div id="buttons> tag ! push @rows, ' </div>' . $HNL; ! ! # start the div for proper display ! push @rows, '<div id="pager">' . $HNL; ! push @rows, ' <table width="100%" border="1" cellpadding="7">' . $HNL; { # -w off ! no warnings qw(numeric uninitialized); # startloop to display field values foreach $column (@$col_order) { # add column labels # set the column to be used by called subs $opts->{column} = $column; ! # skip 'idnum', 'email' and 'created_date' because user ! # is not allowed to influence these next if $column eq 'idnum' || $column eq 'email' || $column eq 'created_date'; ! # show the label ! my $display = ' <tr valign="top"><th'; ! if (exists $link_vars->{cell_class}) { ! $display .= ' class="' . $link_vars->{cell_class} . '"'; ! } ! $display .= '>' . $my_columns->{$table}{$column}{label}; ! $display .= '</th>'; ! push @rows, $display; ! # call a function if defined. Function uses $temp{$column} ! # to get cgi input my $val; my $func = $my_columns->{$table}{$column}{func_verify}; *************** *** 168,191 **** $val = ' '; } ! push @rows, '<td>' . $val . '</td></tr>'; next; } ! # case b) test to see is the value a string, no func_focus in the db elsif ($temp{$column}) { $temp{$column} =~ s/\n/<br \/>/g; ! push @rows, '<td>' . $temp{$column} . '</td></tr>'; } # case b) test to see is it a number which is zero elsif ($temp{$column} == 0 && $temp{$column} eq '0') { ! push @rows, '<td>0</td></tr>'; next; } # case c) only choice left is that the data is '' (blank) else { ! push @rows, '<td> </td></tr>'; } } # end FOREACH loop } # -w on ! push @rows, $HNL . ' </table>' . $HNL; # set titles --- 182,209 ---- $val = ' '; } ! push @rows, '<td>' . $val . '</td></tr>' . $HNL; next; } ! # case b) test to see is the value a string, no ! # func_focus in the db elsif ($temp{$column}) { $temp{$column} =~ s/\n/<br \/>/g; ! push @rows, '<td>' . $temp{$column} . '</td></tr>' . $HNL; } # case b) test to see is it a number which is zero elsif ($temp{$column} == 0 && $temp{$column} eq '0') { ! push @rows, '<td>0</td></tr>' . $HNL; next; } # case c) only choice left is that the data is '' (blank) else { ! push @rows, '<td> </td></tr>' . $HNL; } } # end FOREACH loop } # -w on ! push @rows, ' </table>' . $HNL; ! ! # close the <div> ! push @rows, '</div>' . $HNL; # set titles *************** *** 198,202 **** $opts->{Rows} = \@rows; ! &Apache::AppWrap::Subs::Webify($opts); return OK; } # end handler --- 216,220 ---- $opts->{Rows} = \@rows; ! Apache::AppWrap::Subs::Webify($opts); return OK; } # end handler |
From: <pla...@us...> - 2002-12-10 07:08:36
|
Update of /cvsroot/appwrap/AppWrap/Apache/AppWrap In directory sc8-pr-cvs1:/tmp/cvs-serv18175 Modified Files: DBILogConfig.pm Log Message: add error checking to DB execute statements Index: DBILogConfig.pm =================================================================== RCS file: /cvsroot/appwrap/AppWrap/Apache/AppWrap/DBILogConfig.pm,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** DBILogConfig.pm 8 Dec 2002 02:29:22 -0000 1.11 --- DBILogConfig.pm 10 Dec 2002 07:08:33 -0000 1.12 *************** *** 116,129 **** my $sql = 'UPDATE dailystats SET bytes=bytes+' . $r->bytes_sent; $sql .= ' WHERE stats_date=?'; - # $sql .= ' WHERE stats_date=' . $today; $log->debug("\n\&DBILogConfig: statement=$sql") if $debug; my $sth = $dbh->prepare_cached($sql); my $rc = $sth->execute($today); - # $dbh->do($sent); unless ($rc) { ! my $msg = "DBILogConfig couldn't update dailystats->bytes"; $r->log_error($msg); } - } --- 116,127 ---- my $sql = 'UPDATE dailystats SET bytes=bytes+' . $r->bytes_sent; $sql .= ' WHERE stats_date=?'; $log->debug("\n\&DBILogConfig: statement=$sql") if $debug; my $sth = $dbh->prepare_cached($sql); my $rc = $sth->execute($today); unless ($rc) { ! my $msg = 'SQLERROR. DBILogConfig couldn\'t update'; ! $msg .= ' dailystats->bytes'; $r->log_error($msg); } } *************** *** 181,185 **** my $table = $r->dir_config('DBILogConfig_table'); $table ||= $opts->{my_defaults}{DBILogConfig_table}; ! $table ||= 'accesses'; # Create the statement and insert data --- 179,186 ---- my $table = $r->dir_config('DBILogConfig_table'); $table ||= $opts->{my_defaults}{DBILogConfig_table}; ! unless ($table) { ! my $msg = 'DBILogConfig: Logging table not defined'; ! $r->log_error($msg); ! } # Create the statement and insert data *************** *** 200,221 **** my $field_str = join(", ", @fields); my $bind_str = join(",", @binds); - # my $value_str = join(", ", @values); - - # Create string of values - # my $values = join ', ', map { - # $dbh->quote($Formats{$_->{'format'}}->($r, $_->{'param'})) - # } @format_list; # this is the SQL statement my $sql = "INSERT INTO $table ($field_str) VALUES ($bind_str)"; - # my $sql = qq(INSERT INTO $table ($fields) VALUES ($values)); $log->debug("\nDBILogConfig: statement=$sql") if $debug; # do the SQL - # $dbh->do($statement); my $sth = $dbh->prepare_cached($sql); my $rc = $sth->execute(@values); - # $dbh->do($sent); unless ($rc) { ! my $msg = "DBILogConfig couldn't insert into $table"; $r->log_error($msg); } --- 201,213 ---- my $field_str = join(", ", @fields); my $bind_str = join(",", @binds); # this is the SQL statement my $sql = "INSERT INTO $table ($field_str) VALUES ($bind_str)"; $log->debug("\nDBILogConfig: statement=$sql") if $debug; # do the SQL my $sth = $dbh->prepare_cached($sql); my $rc = $sth->execute(@values); unless ($rc) { ! my $msg = 'SQLERROR. DBILogConfig erred: "' . $sql . '"'; $r->log_error($msg); } |
From: <pla...@us...> - 2002-12-10 07:04:01
|
Update of /cvsroot/appwrap/AppWrap/Apache/AppWrap In directory sc8-pr-cvs1:/tmp/cvs-serv17000 Modified Files: Search.pm Log Message: CSS, warnings Index: Search.pm =================================================================== RCS file: /cvsroot/appwrap/AppWrap/Apache/AppWrap/Search.pm,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Search.pm 22 Nov 2002 10:05:56 -0000 1.4 --- Search.pm 10 Dec 2002 07:03:57 -0000 1.5 *************** *** 8,11 **** --- 8,13 ---- use strict; + use warnings; + no warnings qw(redefine); use CGI::Carp qw(fatalsToBrowser); use Date::Format; *************** *** 18,22 **** use vars qw($VERSION); ! $Apache::AppWrap::Search::VERSION = '0.01'; sub handler { --- 20,25 ---- use vars qw($VERSION); ! $Apache::AppWrap::Search::VERSION = '0.02'; ! # 10Dec02. CSS, warnings pragma. sub handler { *************** *** 42,46 **** if ($kv =~ $my_defaults->{default_picklist}) { $r->header_out(Location => $config{homeurl} . '/search'); - # $r->header_out(Location => $homeurl . 'search'); return REDIRECT; } --- 45,48 ---- *************** *** 70,77 **** # wrapped in <td> tags if ($menu_func) { ! my @subs = split(/;/, $menu_func ); foreach (@subs) { my $ref = eval $_; ! push @{ $opts->{menuitems} }, join("", @$ref) if $ref and scalar(@$ref); } } --- 72,81 ---- # wrapped in <td> tags if ($menu_func) { ! my @subs = split(/\s*;\s*/, $menu_func ); foreach (@subs) { my $ref = eval $_; ! if ($ref and scalar(@$ref)) { ! push @{ $opts->{menuitems} }, join("", @$ref); ! } } } *************** *** 79,83 **** $opts->{Rows} = \@rows; ! &Apache::AppWrap::Subs::Webify($opts); return OK; } # end handler --- 83,87 ---- $opts->{Rows} = \@rows; ! Apache::AppWrap::Subs::Webify($opts); return OK; } # end handler *************** *** 101,109 **** foreach my $tablename (@$valid_tables) { # check all columns for this table ! push @list, $tablename if grep {$_ eq $key_type } keys %{ $my_columns->{$tablename} }; } # end &table_list - # @list = grep {$_ eq $key_type } - # map {$_} - # map { $my_columns->{$_} } @$valid_tables; # get the parent foreach my $tablename (keys %$my_tables) { --- 105,112 ---- foreach my $tablename (@$valid_tables) { # check all columns for this table ! if (grep {$_ eq $key_type } keys %{ $my_columns->{$tablename} }) { ! push @list, $tablename; ! } } # end &table_list # get the parent foreach my $tablename (keys %$my_tables) { *************** *** 141,149 **** $tables{$tablename} = $my_tables->{$tablename}{search_kt}; } ! # my %tables = map { ! # $_ => $my_tables->{$_}{search} ! # } grep { ! # exists $my_tables->{$_}{search} ! # } keys %$my_tables; # start a table for holding this whole bot --- 144,150 ---- $tables{$tablename} = $my_tables->{$tablename}{search_kt}; } ! ! #start the <div> ! push @rows, '<div id="pager">' . $HNL; # start a table for holding this whole bot *************** *** 193,197 **** } # end %key_data loop push @rows, ' </table>' . $HNL; ! push @rows, ' <br />' . $HNL; return \@rows; } # end search_form --- 194,201 ---- } # end %key_data loop push @rows, ' </table>' . $HNL; ! ! #close the <div> ! push @rows, '</div>' . $HNL; ! # push @rows, ' <br />' . $HNL; return \@rows; } # end search_form *************** *** 224,228 **** $from = $tablename; $where = $kt . '=' . $kv; ! $ref = &Apache::AppWrap::Subs::sqlSelectHashRef($select, $from, $where); foreach my $row (@$ref) { $row->{tablename} = $tablename; --- 228,232 ---- $from = $tablename; $where = $kt . '=' . $kv; ! $ref = Apache::AppWrap::Subs::sqlSelectHashRef($select, $from, $where); foreach my $row (@$ref) { $row->{tablename} = $tablename; *************** *** 235,241 **** $from = $parent; $where = 'idnum=' . $kv; ! $ref = &Apache::AppWrap::Subs::sqlSelectHashRef($select, $from, $where); my $parent_result = $ref->[0]; # build tabular output my $text = ' <table align="center" border="1" width="'; --- 239,248 ---- $from = $parent; $where = 'idnum=' . $kv; ! $ref = Apache::AppWrap::Subs::sqlSelectHashRef($select, $from, $where); my $parent_result = $ref->[0]; + #start the <div> + push @rows, '<div id="pager">' . $HNL; + # build tabular output my $text = ' <table align="center" border="1" width="'; *************** *** 314,317 **** --- 321,328 ---- $text = ' </table>'; push @rows, $text . $HNL; + + #close the <div> + push @rows, '</div>' . $HNL; + return \@rows; } # end search_results |
From: <pla...@us...> - 2002-12-09 10:13:29
|
Update of /cvsroot/appwrap/AppWrap/includes In directory sc8-pr-cvs1:/tmp/cvs-serv15804 Modified Files: AppWrap.css Log Message: continued adjustments for better page presentation Index: AppWrap.css =================================================================== RCS file: /cvsroot/appwrap/AppWrap/includes/AppWrap.css,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** AppWrap.css 1 Dec 2002 07:26:39 -0000 1.4 --- AppWrap.css 9 Dec 2002 10:13:26 -0000 1.5 *************** *** 7,11 **** } div#logo { } ! /* "tabbar" is a class as there may be more than one <div> */ div.tabbar a span { display: none; } div.tabbar a:hover span { --- 7,16 ---- } div#logo { } ! div#motdarea { float: right; width: 52%; z-index: 10; } ! /* "tabbar" is a class as there may be more than one of 'em */ ! div.tabbar { ! border-bottom: 1px #000 solid; ! padding-top: 0.2em; ! } div.tabbar a span { display: none; } div.tabbar a:hover span { *************** *** 16,30 **** } div.tabbar img { display: inline; padding: 0 0 0 0; } ! div.tabbar { border-bottom: 1px #000 solid; padding-top: 0.2em; } ! div#motdarea { float: right; width: 52%; z-index: 10; } ! div#mainleft { margin: 0 38% 0 24%; padding: 0 0 0 1em; } ! div#mainright { ! float: right; margin: 0; ! padding: 0 0 0 1em; ! width: 36%; } div#leftvbar { position: absolute; top: 7em; left: 0.5em; --- 21,49 ---- } div.tabbar img { display: inline; padding: 0 0 0 0; } ! div#crumbs { ! width: 100%; ! background: #1682a0; ! font-family: Arial; ! font-size: 11pt; } ! div#crumbs a { margin: 0; ! padding: 0 0.6em; ! color: #f93; ! } ! div#crumbs a:hover { ! color: #1682a0; ! background: #f93; ! } ! div#crumbs a span { display: none } ! div#crumbs a:hover span { ! display: block; ! position: absolute; top: -70px; left: -165px; width: 125px; ! padding: 5px; margin: 10px; z-index: 100; ! color: #AAA; background: black; ! font: 10px Verdana, sans-serif; text-align: center; } div#leftvbar { + /* couldn't get all the browsers to agree unless used "position: absolute;" */ position: absolute; top: 7em; left: 0.5em; *************** *** 33,45 **** margin-top: 2.4em; z-index: 100; ! } ! div#pager { ! clear: none; ! margin: 0 0 0 26%; ! padding-bottom: 0.5em; ! border-bottom: 1px solid #000; } div#leftvbar table { ! margin-top: 1em; width: 98%; border: 1px #aaa solid; --- 52,59 ---- margin-top: 2.4em; z-index: 100; ! border-right: 1px #aaa solid; } div#leftvbar table { ! margin-top: 1.5em; width: 98%; border: 1px #aaa solid; *************** *** 68,71 **** --- 82,95 ---- font-weight: bold; } + div#leftvbar p { + margin: 0.2em 0em; + } + div#mainleft { margin: 0 38% 0 24%; padding: 0 0 0 1em; } + div#mainright { + float: right; + margin: 0; + padding: 0 0 0 1em; + width: 36%; + } p#title { color: #000000; *************** *** 83,102 **** margin-left: 26%; } ! /* this won't work, as it upsets narrow pages div#pager { ! position: absolute; ! top: 14em; left: 26%; ! z-index: 10; ! width: auto; ! ! /* this won't work, as it upsets narrow pages ! width: 1500px; ! # ! float: left; ! # no effect ! display: inline; ! # too far to the right margin: 0 0 0 26%; ! */ } div#pager tr.odd { --- 107,143 ---- margin-left: 26%; } ! div#seqnav { ! float: right; ! width: 35%; ! text-align: right; ! margin: -1em 0 0 0; ! padding: 0 0 0 0; ! } ! div#seqnav h1 { ! font-size: 12pt; ! font-family: arial; ! text-align: center; ! margin: 1em 0em 1em; ! } ! div#noteleft { ! border: 1px red dotted; ! float: right; ! width: 30%; ! margin-left: 26%; ! } ! div#notecenter { ! border: 1px red dotted; ! float: right; ! width: 30%; ! } div#pager { ! clear: right; margin: 0 0 0 26%; ! padding: 0 0 0.5em 0; ! border-bottom: 1px solid #000; ! } ! div#pager table { ! width: 100%; ! /* border: 1px solid #aaa; */ } div#pager tr.odd { *************** *** 127,133 **** h4 { font-size: 10pt; font-family: Helvetica; color: #000000; font-weight: bold; } sup { font-size: x-small; text-decoration: underline; vertical-align: super; } table { } - td { color: #000000; font-family: Arial; margin-top: 0; } th { color: #000000; background: #ddd; font-size: 11pt; font-family: serif; } ul { margin: 0pt 0pt 0.5em 0.5em } li { margin-left: 0.5em; } --- 168,179 ---- h4 { font-size: 10pt; font-family: Helvetica; color: #000000; font-weight: bold; } sup { font-size: x-small; text-decoration: underline; vertical-align: super; } + /* debug + table { border: 1px solid red; } + td { border: 1px solid purple; } + th { border: 1px solid purple; } + */ table { } th { color: #000000; background: #ddd; font-size: 11pt; font-family: serif; } + td { color: #000000; font-family: Arial; margin-top: 0; } ul { margin: 0pt 0pt 0.5em 0.5em } li { margin-left: 0.5em; } |
From: <pla...@us...> - 2002-12-09 10:12:02
|
Update of /cvsroot/appwrap/AppWrap/Apache/AppWrap In directory sc8-pr-cvs1:/tmp/cvs-serv15056 Modified Files: Focus.pm Log Message: Still cleaning up spaghetti code Index: Focus.pm =================================================================== RCS file: /cvsroot/appwrap/AppWrap/Apache/AppWrap/Focus.pm,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Focus.pm 7 Dec 2002 02:05:29 -0000 1.7 --- Focus.pm 9 Dec 2002 10:11:59 -0000 1.8 *************** *** 217,300 **** my $image_dir = $config{homeurl} . '/' . $config{images}; ! my %out = id_browser($opts); ! my %ids = $out{ids}; ! my %sdi = reverse %ids; ! my $this_id = $out{this_id}; ! my $division = $out{division}; ! my $calc_page = $out{calc_page}; ! $page ||= $out{page}; ! my $kv_esc = $out{kv_esc}; ! my $by = $out{by}; ! my @by = @{ $out{by_array} }; ! my $qty_tr_by = $out{qty_tr_by}; ! # get the sort hash. This is used to map different values. ! # my $i = 1; ! # my %sort_hash; ! # foreach my $column (@{ $opts->{page_display} }) { ! # $sort_hash{$i++} = Apache::AppWrap::Pager::fill_sort_new ($i,$column,$my_columns->{$table}{$column}{label}); ! # $sort_hash{$i++} = Apache::AppWrap::Pager::fill_sort_new ($i,$column,$my_columns->{$table}{$column}{label}); ! # } ! # my $log = Apache->request->log; ! ##$log->debug("\nseq_nav: idnum=$idnum"); ! # ! # # default display sequence. Use param('by') if set. Else ! # # derive it from param('sb') ! # my $by = $opts->{args}{by} || $sort_hash{$sb}{by}; ! # $by =~ s/^by //; ! # $opts->{args}{by} = $by; ! # ! # # get the sort column for the db dip ! # my $order_by; ! # $sb ? $order_by = $sort_hash{$sb}{column} . ' ASC' : $order_by = $by . ' ASC'; ! # ! # # get the list of control options. This is used to populate the ! # # popup menu. ! # my @by = grep { $my_columns->{$table}{$_}{page_sort} } @{ $opts->{col_order} }; ! # ! # my ($select,$from,$where,$other); ! # # define this, next and previous id ! # # first, query for values in this id ! ## $select = '*'; ! ## $from = $table; ! ## $where = 'idnum=' . $idnum; ! # my $sql_this_id = "SELECT * FROM $table WHERE idnum=$idnum"; ! # my $sth = $dbh->prepare($sql_this_id); ! # $sth->execute(); ! # my $data_this_id = $sth->fetchrow_hashref; ! # ! # # next, having the data, we can determine the value of the control ! # my $by_value = $data_this_id->{$by}; ! # # while we have the data for this id might as well get the key_type ! # my $kt = $my_tables->{$table}{key_type}; ! # $kv = $data_this_id->{$kt} unless ($kv && $kt); ! ## $kv = $data_this_id->{$kt} unless $kv; ! # my $kv_esc = Apache::Util::escape_uri( $kv ) if $kv; ! # ! # # then, to get the prev and next idnum we need to query to get ! # # them all for this 'by' control. Quote the 'by' value ! # my $by_value_q = $dbh->quote($by_value); ! # my $sql_all_id = "SELECT idnum FROM $table ORDER BY $order_by"; ! # if ($by eq 'idnum') { ! # $sql_this_id = "SELECT idnum FROM $table ORDER BY $order_by"; ! # } ! # else { ! # $sql_all_id = "SELECT idnum FROM $table WHERE $by=$by_value_q ORDER BY $by ASC"; ! # } ! # ! # my $data_all_id = $dbh->selectall_arrayref($sql_all_id); ! # my $qty_tr_by = scalar(@$data_all_id); ! # # get a hash of the idnums ! # my %ids; ! # $i = 1; ! # foreach my $row (@{ $data_all_id }) { ! # $ids{$i++} = $row->[0]; ! # } ! # ! # # reverse the hash to easily get the id from the idnum # my %sdi = reverse %ids; ! # my $this_id = $sdi{$idnum}; ! # my $division = ($this_id / $rows_per); ! # my $calc_page = sprintf("%u", $division); ! # $page ||= $calc_page; # ----------------------------------------------------------------- --- 217,303 ---- my $image_dir = $config{homeurl} . '/' . $config{images}; ! ############################ ! # my %out = id_browser($opts); ! # my %ids = $out{ids}; # my %sdi = reverse %ids; ! # my $this_id = $out{this_id}; ! # my $division = $out{division}; ! # my $calc_page = $out{calc_page}; ! # $page ||= $out{page}; ! # my $kv_esc = $out{kv_esc}; ! # my $by = $out{by}; ! # my @by = @{ $out{by_array} }; ! # my $qty_tr_by = $out{qty_tr_by}; ! ############################ ! ! # get the sort hash. This is used to map different values. ! my $i = 1; ! my %sort_hash; ! foreach my $column (@{ $opts->{page_display} }) { ! $sort_hash{$i++} = Apache::AppWrap::Pager::fill_sort_new ($i,$column,$my_columns->{$table}{$column}{label}); ! $sort_hash{$i++} = Apache::AppWrap::Pager::fill_sort_new ($i,$column,$my_columns->{$table}{$column}{label}); ! } ! my $log = Apache->request->log; ! #$log->debug("\nseq_nav: idnum=$idnum"); ! ! # default display sequence. Use param('by') if set. Else ! # derive it from param('sb') ! my $by = $opts->{args}{by} || $sort_hash{$sb}{by}; ! $by =~ s/^by //; ! $opts->{args}{by} = $by; ! ! # get the sort column for the db dip ! my $order_by; ! $sb ? $order_by = $sort_hash{$sb}{column} . ' ASC' : $order_by = $by . ' ASC'; ! ! # get the list of control options. This is used to populate the ! # popup menu. ! my @by = grep { $my_columns->{$table}{$_}{page_sort} } @{ $opts->{col_order} }; ! ! my ($select,$from,$where,$other); ! # define this, next and previous id ! # first, query for values in this id ! # $select = '*'; ! # $from = $table; ! # $where = 'idnum=' . $idnum; ! my $sql_this_id = "SELECT * FROM $table WHERE idnum=$idnum"; ! my $sth = $dbh->prepare($sql_this_id); ! $sth->execute(); ! my $data_this_id = $sth->fetchrow_hashref; ! ! # next, having the data, we can determine the value of the control ! my $by_value = $data_this_id->{$by}; ! # while we have the data for this id might as well get the key_type ! my $kt = $my_tables->{$table}{key_type}; ! $kv = $data_this_id->{$kt} unless ($kv && $kt); ! # $kv = $data_this_id->{$kt} unless $kv; ! my $kv_esc = Apache::Util::escape_uri( $kv ) if $kv; ! ! # then, to get the prev and next idnum we need to query to get ! # them all for this 'by' control. Quote the 'by' value ! my $by_value_q = $dbh->quote($by_value); ! my $sql_all_id = "SELECT idnum FROM $table ORDER BY $order_by"; ! if ($by eq 'idnum') { ! $sql_this_id = "SELECT idnum FROM $table ORDER BY $order_by"; ! } ! else { ! $sql_all_id = "SELECT idnum FROM $table WHERE $by=$by_value_q ORDER BY $by ASC"; ! } ! ! my $data_all_id = $dbh->selectall_arrayref($sql_all_id); ! my $qty_tr_by = scalar(@$data_all_id); ! # get a hash of the idnums ! my %ids; ! $i = 1; ! foreach my $row (@{ $data_all_id }) { ! $ids{$i++} = $row->[0]; ! } ! ! # reverse the hash to easily get the id from the idnum ! my %sdi = reverse %ids; ! my $this_id = $sdi{$idnum}; ! my $division = ($this_id / $rows_per); ! my $calc_page = sprintf("%u", $division); ! $page ||= $calc_page; # ----------------------------------------------------------------- |
From: <pla...@us...> - 2002-12-09 10:06:35
|
Update of /cvsroot/appwrap/AppWrap/Apache/AppWrap In directory sc8-pr-cvs1:/tmp/cvs-serv11486 Modified Files: Display.pm Log Message: Removed dependence on table my_exceptions Index: Display.pm =================================================================== RCS file: /cvsroot/appwrap/AppWrap/Apache/AppWrap/Display.pm,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Display.pm 1 Dec 2002 00:57:25 -0000 1.7 --- Display.pm 9 Dec 2002 10:06:32 -0000 1.8 *************** *** 61,67 **** # be called by &display, &focus and by &list, while retaining # context sensitivity. ! foreach (keys %{ $my_exceptions->{$table}{display} }) { ! $msgs->{$_} = $my_exceptions->{$table}{display}{$_} if $_ =~ /^alt_/; ! } # tell paginator about any per column function assigned in the db. --- 61,67 ---- # be called by &display, &focus and by &list, while retaining # context sensitivity. ! # foreach (keys %{ $my_exceptions->{$table}{display} }) { ! # $msgs->{$_} = $my_exceptions->{$table}{display}{$_} if $_ =~ /^alt_/; ! # } # tell paginator about any per column function assigned in the db. |
From: <pla...@us...> - 2002-12-09 10:05:45
|
Update of /cvsroot/appwrap/AppWrap/Apache/AppWrap In directory sc8-pr-cvs1:/tmp/cvs-serv10916 Modified Files: Chart_Counts.pm Log Message: warnings pragma, CSS, i18n Index: Chart_Counts.pm =================================================================== RCS file: /cvsroot/appwrap/AppWrap/Apache/AppWrap/Chart_Counts.pm,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Chart_Counts.pm 22 Nov 2002 10:05:55 -0000 1.6 --- Chart_Counts.pm 9 Dec 2002 10:05:43 -0000 1.7 *************** *** 8,11 **** --- 8,13 ---- use strict; + use warnings; + no warnings qw(redefine); use CGI::Carp qw(fatalsToBrowser); use Date::Format; *************** *** 22,28 **** use vars qw($VERSION); ! $Apache::AppWrap::Chart_Counts::VERSION = '0.03'; ############################ ! # 12 Nov 02. handle HEAD requests ############################ --- 24,31 ---- use vars qw($VERSION); ! $Apache::AppWrap::Chart_Counts::VERSION = '0.04'; ############################ ! # 08Dec02. CSS, warnings pragma. ! # 12Nov02. handle HEAD requests ############################ *************** *** 55,62 **** $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 --- 58,65 ---- $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 *************** *** 97,106 **** # 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; --- 100,109 ---- # 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; *************** *** 112,116 **** } ! &Apache::AppWrap::Subs::Webify($opts); return OK; } # end handler --- 115,119 ---- } ! Apache::AppWrap::Subs::Webify($opts); return OK; } # end handler *************** *** 138,142 **** my $chart_title = $args->{chart_title} || 'Some simple Chart'; ! my $graph = GD::Graph::bars->new(400, 300); # my $graph = GD::Graph::lines->new; --- 141,145 ---- my $chart_title = $args->{chart_title} || 'Some simple Chart'; ! my $graph = GD::Graph::bars->new(600, 450); # my $graph = GD::Graph::lines->new; |
From: <pla...@us...> - 2002-12-09 10:04:39
|
Update of /cvsroot/appwrap/AppWrap/Apache/AppWrap In directory sc8-pr-cvs1:/tmp/cvs-serv9684 Modified Files: Calendar.pm Log Message: Trying to i18n Date::Calc. Index: Calendar.pm =================================================================== RCS file: /cvsroot/appwrap/AppWrap/Apache/AppWrap/Calendar.pm,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Calendar.pm 8 Dec 2002 02:41:41 -0000 1.7 --- Calendar.pm 9 Dec 2002 10:04:32 -0000 1.8 *************** *** 24,29 **** use vars qw($VERSION); ! $Apache::AppWrap::Calendar::VERSION = '0.08'; ############################ # 06Dec02. use warnings pragma # 06Dec02. Migrate to CSS-based presentation --- 24,31 ---- use vars qw($VERSION); ! $Apache::AppWrap::Calendar::VERSION = '0.09'; ############################ + # 08Dec02. i18n, Perl warnings + # 07Dec02. i18n # 06Dec02. use warnings pragma # 06Dec02. Migrate to CSS-based presentation *************** *** 61,64 **** --- 63,67 ---- my $log = $r->log; + my $test; # get guery string # my $query_args = Apache::AppWrap::Subs::url_args($opts); *************** *** 111,123 **** $select .= ',idnum'; my $kt = $my_tables->{$table}{key_type}; ! # add the key_type field to the query for later labels $select .= ',' . $kt unless $kt eq 'idnum'; my $from = $table; ! # this limits our select statement to data only in the desired month. my $where = join(" OR ", map {$_ . '>' . $start } @$defaults); $where .= ' AND ' . join(" OR ", map {$_ . '<' . $end } @$defaults); ! my $ref = Apache::AppWrap::Subs::sqlSelectHashRef( $select, $from, $where); # $ref is an array of hash refs of the form $row->{col_name} = $date, # one hash element for each date type field in the table. --- 114,128 ---- $select .= ',idnum'; my $kt = $my_tables->{$table}{key_type}; ! # add the key_type field to the query for later labels. So now ! # the query includes the idnum, the value in the "key_type" ! # field, and all fields of type "date". $select .= ',' . $kt unless $kt eq 'idnum'; my $from = $table; ! # limit select statement to data only in the desired month. my $where = join(" OR ", map {$_ . '>' . $start } @$defaults); $where .= ' AND ' . join(" OR ", map {$_ . '<' . $end } @$defaults); ! my $ref = Apache::AppWrap::Subs::sqlSelectHashRef($select,$from,$where); # $ref is an array of hash refs of the form $row->{col_name} = $date, # one hash element for each date type field in the table. *************** *** 125,128 **** --- 130,135 ---- # date. Each date is an array ref to a hash of all date fields my %date_data; + #$test = scalar(@$ref); + #$log->debug("\nCalendar: num_rows=$test."); # get the 'unpacked_kt' sub to run. We are assuming that all date *************** *** 142,146 **** my $idnum = $row->{idnum}; my $kv = $row->{$kt}; - #$log->debug("\nCalendar: kv=$kv"); # only a single URL per row, even if there are multiple date columns --- 149,152 ---- *************** *** 151,155 **** --- 157,163 ---- foreach my $col_name (keys %$row) { $opts->{column} = $col_name; + # Only save fields of type date in the hash, so skip others next if $col_name eq 'idnum'; + next if $col_name eq $kt; my $date_value = $row->{$col_name}; # some date fields might be blank *************** *** 319,326 **** --- 327,341 ---- # store output dates my %m; + use Date::Language; my $now = time(); $m{now} = $now; + my $lang = $opts->{language}; + $lang = 'de'; + Date::Calc::Language(Date::Calc::Decode_Language($lang)); + # my $pkg_lang = Date::Calc::Language_to_Text(Date::Calc::Language()); + #$log->debug("\nCalendar:monthdates: language=$pkg_lang."); + ############################### # year info *************** *** 350,354 **** $m{next_month_mid_num} = $next_month; # this takes account of the current month being december ! $m{next_month_start_epoch} = &str2time($next_month . '/01/' . $mid_year); $m{current_month_end_epoch} = $m{next_month_start_epoch} - 1 ; # maybe don't need next_month_end_epoch, yet --- 365,369 ---- $m{next_month_mid_num} = $next_month; # this takes account of the current month being december ! $m{next_month_start_epoch} = str2time($next_month . '/01/' . $mid_year); $m{current_month_end_epoch} = $m{next_month_start_epoch} - 1 ; # maybe don't need next_month_end_epoch, yet *************** *** 358,364 **** $m{current_month_label} = time2str("%B", $in_date); - $m{previous_month_label} = time2str("%B", $m{previous_month_start_epoch}); $m{next_month_label} = time2str("%B", $m{next_month_start_epoch}); return \%m; --- 373,386 ---- + # my $current_month_num = time2str("%L", $in_date); + # $m{current_month_label} = Date::Calc::Month_to_Text($current_month_num); + #$log->debug("monthdates: this_month: $current_month_num"); + # had no luck with Date::Format language settings $m{current_month_label} = time2str("%B", $in_date); $m{next_month_label} = time2str("%B", $m{next_month_start_epoch}); + $m{previous_month_label} = time2str("%B", $m{previous_month_start_epoch}); + # $m{previous_month_label} = time2str("%B", $m{previous_month_start_epoch}); + # $m{next_month_label} = time2str("%B", $m{next_month_start_epoch}); + # Date::Calc::Month_to_Text($current_month_num); return \%m; |