public function __construct() { $dbConnect = Config::getDbConf('MongoDB'); $uri = 'mongodb://'; if (!empty($dbConnect['username'])) { $uri .= $dbConnect['username'] . ':' . $dbConnect['password'] . '@'; } $uri .= $dbConnect['host'] . ':' . $dbConnect['port']; $this->manager = new Manager($uri); $this->client = new Client($uri); $this->dbName = $dbConnect['database']; }
/** * creat tools for controller * @return void */ public function _loadTools() { $def = Config::getTools(); foreach ($this->tools as $tool => $params) { if (is_array($params)) { $className = $def[$tool]; $this->{$tool} = Factory::load($className, $params); } else { $className = $def[$params]; $this->{$params} = Factory::load($className); } } }
public static function initGetText($location) { // ca va surment changer // TODO se code est a revoir self::$conf = Config::get('location.' . $location); //Locale::getRegion // je suis sous window ca bug. marchera plus tard setlocale(LC_ALL, self::$conf['langue']); //putenv("LANGUAGE=english"); putenv('LANG=' . self::$conf['langue']); putenv('LC_ALL=' . self::$conf['langue']); //setlocale(LC_MESSAGES, $conf['langue']); $domain = self::$conf['domaine']; bindtextdomain($domain, APP_FOLDER . DS . "locale"); textdomain($domain); }
public function __construct() { try { Config::getConf(); Auth::loadClass(); //we c'est un peux de la triche Session::start(); EventManager::init(); $this->request = Request::getInstance(); $this->router = Router::getInstance(); $this->auth = Auth::getInstance(); include_once APP_FOLDER . DS . 'config' . DS . 'bootstrap.php'; $this->request->securePost(); $view = $this->router->execute(); $view->render(); } catch (Exception $e) { $this->controller = new ErrorController($e); } }
/** * construct * @param Exception $exception the exception */ public function __construct($exception) { $this->request = Request::getInstance(); $save['controller'] = $this->request->controller; $this->request->controller = 'ErrorController'; $save['action'] = $this->request->action; $this->request->params = ['error' => $exception]; $this->view = new HtmlView(); $this->view->set($save); $this->_loadTools(); if (Config::getDebug()) { $this->request->action = 'error'; $this->error($exception); } else { $this->request->action = 'error404'; $this->error404($exception); } $this->view->render(); }
function __construct() { $auth = Session::get('skankydev.auth'); if ($auth) { $this->loged = true; } $this->historique = new Historique(); $this->userAgent = new UserAgent(); $this->cookie = new Cookie('skankydev.auth', Config::get('Auth.cookieTimer')); $this->historique->updateHistorique(); $current = $this->historique->getCurrent(); $controller = Config::get('Auth.redirectAction.controller'); if ($current['link']['controller'] !== $controller) { Session::delete('skankydev.backlink'); } //$this->cookie->set('test.truc',['test1'=>'youpi1','test2'=>'youpi2']); if (empty($_COOKIE)) { $this->firstStep(); } EventManager::getInstance()->event('auth.construct', $this); }
/** * add the * @param Request $request the Request * @return void */ function updateHistorique() { $request = Request::getInstance(); $history = Session::get('skankydev.historique'); if (!$history) { $history = []; } $hData['url'] = $request->sheme . '://' . $request->host . $request->uri; $hData['direct'] = true; $hData['sheme'] = $request->sheme; $hData['method'] = $request->method; $hData['uri'] = $request->uri; $hData['link']['namespace'] = $request->namespace; $hData['link']['controller'] = $request->controller; $hData['link']['action'] = $request->action; $hData['link']['params'] = $request->params; $count = array_unshift($history, $hData); $limit = Config::get('historique.limit'); if ($count > $limit) { unset($history[$limit]); } Session::set('skankydev.historique', $history); }
function __construct() { $classList = Config::getListener(); $this->listeners = Config::getListenerList(); foreach ($this->listeners as $listener => $params) { if (is_array($params)) { $name = $listener; $className = $classList[$listener]; $this->{$name} = Factory::load($className, $params); } else { $name = $params; $className = $classList[$params]; $this->{$name} = Factory::load($className); } $hook = $this->{$name}->infoEvent(); foreach ($hook as $key => $action) { $tmp = $this->arrayGet($key, $this->event); $tmp[$name] = $action; $this->arraySet($key, $tmp, $this->event); } } $this->ready = true; $this->classListe = $classList; }
/** * create the form object * @param array $data the data to put in input */ function __construct() { $request = Request::getInstance(); $this->data = $request->data; $this->dClass = Config::get('form.class'); }
private function openConnect() { $dbConnect = Config::getDbConf('MySQL'); $link = mysqli_connect($dbConnect['host'], $dbConnect['user'], $dbConnect['pass']); if (!$link) { throw new \Exception('Impossible de se connecter : ' . mysqli_error($link)); } mysqli_select_db($link, $dbConnect['database']); if (!$link) { throw new \Exception('Impossible de sélectionner la base de données : ' . mysqli_error($link)); } return $link; }
/** * load a Collection * @param string $name the name * @return mixed a collection */ static function load($name) { $cName = Config::getCurentNamespace() . '\\Model\\Collection\\' . $name . 'Collection'; return Factory::load($cName, ['name' => $name], false); }
public function elementFromView($link) { $friend = Router::getInstance()->getElement($link); if ($friend) { $this->script .= $friend->script; $this->css .= $friend->css; $this->js .= $friend->js; $viewFolder = $this->toDash($link['controller']); $action = $this->toDash($link['action']); $friend->viewPath = Config::viewDir() . DS . $viewFolder . DS . $action . '.ctp'; $friend->loadHelper(); extract($friend->data); ob_start(); require $friend->viewPath; return ob_get_clean(); } else { $element = Config::getAccessDenied(); if ($element) { return $this->element($element); } } return false; }
/** * prepare query for pagination * @param array $option the option for query * @return SkankyDev\Utilities\Paginator the paginator object */ public function paginate($option = []) { $option = array_replace_recursive($this->defaultQuery, $option); $dOption = Config::get('paginator'); $option = array_replace_recursive($dOption, $option); if (!$option['page']) { $option['page'] = 1; } $option['skip'] = $option['limit'] * ($option['page'] - 1); $option['count'] = $this->count($option['query']); $result = $this->find($option); $paginator = new Paginator($result); unset($option['query']); unset($option['skip']); $paginator->setOption($option); return $paginator; }
public function execute() { EventManager::getInstance()->event('router.execute.before', $this); $request = Request::getInstance(); $link = $request->getArrayLink(); $controller = Factory::load($this->makeControllerName($link)); $method = new \ReflectionMethod($controller, $link['action']); if (!isset($this->permission)) { $method->invokeArgs($controller, $link['params']); } else { if ($method->isPublic()) { if ($this->permission->checkPublicAccess($link)) { $method->invokeArgs($controller, $link['params']); } else { $request->redirect(Config::get('Auth.redirectAction')); } } elseif ($method->isProtected()) { if ($this->permission->checkProtectedAccess($link)) { $method->setAccessible(true); $method->invokeArgs($controller, $link['params']); } else { $request->redirect(Config::get('Auth.redirectAction')); } } elseif ($method->isPrivate()) { if ($this->permission->checkPrivateAccess($link)) { $method->setAccessible(true); $method->invokeArgs($controller, $link['params']); } else { $request->redirect(Config::get('Auth.redirectAction')); } } } EventManager::getInstance()->event('router.execute.after', $this); return $controller->_getView(); }
public function loadHelper() { $def = Config::getHelper(); foreach ($this->helpers as $helper => $params) { if (is_array($params)) { $className = $def[$helper]; $this->{$helper} = Factory::load($className, $params); } else { $className = $def[$params]; $this->{$params} = Factory::load($className); } } }