From: Chris W. <la...@us...> - 2004-10-24 15:50:23
|
Update of /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5546/lib/OpenInteract2 Modified Files: Action.pm Log Message: allow 'template_source' to be applied to all tasks in an action Index: Action.pm =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/Action.pm,v retrieving revision 1.56 retrieving revision 1.57 diff -C2 -d -r1.56 -r1.57 *** Action.pm 24 Oct 2004 15:03:52 -0000 1.56 --- Action.pm 24 Oct 2004 15:50:14 -0000 1.57 *************** *** 483,529 **** $content_params->{action_messages} = $self->view_messages; ! # If source wasn't specified see if it's found in ! # 'template_source' ! unless ( $source ) { ! my $task = $self->task; ! if ( my $source_info = $self->template_source ) { ! unless ( ref $source_info eq 'HASH' ) { ! my $msg = "No template source specified in config, " . ! "no source returned for task '$task'"; ! $log->error( $msg ); ! oi_error $msg; ! } ! my $task_template_source = $source_info->{ $task }; ! unless ( $task_template_source ) { ! my $msg = "No template source in config for task '$task'"; ! $log->error( $msg ); ! oi_error $msg; ! } ! $log->is_debug && ! $log->debug( "Found template source from action ", ! "[$task_template_source] config" ); ! my ( $msg_key ) = $task_template_source =~ /^msg:(.*)$/; ! if ( $msg_key ) { ! $source = { message_key => $msg_key }; ! } ! else { ! $source = { name => $task_template_source }; ! } ! } ! else { ! my $msg = "No template source specified in config, " . ! "no source returned for task '$task'"; $log->error( $msg ); oi_error $msg; } } ! my $generator = CTX->content_generator( $self->content_generator ); ! my $content = $generator->generate( $template_params, ! $content_params, ! $source ); ! return $content; } --- 483,540 ---- $content_params->{action_messages} = $self->view_messages; ! if ( ref( $source ) eq 'HASH' and scalar keys %{ $source } == 0 ) { ! $source = undef; ! } ! $source ||= $self->_get_template_source_from_config; ! my $generator = CTX->content_generator( $self->content_generator ); ! return $generator->generate( ! $template_params, $content_params, $source ); ! } ! ! # grab the template source from the configuration key ! # 'template_source', handling per-task configuration as well as ! # message key lookups ! ! sub _get_template_source_from_config { ! my ( $self ) = @_; ! my $task = $self->task; ! my $source_info = $self->template_source; ! unless ( $source_info ) { ! my $msg = "No template source specified in config, " . ! "no source returned for task '$task'"; ! $log->error( $msg ); ! oi_error $msg; ! } ! ! my ( $task_template_source ); ! if ( ref $source_info eq 'HASH' ) { ! $task_template_source = $source_info->{ $task }; ! unless ( $task_template_source ) { ! my $msg = "No template source in config for task '$task'"; $log->error( $msg ); oi_error $msg; } + $log->is_debug && + $log->debug( "Found '$task_template_source' template ", + "for '$task' task" ); } ! # assume we're using the same template for all tasks in action; ! # typically when we specify a 'task' ! else { ! $log->is_debug && ! $log->debug( "Found '$source_info' template for all ", ! "tasks in action" ); ! $task_template_source = $source_info ! } ! $log->is_debug && ! $log->debug( "Found template source from action: ", ! "'$task_template_source'" ); ! my ( $msg_key ) = $task_template_source =~ /^msg:(.*)$/; ! return ( $msg_key ) ! ? { message_key => $msg_key } ! : { name => $task_template_source }; } |