BingoX

 view release on metacpan or  search on metacpan

lib/BingoX/Chromium.pm  view on Meta::CPAN

  $SV = $object->display_search();				- Not Implemented Yet!
  $SV = $object->display_row( $field );
  $SV = $object->display_list_buttons();
  $SV = $object->display_modify_buttons();
  $SV = $object->displat_start_html();
  $SV = $object->hidden_fields();

DATA METHODS

  $SV = $object->save_data();
  $HR = $object->get_data( [ $data, ] [ $fields ] );
  $SV = $object->sanity();
  $BR = $proto->dbh();
  $BR = $object->db_obj();
  $HR = $object->get_list_hash();

CLASS VARIABLE METHODS


  $SV = $proto->data_class();
  $SV = $proto->data_class_name();
  $SV = $proto->adminuri();
  $SV = $proto->classdesc();
  $SV = $proto->qfd();
  $SV = $proto->pkd();  
  $SV = $proto->prefix();  
  $SV = $proto->cpkey_params($pcpkey);
  $AR = $proto->fieldlist();
  $HR = $proto->ui();
  $AR = $proto->parents();  
  $AR = $proto->children();  
  $HR = $proto->fields();
  $SV = $proto->fieldname( $field );
  $SV = $proto->fieldtype( $field );
  $HR = $proto->fieldhtmloptions( $field );
  $SV = $proto->fieldrelclass( $field );
  $SV = $proto->fieldrelclasstype( $field );
  $HR = $proto->fieldoptions( $field );
  $HR = $proto->fieldsanity( $field );

OBJECT METHODS

  $SV = $object->flow();
  $SV = $object->cpkey();
  $SV = $object->pcpkey();
  $SV = $object->parent_class(); 
  $BR = $object->cgi();
  $SV = $object->uri();
  $SV = $object->displaymode();
  $SV = $object->section();
  $BR = $object->conf();
  $BR = $object->r();

HTML DISPLAY METHODS

  $SV = $object->HTML_date( $fieldname );
  $SV = $object->HTML_view( $fieldname );
  $SV = $object->HTML_hidden( $fieldname );
  $SV = $object->HTML_text( $fieldname );
  $SV = $object->HTML_textarea( $fieldname );
  $SV = $object->HTML_popup( $fieldname );		- Not Finished!
  $SV = $object->HTML_scrolling( $fieldname );
  $SV = $object->HTML_checkbox( $fieldname );
  $SV = $object->HTML_file( $fieldname );

=head1 REQUIRES

Time::Object, Apache, CGI, Carp

=head1 EXPORTS

Nothing

=head1 DESCRIPTION

 BingoX::Chromium provides the generic API for BingoX admin classes.
 BingoX::Chromium uses admin objects that wrap Carbon data objects

=head1 CLASS VARIABLES

Classes that inherit from BingoX::Chromium should have the following class variables:

=over 4

=item * @fieldlist

The order in which to display fields (if one so chose to display them ;)

=item * %fields

A hash whose keys are columns (same as in the fieldlist array) and whose values 
are complex arrays. Each array index is described below.

=over 4

=item [0] Descriptive Title

A string describing the field

=item [1] HTML Entity Type

A string that contains one of the following HTML etity types:

 view
 text
 textarea
 datetime
 popup
 reference
 FIXME: more!!!

=item [2] HTML Options

A hash reference containing options for creating the HTML form field for 
this field.

=item [3] Related Classes

FIXME: I dunno

=item [4] Field Options

A hash reference containing special options for this field. The options include:

  not_null - this field cannot be NULL

=item [5] Sanity Methods

This is a list reference. Each item in the list is either a string with a 
sanity method name, or a list ref containing the method name, then any parameters 
that need to be passed to it. An example:

  [
   'sane_foo',
   ['sane_bar', 'baz'],
  ]

For more info, see L<"SANITY METHODS">.

=back

=item * $adminuri

An optional class variable, corresponds to the C<adminuri()> method.  
FIXME: Can someone who knows more about this elaborate?

=item * $classdesc

A simple one- or two-word description of the class being administered.

=back

=item * $data_class

The name of the data class that corresponds to the admin class. If this 
value is not defined, it will default to the name of the admin class, with 
the first instance of "::Admin::" changed to "::Data::".

=back

=head1 METHODS

=over 4

=cut

package BingoX::Chromium;

lib/BingoX/Chromium.pm  view on Meta::CPAN

set of date form fields or in viewable format if the displaymode is 'view'.

=cut

sub HTML_time {
	my $self		= shift;
	return undef unless ref($self);
	my $fieldname	= shift;
	my $qoptions	= shift || $self->fieldhtmloptions( $fieldname ) || { };
	my $q			= $self->cgi;
	my $qfieldname	= $self->qfieldname( $fieldname );

	my $hr24		= $qoptions->{'-SHOW_24HOURS'};

	my $date_obj;
	$date_obj		= $self->db_obj->$fieldname() unless ($self->displaymode eq 'add');
	if (!ref($date_obj)) {
		return undef if ($self->displaymode eq 'view');
		$date_obj	= BingoX::Time->new();
	}

	my ($hour, $minute, $ampm);
	## get hour from the date object ##
	$hour			= $date_obj->hour;
	## get minute from the date object ##
	$minute			= $date_obj->min;
	unless ($hr24) {
		$ampm = ($hour >= 12 ? 'PM' : 'AM');
		$hour -= 12 if ($hour > 12);
		$hour = 12  if ($hour == 0);
	}

	return ($hour . ':' . $minute . ' ' . $ampm ,
			$q->hidden(-NAME => $qfieldname.'_hour', -VALUE => $hour)
		.	$q->hidden(-NAME => $qfieldname.'_min',  -VALUE => $minute)
		.	$q->hidden(-NAME => $qfieldname.'_ampm', -VALUE => $ampm))
		if ($self->displaymode eq 'view' || $qoptions->{'-TYPE'} =~ /view/i);
	
	if ($qoptions->{'-TYPE'} =~/view/io) {
		return	$q->hidden(	-NAME	=> $qfieldname.'_hour',
							-VALUE	=> $hour)
			.	$q->hidden(	-NAME	=> $qfieldname.'_min',
							-VALUE	=> $minute)
			.	$q->hidden(	-NAME	=> $qfieldname.'_ampm',
							-VALUE	=> $ampm);
	} elsif ($qoptions->{'-TYPE'} =~/text/io) {
		return	$q->textfield(	-NAME		=> $qfieldname.'_hour',
								-SIZE		=> $qoptions->{'-HR_SIZE'}		|| 2,
								-MAXLENGTH	=> $qoptions->{'-HR_MAXLENGTH'}	|| 2,
								-OVERRIDE	=> $qoptions->{'-HR_OVERRIDE'}	|| 1,
								-DEFAULT	=> sprintf("%02d", $q->param( $qfieldname.'_hour' )	|| $hour)
							)
			.	' : '
			.	$q->textfield(	-NAME		=> $qfieldname.'_min',
								-SIZE		=> $qoptions->{'-MIN_SIZE'}			|| 2,
								-MAXLENGTH	=> $qoptions->{'-MIN_MAXLENGTH'}	|| 2,
								-OVERRIDE	=> $qoptions->{'-MIN_OVERRIDE'}		|| 1,
								-DEFAULT	=> sprintf("%02d", $q->param( $qfieldname.'_min' )	|| $minute)
							)
			.	($hr24 ? '' :
				'&nbsp;' . $q->popup_menu(	-NAME		=> $qfieldname.'_ampm',
											-VALUES		=> [ 'AM', 'PM' ],
											-DEFAULT	=> ($q->param( $qfieldname.'_ampm' )	|| $ampm),
											-OVERRIDE	=> $qoptions->{'-AMPM_OVERRIDE'}		|| 1
										));
	} else {
		return $q->popup_menu(	-NAME		=> $qfieldname.'_hour',
								-VALUES		=> ($hr24 ? $date_obj->hours24 : $date_obj->hours),
								-DEFAULT	=> sprintf("%02d", $hour),
								-OVERRIDE	=> $qoptions->{'-HR_OVERRIDE'} || 1
							)
			. '&nbsp;:&nbsp;'
			. $q->popup_menu(	-NAME		=> $qfieldname.'_min',
								-VALUES		=> $date_obj->minutes,
								-DEFAULT	=> sprintf("%02d", $q->param( $qfieldname.'_min' )	|| $minute),
								-OVERRIDE	=> $qoptions->{'-MIN_OVERRIDE'} || 1
							)
			. ($hr24 ? '' :
				'&nbsp;' . $q->popup_menu(	-NAME		=> $qfieldname.'_ampm',
											-VALUES		=> [ 'AM', 'PM' ],
											-DEFAULT	=> ($q->param( $qfieldname.'_ampm' )	|| $ampm),
											-OVERRIDE	=> $qoptions->{'-AMPM_OVERRIDE'}		|| 1
										));
	}					
} # END sub HTML_time


=item C<HTML_day> ( $fieldname [, $qoptions ] )

Object Method:

Generic Day Form Tag.  Called by AUTOLOAD.  
Gets the default field params based on the fieldname and returns a 
set of date form fields or in viewable format if the displaymode is 'view'.

=cut

sub HTML_day {
	my $self		= shift;
	return undef unless ref($self);
	my $fieldname	= shift;
	my $qoptions	= shift || $self->fieldhtmloptions( $fieldname ) || { };
	my $q			= $self->cgi;
	my $qfieldname	= $self->qfieldname( $fieldname );
	
	my $date_obj;
	$date_obj		= $self->db_obj->$fieldname() unless ($self->displaymode eq 'add');
	if (!ref($date_obj)) {
		return undef if ($self->displaymode eq 'view');
		$date_obj	= BingoX::Time->new();
	}

	return $date_obj->mday if ($self->displaymode eq 'view');

	if ($qoptions->{'-TYPE'} =~/view/io) {
		return ( $date_obj->mday 
				,$q->hidden(	-NAME	=> $qfieldname.'_day',
								-VALUE	=> $date_obj->mday));
	} elsif ($qoptions->{'-TYPE'} =~/text/io) {
		return $q->textfield(	-NAME		=> $qfieldname.'_day',
								-SIZE		=> $qoptions->{'-DAY_SIZE'}			|| 2,
								-MAXLENGTH	=> $qoptions->{'-DAY_MAXLENGTH'}	|| 2,
								-OVERRIDE	=> $qoptions->{'-DAY_OVERRIDE'}		|| 1,
								-DEFAULT	=> $q->param( $qfieldname.'_day' )	|| $date_obj->mday
							);
	} else {
		return $q->popup_menu(	-NAME		=> $qfieldname.'_day',
								-VALUES		=> [ 1 .. 31 ],
								-OVERRIDE	=> $qoptions->{'-DAY_OVERRIDE'}		|| 1,
								-DEFAULT	=> $q->param( $qfieldname.'_day' )	|| $date_obj->mday
							);
	}
} # END sub HTML_day


=item C<HTML_month> ( $fieldname [, $qoptions ] )

Object Method:

Generic Month Form Tag.  Called by AUTOLOAD.  
Gets the default field params based on the fieldname and returns a 
set of date form fields or in viewable format if the displaymode is 'view'.

=cut

sub HTML_month {
	my $self		= shift;
	return undef unless ref($self);
	my $fieldname	= shift;
	my $qoptions	= shift || $self->fieldhtmloptions( $fieldname ) || { };
	my $q			= $self->cgi;
	my $qfieldname	= $self->qfieldname( $fieldname );

	my $format		= $qoptions->{'-FORMAT'} || "%B %e %Y";
	my $date_obj;
	$date_obj		= $self->db_obj->$fieldname() unless ($self->displaymode eq 'add');
	if (!ref($date_obj)) {
		return undef if ($self->displaymode eq 'view');
		$date_obj	= BingoX::Time->new();
	}

	return $date_obj->mon if ($self->displaymode eq 'view');

	if ($qoptions->{'-TYPE'} =~/view/io) {
		return ($date_obj->mon,
				$q->hidden(	-NAME	=> $qfieldname.'_mon',
							-VALUE	=> $date_obj->mon));
	} elsif ($qoptions->{'-TYPE'} =~/text/io) {
		return $q->textfield(	-NAME		=> $qfieldname.'_mon',
								-SIZE		=> $qoptions->{'-MON_SIZE'}			|| 2,
								-MAXLENGTH	=> $qoptions->{'-MON_MAXLENGTH'}	|| 2,
								-OVERRIDE	=> $qoptions->{'-MON_OVERRIDE'}		|| 1,
								-DEFAULT	=> $q->param( $qfieldname.'_mon' )	|| $date_obj->mon
							);
	} else {
		return $q->popup_menu(	-NAME		=> $qfieldname . '_mon',
								-VALUES		=> [ 1 .. 12 ],
								-LABELS		=> ($format =~ /\%B/o ? $date_obj->months_full : $date_obj->months),
								-OVERRIDE	=> $qoptions->{'-MON_OVERRIDE'}		|| 1,
								-DEFAULT	=> $q->param( $qfieldname.'_mon' )	|| $date_obj->mon
							);
	}
} # END sub HTML_month


=item C<HTML_year> ( $fieldname [, $qoptions ] )

Object Method:

Generic Year Form Tag.  Called by AUTOLOAD.  
Gets the default field params based on the fieldname and returns a 
set of date form fields or in viewable format if the displaymode is 'view'.

=cut

sub HTML_year {
	my $self		= shift;
	return undef unless ref($self);
	my $fieldname	= shift;
	my $qoptions	= shift || $self->fieldhtmloptions( $fieldname ) || { };
	my $q			= $self->cgi;
	my $qfieldname	= $self->qfieldname( $fieldname );

	my $format		= $qoptions->{'-FORMAT'} || "%B %e %Y";
	my $date_obj;
	$date_obj		= $self->db_obj->$fieldname() unless ($self->displaymode eq 'add');
	if (!ref($date_obj)) {
		return undef if ($self->displaymode eq 'view');
		$date_obj	= BingoX::Time->new();
	}
	my $start		= $qoptions->{'-YEAR_START'}		|| 20;
	my $end			= $qoptions->{'-YEAR_END'}			|| 20;
	my ($values, $year, $size, $max);
	if ($format =~ /\%Y/o) {
		$year		= $date_obj->year;
		$values		= [ ($year - $start) .. ($year + $end) ];
		$size		= 4;
		$max		= 4;
	} else {
	### THERE IS NO REASON TO USE NON-COMPLIANT YEARS ###
		$size		= 2;
		$max		= 2;
		$year		= substr($date_obj->year, -2, 2);
		my $yr		= $year;
		$values		= [ $year ];
		$start		= 49 if ($start >= 50);		# can only display 100 years at a time in two digit format
		foreach (1 .. $start) {
			$yr = 100 if ($yr == 0);			# can't have negative years
			unshift(@$values, sprintf("%02d", --$yr));
		}
		$yr			= $year;
		foreach (1 .. $start + 1) {
			push(@$values, sprintf("%02d", ++$yr));
		}
	}

	return $year if ($self->displaymode eq 'view');

	if ($qoptions->{'-TYPE'} =~/view/io) {
		return ($year ,$q->hidden(	-NAME	=> $qfieldname.'_year',
									-VALUE	=> $year));
	} elsif ($qoptions->{'-TYPE'} =~/text/io) {
		return $q->textfield(	-NAME		=> $qfieldname.'_year',
								-SIZE		=> $size, 
								-MAXLENGTH	=> $max, 
								-OVERRIDE	=> $qoptions->{'-YEAR_OVERRIDE'}	|| 1,
								-DEFAULT	=> $q->param( $qfieldname.'_year' )	|| $year
							);
	} else {
		return $q->popup_menu(	-NAME		=> $qfieldname.'_year',
								-VALUES		=> $values,
								-OVERRIDE	=> $qoptions->{'-YEAR_OVERRIDE'}	|| 1,
								-DEFAULT	=> $q->param( $qfieldname.'_year' )	|| $year
							);
	}
} # END sub HTML_year


=item C<HTML_date> ( $fieldname [, $qoptions ] )

Object Method:

Generic form field method called by AUTOLOAD.  
Gets the default field params based on the fieldname and returns a 
set of date form fields or in viewable format if the displaymode is 'view'.

B<Needs to be less Sybase Dependant and handle Time>

=cut

sub HTML_date {
	my $self		= shift;
	return undef unless ref($self);
	my $fieldname	= shift;
	my $qoptions	= shift || $self->fieldhtmloptions( $fieldname ) || { };
	my $q			= $self->cgi;
	my $qfieldname	= $self->qfieldname( $fieldname );

	my $showhrs		= $qoptions->{'-SHOW_HOURS'}	|| $qoptions->{'-SHOW_24HOURS'};	# Show the hours flag
	my $format		= $qoptions->{'-FORMAT'}		|| "%B %e %Y";						# format for date strings
	my $delim		= $qoptions->{'-DELIMITER'}		|| '/';								# delimiter for text dates

	my ($day, $dhidden)		= $self->HTML_day(	$fieldname, $qoptions );
	my ($mon, $mhidden)		= $self->HTML_month($fieldname, $qoptions );
	my ($year, $yhidden)	= $self->HTML_year(	$fieldname, $qoptions );
	my ($time, $thidden)	= $self->HTML_time(	$fieldname, $qoptions );

	my $date_obj;
	$date_obj		= $self->db_obj->$fieldname() unless ($self->displaymode eq 'add');
	if (!ref($date_obj)) {
		return undef if ($self->displaymode eq 'view');
		$date_obj	= BingoX::Time->new();
	}

	## if in display view mode get the date object from the scalar values ##
	if ($self->displaymode eq 'view') {
		if ($qoptions->{'-FORMAT'}) {
			return $date_obj->strftime( $format ) . $dhidden . $mhidden . $yhidden . $thidden;
		} elsif ($qoptions->{'-DELIMITER'}) {
			return "$mon $delim $day $delim $year" . ($showhrs ? " $time" : '');
		} else {
			return "$mon  $day  $year" . ($showhrs ? "  $time" : '');
		}
	}

	my $html;
	if ($qoptions->{'-TYPE'} =~/view/io) {
		$html = "$mon  $day  $year";
	} elsif ($qoptions->{'-TYPE'} =~/text/io) {
		$html = "$mon $delim $day $delim $year";

lib/BingoX/Chromium.pm  view on Meta::CPAN

sub HTML_password {
	my $self		= shift;
	return undef unless ref($self);
	my $fieldname	= shift;
	my $qoptions	= shift || $self->fieldhtmloptions( $fieldname );
	my $q			= $self->cgi;
	my $qfieldname	= $self->qfieldname( $fieldname );
	($self->displaymode eq 'view')
	? '&lt;NOT DISPLAYED&gt;'
	: $q->password_field(-NAME		=> $qfieldname,
						 -SIZE		=> $qoptions->{'-SIZE'}		|| 50,
						 -MAXLENGTH	=> $qoptions->{'-MAXLENGTH'}|| 200,
						 -OVERRIDE	=> $qoptions->{'-OVERRIDE'} || 1,
						 -DEFAULT	=> (defined($q->param( $qfieldname ))
										?	$q->param( $qfieldname )
										:	(($self->displaymode eq 'modify')
											? $self->db_obj->$fieldname()
											: ($qoptions->{'-DEFAULT'} || '')))
						) . "\n";
} # END sub HTML_password


=item C<HTML_textarea> ( $fieldname [, $qoptions ] )

Object Method:

Generic form field method called by AUTOLOAD.  
Gets the default field params based on the fieldname and returns 
the value in a text input field or in viewable format if the 
displaymode is 'view'.

=cut

sub HTML_textarea {
	my $self		= shift;
	return undef unless ref($self);
	my $fieldname	= shift;
	my $qoptions	= shift || $self->fieldhtmloptions( $fieldname );
	my $q			= $self->cgi;
	my $qfieldname	= $self->qfieldname( $fieldname );

	if ($self->{'_displaymode'} eq 'view') {
		my $content = $self->db_obj->$fieldname();
		$content =~ s/(\r\n)|[\n\r]/<BR>/go;
		return $content;
	}
	$q->textarea(	-NAME		=> $qfieldname, 
					-ROWS		=> $qoptions->{'-ROWS'}		|| 6,
					-COLS		=> $qoptions->{'-COLS'}		|| 50,
					-WRAP		=> $qoptions->{'-WRAP'}		|| 'VIRTUAL',
					-OVERRIDE	=> $qoptions->{'-OVERRIDE'}	|| 1,
					-DEFAULT	=> (defined($q->param( $qfieldname ))
									?	$q->param( $qfieldname )
									:	(($self->displaymode eq 'modify')
										? $self->db_obj->$fieldname()
										: ($qoptions->{'-DEFAULT'} || '')))
				) . "\n";
} # END sub HTML_textarea


=item C<HTML_popup> ( $fieldname [, $qoptions ] )

Object Method:

Generic form field method called by AUTOLOAD.  
Gets the default field params based on the fieldname and returns the value 
in a popup field or in viewable format if the displaymode is 'view'.

Note: Not used yet because its not easy to populate the 
vaules & labels fields. USually always overloaded in the subclasses.

B<OPTIMIZE>

=cut

sub HTML_popup {
	my $self		= shift;
	my $class		= ref($self) || return undef;
	my $fieldname	= shift;
	my $qoptions	= shift || $self->fieldhtmloptions( $fieldname );
	my $foptions	= $self->fieldoptions( $fieldname );
	my $q			= $self->cgi;

	## if modify then grab the actual values of the primary keys of the obect				##
	## and prepend the fieldname with them.  This will allow people to modify multiple		##
	## objects on the same page.   Always put the classname and the fieldname at the end	##
	## of the fieldname.																	##
	my $qfieldname				= $self->qfieldname( $fieldname );
	my $relclass				= $class->fieldrelclass( $fieldname );
	my $relclass_title_field	= $relclass->title_field;
	$relclass					=~ /(.+)::Data::(.+)$/;
	my $reladminclass			= "${1}::Admin::${2}";

	## show all of the objects as text. ##
	if ($self->displaymode eq 'view') {
		my $obj		= @{ $relclass->list_obj(
							$self->dbh,
							{
								$relclass->primary_keys->[0] => $self->db_obj->$fieldname()
							}
					) || [ ] }->[0];
		(ref($obj) ? return $obj->$relclass_title_field() : return 'None Selected') . "\n";

	## get all of the objects with get_list_hash. ##
	} else {
		my $hashref	= $relclass->get_list_hash( $self->dbh );

		## Allows null value for popups ##
		if (!$foptions->{'not_null'} && $foptions->{'null_label'}) {
			$hashref->{'NULL'} = $foptions->{'null_label'};
		}

#		## if the displaymode isn't add, then highlite the already related objects. ##
#		my $selected = ($self->displaymode eq 'add')
#					? [ ]
#					: $self->db_obj->list_related( $relclass );
#		warn "Too Many Related" if ($selected->[1] && $debug);

		## default - if there's already data in the query object, highlite those objects,			##
		## otherwise if the displaymode if modify, show the data in the scrolling list where the	##
		## keys are composit primary keys seperated by $self->pkd and the									##
		## values are the title_fields of the objects, else don't highlite anything.				##
		$q->popup_menu(	-NAME		=> $qfieldname,
						-VALUES		=> [ sort { $hashref->{$a} cmp $hashref->{$b} } keys %$hashref ],	# need to fill in info later
						-LABELS		=> $hashref,														# need to fill in info later
						-DEFAULT	=> (defined($q->param( $qfieldname ))
									?	$q->param( $qfieldname )
									:	(($self->displaymode eq 'modify')
										? (defined($self->db_obj->$fieldname())
											? $self->db_obj->$fieldname()
											: ($foptions->{'null_label'}
												? 'NULL'
												: $qoptions->{'-DEFAULT'} || ''))
		## The trinary below is for parent child relationships.  Basically, if	##
		## we're adding a new object and this pop-up represents a list of our	##
		## parent fields, we should default to the parent we came through.		##
										: ((($self->displaymode eq 'add') && ($reladminclass eq $self->parent_class) && ($q->param('parent_pcpkey'))) 
											? (substr($q->param('parent_pcpkey'),rindex($q->param('parent_pcpkey'),$self->qfd)+1))
											: ($qoptions->{'-DEFAULT'} || ''))))
						) . "\n";
	}
} # END sub HTML_popup


=item C<HTML_radio> ( $fieldname [, $qoptions ] )

Object Method:

Generic form field method called by AUTOLOAD.  
Gets the default field params based on the fieldname and returns the value 
in a group of radio buttons or in viewable format if the displaymode is 'view'.

=cut

sub HTML_radio {
	my $self		= shift;
	my $class		= ref($self) || return undef;
	my $fieldname	= shift;
	my $qoptions	= shift || $self->fieldhtmloptions( $fieldname );
	my $q			= $self->cgi;
	my $qfieldname	= $self->qfieldname( $fieldname );

	my $relclass	= $class->fieldrelclass( $fieldname );
	my $relclass_title_field = $relclass->title_field;

	## show all of the objects as text. ##
	if ($self->displaymode eq 'view') {
		my $obj		= @{ $relclass->list_obj(	$self->dbh,
												{
													$relclass->primary_keys->[0] => $self->db_obj->$fieldname()
												}
											) || [ ] }->[0];
		(ref($obj) ? return $obj->$relclass_title_field() : return 'None Selected') . "\n";

	## get all of the objects with get_list_hash. ##
	} else {
		my $hashref = $relclass->get_list_hash( $self->dbh );
		
		## if the displaymode isn't add, then highlite the already related objects. ##
		my $selected = ($self->displaymode eq 'add')
					? [ ]
					: $self->db_obj->list_related( $relclass );

		warn "Too Many Related" if ($selected->[1] && $debug);

		$q->autoEscape(0) if ($qoptions->{'-NOESCAPE'});
		my $val = $q->radio_group(
									-NAME		=> $qfieldname,
									-VALUES		=> [ keys %$hashref ],				# need to fill in info later
									-LABELS		=> $hashref,						# need to fill in info later
									-LINEBREAK	=> $qoptions->{'-LINEBREAK'} || 'true',
									-DEFAULT	=> (defined($q->param( $qfieldname ))
												?	$q->param( $qfieldname )
												:	(($self->displaymode eq 'modify')
													? $self->db_obj->$fieldname()
													: ($qoptions->{'-DEFAULT'} || '')))
								);
		$q->autoEscape(1) if ($qoptions->{'-NOESCAPE'});
		return $val;
	}
} # END sub HTML_radio

lib/BingoX/Chromium.pm  view on Meta::CPAN


 Revision 2.23  2000/09/20 00:31:59  zhobson
 Fixed a scope warning in flow() (used "my $other_class" twice in the same scope)

 Revision 2.22  2000/09/19 23:40:59  dweimer
 Version update 1.91

 Revision 2.21  2000/09/13 20:58:27  adam
  - in get_data, changed how dates are handled if SHOW_24HOURS is off

 Revision 2.20  2000/09/12 16:03:35  david
 Made Data::Dumper optional -- only called when $debug is activated.  Changed all of its calls to Data::Dumper::Dumper().
 Caused handler to return result of flow(), flow ends up returning results of display_*(), display_*() methods now return Apache response constants.

 Revision 2.19  2000/09/08 22:06:24  colin
  - get_data - if the field is a date it makes sure there is at least
    the year in the query object.  Before it would break if you had a year
    in your %fields hash, but were not submitting that datefield in your
    add or modify form.  get_data would blindly try and build a date.

 Revision 2.18  2000/09/08 21:31:23  thai
  - cleaned up the code

 Revision 2.17  2000/09/08 05:19:38  thai
  - turned off debug

 Revision 2.16  2000/09/08 03:19:09  adam
  GENERAL
    Added parent/child relationship functionality, where each class can
    specify parent and child classes.  These are used to display buttons
    at the bottom of the display list screens to access your parents or
    children based on the selected item in the list.

  - updated POD
  - new
      - now accepts a CGI as an optional 4th param.
      - sets the selection from the $q->param('parent_pcpkey');
      - sets the parent_class object var from the $q->param('parent_pcpkey')
  - flow
      - checks to see if you are entering from a parent or child and sets
        $q->param('parent_pcpkey') with whats passed.
      - Gets the desired child or parent admin object and calls flow against it.
      - added debugging
  - changed all occurances of $q->startform to try and print $self->adminuri
    as the ACTION.  If there is no adminuri it uses uri as before.
  - display_list
      - displays information at the top of the page about what parent you
        came from (if there is a parent)
  - all forms now include hidden for parent_pcpkey
  - display_list_buttoms
  - displays buttons to view the display list page of any child or
           parent classes you might have.
  - pcpkey
    - renamed qkey to pcpkey
    - changed all occurances of qkey to pcpkey
  - cpkey
    - cpkey now just calls cpkey against the db_obj
  - cpkey_params
    - calls cpkey_params against your data_class
  - added children and parents class var accessor methods
  - HTML_popup
    - if your displaymode is add and you have a parent_pcpkey it attempts to
      select the parent in the pop-up menu.

 Revision 2.15  2000/09/07 22:49:03  thai
  - changed line 1200 to use BingoX::Time

 Revision 2.14  2000/09/07 20:00:02  thai
  - changed all occurances of DateTime::Date to BingoX::Time

 Revision 2.13  2000/08/31 21:54:18  greg
 Added COPYRIGHT information.
 Added file COPYING (LGPL).
 Cleaned up POD.
 Moved into BingoX namespace.
 References to Bingo::XPP now point to Apache::XPP.

 "To the first approximation, syntactic sugar is trivial to implement.
  To the second approximation, the first approximation is totally bogus."
 	-Larry Wall

 Revision 2.12  2000/08/10 21:10:55  thai
  - added qkey() to get the prefix and the cpkey
  - changed occurrances where primary keys were being iterated to use
    cpkey()
  - added prefix() method to return the correct prefix combination

 Revision 2.11  2000/08/09 21:25:03  thai
  - changed get_list_hash() to be more Carbon friendly

 Revision 2.10  2000/08/07 23:10:25  thai
  - added main_index() method to return the main index url
  - changed regex pattern for HTML_textarea()

 Revision 2.9  2000/08/07 17:59:32  thai
  - added remove and modify to the display_list_buttons() method
    and to flow

 Revision 2.8  2000/08/03 20:48:09  thai
  - addd qfd() method to handle qfds
  - fixed bug in HTML_date() that would create a new date object when
    displaymode was 'view'
  - the sub pkd() now calls data_class->pkd()

 Revision 2.7  2000/08/01 00:43:51  thai
  - changed db_obj->errstr to dbh->errstr on line 305
  - moved all the $qfieldname stuff to the qfieldname() method
  - removed the fieldtype eq 'custom' from line 1174 in get_data()

 Revision 2.6  2000/07/14 19:27:05  dougw
 save_data returns undef if it can't ref get_data's return value, should be a hashref.
 Small typo fix, hidden_fields returns a string as it should.

 Revision 2.5  2000/07/12 19:30:17  thai
  - fixed POD, cleaned up code

 Revision 2.4  2000/07/07 01:20:43  dougw
  - Added 1 instead of Turned On for the check box value. Who ever thought 
    of that?  Changed the comparisons for hashrefs. Beware !%$hashref is 
    different than ref $hashref ne 'HASH'

 Revision 2.3  2000/05/31 02:39:20  greg
 changed use of s/.*:// to substr(...) in AUTOLOAD for efficiency.

 Revision 2.2  2000/05/24 20:47:25  thai
  - added more sanity when dereferencing, @{ $code->() || [ ] }
  - added warning when creating new date objects fail

 Revision 2.1  2000/05/19 01:25:11  thai
  - cleaned up code
  - is now part of the Bingo user space

 Revision 2.0  2000/05/02 00:54:33  thai
  - committed as 2.0

 Revision 1.38  2000/03/21 02:00:23  dougw
 Fixed a bug introduced recently that broke adding new object when
 the identity key was in the fields list. This is so wierd. (zack)

 Revision 1.37  2000/03/17 21:09:00  dougw
 Allowed hidden values to be used in HTML_date for -TYPE=>'view'
 Fixed checkbox undef error

 Revision 1.36  2000/03/15 22:26:17  zack
 Added HTML_radio() and modified new() to allow passing a display mode.

 Revision 1.35  2000/03/15 19:25:43  colin
 -HTML_popup now sorts options alphabetically

 Revision 1.34  2000/03/14 21:45:08  dougw
 Fixed get_data->save_data problems (thanks dave).
 Removed spurious comments.

 Revision 1.33  2000/03/14 20:58:10  dougw
 Modified HTML_popup to allow a NULL selection. Use the fieldoption -null_label
 to specify what you want the option to be named. The option must not have the
 -not_null option set for obvious reasons.

 Revision 1.32  2000/03/10 01:57:54  colin
 made display_list()'s hash sorter even cooler (thanks doug)

 Revision 1.31  2000/03/10 01:18:02  colin
 -display_list() now sorts its entries alphabetically.

 Revision 1.30  2000/03/09 18:58:23  colin
 -fixed a bug in HTML_date() where $qfieldname was being used as a global.
 -fixed similar bugs in HTML_day(),HTML_month(),and HTML_year()
 -one can now pass a hashref to hidden_fields(). If one wanted to.

 Revision 1.29  2000/03/09 00:45:32  colin
 -(thai) fixed a bug in HTML_date() where it wasn't passing fieldnames to its helper methods.
 -HTML_date() now checks the -TYPE it's passed in fieldoptions

 Revision 1.28  2000/03/08 03:09:32  thai
  - parsed out HTML_date() to HTML_day(), HTML_month(), HTML_year(),
    and HTML_time()

 Revision 1.27  2000/02/25 20:24:17  colin
 corrected some minor ui bugs in display_list() and display_modify()

 Revision 1.26  2000/02/18 23:38:56  colin
 - altered sanity() so that it now accepts a passed \%data hashref instead
   of looking for things in the query object. this way the data is already
   formatted and we don't have to format data again (especially useful because
   we don't have to re-sort all the date fields, etc)

 Revision 1.25  2000/02/17 23:37:43  colin
 -get_data() now gives meaningful error messages when users enter invalid info in date fields

 Revision 1.24  2000/02/17 03:46:27  dougw
 Small modifications to take advantage of DateTime changes.
 Using $obj instead of $obj->time_local;

 Revision 1.23  2000/02/11 18:52:00  colin
 - (doug) HTML_* methods now use DateTime to manage date info.
 - (colin) Changed ui() so that a) it caches the hasref if called as an object method and b)
   allows you to override default settings (and add others) when calling the method, as
   opposed to calling SUPER::ui() and then re-setting the resulting hashref.

 Revision 1.22  2000/02/08 03:34:31  zack
 - documented the %fields class variable
 - added not_null to field options (index [4])
 - implemented flexible sanity checking
   - added sane_regex()
   - added sane_minlength() and sane_maxlength()
 - updated docs for fieldoptions() and fieldsanity()
 - HTML_textarea(): 'WRAP' defaults to 'VIRTUAL'

 Revision 1.21  2000/02/04 19:48:28  derek
  - Fixed two instances where $ui wasn't being accessed to include font tags

 Revision 1.20  2000/02/04 19:28:45  derek
  - Changed Cancel button on View page to Return to List and modified flow
    to reflect the change
  - Added tons of CGI HTML code to make the Chromium interface look better

lib/BingoX/Chromium.pm  view on Meta::CPAN

 postadd_handler()
 hidden_fields()
 display_list_buttons()
 display_modify_buttons()

 HooHah!

 Revision 1.13  2000/01/24 22:19:39  dougw
 Adam added adminuri

 Revision 1.12  2000/01/24 22:11:03  colin
 added some Center tags.

 Revision 1.11  2000/01/21 22:08:24  colin
 added display_start_html().

 Revision 1.9  2000/01/21 21:35:26  colin
 took out an extra warn(). my bad.

 Revision 1.6  2000/01/12 22:43:35  adam
  - removed Carbon::debug

 Revision 1.5  2000/01/11 02:30:19  zack
 HTML_textarea() now accepts a -WRAP option (default 'NONE')
 HTML_checkbox() works with "add" functionality

 Revision 1.4  1999/12/21 00:51:57  zack
 implemented selections. added selection()

 Revision 1.3  1999/12/05 04:05:38  greg
 new - fixed _db_class to be generic instead of hard coded to 'Mogwai'
 dbh - now handles the cleanup of cached dbh instead of Data

 Revision 1.2  1999/12/04 23:48:08  greg
 fixed POD errors

 Revision 1.1.1.1  1999/12/03 20:10:40  adam
 START


=head1 SEE ALSO

perl(1).

=head1 KNOWN BUGS

None

=head1 TODO

=over 4

=item * HTML_checkbox - needs work

=item * HTML_checkboxes (for multiple checkboxes)

=item * HTML_radio

=item * HTML_file - needs work

=item * HTML_popup - should support getting a hashref or a coderef as the LABELS or VALUES

=item * HTML_date - Only supports PST (hardcoded text)

=item * HTML_date - should it be some DateTime dependant? Is there a way to make it more universal?

=item * HTML_date - Needs to be able to show hours and minutes in a flexable way.

=item * HTML_date - Needs ability to display time in 24 hour time. (Fix in get_data as well).

=item * display_modify, view, list - need class data to control HTML options like title, table sizes etc...

=item * get_data - needs to be able to get times as well as dates in 24hr and 12hr formats.

=item * %fields - figure out how fields hash would pass other options to HTML methods

=item * %fields - figure out how to structure relationship info (many2many vs. many2one)

=item * %fields - figure out how to structure sanity information in hash 

=item * Should flow be broken up into different methods based on displaymode.

=item * Flow should be controllable with class data.  ie. to View before Modify.  Search before List.

=item * display_search() - needs to be added.

=item * Apache error page (nicer then Server Error)

=item * New class variable for adminpath (Where that thing can be administered).

=item * Add seperator method (for drawing HRs) between column edit things.

=item * HTML_scrolling (or any method that relates) - Can link to that methods view page for that object.

=item * HTML methods should use options hash from fields hash.

=item * HTML_popup - doesn't totally work because I don't know how one 2 many carbon relationships 
   work.  I am also not sure if I want to structure the class data the way I did.  It also 
   doesn't support composite primary keys (how would it?)

=item * need HTML_popupwindow method which lets users select related items from a js pop-up window. 
   (See Derek's Code or CyberStore Code)

=item * have AUTLOAD create dynamic methods

=item * dbh() - doesn't use Carboniums dbh.  Doesn't cache dbh object.  Should just 
   call Carboniums dbh. (or uses object's dbh.)

=back

=head1 COPYRIGHT

    Copyright (c) 2000, Cnation Inc. All Rights Reserved. This module is free
    software. It may be used, redistributed and/or modified under the terms
    of the GNU Lesser General Public License as published by the Free Software
    Foundation.

    You should have received a copy of the GNU Lesser General Public License
    along with this library; if not, write to the Free Software Foundation, Inc.,
    59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

=head1 AUTHORS

 Adam Pisoni <adam@cnation.com>

=cut



( run in 1.050 second using v1.01-cache-2.11-cpan-364913b4093 )