<?php
namespace nur\v\bs3;

use nur\co;
use nur\md;
use nur\msg;
use nur\v\fo;
use nur\v\html5\Html5NavigablePageContainer;
use nur\v\icon;
use nur\v\ly;
use nur\v\navbar;
use nur\v\v;

class Bs3PageContainer extends Html5NavigablePageContainer {
  protected function initToolkit(): void {
    parent::initToolkit();
    msg::set_messenger_class(Bs3Messenger::class);
    fo::set_manager_class(Bs3FormManager::class);
    ly::set_manager_class(Bs3LayoutManager::class);
    navbar::set_manager_class(Bs3NavbarManager::class);
    icon::set_manager_class(Bs3IconManager::class);
  }

  function doResolveConfig(): void {
    $this->setHaveJs("jquery");
    parent::doResolveConfig();
  }

  function printStartHead(): void {
    $page = $this->page;
    $page->beforePrintStartHead();
    $prefix = $this->getSelfRelativePrefix();
    ?>
<head>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="shortcut" href="<?=$prefix?>nur-v-bs3/favicon.ico" />
<link rel="icon" href="<?=$prefix?>nur-v-bs3/appicon.png" />
<link rel="apple-touch-icon" href="<?=$prefix?>nur-v-bs3/appicon.png" />
<link href="<?=$prefix?>nur-v-bs3/bootstrap/css/bootstrap.min.css" rel="stylesheet"/>
<link href="<?=$prefix?>nur-base/base.css" rel="stylesheet"/>
<link href="<?=$prefix?>nur-v-bs3/base.css" rel="stylesheet"/>
<script src="<?=$prefix?>nur-v-bs3/jquery/jquery.min.js" type="text/javascript"></script>
<script src="<?=$prefix?>nur-v-bs3/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<!--[if lt IE 9]>
<script src="<?=$prefix?>nur-v-bs3/html5shiv/html5shiv.js"></script>
<script src="<?=$prefix?>nur-v-bs3/respond/respond.min.js"></script>
<![endif]-->
<?php
    $page->afterPrintStartHead();
  }

  const CONTAINER_OPTIONS_SCHEMA = [
    "container" => ["?string", _container::CONTAINER_NORMAL, "type de container"],
  ];

  function printStartContainer(?array $options): void {
    md::ensure_schema($options, self::CONTAINER_OPTIONS_SCHEMA);
    co::_print(v::sdiv(["class" => _container::get_class($options["container"])]));
  }

  function printEndContainer(): void {
    co::_print(v::ediv());
  }
}
