NAME
    CGI::AppBuilder - Configuration initializer

SYNOPSIS
      use CGI::AppBuilder;

      my $cg = CGI::AppBuilder->new('ifn', 'my_init.cfg', 'opt', 'vhS:a:');
      my $ar = $cg->get_inputs; 

DESCRIPTION
    There are already many application builders out there. Why you need
    another one? Well, if you are already familiar with CGI::Builder or
    CGI::Application, this one will provide some useful methods to you to
    read your configuration file and pre-process your templates. Please read
    on.

   new (ifn => 'file.cfg', opt => 'hvS:')
    Input variables:

      $ifn  - input/initial file name. 
      $opt  - options for Getopt::Std

    Variables used or routines called:

      None

    How to use:

       my $ca = new CGI::AppBuilder;      # or
       my $ca = CGI::AppBuilder->new;     # or
       my $ca = CGI::AppBuilder->new(ifn=>'file.cfg',opt=>'hvS:'); # or
       my $ca = CGI::AppBuilder->new('ifn', 'file.cfg','opt','hvS:'); 

    Return: new empty or initialized CGI::AppBuilder object.

    This method constructs a Perl object and capture any parameters if
    specified. It creates and defaults the following variables:

      $self->{ifn} = ""
      $self->{opt} = 'hvS:'; 

   start_app ($prg,$arg,$nhh)
    Input variables:

      $prg  - program name 
      $arg  - array ref for arguments - %ARGV
      $nhh  - no html header pre-printed 
              1 - no HTML header is set in any circumstance
              0 - HTML header will be set when it is possible

    Variables used or routines called:

      build_html_header - build HTML header array
      Debug::EchoMessage
        echoMSG  - echo messages
        start_log - start and write message log
      CGI::Getopt
        get_inputs - read input file and/or CGI form inputs
    
    How to use:

       my ($q, $ar, $ar_log) = $self->start_app($0,\@ARGV);

    Return: ($q,$ar,$ar_log) where

      $q - a CGI object
      $ar - hash ref containing parameters from input file and/or 
            CGI form inputs and the following elements:
        ifn - initial file name
        opt - command input options
        cfg - configuratoin array
        html_header - HTML header parameters (hash ref)
        msg - contain message hash
      $ar_log - hash ref containing log information

    This method performs the following tasks:

      1) initial a CGI object
      2) read initial file if specified or search for a default file
         (the same as $prg with .ini extension) and save the file name
         to $ar->{ifn}. 
      3) define message level
      4) start HTML header and body using I<page_title> and I<page_style>
         if they are defined.
      5) parse CGI form inputs and combine them with parameters defined
         in initial file
      6) read configuration file ($prg.cfg) if it exists and save the 
         array to $ar->{cfg}
      7) prepare log record if write log is enabled

    It checks the parameters read from initial file for page_title,
    page_style, page_author, page_meta, top_nav, bottom_nav, and js_src.

   end_app ($q, $ar, $ar_log)
    Input variables:

      $q    - CGI object 
      $ar   - array ref for parameters 
      $ar_log - hash ref for log record

    Variables used or routines called:

      Debug::EchoMessage
        echoMSG - echo messages
        end_log - start and write message log
        set_param - get a parameter from hash array

    How to use:

       my ($q, $ar, $ar_log) = $self->start_app($0,\@ARGV);
       $self->end_app($q, $ar, $ar_log);

    Return: none

    This method performs the following tasks:

      1) ends HTML document 
      2) writes log records to log files 
      3) close database connection if it finds DB handler in {dbh}

   build_html_header ($q, $ar)
    Input variables:

      $q    - CGI object 
      $ar   - array ref for parameters 

    Variables used or routines called:

      Debug::EchoMessage
        echoMSG - echo messages
        set_param - get a parameter from hash array

    How to use:

      my $ifn = 'myConfig.ini'; 
      my ($q,$ar) = $s->get_inputs($ifn);
      my $hrf = $self->build_html_header($q, $ar);

    Return: hash array or array ref

    This method performs the following tasks:

      1) check the following parameters: page_title, page_style, 
         page_meta, page_author, page_target, js_src, 
      2) writes log records to log files 
      3) close database connection if it finds DB handler in {dbh}

   disp_form ($q, $ar)
    Input variables:

      $q    - CGI object 
      $ar   - array ref for parameters 

    Variables used or routines called:

      Debug::EchoMessage
        echoMSG - echo messages
        set_param - get a parameter from hash array

    How to use:

      my $ifn = 'myConfig.ini'; 
      my ($q,$ar) = $s->get_inputs($ifn);
      $self->disp_form($q, $ar);

    Return: none

    This method expects the following varialbes:

      gi - GUI items
      gc - GUI columns
      gf - GUI form
      db - database connection varialbes (optional)
      vars_keep - variables separated by comma for hidden variables

    This method performs the following tasks:

      1) checks whether GI, GC and GF variables being defined. 
      2) replaces AR, DB, GI, and GC variables with their contents
      3) builds GF elements 
      4) add hidden variables
      5) print the form

HISTORY
    * Version 0.10
        This version is to extract out the app methods from CGI::Getopt
        class. It was too much for CGI::Getopt to include the start_app,
        end_app, build_html_header, and disp_form methods.

    * Version 0.11
        Rewrote start_app method so that content-type can be changed.

SEE ALSO (some of docs that I check often)
        CGI::Getopt, Oracle::Loader, Oracle::Trigger, CGI::AppBuilder,
        File::Xcopy, Debug::EchoMessage

AUTHOR
        Copyright (c) 2005 Hanming Tu. All rights reserved.

        This package is free software and is provided "as is" without
        express or implied warranty. It may be used, redistributed and/or
        modified under the terms of the Perl Artistic License (see
        http://www.perl.com/perl/misc/Artistic.html)