|
From: Chris W. <la...@us...> - 2001-10-14 20:56:33
|
Update of /cvsroot/openinteract/OpenInteract/OpenInteract
In directory usw-pr-cvs1:/tmp/cvs-serv9051/OpenInteract
Modified Files:
CommonHandler.pm
Log Message:
debugging updates and enable the template specified to depend on the
parameters (in particular 'do_edit' will get the form, not will get
the detail, as implemented by the user)
Index: CommonHandler.pm
===================================================================
RCS file: /cvsroot/openinteract/OpenInteract/OpenInteract/CommonHandler.pm,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** CommonHandler.pm 2001/10/08 21:35:01 1.23
--- CommonHandler.pm 2001/10/14 20:56:30 1.24
***************
*** 35,39 ****
$class->_search_form_customize( \%params );
! my $template_name = $class->_template_name( \%params, $class->MY_SEARCH_FORM_TEMPLATE );
return $R->template->handler( {}, \%params, { name => $template_name } );
}
--- 35,41 ----
$class->_search_form_customize( \%params );
! my $template_name = $class->_template_name(
! \%params,
! $class->MY_SEARCH_FORM_TEMPLATE( \%params ) );
return $R->template->handler( {}, \%params, { name => $template_name } );
}
***************
*** 53,57 ****
$p ||= {};
! my $R = OpenInteract::Request->instance;
my %params = %{ $p };
--- 55,61 ----
$p ||= {};
! my $R = OpenInteract::Request->instance;
! my $apr = $R->apache;
!
my %params = %{ $p };
***************
*** 64,67 ****
--- 68,72 ----
if ( $search_id ) {
+ $R->DEBUG && $R->scrib( 1, "Retrieving search for ID ($search_id)" );
$results->{search_id} = $search_id;
}
***************
*** 72,84 ****
else {
my $iterator = $class->_search_build_and_run({ is_paged => 1 });
$results->save( $iterator );
$class->_search_save_id( $results->{search_id} );
}
$params{page_number_field} = $class->MY_SEARCH_RESULTS_PAGE_FIELD;
! $params{current_page} = $R->apache->param( $params{page_number_field} ) || 1;
my $hits_per_page = $class->MY_SEARCH_RESULTS_PAGE_SIZE;
! my ( $min, $max ) = $results->find_page_boundaries( $params{current_page}, $hits_per_page );
$params{iterator} = $results->retrieve({ min => $min, max => $max,
return => 'iterator' });
--- 77,92 ----
else {
+ $R->DEBUG && $R->scrib( 1, "Running search for the first time" );
my $iterator = $class->_search_build_and_run({ is_paged => 1 });
$results->save( $iterator );
+ $R->DEBUG && $R->scrib( 1, "Search ID ($results->{search_id})" );
$class->_search_save_id( $results->{search_id} );
}
$params{page_number_field} = $class->MY_SEARCH_RESULTS_PAGE_FIELD;
! $params{current_page} = $apr->param( $params{page_number_field} ) || 1;
my $hits_per_page = $class->MY_SEARCH_RESULTS_PAGE_SIZE;
! my ( $min, $max ) = $results->find_page_boundaries(
! $params{current_page}, $hits_per_page );
$params{iterator} = $results->retrieve({ min => $min, max => $max,
return => 'iterator' });
***************
*** 87,90 ****
--- 95,100 ----
$params{search_id} = $results->{search_id};
$params{search_results_key} = $class->MY_SEARCH_RESULTS_KEY;
+ $R->DEBUG && $R->scrib( 1, "Search info: min: ($min); max: ($max)",
+ "records ($results->{num_records})" );
}
***************
*** 99,103 ****
$class->_search_customize( \%params );
! my $template_name = $class->_template_name( \%params, $class->MY_SEARCH_RESULTS_TEMPLATE );
return $R->template->handler( {}, \%params, { name => $template_name } );
}
--- 109,115 ----
$class->_search_customize( \%params );
! my $template_name = $class->_template_name(
! \%params,
! $class->MY_SEARCH_RESULTS_TEMPLATE( \%params ) );
return $R->template->handler( {}, \%params, { name => $template_name } );
}
***************
*** 274,278 ****
}
push @value, $search_value;
! $R->DEBUG && $R->scrib( 1, "Set ($field_name) ($oper) ($search_value)" );
}
push @where, '( ' . join( ' OR ', @where_param ) . ' )';
--- 286,290 ----
}
push @value, $search_value;
! $R->DEBUG && $R->scrib( 1, "Set ($field_name) $oper ($search_value)" );
}
push @where, '( ' . join( ' OR ', @where_param ) . ' )';
***************
*** 308,312 ****
elsif ( $num_linking_fields == 3 ) {
my ( $base_id_field, $middle_table, $link_id_field ) = @{ $id_link };
! $R->DEBUG && $R->scrib( 1, "Linking to ($link_table) through ($middle_table)" );
push @where, join( ' = ', "$object_table.$base_id_field",
"$middle_table.$base_id_field" );
--- 320,325 ----
elsif ( $num_linking_fields == 3 ) {
my ( $base_id_field, $middle_table, $link_id_field ) = @{ $id_link };
! $R->DEBUG && $R->scrib( 1, "Linking to ($link_table) through ",
! "($middle_table)" );
push @where, join( ' = ', "$object_table.$base_id_field",
"$middle_table.$base_id_field" );
***************
*** 324,328 ****
}
else {
! $R->DEBUG && $R->scrib( 1, "Straight link to ($link_table) with ($id_link)" );
push @where, join( ' = ', "$object_table.$id_link",
"$link_table.$id_link" );
--- 337,342 ----
}
else {
! $R->DEBUG && $R->scrib( 1, "Straight link to ($link_table) with",
! "($id_link)" );
push @where, join( ' = ', "$object_table.$id_link",
"$link_table.$id_link" );
***************
*** 363,368 ****
# create and modify?
! my $do_edit = ( $R->apache->param( 'edit' ) and
! $p->{level} >= SEC_LEVEL_WRITE );
# Setup our default info
--- 377,382 ----
# create and modify?
! $params{do_edit} = ( $R->apache->param( 'edit' ) and
! $p->{level} >= SEC_LEVEL_WRITE );
# Setup our default info
***************
*** 377,381 ****
# Ensure the object can be edited
! unless ( $do_edit or $object->is_saved ) {
my $error_msg = 'Sorry, did not specify an object to display nor did ' .
'you request to edit an object. (Try: "?edit=1" at the ' .
--- 391,395 ----
# Ensure the object can be edited
! unless ( $params{do_edit} or $object->is_saved ) {
my $error_msg = 'Sorry, did not specify an object to display nor did ' .
'you request to edit an object. (Try: "?edit=1" at the ' .
***************
*** 391,395 ****
$class->_show_customize( \%params );
! my $template_name = $class->_template_name( \%params, $class->MY_OBJECT_FORM_TEMPLATE );
return $R->template->handler( {}, \%params, { name => $template_name } );
}
--- 405,411 ----
$class->_show_customize( \%params );
! my $template_name = $class->_template_name(
! \%params,
! $class->MY_OBJECT_FORM_TEMPLATE( \%params ) );
return $R->template->handler( {}, \%params, { name => $template_name } );
}
***************
*** 404,408 ****
my ( $class, $p ) = @_;
unless ( $class->MY_ALLOW_EDIT ) {
! my $error_msg = 'Objects of this type cannot be edited. No modification made.';
return $class->search_form({ error_msg => $error_msg });
}
--- 420,424 ----
my ( $class, $p ) = @_;
unless ( $class->MY_ALLOW_EDIT ) {
! my $error_msg = 'Objects of this type cannot be edited. No action done.';
return $class->search_form({ error_msg => $error_msg });
}
***************
*** 615,619 ****
$class->_wizard_form_customize( \%params );
! my $template_name = $class->_template_name( \%params, $class->MY_WIZARD_FORM_TEMPLATE );
return $R->template->handler( {}, \%params, { name => $template_name } );
}
--- 631,637 ----
$class->_wizard_form_customize( \%params );
! my $template_name = $class->_template_name(
! \%params,
! $class->MY_WIZARD_FORM_TEMPLATE( \%params ) );
return $R->template->handler( {}, \%params, { name => $template_name } );
}
***************
*** 640,644 ****
$class->_wizard_search_customize( \%params );
! my $template_name = $class->_template_name( \%params, $class->MY_WIZARD_RESULTS_TEMPLATE );
return $R->template->handler( {}, \%params, { name => $template_name } );
}
--- 658,664 ----
$class->_wizard_search_customize( \%params );
! my $template_name = $class->_template_name(
! \%params,
! $class->MY_WIZARD_RESULTS_TEMPLATE( \%params ) );
return $R->template->handler( {}, \%params, { name => $template_name } );
}
***************
*** 1276,1281 ****
searched is an exact match, we use '=' as a search test.
! Otherwise we use 'LIKE' and wrap the value in '%' so it will match
! anywhere in the string.
If you need other custom behavior, do not include the field in
--- 1296,1302 ----
searched is an exact match, we use '=' as a search test.
! Otherwise we use 'LIKE' and, if the field is not in
! C<MY_SEARCH_FIELDS_LEFT_EXACT> or C<MY_SEARCH_FIELDS_RIGHT_EXACT>,
! wrap the value in '%'.
If you need other custom behavior, do not include the field in
***************
*** 1296,1300 ****
Optional. Returns fields from C<MY_SEARCH_FIELDS> that must match
! exactly on the right-hand side. This basically sets up:
$fieldname LIKE "%$fieldvalue"
--- 1317,1321 ----
Optional. Returns fields from C<MY_SEARCH_FIELDS> that must match
! exactly on the right-hand side. This sets up:
$fieldname LIKE "%$fieldvalue"
***************
*** 1305,1313 ****
Optional. Returns table name => ID field mapping used to build WHERE
! clauses with multiple tables.
A key is a table name, and the value enables us to build a join clause
to link table specified in the key to the table containing the object
! being searched. The value is either a scalar or an arrayref:
If a scalar, the value is just the ID field in the destination table
--- 1326,1334 ----
Optional. Returns table name => ID field mapping used to build WHERE
! clauses that JOIN multiple tables when executing a search.
A key is a table name, and the value enables us to build a join clause
to link table specified in the key to the table containing the object
! being searched. The value is either a scalar or an arrayref.
If a scalar, the value is just the ID field in the destination table
***************
*** 1320,1324 ****
the ID of our object matches.
! If the value is an arrayref that means one of two things.
First, a two-element arrayref. This means we are have a non-key field
--- 1341,1346 ----
the ID of our object matches.
! If the value is an arrayref that means one of two things, depending on
! the number of elements in the arrayref.
First, a two-element arrayref. This means we are have a non-key field
***************
*** 1533,1541 ****
Modify the GenericDispatcher so that things like security information,
forbidden methods, etc. are available through class methods we can
! override.
=head1 SEE ALSO
! L<OpenInteract::Handler::GenericDispatcher>
=head1 COPYRIGHT
--- 1555,1565 ----
Modify the GenericDispatcher so that things like security information,
forbidden methods, etc. are available through class methods we can
! override. We might hold off on this until we implement the
! ActionDispatcher -- no reason to modify something we will
! remove/modify soon anyway...
=head1 SEE ALSO
! L<OpenInteract::Handler::GenericDispatcher|OpenInteract::Handler::GenericDispatcher>
=head1 COPYRIGHT
|