Example #1
0
 function __construct($admin_path)
 {
     $this->check_magic_quotes();
     require $admin_path . '/core/library/config.php';
     $config = $this->config = new Config($admin_path);
     require $config->library_path . '/string.php';
     require $config->library_path . '/file.php';
     spl_autoload_register(array($this, 'autoload'));
     $is_config_loaded = $this->config->load();
     $this->setup_error_reporting();
     if (!$is_config_loaded) {
         $router = new Router($config, null, '/setup/install/');
     } else {
         $router = new Router($config);
     }
     $hook = new Hook();
     $admin_script = new Admin\Scripts($router->admin_url, $router, $config);
     $admin_style = new Admin\Styles($router->admin_url, $router, $config);
     $hook->add('admin_head', array($admin_style, 'do_items'), 0, 10);
     $hook->add('admin_head', array($admin_script, 'do_head_items'), 0, 10);
     $hook->add('admin_footer', array($admin_script, 'do_footer_items'), 0, 100);
     $settings = new Settings($config);
     $router->settings = $settings;
     $active_template = $settings->get_template_about();
     $template_script = new Template\Scripts('', $router, $config, $active_template['version']);
     $template_style = new Template\Styles('', $router, $config, $active_template['version']);
     $hook->add('head', array($template_style, 'do_items'), 0, 10);
     $hook->add('head', array($template_script, 'do_head_items'), 0, 10);
     $hook->add('footer', array($template_script, 'do_footer_items'), 0, 100);
     $user = new User($config, $router);
     $view = new View($config, $router, $hook);
     if ($settings->get('connection', 'type') && 'direct' != $settings->get('connection', 'type')) {
         $class_name = Filesystem::get_class_name($settings->get('connection', 'type'));
         $filesystem = new $class_name($config, array('connection_type' => $settings->get('connection', 'type'), 'hostname' => $settings->get('connection', 'hostname'), 'username' => $settings->get('connection', 'username'), 'password' => $settings->get('connection', 'password')));
     } else {
         $filesystem = new Filesystem\Direct($config);
     }
     $addon = new Addon($config, $settings, $hook, $admin_script, $admin_style, $template_script, $template_style, $filesystem, $router);
     $addon->load_active();
     $content = new Content($config, $filesystem, $router, $settings, $hook);
     $template = new Template($config, $filesystem, $router, $settings, $hook, $template_script, $template_style, $content);
     $router->parse_request_url();
     $router->set_controller_class();
     $controller_class = $router->controller_class;
     $controller = new $controller_class($router, $view, $filesystem, $config, $user, $template, $settings, $hook, $content, $addon);
     if (!$user->is_logged_in() && !$controller->is_no_auth_action()) {
         Router::redirect($router->admin_url('/user/login/'));
         exit;
     }
     $controller->call_action();
 }