Re: Mixing classes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Tomy,

I did the same thing!

I´ve used a class called framework to encapsulate everything... here is what looks like:

framework.inc.php
<?php
/**
* Project: BBBM Framework
* File: framework.inc.php
*
* @desc Main Framework Include
* @link http://www.bbbm.com.br/
* @copyright 2004 Bruno B B Magalhaes
* @author Bruno B B Magalhaes <brunomagalhaes@xxxxxxxxxxx>
* @package BBBM Framework
* @version 0.5-dev
*/
session_start();

/**
* Include Core Classes
*/
require_once(FRAMEWORK_DIR.'core/framework.class.php');
require_once(FRAMEWORK_DIR.'core/preferences.class.php');
require_once(FRAMEWORK_DIR.'core/languages.class.php');
require_once(FRAMEWORK_DIR.'core/database.class.php');
require_once(FRAMEWORK_DIR.'core/authentication.class.php');
require_once(FRAMEWORK_DIR.'core/input.class.php');
require_once(FRAMEWORK_DIR.'smarty/smarty.class.php');
require_once(FRAMEWORK_DIR.'core/output.class.php');
require_once(FRAMEWORK_DIR.'core/modules.class.php');
require_once(FRAMEWORK_DIR.'core/validation.class.php');
require_once(FRAMEWORK_DIR.'core/filters.class.php');

/**
* Include Shared Classes
*/
include_once(FRAMEWORK_DIR.'shared/categories.class.php');

?>

framework.class.php
<?php
/**
* Project: BBBM Framework
* File: framework.class.php
*
* @desc Main Framework Class
* @link http://www.bbbm.com.br/
* @copyright 2004 Bruno B B Magalhaes
* @author Bruno B B Magalhaes <brunomagalhaes@xxxxxxxxxxx>
* @package BBBM Framework
* @version 0.5-dev
*/
class framework
{
var $preferences;
var $database;
var $authentication;
var $input;
var $output;
var $modules;
var $validation;
var $filters;
var $languages;

var $controller;

/**
* PHP 4 Constructor
*/
function framework()
{
$this->preferences = new preferences(); // Preferences Layer
$this->languages = new languages(); // Language Layer
$this->database = new database($this->preferences); // Database Layer
$this->input = new input(); // Input Layer
$this->modules = new modules($this->database); // Modules Layer
$this->authentication = new authentication($this->database); // Authentication Layer
$this->output = new output($this->preferences,$this->languages); // Ouput Layer
$this->validation = new validation(); // Validation functions
$this->filters = new filters(); // Filters Functions
}

function is_valid_controller($contoller='')
{
if($contoller != '')
{
$contoller = addslashes(strip_tags($contoller));
$this->database->build_table(array('controllers'));

$query = 'SELECT
controllerStatus
FROM
'.$this->database->table['controllers'].'
WHERE
controllerPath=\''.$contoller.'\'
';

$this->database->query($query);

if($this->database->num_rows() > 0)
{
$this->database->fetch_array();

if($this->database->row['controllerStatus'] > 0)
{
$this->controller = $contoller;
return true;
}
else
{
$this->controller = false;
return false;
}
}
else
{
$this->controller = false;
return false;
}
}
else
{
return false;
}
}
}
?>



Regards, Bruno B B Magalhães

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux