Help-Site Computer Manuals
Software
Hardware
Programming
Networking
  Algorithms & Data Structures   Programming Languages   Revision Control
  Protocols
  Cameras   Computers   Displays   Keyboards & Mice   Motherboards   Networking   Printers & Scanners   Storage
  Windows   Linux & Unix   Mac

Postgres::Handler::HTML
HTML Component for PostgreSQL data.

Postgres::Handler::HTML - HTML Component for PostgreSQL data.


NAME

Postgres::Handler::HTML - HTML Component for PostgreSQL data.


DESCRIPTION

Accessors for PostgreSQL data. Simplifies data access through a series of standard class methods.


SYNOPSIS


 # Instantiate Object

 #

 use Postgres::Handler;

 my $DB = Postgres::Handler->new(dbname=>'products',dbuser=>'postgres',dbpass=>'pgpassword');

 

 # Retrieve Data & List Records

 #

 $DB->PrepLEX('SELECT * FROM products');

 while ($item=$DB->GetRecord()) {

     print "$item->{PROD_ID}\t$item->{PROD_TITLE}\t$item->{PROD_QTY}\n";

 }

 

 # Add / Update Record based on CGI Form

 # assuming objCGI is an instatiated CGI object

 # if the CGI param 'prod_id' is set we update

 # if it is not set we add

 #

 my %cgimap;

 foreach ('prod_id','prod_title','prod_qty') { $cgimap{$_} = $_; }

 $DB->AddUpdate( CGI=>$objCGI     , CGIKEY=>'prod_id', 

                 TABLE=>'products', DBKEY=>'prod_id',

                 hrCGIMAP=>\%cgimap

                );


REQUIRES


        Subclass of Postgres::Handler

        Postgres::Handler

                 +- CGI::Carp

                 +- CGI::Util

                 +- Class::Struct

                 +- DBI


METHODS




=cut

#==============================================================================

#--------------------------------------------------------------------

CheckBox()

 Produce an HTML Checkbox for the specified boolean field

 Parameters

        TABLE                   =>      name of table to get data from

        CBNAME          =>      name to put on the checkbox, defaults to VALUE

        VALUE                   => field that contains the t/f use to set the checkmark

        LABEL                   => what to put next to the checkbox as a label (defaults to field name)

        KEY                     =>      value of the key used to lookup the data in the database

        CHECKED         => set to '1' to check by default if KEY not found

        SCRIPT          => script tags (or class tags) to add to checkbox HTML

        NOLABEL         => set to '1' to skip printing of label

 Action

 prints out the HTML Checkbox, checked if field is true

 Return

 0 = failure, sets error message, get with lasterror()

 1 = success
Pulldown()

 Produce an HTML pulldown menu for the specified table/fields

 Parameters

        TABLE                   =>       name of table to get data from

        PDNAME          =>       name to put on the pulldown, defaults to VALUE

        VALUE                   =>  which field we stick into the option values

        SHOW                    =>  which field we spit out on the selection menu, defaults to VALUE

        SELECT          =>  mark the one with this VALUE as selected

        ALLOWBLANK      => set to 1 to allow blank selection (noted as ---)

        ORDERBY         => special ordering, defaults to SHOW field

        WHERE                   => filtering selection clause (without WHERE, i.e. pdclass='class1')

        SCRIPT          => event script, such as 'onChange="DoSumthin();"'

 Action

 prints out the HTML pulldown
RadioButtons()

 Produce an HTML Radio Button menu for the specified table/fields

 Parameters

        TABLE                   =>       name of table to get data from

        RBNAME          =>       name to put on the pulldown, defaults to VALUE

        VALUE                   =>  which field we stick into the option values

        SHOW                    =>  which field we spit out on the menu, defaults to VALUE

        SELECT          =>  mark the one with this VALUE as selected

        ORDERBY         => special ordering, defaults to SHOW field

        WHERE                   => filtering selection clause (without WHERE, i.e. rbclass='class1')

 Action

 prints out the HTML Radio Buttons
ShowHeader()

 Display header for retrieved records in an HTML <table> row

 One of these 2 id required

 DATAREF                => reference to hash storing record 

 DISPCOLS       => reference to array of columns to show, defaults to hash key names

 Optional parameters

 FULLNAME       => set to 1 to show full field name, otherwise we trunc up to first _

 SORT                   => set to 1 to sort keys
ShowRecord()

 Display retrieved records in an HTML <table> row

 Parameters

 DATAREF                => reference to hash storing record (required)

 DATAMODREF     => reference to hash storing data modifiers

                                                The field specified by the hash key is replaced

                                                with the data specified in the value.

                                                Use $Record{???} to place the record field ??? within 

                                                the substitution string.

                                                If the modifier starts with ~eval(<blah>) then the modifier

                                                evaluates <blah> and returns it's result.  For example:

                                                $datmodref{THISFIELD} = '~eval(substr($Record{FIELD},0,10))';

                                                would display the first 10 characters of the field.

 DISPLAYREF     => reference to hash storing special cell formats for

                                                each data element. Key = element, value = <td> modifier

 DISPCOLS       => reference to array of columns to show, defaults to hash key names

 TRIMDATES      => set to 'minute' or 'day' to trim date fields

                                                date fields are any ending in 'LASTUPDATE' 

 WRAP                   => set to 1 to allow data wrapping

 SORT                   => set to 1 to sort keys

 ASFORM         => set to 1 to show data as input form fields

 NOTABLE                => set to 1 to drop all table html tags

 OUTPUT         => output file handle

 ROWMOD         => modifier to <tr> row definition

 CELLMOD                => modifier to each <td> Cell definition
ValOrZero()

 Set these CGI parameters to 0 if not defined.  Used for checkbox

 form variables when we want to ensure the value is set to 0 (false)

 if they are not set via the CGI interface.

 HTML checkboxes are NOT passed to the CGI module if they are not

 checked, so this function helps us out by forcing the assumption

 that the CGI parameters passed here should be 0 if the are not

 received.

 Parameters

 [0] - the CGI variable

 [1] - an array of CGI parameters to be set

 Action

 Sets the named CGI parameters to 0 if they are not set, otherwise

 leaves the original value intact.
ShowThe

 Load the DB record and spit out the value of the specified field

 Parameters 

 [0] = field name in "table!field" format

 [1] = key value to lookup

 [2] = trim to this many characters


AUTHOR


 Lance Cleveland, Advanced Internet Technology Consultant

 Contact info@charlestonsw.com for more info.


ABOUT CSA


 Charleston Software Associates (CSA) is and advanced internet technology

 consulting firm based in Charleston South Carolina.   We provide custom

 software, database, and consulting services for small to mid-sized

 businesses.

 For more information, or to schedule a consult, visit our website at

 www.CharlestonSW.com


CONTRIBUTIONS


 Like the script and want to contribute?  

 You can send payments via credit card or bank transfer using

 PayPal and sending money to our info@charlestonsw.com PayPal address.


COPYRIGHT


 (c) 2005, Charleston Software Associates

 This script is covered by the GNU GENERAL PUBLIC LICENSE.

 View the license at http://www.charlestonsw.com/community/gpl.txt

 or at http://www.gnu.org/copyleft/gpl.html


REVISION HISTORY


 v0.6 - Jun 13 2005

      added script option to checkbox type

                added no label option to checkbox type

 v0.5 - Jun 09 2005

      moved under Postgres::Handler:: namespace

                initial CPAN release

 v0.4 - Apr 28 2005

                pod updates

                Updated CheckBox() w/ default 'checked' option

                Added ShowThe() method

 v0.1 - Dec/2004

      Initial private release
Programminig
Wy
Wy
yW
Wy
Programming
Wy
Wy
Wy
Wy