From: Chris W. <la...@us...> - 2005-03-29 05:07:44
|
Update of /cvsroot/openinteract/OpenInteract2/pkg/base_box/OpenInteract2/Action In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28818/base_box/OpenInteract2/Action Modified Files: Box.pm Log Message: OIN-58: more fixes... Index: Box.pm =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/pkg/base_box/OpenInteract2/Action/Box.pm,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Box.pm 29 Mar 2005 02:36:22 -0000 1.13 --- Box.pm 29 Mar 2005 05:07:35 -0000 1.14 *************** *** 23,27 **** my $DEFAULT_WEIGHT = 5; my $MAX_WEIGHT = 100; ! my ( $BLANK_SHELL, $DEFAULT_SHELL ); my ( $BASE_TEMPLATE_ACTION ); --- 23,30 ---- my $DEFAULT_WEIGHT = 5; my $MAX_WEIGHT = 100; ! my ( $BLANK_SHELL_NAME, $DEFAULT_SHELL ); ! my ( $DEFAULT_TITLE, $DEFAULT_TITLE_KEY ); ! my ( $DEFAULT_TITLE_IMG, $DEFAULT_TITLE_IMG_KEY ); ! my ( $DEFAULT_TITLE_ALT, $DEFAULT_TITLE_ALT_KEY ); my ( $BASE_TEMPLATE_ACTION ); *************** *** 30,35 **** my $action_info = CTX->lookup_action_info( $action_name ); my $log_init = get_logger( LOG_INIT ); ! $BLANK_SHELL = $action_info->{blank_box_template}; ! $DEFAULT_SHELL = $action_info->{default_box_template}; my @classes = (); --- 33,40 ---- my $action_info = CTX->lookup_action_info( $action_name ); my $log_init = get_logger( LOG_INIT ); ! $BLANK_SHELL_NAME = $action_info->{blank_box_template}; ! $DEFAULT_SHELL = $action_info->{default_box_template}; ! $DEFAULT_TITLE = $action_info->{default_title}; ! $DEFAULT_TITLE_KEY = $action_info->{default_title_key}; my @classes = (); *************** *** 47,55 **** $log->info( "Brought in box implementation class '$_' ok" ); } - $BASE_TEMPLATE_ACTION = eval { CTX->lookup_action( 'template_only' ) }; - if ( $@ ) { - oi_error "Cannot create 'template_only' action -- this should be ", - "in the 'base' package but I could not find it." - } } --- 52,55 ---- *************** *** 58,72 **** $log ||= get_logger( LOG_APP ); my $controller = CTX->controller; - my @base_actions = grep { ! $controller->is_box_removed( $_->{name} ) } $self->_create_box_actions, $self->_create_additional_boxes( $self->param( 'system_box_class' ) ), $self->_create_additional_boxes( $self->param( 'custom_box_class' ) ); - $log->is_info && $log->info( "Found ", scalar( @base_actions ), " boxes to process ", "after getting all boxes (added, system and custom) ", "and ensuring that none of them are to be removed" ); - my @sorted_actions = sort { $a->param( 'weight' ) <=> $b->param( 'weight' ) --- 58,69 ---- *************** *** 98,101 **** --- 95,106 ---- my ( $self ) = @_; $log ||= get_logger( LOG_APP ); + unless ( $BASE_TEMPLATE_ACTION ) { + $BASE_TEMPLATE_ACTION = eval { CTX->lookup_action( 'template_only' ) }; + if ( $@ ) { + oi_error "Cannot create 'template_only' action -- this should be ", + "in the 'base' package but I could not find it." + } + } + my @actions = (); foreach my $box_info ( @{ CTX->controller->get_boxes } ) { *************** *** 134,144 **** my ( $self, $box, $box_info ) = @_; ! # first, assign defaults from box action foreach my $box_key ( @BOX_PARAMS ) { ! my $value = $box_info->{ $box_key } ! || $self->param( 'default_' . $box_key ); $box->param( $box_key, $value ); ! $log->is_debug && ! $log->debug( "Assigned $box_key => $value" ); delete $box_info->{ $box_key }; } --- 139,148 ---- my ( $self, $box, $box_info ) = @_; ! # first, assign data from box action -- don't assign defaults here foreach my $box_key ( @BOX_PARAMS ) { ! my $value = $box_info->{ $box_key }; ! next unless ( $value ); $box->param( $box_key, $value ); ! $log->is_debug && $log->debug( "Assigned $box_key => $value" ); delete $box_info->{ $box_key }; } *************** *** 186,190 **** # user has requested to keep box naked... ! if ( $shell_template eq $BLANK_SHELL ) { push @content, $base_content; $log->is_debug && --- 190,194 ---- # user has requested to keep box naked... ! if ( $shell_template eq $BLANK_SHELL_NAME ) { push @content, $base_content; $log->is_debug && *************** *** 195,207 **** my %shell_params = (); $shell_params{content} = $base_content; ! $shell_params{label} = $action->message_from_key_or_param( ! 'title', 'title_key' ); ! $shell_params{label_image_src} = $action->message_from_key_or_param( ! 'title_image_src', 'title_image_src_key' ); ! $shell_params{label_image_alt} = $action->message_from_key_or_param( ! 'title_image_alt', 'title_image_alt_key' ); push @content, $action->generate_content( \%shell_params, { name => $shell_template } --- 199,220 ---- my %shell_params = (); $shell_params{content} = $base_content; ! $shell_params{label} = _assign_from_key_or_param_or_defaults( ! $action, 'title', 'title_key', ! $DEFAULT_TITLE, $DEFAULT_TITLE_KEY ); ! $shell_params{label_image_src} = _assign_from_key_or_param_or_defaults( ! $action, 'title_image_src', 'title_image_src_key', ! $DEFAULT_TITLE_IMG, $DEFAULT_TITLE_IMG_KEY ); ! $shell_params{label_image_alt} = _assign_from_key_or_param_or_defaults( ! $action, 'title_image_src', 'title_image_src_key', ! $DEFAULT_TITLE_ALT, $DEFAULT_TITLE_ALT_KEY ); + my $name = $action->name; + $log->is_debug && + $log->debug( "Filling box shell for '$name' with ", + "[Label: $shell_params{label}] ", + "[img src: $shell_params{label_image_src}] ", + "[img alt: $shell_params{label_image_alt}] " ); push @content, $action->generate_content( \%shell_params, { name => $shell_template } *************** *** 212,215 **** --- 225,245 ---- } + sub _assign_from_key_or_param_or_defaults { + my ( $action, $name, $key, $default_name, $default_key ) = @_; + my $rv = $action->message_from_key_or_param( $name, $key ); + unless ( $rv ) { + if ( $default_name ) { + $rv = $default_name; + } + if ( ! $rv and $default_key ) { + $rv = $action->_msg( $default_key ); + } + } + $log->is_debug && + $log->debug( "Param default: $rv; given ($name, $key, ", + "$default_name, $default_key) "); + return $rv; + } + 1; |