<?php
// $Id: pimox.php,v 1.4 2001/11/21 15:47:04 www Exp $
// Project : The pimox Engine Project
// Module : The pimox Engine
// This program is licensed as explained in the LICENCE-file of the distribution
/**
** The pimox Engine class. On top of the each page, before the <html>-tag,
** user would create a pimox object with a given configuration information:
** <pre>
** $pimox_include_path = "../pimox/";
** require_once ($pimox_include_path . "pimox.php");
** $pimox = new pimox;
** $pimox->init( "conf_defs", "en" );
** </pre>
** The object's pointer is then passed to consecutive objects created further down
** on the HTML-stream of the page. Therefore all other pimox objects have access
** to the unique pimox engine object and its methods.
** @author hide@address.com
** @version $Revision: 1.4 $
**/
class pimox {
// ----------------------------- Public fields ----------------------------------
/**
** (read only) When true, The pimox Engine has succesfully started
** @public
** @type boolean
**/
var $pimoxUp;
/**
** Print pimox's error messages when true
** @public
** @type boolean
**/
var $printErrors;
/**
** Print debug information when true
** @public
** @type boolean
**/
var $printDebug;
/**
** Output engine selection (HTML4, XML, whatever available)
** @public
** @type string
**/
var $outEngine;
/**
** Style engine selection (CSS2, CSS3, whatever available)
** @public
** @type string
**/
var $styEngine;
/**
** Allow client side form field validity testing when true
** @public
** @type boolean
**/
var $clsValidity;
/**
** Client side scripting engine (JavaScript 1.2, whatever available)
** @public
** @type string
**/
var $clsEngine;
/**
** Database engine selection (MySQL, whatever available)
** @public
** @type string
**/
var $dbEngine;
/**
** The pimox Database Engine object with the connection to the management database.
** The exact type depends of the configuration file contents.
** @type pimoxDb
**/
var $pxAdmDb;
// ---------------------------- Private fields ----------------------------------
/**
** Settings for this instance are in this directory
** @type string
**/
var $confdir;
/**
** Language directory (ex. 'en')
** @type string
**/
var $lang;
/**
** Character set used with the language
** @type string
**/
var $charset;
/**
** Where the Management Database is located.
** @type string
**/
var $adminDbHost;
/**
** What is the name of the Management Database
** @type string
**/
var $adminDbName;
/**
** what is the password for the Administrative User
** @type string
**/
var $adminDbPassword;
// ----------------------------- Public methods ---------------------------------
/**
** Create an instance of The pimox Engine.
** Note that the constructor does not start any sub engines and that the Engine
** is marked not yet running.
** <p>
** The pimox instance creation <em>must</em> occur before any headers are sent
** out. This means usually that it should be in top of the file.</p>
** <p>
** <b>Warning:</b> Do not use your own forms to send data to pages that are
** using The pimox Engine. Due to the use of the session control, it is not
** possible to return to your own form using the browser's back button without
** loosing all the data in your form's fields. Never mix your own forms
** with the forms generated by The pimox Engine.</p>
** @return void
** @returns void
**/
function pimox() {
/** ---------------------- NOTE -------------------------------
** About PHP's session_start() function:
** 1) It must be called before any headers are sent!!
** 2) When it is used, user _cannot_ press the back button.
** If he/she does, all the form's fields are cleared!!
** Users will be unhappy if you ask them to "press the
** back button".
**/
session_start(); // If you grep(1)'ed this, please read above..
/** ------------------------------------------------------------ **/
$this->pimoxUp = false;
} // constructor
/**
** Starts The pimox Engine
** @param pimox_configuration_dir The instance's streamed-in configuration files,
** for example, "conf_wap".
** @param pimox_language_dir The instance's language files directory,
** for example, "fr".
** @return true if success, false otherwise
** @returns boolean
**/
function init( $pimox_configuration_dir, $pimox_language_dir ) {
global $pimox_include_path;
// Configuration
$this->confdir = $pimox_configuration_dir;
include_once ( $this->confThis( $this ) );
// Language
$this->lang = $pimox_language_dir;
include_once ( $this->langThis( $this ) );
// Administrative database
include_once( $this->dbeClass( "pimoxDb" ) );
eval ("\$this->pxAdmDb = new pimoxDb$this->dbEngine ( \$this,
\$this->adminDbName,
\$this->adminDbHost,
\$this->adminDbUser,
\$this->adminDbPassword);");
if ( !$this->pxAdmDb ) {
return;
} // cannot open database connection
if ( !$this->pxAdmDb->connect() ) {
return false;
} // connection to the management database failed
$this->pimoxUp = true;
return true;
} // init()
/**
** Resolve the configuration directory path
** @return directory path, extended with a slash
** @returns string
**/
function confDir () {
global $pimox_include_path;
return $pimox_include_path . $this->confdir . "/";
} // confDir
/**
** Resolve the configuration file path for a derived class. Example:
** <pre>
** <em>class</em> pimoxMyClassHTML4 extends pimoxMyClass {
** ..
** function pimoxMyClassHTML4 ( &$pimox, ...
** ..
** include ( $pimox->confThis( $this ) );
** </pre>
** @param object Give always "$this"
** @return file path
** @returns string
**/
function confThis ( &$object ) {
return $this->confDir() . "pimoxConf_" . get_class($object) . ".php";
} // confThis
/**
** Resolve the configuration file path for a base class
** <pre>
** <em>class</em> pimoxMyClass {
** ..
** function pimoxMyClass ( &$pimox, ...
** ..
** include ( $pimox->confBase( $this ) );
** </pre>
** @param object Give always "$this"
** @return file path
** @returns string
**/
function confBase ( &$object ) {
return $this->confDir() . "pimoxConf_" . get_parent_class($object) . ".php";
} // confBase
/**
** Resolve the language directory path
** @return directory path, extended with a slash
** @returns string
**/
function langDir () {
global $pimox_include_path;
return $pimox_include_path . $this->lang . "/";
} // langDir
/**
** Resolve the language file path for a derived class. Example:
** <pre>
** <em>class</em> pimoxMyClassHTML4 extends pimoxMyClass {
** ..
** function pimoxMyClassHTML4 ( &$pimox, ...
** ..
** include ( $pimox->langThis( $this ) );
** </pre>
** @param object Give always "$this"
** @return file path
** @returns string
**/
function langThis ( &$object ) {
return $this->langDir() . "pimoxLang_" . get_class($object) . ".php";
} // langThis
/**
** Resolve the language file path for a base class
** <pre>
** <em>class</em> pimoxMyClass {
** ..
** function pimoxMyClass ( &$pimox, ...
** ..
** include ( $pimox->langBase( $this ) );
** </pre>
** @param object Give always "$this"
** @return file path
** @returns string
**/
function langBase ( &$object ) {
return $this->langDir() . "pimoxLang_" . get_parent_class($object) . ".php";
} // langBase
/**
** Resolve the Database Engine directory path
** @return directory path, extended with a slash
** @returns string
**/
function dbeDir () {
global $pimox_include_path;
return $pimox_include_path . $this->dbEngine . "/";
} // dbeDir
/**
** Resolve the path to the class file of the Database Engine. Example of use:
** <pre>
** $inst = &$this->pimox;
** include_once ( $inst->dbeClass ( "pimoxDb" ) );
** eval ("\$this->myDbAccess = new pimoxDb$inst->dbEngine ( \$inst, ... );");
** </pre>
** @param baseclassname Name of the abstract Database Engine class
** @return file path
** @returns string
**/
function dbeClass ( $baseclassname ) {
global $pimox_include_path;
return $pimox_include_path . "/" . $this->dbEngine . "/" . $baseclassname . $this->dbEngine . ".php";
} // dbeClass
/**
** Resolve the Output Engine directory path
** @return directory path, extended with a slash
** @returns string
**/
function opeDir () {
global $pimox_include_path;
return $pimox_include_path . $this->outEngine . "/";
} // opeDir
/**
** Resolve the path to the class file of the Output Engine. Example of use:
** <pre>
** $inst = &$this->pimox;
** include_once ( $inst->opeClass ( "pimoxMyClass" ) );
** eval ("\$this->myMyClass = new pimoxMyClass$inst->opeEngine ( \$inst, ... );");
** </pre>
** @param baseclassname Name of the abstract Output Engine class
** @return file path
** @returns string
**/
function opeClass ( $baseclassname ) {
global $pimox_include_path;
return $pimox_include_path . "/" . $this->outEngine . "/" . $baseclassname . $this->outEngine . ".php";
} // opeClass
/**
** Resolve the Style Engine directory path
** @return directory path, extended with a slash
** @returns string
**/
function styDir () {
global $pimox_include_path;
return $pimox_include_path . $this->styEngine . "/";
} // styDir
/**
** Resolve the path to the class file of the Style Engine. Example of use:
** <pre>
** $inst = &$this->pimox;
** include_once ( $inst->styClass ( "pimoxMyClass" ) );
** eval ("\$this->myMyClass = new pimoxMyClass$inst->styEngine ( \$inst, ... );");
** </pre>
** @param baseclassname Name of the abstract Style Engine class
** @return file path
** @returns string
**/
function styClass ( $baseclassname ) {
global $pimox_include_path;
return $pimox_include_path . "/" . $this->styEngine . "/" . $baseclassname . $this->styEngine . ".php";
} // styClass
/**
** Resolve the Client Side Scripting Engine directory path
** @return directory path, extended with a slash
** @returns string
**/
function clsDir () {
global $pimox_include_path;
return $pimox_include_path . $this->clsEngine . "/";
} // clsDir
/**
** Resolve the path to the class file of the Client Side Scripting Engine.
** Example of use:
** <pre>
** $inst = &$this->pimox;
** include_once ( $inst->clsClass ( "pimoxMyClass" ) );
** eval ("\$this->myMyClass = new pimoxMyClass$inst->clsEngine ( \$inst, ... );");
** </pre>
** @param baseclassname Name of the abstract Client Side Scripting class
** @return file path
** @returns string
**/
function clsClass ( $baseclassname ) {
global $pimox_include_path;
return $pimox_include_path . "/" . $this->clsEngine . "/" . $baseclassname . $this->clsEngine . ".php";
} // clsClass
/**
** An abstract method of the base class has been called. The abstract method should
** contain the following code to indicate that it has not been overridden:
** <pre>
** function theMethodToImplement ( $variable1, ...
** ..
** $this->pimox->methodNotImplemented ( $this, "theMethodToImplement" );
** </pre>
** @param object Give always "$this"
** @param method Name of the abstract method
** @return nothing
** @returns void
**/
function methodNotImplemented ( &$object, $method ) {
if ( $this->printErrors ) {
$baseclassname = get_parent_class($object);
$classname = get_class($object);
echo "<br>$baseclassname::$classname::$method - not implemented<br>";
} // the want to know about these
} // methodNotImplemented
// ---------------------------- Private methods ---------------------------------
} // pimox
?>