Пример #1
0
 public function __construct()
 {
     $this->authController = \core\Loader::load('\\auth\\controller\\AuthController');
     self::$userIsloggedIn = $this->authController->userIsLoggedIn();
     //WHY STATIC??
     $this->settings = \core\Loader::load('\\blogg\\model\\admin\\Settings');
 }
Пример #2
0
 public function dispatch($testing = false)
 {
     $controllerName = $this->getController();
     $action = $this->getAction();
     $params = $this->getParams();
     if (!file_exists(SRC_DIR)) {
         throw new \Exception("Something wrong with the configuration of this project check global SRC_DIR in definer.php");
     }
     //Tar fram alla mappar i src mappen
     $files = scandir(SRC_DIR, 1);
     $controllerfile = "";
     $namespace = "";
     //Loopa dessa filer
     foreach ($files as $file) {
         $controllerDir = SRC_DIR . $file . DS . 'controller';
         if (file_exists($controllerDir)) {
             //Om man hittar controller mappen
             $filesInControllerDir = scandir($controllerDir, 1);
             //Hämta alla filnamn i den mappen
             foreach ($filesInControllerDir as $fileInControllerDir) {
                 if (0 === strpos($fileInControllerDir, $controllerName)) {
                     $controllerfile = SRC_DIR . $file . DS . 'controller' . DS . $fileInControllerDir;
                     $namespace = $file;
                     //Hitttat rätt fil
                     break;
                 }
             }
         }
     }
     $controller = '\\' . $namespace . '\\controller\\' . ucfirst($controllerName) . 'Controller';
     //Alltid stor första bokstav på objekt
     if (file_exists($controllerfile)) {
         require_once $controllerfile;
         try {
             $app = \core\Loader::load($controller);
             $app->setParams($params);
             if (!method_exists($app, $action)) {
                 throw new \Exception('Controller ' . $controller . ' does not have ' . $action . ' function');
             }
             $app->{$action}();
             //Denna delen bör förändras, men vet inte exakt hur jag ska göra och vilket objekt som ska ansvara för renderingen
             $view = $app->getView();
             $view->render($action);
         } catch (\PDOException $e) {
             if ($testing) {
                 throw new $e();
             }
             $this->redirectToAdminSettings($e);
         } catch (\Exception $e) {
             if ($testing) {
                 throw new $e();
             }
             $this->redirectToError($e);
         }
     } else {
         throw new \Exception('Controller ' . $controller . ' not found');
     }
 }
Пример #3
0
 public function __construct()
 {
     $config = new Config(DEBUG ? 'dev' : 'release');
     //初始化环境
     $this->_initEnv();
     //加载通用函数
     Loader::loadFile(ROOT_PATH . 'Core/Common.func.php');
     //路由,默认r=app/controller/action形式
     $router = new \Core\util\Router(Config::get('url.url_type'));
     $router->start();
     $config->loadAppConfig();
 }
Пример #4
0
 /**
  * @return PDO object, 
  */
 protected function connection()
 {
     if ($this->dbConnection == null) {
         $settings = \core\Loader::load('blogg\\model\\admin\\Settings');
         $settings = $settings->getBloggSettings();
         $this->dbConnection = new \PDO($settings->connectionString, $settings->dbUserName, $settings->dbPassword);
         if (\Config::DEBUG) {
             $this->dbConnection->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
         }
     }
     return $this->dbConnection;
 }
Пример #5
0
defined('GITHUB_CLIENT_SECRET') or define('GITHUB_CLIENT_SECRET', '');
// Proxy authentication
defined('REVERSE_PROXY_AUTH') or define('REVERSE_PROXY_AUTH', false);
defined('REVERSE_PROXY_USER_HEADER') or define('REVERSE_PROXY_USER_HEADER', 'REMOTE_USER');
defined('REVERSE_PROXY_DEFAULT_ADMIN') or define('REVERSE_PROXY_DEFAULT_ADMIN', '');
defined('REVERSE_PROXY_DEFAULT_DOMAIN') or define('REVERSE_PROXY_DEFAULT_DOMAIN', '');
// Mail configuration
defined('MAIL_FROM') or define('MAIL_FROM', '*****@*****.**');
defined('MAIL_TRANSPORT') or define('MAIL_TRANSPORT', 'mail');
defined('MAIL_SMTP_HOSTNAME') or define('MAIL_SMTP_HOSTNAME', '');
defined('MAIL_SMTP_PORT') or define('MAIL_SMTP_PORT', 25);
defined('MAIL_SMTP_USERNAME') or define('MAIL_SMTP_USERNAME', '');
defined('MAIL_SMTP_PASSWORD') or define('MAIL_SMTP_PASSWORD', '');
defined('MAIL_SMTP_ENCRYPTION') or define('MAIL_SMTP_ENCRYPTION', null);
defined('MAIL_SENDMAIL_COMMAND') or define('MAIL_SENDMAIL_COMMAND', '/usr/sbin/sendmail -bs');
$loader = new Loader();
$loader->execute();
$registry = new Registry();
$registry->db = function () use($registry) {
    require __DIR__ . '/../vendor/PicoDb/Database.php';
    switch (DB_DRIVER) {
        case 'sqlite':
            require __DIR__ . '/Schema/Sqlite.php';
            $params = array('driver' => 'sqlite', 'filename' => DB_FILENAME);
            break;
        case 'mysql':
            require __DIR__ . '/Schema/Mysql.php';
            $params = array('driver' => 'mysql', 'hostname' => DB_HOSTNAME, 'username' => DB_USERNAME, 'password' => DB_PASSWORD, 'database' => DB_NAME, 'charset' => 'utf8');
            break;
        case 'postgres':
            require __DIR__ . '/Schema/Postgres.php';
Пример #6
0
 /**
  * Check if route dispatchable
  * @param array $mvcData
  */
 private function _isDispatchable(array $mvcData)
 {
     $loader = \Core\Loader::getInstance();
     return $loader->canLoadModule($mvcData['module']) && $loader->canLoadController($mvcData['module'], $mvcData['controller']) && $loader->canRunAction($mvcData['module'], $mvcData['controller'], $mvcData['action']);
 }
Пример #7
0
<?php

session_start();
define('DS', DIRECTORY_SEPARATOR);
define('ROOT_DIR', dirname(__FILE__) . DS);
define('ROOT_PATH', '/' . basename(dirname(__FILE__)) . '/');
require_once './core/definer.php';
\core\Loader::load('blogg\\model\\admin\\Settings');
//börja med att läsa in inställningar
$router = \core\Loader::load('\\core\\Router');
$router->dispatch();
Пример #8
0
<?php

require __DIR__ . '/../../app/Core/Loader.php';
require __DIR__ . '/../../app/helpers.php';
require __DIR__ . '/../../app/functions.php';
require __DIR__ . '/../../app/constants.php';
use Core\Loader;
use Core\Registry;
if (version_compare(PHP_VERSION, '5.5.0', '<')) {
    require __DIR__ . '/../../vendor/password.php';
}
date_default_timezone_set('UTC');
$loader = new Loader();
$loader->setPath('app');
$loader->setPath('vendor');
$loader->execute();
abstract class Base extends PHPUnit_Framework_TestCase
{
    public function setUp()
    {
        $this->registry = new Registry();
        $this->registry->db = function () {
            return setup_db();
        };
        $this->registry->event = function () {
            return setup_events();
        };
        if (DB_DRIVER === 'mysql') {
            $pdo = new PDO('mysql:host=' . DB_HOSTNAME, DB_USERNAME, DB_PASSWORD);
            $pdo->exec('DROP DATABASE ' . DB_NAME);
            $pdo->exec('CREATE DATABASE ' . DB_NAME);
Пример #9
0
 function getDefaultCache()
 {
     $params = array('DelegateTarget' => $this, 'DelegateMethod' => 'getPath');
     $this->parameters['CacheParameters'] += $params;
     return parent::getDefaultCache();
 }