Пример #1
0
 public function loadModels(PhpBURN_ConfigurationItem $packageConfig)
 {
     //		Determine the wildcard based ONLY in SYS_MODEL_EXT to not load extra garbage
     $dir = sprintf("%s*%s", $packageConfig->class_path . DS . $packageConfig->package . DS, SYS_MODEL_EXT);
     //		Searching
     foreach (glob($dir) as $filename) {
         //			Fixing some stuff in the name
         $filename = explode(DS, $filename);
         $filename = end($filename);
         $filename = explode(SYS_MODEL_EXT, $filename);
         array_pop($filename);
         $filename = implode('', $filename);
         //			Loading model
         if (!is_dir($filename)) {
             PhpBURN::import($packageConfig->package . '.' . $filename);
             $model = new $filename();
             if ($model instanceof PhpBURN_Core && !empty($model->_tablename)) {
                 if ($_SERVER['HTTP_HOST']) {
                     print "<pre>";
                 }
                 print sprintf("Creating %s table for %s model from %s package into %s database: ", $model->_tablename, get_class($model), $packageConfig->package, $packageConfig->database);
                 if ($model->getDialect()->migrate()) {
                     print "OK \r\n";
                 } else {
                     print "FAIL \r\n";
                 }
                 $model->__destruct();
             }
             unset($model);
             if ($_SERVER['HTTP_HOST']) {
                 print "</pre>";
             }
         }
     }
 }
Пример #2
0
 /**
  * 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;
 }
Пример #3
0
 /**
  * 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;
 }
Пример #4
0
<?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)
Пример #5
0
<?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();
Пример #6
0
 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();
 }
Пример #7
0
<?php

################################
# Controller Settings
################################
PhpBURN::load('Tools.Controller.ControllerConfig');
//Loading ControllerConfig Tool
Пример #8
0
<?php

namespace PhpBURN\Spices\ACL;

\PhpBURN::loadSpice('acl', array('1.0'));
############################################
# Create Settings
############################################
/**
 * ACL Spice Settings
 */
$aclSettings = array('defaultVisibile' => array('public'), 'defaultPermission' => 'allow', 'defaultType' => 'unknown', 'authInfo' => array('allowedMethods' => &$_SESSION[PHPBURN_SESSIONNAME]['userInfo']['allowedMethods']));
############################################
# Define ACL configuration
############################################
PhpBURN_ACL::setConfig($aclSettings);
PhpBURN_ACL_Control::generateRules();
############################################
# callBack functions
############################################
$callBack = array('granted' => function () {
    return true;
}, 'denied' => function () {
    die("Your access to this area has been denied. You've been a bad bad dog!");
});
PhpBURN_ACL::setCallBack($callBack);
############################################
# Add Controller onCallActionBefore to be
# executed before each controller call
############################################
\PhpBURN_ControllerConfig::addOnCallActionBefore('phpburn_spice_acl', function ($controllerName, $action, $parms) {
Пример #9
0
<?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!]';
Пример #10
0
<?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;
Пример #11
0
<?php

PhpBURN::load('Mapping.Map');
/**
 * This class manage the map controller. 
 * It is the main responsable for create and delegate the maps into the models.
 * Can be used by many ways but by default its better if you simply do not mess around ;) let the application work for you.
 * 
 * @package PhpBURN
 * @subpackage Mapping
 * 
 * @author Kléderson Bueno <*****@*****.**>
 * @version 0.1a
 */
class PhpBURN_Mapping
{
    /**
     * This variable storage in runtime all maps for each kind of model. For more details 
     * @see getMapping()
     * @var Array
     */
    public static $mapping = array();
    /**
     * Creates and return a PhpBURN_Map Object for the calling model
     * If the map already exists it just return it ( caching )
     *
     * @param PhpBURN_Core $modelObj
     * @return PhpBURN_Map
     */
    public static function create(PhpBURN_Core &$modelObj, $fromMulti = false)
    {
Пример #12
0
require_once 'sysConfig.php';
################################
# Getting current session if exists
################################
session_name(PHPBURN_SESSIONNAME);
session_start();
################################
# Error and Message System
################################
error_reporting(E_ALL & ~E_NOTICE);
//Turn the Messages and Logs and Erros ON
PhpBURN_Message::setMode(PhpBURN_Message::FIREBUG);
//You can Choose FIREPHP, BROWSER OR FILE for now than more can came latter
################################
# Internacionalization Settings
################################
setlocale(LC_ALL, 'en_US');
date_default_timezone_set('America/Sao_Paulo');
################################
# Modules
################################
# To load the module just remove the # comment from the line
# Views
PhpBURN::loadModule('View');
# Controller
PhpBURN::loadModule('Controller');
# To load the module just remove the # comment from the line
PhpBURN::loadModule('Model');
# Spices
PhpBURN::loadModule('Spices');
Пример #13
0
<?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
Пример #14
0
<?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();
Пример #15
0
<?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;
    }
Пример #16
0
<?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();
Пример #17
0
 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();
 }
Пример #18
0
 /**
  * Just checks if a model exists based on the configured packages you just have to know the name
  *
  * @param String $modelName
  * @return Boolean
  */
 private function modelExist($modelName)
 {
     if (PhpBURN::import($modelName) != 'error') {
         return true;
     } else {
         return false;
     }
 }
Пример #19
0
<?php

################################
# Hooks
################################
define('SYS_USE_FIREPHP', true, true);
################################
# Including required files
################################
require_once 'app/phpBurn.php';
require_once 'config.php';
################################
# Starting application
################################
PhpBURN::startApplication();
################################
# Sending a End of File
################################
PhpBURN_Message::output('[!EOF!]');
Пример #20
0
<?php

PhpBURN::load('Exception.IException');
class PhpBURN_Exception extends Exception implements IException
{
}
?>

Пример #21
0
 /**
  * Maps the model based on its XML
  *
  * @param PhpBURN_Core $modelObj
  * @return SimpleXMLElement $configXML
  */
 private function getXmlMap()
 {
     $xmlMapping = PhpBURN::loadXMLMapping($this->modelObj->_package . '.' . get_class($this->modelObj));
     if ($xmlMapping == 'error') {
         $xmlMapping = false;
     } else {
         $configXML = new SimpleXMLElement($xmlMapping);
     }
     return $configXML;
 }
Пример #22
0
 /**
  * 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');
         }
     }
 }
Пример #23
0
<?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)
    {
Пример #24
0
<?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!]';
Пример #25
0
 /**
  * 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');
         }
     }
 }
Пример #26
0
<?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);
        }
        /**
Пример #27
0
 * @version		0.2.2
 *
 */
@ob_start();
@session_start();
################################
# System Settings
################################
require_once 'sysConfig.php';
################################
# Error and Message System
################################
error_reporting(E_ALL & ~E_NOTICE);
//Turn the Messages and Logs and Erros ON
//PhpBURN_Message::setMode(PhpBURN_Message::FIREBUG); //You can Choose FIREPHP, BROWSER OR FILE for now than more can came latter
################################
# Internacionalization Settings
################################
setlocale(LC_ALL, 'en_US');
date_default_timezone_set('America/Sao_Paulo');
################################
# Modules
################################
# To load the module just remove the # comment from the line
# Views
//PhpBURN::loadModule('View');
# Controller
//PhpBURN::loadModule('Controller');
# To load the module just remove the # comment from the line
PhpBURN::loadModule('Model');
Пример #28
0
<?php

namespace PhpBURN\Spices;

################################
# Spices Configuration
################################
\PhpBURN::load('Spices');
Spices::loadSpice();