Microweber\Controllers\AdminController::index PHP Method

index() public method

public index ( )
    public function index()
    {
        $is_installed = mw_is_installed();
        if (!$is_installed) {
            if (!$is_installed) {
                $installer = new InstallController();
                return $installer->index();
            }
        } elseif (defined('MW_VERSION')) {
            $config_version = Config::get('microweber.version');
            if ($config_version != MW_VERSION) {
                $this->app->update->post_update(MW_VERSION);
            }
        }
        if (!defined('MW_BACKEND')) {
            define('MW_BACKEND', true);
        }
        //create_mw_default_options();
        mw()->content_manager->define_constants();
        if (defined('TEMPLATE_DIR')) {
            $load_template_functions = TEMPLATE_DIR . 'functions.php';
            if (is_file($load_template_functions)) {
                include_once $load_template_functions;
            }
        }
        event_trigger('mw.admin');
        event_trigger('mw_backend');
        $view = modules_path() . 'admin/';
        $hasNoAdmin = User::where('is_admin', 1)->limit(1)->count();
        if (!$hasNoAdmin) {
            $this->hasNoAdmin();
        }
        $hasNoAdmin = User::where('is_admin', 1)->limit(1)->count();
        $view .= (!$hasNoAdmin ? 'create' : 'index') . '.php';
        $layout = new View($view);
        $layout = $layout->__toString();
        $layout = mw()->parser->process($layout);
        event_trigger('on_load');
        $layout = execute_document_ready($layout);
        event_trigger('mw.admin.header');
        $apijs_loaded = mw()->template->get_apijs_url();
        $apijs_settings_loaded = mw()->template->get_apijs_settings_url();
        $default_css = '<link rel="stylesheet" href="' . mw_includes_url() . 'default.css" type="text/css" />';
        if (!stristr($layout, $apijs_loaded)) {
            $rep = 0;
            $default_css = $default_css . "\r\n" . '<script src="' . $apijs_settings_loaded . '"></script>' . "\r\n";
            $default_css = $default_css . "\r\n" . '<script src="' . $apijs_loaded . '"></script>' . "\r\n";
            $layout = str_ireplace('<head>', '<head>' . $default_css, $layout, $rep);
        }
        $template_headers_src = mw()->template->admin_head(true);
        if ($template_headers_src != false and $template_headers_src != '') {
            $layout = str_ireplace('</head>', $template_headers_src . '</head>', $layout, $one);
        }
        return $layout;
    }