%#-- Begin HTML --#
<%perl>
# Make sure we've got an ID.
redirect('/admin/manager/pref') unless defined $id;
# Instantiate an object.
my $pref = $class->lookup({ id => $id});
# Check authorization.
chk_authz($pref, $id ? READ : CREATE);
my $no_edit = !chk_authz($pref, EDIT, 1);

# Output the header and other necessities.
$m->comp('/widgets/wrappers/sharky/header.mc',
         title => "$disp Profile",
	 context => "Admin | Profile | $disp | &quot;" . $pref->get_name . "&quot"
);
$m->out(qq{<form method="post" name="pref_profile" action="} . $r->uri
        . qq{" onSubmit="return confirmChanges(this)">\n});
$m->comp('/javascripts/profile/formValidator.js', id => $id);

# Output a hidden field with the ID.
$m->comp('/widgets/profile/hidden.mc', value => $id, name => 'pref_id');

# Grab the name and output the hidden field.
my $name = $pref->get_name;

# Set up the select list data.
my $vals = $pref->get_opts_href;
my $c = scalar keys %$vals;

$m->comp("/widgets/wrappers/sharky/table_top.mc",
	 caption => $name);

if( $name eq 'URI Format' || $name eq 'Fixed URI Format' ) {
	my $fixed = $name eq 'URI Format' ? 0 : 1;
	$m->comp("/widgets/profile/uri_pref.mc", fixed => $fixed,
		 pref => $pref, vals => $vals);
} else {
	$m->comp('/widgets/profile/displayFormElement.mc', key => 'value',
	 	readOnly => $no_edit,
	 	vals => { props => { type =>  $c < 4 ? 'radio' : 'select',
			  	     size => $c > 15 ? 10 : 1,
			  	     vals => $vals },
		disp => '',
		value => $pref->get_value } );
}

$m->comp("/widgets/wrappers/sharky/table_bottom.mc");

# Output the form buttons.
$m->out("<br />\n");
$m->comp("/widgets/profile/formButtons.mc", type => $type, section => $widget,
   no_del => 1, no_save => $no_edit );

</%perl>
</form>

<& '/widgets/wrappers/sharky/footer.mc', param => \%ARGS &>
%#-- End HTML --#

%#-- Once Section --#
<%once>;
my $class = 'Bric::Util::Pref';
my $widget = 'profile';
my $type = 'pref';
my $disp = get_disp_name($type);
</%once>

%#-- Args Section --#
<%args>
$id => undef
</%args>
<%doc>
###############################################################################

=head1 NAME

/admin/profile/preferences/dhandler - Manages application global preferences.

=head1 VERSION

$Revision: 1.6 $

=head1 DATE

$Date: 2002/03/15 22:55:02 $

=head1 DESCRIPTION

Simple interface for managing global preferences.

</%doc>
