package HTML::Mason::Commands;
use strict;
use vars qw($m $r);
my $_escape = \&HTML::Mason::Parser::_escape_perl_expression;
my $fmt_name = sub {
my ($name) = @_;
# Lowercase the name and replace non-alphanumeric characters
($name = lc $name) =~ y/a-z0-9/_/cs;
return $name;
};
my $show_element_flags = sub {
my ($at) = @_;
my @flags;
push @flags, 'paginated' if $at->get_paginated;
push @flags, 'top level' if $at->get_top_level;
push @flags, 'fixed url' if $at->get_fixed_url;
push @flags, 'media' if $at->is_media;
push @flags, 'related media' if $at->is_related_media;
push @flags, 'related story' if $at->is_related_story;
if (scalar @flags) {
return ' ('.join(', ', @flags).')';
} else {
return;
}
};
my $show_data_flags = sub {
my ($d) = @_;
my @flags;
push @flags, 'required' if $d->get_required;
push @flags, 'repeatable' if $d->get_quantifier;
if (scalar @flags) {
return ' ('.join(', ', @flags).')';
} else {
return;
}
};
my $show_subelement_flags = sub {
my ($at, $c) = @_;
my @flags;
push @flags, 'repeatable' if $at->is_repeatable($c);
if (scalar @flags) {
return ' ('.join(', ', @flags).')';
} else {
return;
}
};
HTML::Mason::Component::FileBased->new
(
'code'=>sub {
my %ARGS;
if (@_ % 2 == 0) { %ARGS = @_ } else { die "Odd number of parameters passed to component expecting name/value pairs" }
my $widget = (!exists $ARGS{'widget'} ? die "no value sent for required parameter 'widget'" : $ARGS{'widget'});
my $_out = $m->current_sink;
$m->debug_hook($m->current_comp->path) if (%DB::);
my $fa = get_state_data($widget, 'fa');
my $at = $fa->get_element;
# Use the same reset key for this widget in all the widgets we call.
my $rk = get_state_data($widget, 'reset_key');
# Get the workflow ID.
my $wf_id = get_state_data($widget, 'work_id') || $fa->get_workflow_id();
# Lookup the workflow and get its allowed desks.
my $wf = Bric::Biz::Workflow->lookup({id => $wf_id});
my $desks = $wf->allowed_desks();
# Get the current desk, or if this hasn't been put on a desk yet, the start desk
my $cd = $fa->get_current_desk() || $wf->get_start_desk();
# Set up a formatting variable
my $agent = $m->comp("/widgets/util/detectAgent.mc");
my $infoIndent = ($agent->{browser} eq "Netscape") ? FIELD_INDENT - 5 : FIELD_INDENT + 8;
my $rightText = $m->scomp( '/widgets/profile/imageSubmit.mc',
formName => "theForm",
callback => $widget . "|notes_cb",
value => 'edit',
image => "view_notes_teal"
);
$rightText .= $m->scomp( '/widgets/profile/imageSubmit.mc',
formName => "theForm",
callback => $widget . "|trail_cb",
image => "view_trail_teal"
);
$m->comp("/widgets/wrappers/sharky/table_top.mc",
caption => "Information",
number => 1,
rightText => $rightText
);
$_out->('
');
$_out->( $fa->get_element_name );
$_out->(' |
 |
');
$_out->( $fa->get_name );
$_out->(' |
 |
');
$_out->( $fa->get_output_channel_name );
$_out->(' |
 |
');
$_out->( $fa->get_category_name );
$_out->(' |
 |
');
$_out->( $fa->get_uri );
$_out->(' |
');
$m->comp('/widgets/profile/displayFormElement.mc',
objref => $fa,
key => 'priority',);
$_out->('
');
$m->comp('/widgets/profile/displayFormElement.mc',
objref => $fa,
key => 'description',);
$_out->('
');
$m->comp('/widgets/profile/displayFormElement.mc',
objref => $fa,
key => 'expire_date',);
$_out->('
');
$m->comp('/widgets/wrappers/sharky/table_bottom.mc');
$_out->('
');
$m->comp('/widgets/wrappers/sharky/table_top.mc',
caption => 'Template Code',
number => 2);
$_out->('
');
if ($at) {
$_out->('
 |
');
$_out->( $at->get_name );
$_out->('
');
$_out->( $show_element_flags->($at) );
$_out->('
|
 |
');
if (@{$at->get_data}) {
$_out->('
 |
');
my $comma = '';
foreach my $d ($at->get_data) {
$_out->(' ');
$_out->( $comma );
$_out->('
');
$_out->( $fmt_name->($d->get_name) );
$_out->('
');
$_out->( $show_data_flags->($d) );
$_out->('
');
$comma = ', ';
}
$_out->(' |
 |
');
}
if (@{$at->get_containers}) {
$_out->('
 |
');
my $comma = '';
foreach my $c ($at->get_containers) {
$_out->(' ');
$_out->( $comma );
$_out->('
');
$_out->( $fmt_name->($c->get_name) );
$_out->('
');
$_out->( $show_subelement_flags->($at, $c) );
$_out->('
');
$comma = ', ';
}
$_out->(' |
');
}
$_out->('
');
}
$_out->('
|
');
$m->comp('/widgets/profile/textarea.mc',
'name' => $widget.'|code',
'value' => $fa->get_data,
'cols' => ($agent->{browser} eq "Internet Explorer") ? 60 : 72,
'rows' => 20 ,
'useTable' => 0);
$_out->('
|
');
$m->comp('/widgets/wrappers/sharky/table_bottom.mc');
$_out->('
');
$m->comp("/widgets/profile/buttonBar.mc",
widget => $widget,
desks => $desks,
cd => $cd,
obj => $fa,
);
$_out->('
');
$_out->('
');
$_out->('
');
return undef;
},
'create_time'=>1001670197,
'declared_args'=> {
'$widget' => {
'default' => undef
}
},
'object_size'=>8694,
'parser_version'=>0.8
)
;