NAME
Labyrinth::Globals - Configuration and Parameter Handler for Labyrinth
SYNOPSIS
use Labyrinth::Globals qw(:all);
# database object creation
DBConnect();
# Interface (CGI) parameter handling
ParseParams();
DESCRIPTION
The Globals package contains a number of variables and functions that are used across the system. The variables contain input and output values, and the functions are generic.
EXPORT
All by default.
use Labyrinth::Globals qw(:all); # all methods
FUNCTIONS
Loaders
- LoadAll([$dir])
-
LoadAll() automatically loads and instatiates many global variables. The method assumes default values are required. Can be called with a base install directory path, which is then used by LoadSettings().
This method should be called at the beginning of any script.
- LoadSettings($dir)
-
LoadSettings() loads a settings file (config/settings.ini) and stores them in an internal hash. Typical settings are database settings (eq driver, database, user, password) and general settings (eg administrator email).
LoadSettings() can be passed the name of the base install directory, or it will attempt to figure it out via the current working directory.
- LoadRules()
-
LoadRules() loads a rules file (default is parserules.ini or the name of the 'parsefile' in the settings configuration file) and store the rules in an internal hash. This hash is then used to verify the contains of any interface (CGI) parameters passed to the script.
Note that as LoadRules() can be called many times with different rules files, only the last value of a given rule is stored. This is useful if you wish to have a standard rules file and wish to load further or different rules dependant upon the script being used.
Script Name
Database Handling
- DBConnect()
-
The method to initiate the Database access object. The method passes the values held within the internal settings (set LoadSettings()), to the DB access object constructor. It returns and stores internally the object reference, which can be accessed across the system via the $dbi scalar.
- dbh
-
Returns the reference to the DB access object, as created by the DBConnect() method, or calls DBConnect() if not previously invoked.
Interface Parameter Handling
- ParseParams($rules)
-
ParseParams() reads and validates the interface (CGI) parameters that are sent via a HTTP request, before storing them in the %cgiparams hash. Each parameter must have a rule for it to be accepted.
The rules file (default is parserules.ini) is automatically loaded and stored.
All valid input parameter values (scalars only) are also automatically stored in the template variable hash, %tvars. This is to enable templates to be reparsed in the event of an error, and retain the user's valid entries.
SEE ALSO
IO::File,
Cwd,
File::Path,
File::Basename,
File::Spec::Functions,
Data::FormValidator,
Data::FormValidator::Constraints::Upload
Labyrinth
AUTHOR
Barbie, <barbie@missbarbell.co.uk> for Miss Barbell Productions, http://www.missbarbell.co.uk/
COPYRIGHT & LICENSE
Copyright (C) 2002-2014 Barbie for Miss Barbell Productions
All Rights Reserved.
This module is free software; you can redistribute it and/or
modify it under the Artistic License 2.0.