No to prosze - zauwaz, ze dla adodb przeznaczyłem sobną metodę. Być może dla smarty tez by było warto...
Dodatkowo chciałem zauważyć, ze zawsze w CORE dołaczam 2 klasy c_error i c_info - które nie są oczywisćie konieczne do poprawnego działania.
[php:1:8d154cdda7]<?php
/**
* 03-12-07 by DeyV
*/
class core{
function core( $arrParm='' ) { $this->__construct( &$arrParm ); }
var $arrDir = array(
'class' => 'core/class/' ,
'mods' => 'core/mods/' ,
);
var $arrMods = array();
var $arrClass = array();
var $objError, $objInfo ;
function __construct( $arrParm ='' )
{
if( !empty( $arrParm['dirClass'] ) ) {
$this->arrDir['class'] = $arrParm['dirClass'] ;
}
if( !empty( $arrParm['dirMods'] ) ) {
$this->arrDir['mods'] = $arrParm['dirMods'] ;
}
require_once $this->arrDir['class'] . "c_error.php";
$this->objError = new c_error;
require_once $this->arrDir['class'] . "c_info.php";
$this->objInfo = new c_info;
}
function isSetMod( $strName='', $strPrefix='' )
{
return( isset($this->arrMods[ $strPrefix . $strName ] ) );
}
function &getMod( $strName='', $strPrefix='' )
{
if( empty( $strName ) )
{
return FALSE;
}
if( $this->isSetMod( $strName , $strPrefix ) )
{
return( $this->arrMods[ $strPrefix . $strName ] );
}elseif( class_exists( $strName ) )
{
$this->arrMods[ $strPrefix . $strName] = new $strName;
return( $this->arrMods[ $strPrefix . $strName] );
}elseif( file_exists ( $this->arrDir['mods'] . $strName . '.mod.php' ) )
{
include_once( $this->arrDir['mods'] . $strName . '.mod.php' );
if( class_exists( $strName ) )
{
$this->arrMods[$strPrefix . $strName] = new $strName;
return( $this->arrMods[ $strPrefix . $strName] );
} else
{
return FALSE;
}
}else
{
trigger_error('bład: nie mozna zaladowac moda <b>'. $strName . '</b> ('. $this->arrDir['mods'] . $strName . '.mod.php)' );
return FALSE;
}
}
function &getADoDB( )
{
if( empty( $this->arrClass['ADoDB'] ) )
{
require_once('../lib/adodb/adodb.inc.php');
$this->arrClass['ADoDB'] =& ADONewConnection( $GLOBALS['dbtyp'] );
$this->arrClass['ADoDB'] -> debug = $GLOBALS['dbdebug'];
if( false === $this->arrClass['ADoDB'] ->
Connect( $GLOBALS['dbhost'], $GLOBALS['dbuser'], $GLOBALS['dbhaslo'], $GLOBALS['dbname'] ) )
{
$this->objError->dodaj("Bł±d startu","Brak połaczenia z baz± danych");
return false;
}
}
return $this->arrClass['ADoDB'] ;
}
}
?>[/php:1:8d154cdda7]