Пример #1
0
 protected function controllerExists($route)
 {
     $namespace = $this->toPhpName($route['namespace']);
     $controller = $this->toPhpName($route['controller']);
     $appNs = $this->config->get('b8.app.namespace');
     $controllerClass = $appNs . '\\' . $namespace . '\\' . $controller . 'Controller';
     return class_exists($controllerClass);
 }
Пример #2
0
 public function init()
 {
     $base = $this->getPath();
     $templatePath = $base . 'Template/';
     $adminTemplatePath = $base . 'Admin/Template/';
     $octoConfig = $this->config->get('Octo', []);
     if (is_dir($templatePath)) {
         $octoConfig['paths']['templates'][$this->getName()] = $templatePath;
     }
     if (is_dir($adminTemplatePath)) {
         $octoConfig['paths']['admin_templates'][$this->getName()] = $adminTemplatePath;
     }
     $octoConfig['paths']['modules'][$this->getName()] = $base;
     $octoConfig['paths']['namespaces'][$this->namespace . '\\' . $this->getName()] = $base;
     if (!isset($octoConfig['namespaces']['blocks'])) {
         $octoConfig['namespaces']['blocks'] = [];
     }
     $blocks = $this->getBlocks($this->namespace);
     $octoConfig['namespaces']['blocks'] = array_merge($octoConfig['namespaces']['blocks'], $blocks);
     $app = $this->config->get('app', []);
     $app['namespaces'] = array_merge($app['namespaces'], $this->getModels($this->namespace));
     $this->config->set('app', $app);
     $this->config->set('Octo', $octoConfig);
 }
Пример #3
0
 /**
  * @param Config $config
  * @param Request $request
  * @param Response $response
  */
 public function __construct(Config $config, Request $request, Response $response)
 {
     $class = explode('\\', get_class($this));
     $this->className = substr(array_pop($class), 0, -10);
     $this->layout = Template::getAdminTemplate('layout');
     if (isset($_SESSION['user'])) {
         $this->menu = new Menu();
         $this->currentUser = $_SESSION['user'];
     }
     $this->layout->siteName = $config->get('site.name');
     $this->layout->breadcrumb = array();
     $this->layout->currentUser = $this->currentUser;
     $this->layout->menu = $this->menu;
     if (file_exists(APP_PATH . 'public/assets/backoffice.css')) {
         $this->layout->siteCss = true;
     }
     if (file_exists(APP_PATH . 'public/assets/images/cms-logo.png')) {
         $this->layout->siteLogo = true;
     }
     return parent::__construct($config, $request, $response);
 }
Пример #4
0
 /**
  * Initialise the Language helper, try load the language file for the user's browser or the configured default.
  * @param Config $config
  */
 public static function init(Config $config)
 {
     self::loadAvailableLanguages();
     // Try cookies first:
     if (isset($_COOKIE) && array_key_exists('phpcilang', $_COOKIE) && self::setLanguage($_COOKIE['phpcilang'])) {
         return;
     }
     // Try user language:
     if (isset($_SERVER) && array_key_exists('HTTP_ACCEPT_LANGUAGE', $_SERVER)) {
         $langs = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
         foreach ($langs as $lang) {
             $parts = explode(';', $lang);
             $language = strtolower($parts[0]);
             if (self::setLanguage($language)) {
                 return;
             }
         }
     }
     // Try the installation default language:
     $language = $config->get('phpci.basic.language', null);
     if (self::setLanguage($language)) {
         return;
     }
     // Fall back to English:
     self::$language = 'en';
     self::$strings = self::loadLanguage();
 }
Пример #5
0
 public function get($key, $default = null)
 {
     return $this->config->get($key, $default);
 }