DBIx-Frame

 view release on metacpan or  search on metacpan

DBIx/Frame/CGI.pm  view on Meta::CPAN

  
  unless ( $$options{'nomenu'} ) { 
    push @return, "<center> <h2>Table Options</h2> </center> ";
    push @return, "<center>" . $self->html_menu($table) . "</center>";
  }
  
  return wantarray ? @return : join("\n", @return);
}


=item html_actions ( [ TABLE [, PARAMS, OPTIONS ]] )

Returns a table of table/action pairs available to the user.  Gets the
information from C<tables()> and C<@DBIx::Frame::ACTIONS>.  Each column of
the table is a different action; each row is a table.  

=cut

sub html_actions {
  my ($self, $table, $params, $options, @other) = @_;
  my @list = sort $self->tables;
  my @return = "<table align=center width=100%>";
  my $list = scalar @list;

  foreach my $action ( @ACTIONS ) {
    my $act = ucfirst $action;
    push @return, "  <td align=center> $act </td>";
  }
  push @return, " </tr>";

  foreach my $table (@list) {
    next unless $table;
    foreach my $action ( @ACTIONS ) {
      next unless $action;
      push (@return, "  <td align=center>" . 
     		"<a href='$0?table=$table&action=$action'>$table</a>"
	. "</td>");
    }
    push (@return, " </tr>");
  }
  push (@return, "</table>\n");
  wantarray ? @return : join("\n", @return);
}

=item html_menu ( [TABLE] )

Returns a menu in HTML to navigate the various tables and actions
available to the user.  Gets the information from C<tables()> and 
C<@DBIx::Frame::ACTIONS>.  The menu is an HTML form that reinvokes the
calling program, using the fields 'action' and 'table'.  

=cut

sub html_menu {
  my ($self, $table, @other) = @_;
  my $cgi = new CGI;

  my @return = $cgi->start_form;
  
  my @list = sort $self->tables;
  push @return, $cgi->popup_menu('table', \@list, $table);
  foreach ( @ACTIONS ) { 
    next unless $_; 
    push @return, $cgi->submit('action', ucfirst $_ ); }
  push @return, $cgi->end_form;

  wantarray ? @return : join("\n", @return);
}

=back

=head2 HTML Form Layout 

The HTML Form Layout functions are generally based around each table's
C<html()> function, which is defined in its class.  Note that this
function must be properly created if you expect these functions to
actually do anything.

=over 4

=item html_create ( TABLE, PARAMS, OPTIONS )

Returns an HTML form containing the code necessary to insert an item into
the database.  Submitting the form should invoke C<html_insert()>.

=cut

sub html_create {
  my ($self, $table, $params, $options, @other) = @_;
  my $html = $self->html->{$table}; 
  my @return;
  push @return, "<center><font size=+2>Add to '$table'</font></center><br />" 
			unless $$options{'quiet'};
  push @return, <<EOL;
  <center>
   <FORM action='$0' method=post>
    <input type=hidden name=action value='insert'>
    <input type=hidden name=table value=$table>
    @{[ $self->_replace($params || {}, $html->( $self, undef, 'create', 
			 $options )) ]}
   </FORM>
  </center>
EOL
  wantarray ? @return : join("\n", @return);
}

=item html_list ( TABLE, PARAMS, OPTIONS )

=item html_list_banner ( TABLE, PARAMS, OPTIONS )

=item html_list_nosearch ( TABLE, PARAMS, OPTIONS, ENTRIES )

Returns an HTML table containing data selected with C<PARAMS>, using 
C<make_list()>.  (Note that this does not use the C<html()> function.)
The table also includes links to a perform more actions on the items -
by default, it's 'view', but 'edit' and 'delete' can be added.

Valid options for C<OPTIONS>:

  nodetail	Doesn't offer 'view' action
  admin		Offers 'edit' and 'delete' action



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