<?php

use Cbikt\Front\PageModelFactory;
use Cbikt\Front\UserIdVariable;
use Cbikt\Security\AlwaysLoggedIn;
use Cbikt\Security\AuthenticationStrategy;
use Cbikt\Security\DbIdProvider;
use Cbikt\Security\IdProvider;
use Cbikt\Views\Metronic;

return array(
    "output" => array(
        "enable-xhtml" => false,
    ),
    "lang" => array(
        "enabled-languages" => array("en", "de"),
        "cookie" => array(
            "duration" => 2*7*24*3600, // 2 weeks
            //"domain" => "example.org", // optional
        ),
    ),
    "login" => array(
        "default-startpage" => "/PAGE_PATH",
        "cookie_domain" => "example.org",
        "cookie_runtime" => 2*7*24*3600, // 2 weeks
    ),
    "messaging" => array(
        "scope" => "admin",
    ),

    // This is an example configuration that enables the metronic theme.
    "theme" => array(
        "stylesheets" => array(
            "/lib/font-awesome-4.7.0/css/font-awesome.css",
            "/lib/bootstrap-3.3.7/css/bootstrap.css",
            "/rad-assets/style.css",
        ),

        "scripts" => array(
            "/lib/jquery-3.2.0.js",
            "/lib/bootstrap-3.3.7/js/bootstrap.js",
            "/rad-assets/script.js",
        ),

        // Variables accessible by all top level templates through
        // $this["var-name"].
        "vars" => array(
            "logo-html" => '<img src="/images/logo.png" />',
            "footer-html" => 'Created by <strong>Company</strong>',
            "title-suffix" => " | My application",
        ),

        // A list of layouts that can be used in the 'template' attribute of
        // a rad:page XML element and as a parameter to Layout::create().
        "layouts" => array(
            "modal" => array(
                "template" => RESOURCES_RAD . "/metronic/modal.phtml",
            ),

            "layout_full" => array(
                "stylesheets" => array(
                    "/themes/metronic/css/components.css",
                    "/themes/metronic/css/plugins.css",
                    "/themes/metronic/css/layout.css",
                    "/themes/metronic/css/themes/darkblue.css",
                ),
                "scripts" => array(
                    "/themes/metronic/js/metronic-bare.js",
                ),
                "scripts-ie" => array(
                    "lt IE 9" => array(
                        "/themes/metronic/js/respond.js",
                        "/themes/metronic/js/ie8.fix.js",
                    ),
                ),

                // Path to the top level template file.
                "template" => \RESOURCES_RAD . "/metronic/layout_full.phtml",
                "regions" => array(
                    "breadcrumb" => array(
                        array(
                            "type" => "breadcrumb",
                            "class" => Metronic\BreadcrumbView::class,
                            // Optional: don't display n leading components.
                            // "strip-leading" => 1,
                        ),
                    ),
                    "sidebar" => array(
                        array(
                            "type" => "menu",
                            "class" => Metronic\MenuView::class,
                            // Optional: display menu starting from a
                            // particular path instead of the root directory.
                            // "root-path" => "/admin/",

                            // Optional: Run custom code before the menu is
                            // rendered.
                            // "preprocessors" => array(
                            //     MyApp\CustomMenuPreprocessor::class,
                            // ),
                        ),
                    ),
                ),
            ),
        ),
    ),

    "php-di" => array(
        PDO::class => function($_) {
            return new PDO(
                "mysql:host=localhost;dbname=DATABASE;charset=utf8",
                "USERNAME",
                "PASSWORD",
                array(
                    PDO::MYSQL_ATTR_INIT_COMMAND => "SET sql_mode='IGNORE_SPACE'",
                    PDO::ATTR_PERSISTENT => false,
                    PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
                )
            );
        },
        AuthenticationStrategy::class => function($_) {
            return new AlwaysLoggedIn(1);
        },
        IdProvider::class => \DI\autowire(DbIdProvider::class),
        PageModelFactory::class => \DI\autowire()
            ->method("addVariable", "userid", \DI\get(UserIdVariable::class)),
    ),
);
