Exemplo n.º 1
3
 public function __construct($string)
 {
     \Twig_Autoloader::register();
     $this->loader = new \Twig_Loader_String();
     $this->twig = new \Twig_Environment($this->loader);
     $this->string = $string;
     /**
      * let twig know the BACBOX_URLBASE
      * templates need this information to correctly locate css, js and any other
      * static content from the webserver
      */
     $this->_urlbase = BACBOX_URLBASE;
     /**
      * in case that multilanguage is enabled, we need to append the
      * language token to the urlbase for in-template links
      */
     if (Registry::get('language_token')) {
         $this->_linkbase = BACBOX_URLBASE . Registry::get('language_token') . '/';
     } else {
         $this->_linkbase = BACBOX_URLBASE;
     }
     // register the hostname for absolute linking
     $this->_hostname = Config::get('system.hostname');
     $this->setHeader('Content-Type', 'text/html; charset="UTF-8"');
 }
Exemplo n.º 2
0
 /**
  * @param $template
  * @param null $envelope
  * @param string $envelopeVariable
  */
 public function __construct($template, $envelope = null, $envelopeVariable = 'CONTENT')
 {
     $this->smarty = new SmartyWrapper();
     $this->setTemplate($template);
     $this->setEnvelope($envelope);
     $this->envelopeVariable = $envelopeVariable;
     /**
      * let smarty know the BACBOX_URLBASE
      * templates need this information to correctly locate css, js and any other
      * static content from the webserver
      */
     $this->smarty->_urlbase = BACBOX_URLBASE;
     /**
      * in case that multilanguage is enabled, we need to append the
      * language token to the urlbase for in-template links
      */
     if (Registry::get('language_token')) {
         $this->smarty->_linkbase = BACBOX_URLBASE . Registry::get('language_token') . '/';
     } else {
         $this->smarty->_linkbase = BACBOX_URLBASE;
     }
     // register the hostname for absolute linking
     $this->smarty->_hostname = Config::get('system.hostname');
     $this->setHeader('Content-Type', 'text/html; charset="UTF-8"');
 }
Exemplo n.º 3
-2
 public function __construct($debug = false)
 {
     define('DEBUG', $debug);
     /**
      * Initialize whoops to handle exceptions
      */
     Registry::set('whoops', new Run());
     if (DEBUG) {
         Registry::get('whoops')->pushHandler(new PrettyPageHandler());
     }
     Registry::get('whoops')->pushHandler(new ExceptionHandler());
     Registry::get('whoops')->register();
     if (!defined('BACBOX_APP')) {
         throw new Exception("Please define the path to the app directory in your bootstrap by setting BACBOX_APP");
     }
     /**
      * set some basic php configuration parameters
      * these are mainly used for new installations and
      * will be overriden later based on configuration tokens
      */
     ini_set('display_errors', (bool) $debug);
     ini_set('error_reporting', E_ALL ^ E_STRICT);
     ini_set('max_execution_time', 30);
     // define paths
     define('DS', preg_match("/\\//", __DIR__) ? "/" : "\\");
     define('BACBOX_LIB', __DIR__);
     define('BACBOX_SRC', BACBOX_APP . '../src' . DS);
     // set the bacbox urlbase, e.g. /bacbox/
     $urlbase = dirname($_SERVER['SCRIPT_NAME']);
     $urlbase = preg_replace('#\\\\+#', '/', $urlbase);
     if (!preg_match('#/$#', $urlbase)) {
         $urlbase .= "/";
     }
     define('BACBOX_URLBASE', $urlbase);
     // setup cache
     phpFastCache::setup('storage', 'files');
     phpFastCache::setup('path', BACBOX_APP . 'cache');
     phpFastCache::setup('securityKey', 'phpFastCache');
     // initialize Uberloader
     $loader = new Uberloader();
     $loader->set_cache_backend(new UberloaderCacheBackendFilesystem(BACBOX_APP . "cache" . DS));
     $loader->add_path(BACBOX_LIB . DS . 'models');
     $loader->add_path(BACBOX_LIB . DS . 'migrations');
     $loader->add_path(BACBOX_SRC);
     $loader->register();
     Registry::set('loader', $loader);
     // init basic configuration tokens to gain database-access
     Config::init();
     // establish database link
     ORM::configure('mysql:host=' . Config::get('mysql.host') . ';dbname=' . Config::get('mysql.database'));
     ORM::configure('username', Config::get('mysql.user'));
     ORM::configure('password', Config::get('mysql.pass'));
     ORM::configure('driver_options', array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'));
     ORM::configure('logging', true);
     // load remaining configuration tokens from database or cache
     Config::load();
     // execute database migrations if .autoMigrate = true
     Config::get('migrations.autoMigrate') ? Migrator::run() : null;
     // initialize and register request helper
     Registry::set('Request', $request = new Request());
     // run core controller to pre-process the user's request
     Controller::run();
     // run site migrations
     if (Registry::get('site')->site_auto_migrate) {
         SiteMigrator::run();
     }
     // initialize hooks subsystem
     Hooks::init();
     Hooks::run('core.hooks.initialized');
     // run config overrides in case the site specifies any
     Config::run_config_overrides();
     // initialize and register session handler
     Registry::set('Session', new Session());
     // initialize localization subsystem
     Registry::set('Localization', new Localization());
     // run the user's request
     Hooks::run('core.response.before');
     Registry::set('Response', $response = Dispatcher::run($request));
     Hooks::run('core.response.after');
     // send the response
     $response->send();
     // that's it, folks
     exit;
 }
Exemplo n.º 4
-2
 /**
  * method sets environmental settings based on configuration tokens
  */
 private static function set_system_settings()
 {
     // set ORM properties
     ORM::configure('error_mode', constant(Config::get('mysql.error_mode')));
     ORM::configure('logging', Config::get('mysql.log'));
     // set system properties
     ini_set('error_reporting', E_ALL ^ E_STRICT);
     Config::get('system.display_errors') ? ini_set('display_errors', true) : ini_set('display_errors', false);
     Config::get('system.log_errors') ? ini_set('log_errors', true) : ini_set('log_errors', false);
     ini_set('error_log', BACBOX_APP . 'logs' . DS . Config::get('system.error_log_name'));
     ini_set('log_errors_max_len', Config::get('system.log_max_length'));
     mb_internal_encoding("UTF-8");
     mb_regex_encoding("UTF-8");
     date_default_timezone_set(Config::get('system.default_timezone'));
     ini_set('upload_tmp_dir', BACBOX_APP . 'tmp' . DS . 'uploads');
 }