/** * Creates a new Connector or retreive the existing one based on the Configuration. * * @param PhpBURN_ConfigurationItem $config * @return PhpBURN_Connection */ public static function create(PhpBURN_ConfigurationItem &$config) { $conn = self::getConnection($config->package); if (!$conn) { //Create a new connection //Loads the interface for dialect uses PhpBURN::load('Connection.IConnection'); if (PhpBURN::load("Connection.{$config->dialect}") != "error") { $className = self::getConnectionClass($config->dialect); $connectionClass = new $className(); if ($config->host != null) { $connectionClass->setHost($config->host); } if ($config->port != null) { $connectionClass->setPort($config->port); } if ($config->user != null) { $connectionClass->setUser($config->user); } if ($config->password != null) { $connectionClass->setPassword($config->password); } if ($config->database != null) { $connectionClass->setDatabase($config->database); } // if($config->options != null) //$connectionClass->setOptions($config->options); $conn = self::$connections[$config->package] = $connectionClass; } else { exit; } } return $conn; }
/** * Creates a new Dialect or retreive the existing one based on the Model and Configuration. * * @param PhpBURN_ConfigurationItem $config * @param PhpBURN_Core $obj * @return PhpBURN_Dialect */ public static function create(PhpBURN_ConfigurationItem $config, PhpBURN_Core $obj) { $dialect = self::getDialect($config->dialect); if (!$dialect) { //Loads the interface for dialect uses PhpBURN::load('Dialect.IDialect'); // Loads the correspondent dialect based on config if (PhpBURN::load("Dialect.{$config->dialect}") != "error") { $className = self::getDialectClass($config->dialect); // Instance the dialect $dialectClass = new $className($obj); $dialect = self::$dialects[$config->package] = $dialectClass; unset($dialectClass); } else { PhpBURN_Message::output('[!Cannot find dialect!]: ' . $config->dialect, PhpBURN_Message::EXCEPTION); } } return $dialect; }
<?php ################################ # Hooks ################################ define('SYS_USE_FIREPHP', false, true); ################################ # Including required files ################################ require_once 'app/phpBurn.php'; require_once 'config.php'; ################################ # Start PhpBURN needed resources ################################ PhpBURN::enableAutoload(); PhpBURN_Message::setMode(PhpBURN_Message::CONSOLE); //Migrations tool PhpBURN::load('Migrations.Reverse'); ################################ # Starting application ################################ PhpBURN_Reverse::init();
<?php PhpBURN::load('Dialect.Dialect'); PhpBURN::load("Dialect.IDialect"); /** * This class manages all content, queries and result stuff in a system level and for all database driver interaction level * it calls PhpBURN_Connection object that is the main responsable between the application data and database interaction * * @package PhpBURN * @subpackage Dialect * * @author Klederson Bueno <*****@*****.**> * */ class PhpBURN_Dialect_MSSQL extends PhpBURN_Dialect implements IDialect { /* Common Persistent Methods */ /** * (non-PHPdoc) * @see app/libs/Dialect/PhpBURN_Dialect#find() */ public function find($pk = null) { return parent::find($pk); } /** * Distinct Fields in a query * * @param $field */ public function distinct($field)
<?php ################################ # Controller Settings ################################ PhpBURN::load('Tools.Controller.ControllerConfig'); //Loading ControllerConfig Tool
<?php PhpBURN::load('Configuration.ConfigurationItem'); /** * @package PhpBURN Configuration * @author Kléderson Bueno <*****@*****.**> */ class PhpBURN_Configuration { public static $options = array(); private $connection = null; public function __construct(array $options) { $default_options = array('database' => '', 'user' => '', 'password' => '', 'class_path' => '', 'dialect' => 'MySQL', 'port' => 3306, 'host' => 'localhost', 'packages' => array()); $options = array_merge($default_options, $options); /* * Fatal Errors */ if (empty($options['database'])) { PhpBURN_Message::output('[!Empty database into configuration!]', PhpBURN_Message::ERROR); } if (empty($options['user'])) { PhpBURN_Message::output('[!Empty database user into configuration!]', PhpBURN_Message::ERROR); } if (empty($options['password'])) { PhpBURN_Message::output('[!Empty password into configuration!]', PhpBURN_Message::ERROR); } if (empty($options['class_path'])) { PhpBURN_Message::output('[!Empty class_path into configuration!]', PhpBURN_Message::ERROR); } /**
public function chooseViewMethod() { self::$viewMethod = self::$viewMethod = !defined('PHPBURN_VIEWS_METHOD') ? 'default' : PHPBURN_VIEWS_METHOD; PhpBURN::load('Tools.Views.' . self::$viewMethod); $classString = sprintf("%s_PhpBURN_ViewProcess", self::$viewMethod); return new $classString(); }
/** * Starts the PhpBURN Application - Should be called at the index of the application * <code> * PhpBURN::StartApplication(); * </code> */ public static function startApplication() { self::enableAutoload(); // Setting up Controller if (array_search('Controller', get_declared_classes()) == true) { PhpBURN::load('Tools.Util.Router'); include_once SYS_APPLICATION_PATH . DS . 'config' . DS . 'routes.php'; //Define the main route functions $router = new Router($routes); $currentRoute = $router->parseRoute(); if ($currentRoute != false) { $router->executeRoute($currentRoute); } else { @Controller::callErrorPage('404'); } } }
<?php /** * All phpBurn models should extend this class * It is the main responsable for the Magic. * * @package PhpBURN * * @author Kléderson Bueno <*****@*****.**> * @version 0.4a * @abstract */ PhpBURN::load('ConnectionManager', 'DialectManager', 'Mapping', 'IPhpBurn'); abstract class PhpBURN_Core implements IPhpBurn { /* The structure of the constants follow the concept * The two first numbers identify the TYPE of constant for example: * 100001, 10 means that integer corresponds to a SQL DATABASE constant, 00 means it corresponds to an QUERY and 01 at the end corresponds to the SELECT query * For more information see the detailed documentation with all constants indexes. * * TABLE OF REFERENCE: * 10XXXX = SQL DATABASE * 1000XX = QUERY TYPE * 1001XX = QUERY TYPE RELATIONSHIP * 1002XX = DATABASE CONNECTION * * It has been made to make easier to identify an number in debugs and other stuffs. */ //Relationship types const ONE_TO_ONE = 100101; const ONE_TO_MANY = 100102;
<?php PhpBURN::load('Tools.Views.IProcessView'); PhpBURN::load('Addons.PHPTAL.PHPTAL'); PhpBURN::load('Addons.PHPTAL.PHPTAL.GetTextTranslator'); class dcampos_PhpBURN_ViewProcess implements IProcessView { /** * This method is used to process the data into the view and than return it to the main method that will handle what to do. * It also uses buffer to handle that content. * * @author Klederson Bueno <*****@*****.**> * @version 0.1a * * @param String $___phpBurnFilePath * @param Array $__phpBurnData * @return String */ public function processViewData($___phpBurnFilePath, $__phpBurnData) { $tpl = new PHPTAL($___phpBurnFilePath); $tpl->setOutputMode(PHPTAL::HTML5); $tr = new PHPTAL_GetTextTranslator(); // set language to use for this session (first valid language will // be used) $tr->setLanguage('pt_BR.utf8', 'pt_BR'); // register gettext domain to use $tr->addDomain('system', SYS_BASE_PATH . 'locale'); // specify current domain $tr->useDomain('system'); // tell PHPTAL to use our translator
<?php ################################ # Hooks ################################ define('SYS_USE_FIREPHP', true, true); ################################ # Including required files ################################ require_once 'app/phpBurn.php'; require_once 'config.php'; //Migrations tool PhpBURN::load('Migrations.Migrations'); ################################ # Starting application ################################ PhpBURN_Migrations::migrate();
<?php PhpBURN::load('Tools.Views.IProcessView'); class default_PhpBURN_ViewProcess implements IProcessView { /** * This method is used to process the data into the view and than return it to the main method that will handle what to do. * It also uses buffer to handle that content. * * @author Klederson Bueno <*****@*****.**> * @version 0.1a * * @param String $___phpBurnFilePath * @param Array $__phpBurnData * @return String */ public function processViewData($___phpBurnFilePath, $__phpBurnData) { //Starting a new buffer ob_start(); //Parsing Array data to Variables foreach ($__phpBurnData as $__index => $__value) { ${$__index} = $__value; } include $___phpBurnFilePath; //Storing buffer result to a var $___phpBurnBufferStored = ob_get_contents(); //Cleaning the buffer for new sessions ob_clean(); return $___phpBurnBufferStored; }
<?php set_include_path(get_include_path() . ":" . realpath(dirname(__FILE__)) . DIRECTORY_SEPARATOR . "../../Addons/PHPTAL/classes/"); PhpBURN::load('Tools.Views.IProcessView'); PhpBURN::load('Addons.PHPTAL.PHPTAL'); class phptal_PhpBURN_ViewProcess implements IProcessView { /** * This method is used to process the data into the view and than return it to the main method that will handle what to do. * It also uses buffer to handle that content. * * @author Klederson Bueno <*****@*****.**> * @version 0.1a * * @param String $___phpBurnFilePath * @param Array $__phpBurnData * @return String */ public function processViewData($___phpBurnFilePath, $__phpBurnData) { $tpl = new PHPTAL($___phpBurnFilePath); $tpl->setOutputMode(PHPTAL::HTML5); foreach ($__phpBurnData as $index => $value) { if (is_string($value)) { $value = PhpBURN_Views::lazyTranslate($value, PhpBURN_Views::getLang()); } $tpl->{$index} = $value; } ob_start(); try { echo $tpl->execute();
<?php PhpBURN::load('Exception.IException'); class PhpBURN_Exception extends Exception implements IException { } ?>
public static function chooseViewMethod() { self::$viewMethod = !defined('PHPBURN_VIEWS_METHOD') || !empty(self::$viewMethod) ? self::$viewMethod : PHPBURN_VIEWS_METHOD; if (self::$viewMethod == null) { self::$viewMethod = 'default'; } PhpBURN::load('Tools.Views.' . self::$viewMethod); $classString = sprintf("%s_PhpBURN_ViewProcess", self::$viewMethod); return new $classString(); }
<?php PhpBURN::load('Connection.IConnection'); /** * This class is responsable for connect the application to the database and perform the queries in a driver-level * Than translate the results and resultSets to the application trought Dialect * * * This class has been adapted from Lumine 1.0 * The original idea is from Hugo Ferreira da Silva in Lumine * * @package PhpBURN * @subpackage Connection * * It has been modified and implemented into PhpBURN by: * * @author Klederson Bueno Bezerra da Silva * */ class PhpBURN_Connection_MySQL implements IConnection { const CLOSED = 100201; const OPEN = 100202; const SERVER_VERSION = 10; const CLIENT_VERSION = 11; const HOST_INFO = 12; const PROTOCOL_VERSION = 13; const RANDOM_FUNCTION = 'rand()'; const ESCAPE_CHAR = '\\'; protected $_event_types = array('preExecute', 'posExecute', 'preConnect', 'onConnectSucess', 'preClose', 'posClose', 'onExecuteError', 'onConnectError'); private $conn_id;
<?php PhpBURN::load('Mapping.IMap'); /** * @package PhpBURN * @subpackage Mapping * * @author Kléderson Bueno <*****@*****.**> */ /** * iGrape Framework * * @category iGrape * @author iGrape Dev Team * @copyright Copyright (c) 2007-2010 iGrape Framework. (http://www.igrape.org) * @license LICENSE New BSD License * @version 0.2.2 * */ class PhpBURN_Map implements IMap { //Relationship types const ONE_TO_ONE = 100101; const ONE_TO_MANY = 100102; const MANY_TO_ONE = 100103; const MANY_TO_MANY = 100104; /** * This attribute carries all mapping information such as relationships, witch field is witch column, etc. * This is mapped only once and is cached for all the objects from the same type. * It means all Teste() Objects only will load the xmlmapping once and not for each as in the others ORMs *
/** * Starts the PhpBURN Application - Should be called at the index of the application * <code> * PhpBURN::StartApplication(); * </code> */ public static function startApplication() { // Setting up Model if (array_search('PhpBURN_Core', get_declared_classes()) == true) { // Adds Models Paths to include Path $packages = PhpBURN_Configuration::getConfig(); foreach ($packages as $package => $configItem) { $includePath = get_include_path(); $separator = strpos($includePath, ':') !== false ? ':' : ';'; set_include_path($includePath . $separator . $configItem->class_path . DS . $package); } } // Setting up Controller if (array_search('Controller', get_declared_classes()) == true) { PhpBURN::load('Tools.Util.Router'); include_once SYS_APPLICATION_PATH . DS . 'config' . DS . 'routes.php'; //Define the main route functions $router = new Router($routes); $currentRoute = $router->parseRoute(); if ($currentRoute != false) { $router->executeRoute($currentRoute); } else { Controller::callErrorPage('404'); } } }
<?php PhpBURN::load('Tools.Controller.IController'); /** * This class controls the main functions of controllers and actions calls * * @version 0.1 * @package PhpBURN * @subpackage Controllers * * @author Klederson Bueno <*****@*****.**> */ abstract class Controller { public $_viewData = array(); public static $stack = array('url', 'controller', 'action', 'params' => array()); public function __construct() { } /** * List all files into a specified directory. * * @param String $folder * @param String $extension * @param Integer $amount * @param Boolean $rand * * @return Array */ public function getFilesFromFolder($folder, $extension = "*", $amount = null, $rand = true) {
<?php //Load firephp only when we need if (@SYS_USE_FIREPHP == true) { PhpBURN::load('Tools.Extras.FirePHPCore.fb'); } /** * This class manages all internal messages into the system * from the LOG messages until EXCEPTIONS throught files, * browser, database or even FirePHP * * @package PhpBURN * @subpackage Messages * * @author Kléderson Bueno <*****@*****.**> * @version 0.1a */ class PhpBURN_Message { /* MODE */ const CONSOLE = 300001; const BROWSER = 300002; const FIREBUG = 300003; const FILE = 300004; const DATABASE = 300005; /* TYPE */ const NOTICE = '[!Notice!]'; const EXCEPTION = '[!Exception!]'; const WARNING = '[!Warning!]'; const LOG = '[!Log!]'; const ERROR = '[!Error!]';
<?php //Load firephp only when we need if (@SYS_USE_FIREPHP == true) { PhpBURN::load('Addons.FirePHPCore.fb'); } /** * This class manages all internal messages into the system * from the LOG messages until EXCEPTIONS throught files, * browser, database or even FirePHP * * @package PhpBURN * @subpackage Messages * * @author Kléderson Bueno <*****@*****.**> * @version 0.1a */ class PhpBURN_Message { /* MODE */ const CONSOLE = 300001; const BROWSER = 300002; const FIREBUG = 300003; const FIREPHP = 300003; const FILE = 300004; const DATABASE = 300005; const NONE = 300006; /* TYPE */ const NOTICE = '[!Notice!]'; const EXCEPTION = '[!Exception!]'; const WARNING = '[!Warning!]';
<?php namespace PhpBURN\Spices; ################################ # Spices Configuration ################################ \PhpBURN::load('Spices'); Spices::loadSpice();