diff --git a/README.md b/README.md index 4fdd7ad..e0efc1a 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ Bootstrap version | Template version 3.3 | 3.3 3.* | 4.0 3.* | 4.1 +4.* | 5.0 Bootstrap menu rendererer ------------------------- diff --git a/composer.json b/composer.json index 710f116..d8777b0 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,6 @@ } ], "keywords" : [ - "javascript", "mouf", "bootstrap", "template" @@ -18,13 +17,11 @@ "license" : "MIT", "require" : { "mouf/html.utils.weblibrarymanager" : "~3.0", - "mouf/html.utils.weblibrarymanager.component-installer" : "~2.2", + "mouf/html.utils.weblibrarymanager.component-installer" : "~2.2", "mouf/html.widgets.messageservice" : "~3.0", "php" : ">=5.4.0", "mouf/html.widgets.menu" : "~3.0", - "mouf/html.template.templateinterface" : "~2.1", - "components/jquery": "~1.9", - "components/bootstrap": "3.*" + "mouf/html.template.templateinterface" : "~2.1" }, "autoload" : { "psr-0" : { diff --git a/src/Mouf/Html/Template/BootstrapTemplate.php b/src/Mouf/Html/Template/BootstrapTemplate.php index 240e615..63afd6e 100644 --- a/src/Mouf/Html/Template/BootstrapTemplate.php +++ b/src/Mouf/Html/Template/BootstrapTemplate.php @@ -135,7 +135,7 @@ public function toHtml() // Let's register the template renderer in the default renderer. $this->getDefaultRenderer()->setTemplateRenderer($this->getTemplateRenderer()); - if (PHP_SAPI !== 'cli') { + if (PHP_SAPI !== 'cli' && !headers_sent()) { header('Content-Type: text/html; charset=utf-8'); } //Renderable::toHtml();// __DIR__."/../../../../views/template.php"; diff --git a/src/Mouf/Html/Template/BootstrapTemplateInstaller.php b/src/Mouf/Html/Template/BootstrapTemplateInstaller.php index e3950fd..ebdc5ca 100644 --- a/src/Mouf/Html/Template/BootstrapTemplateInstaller.php +++ b/src/Mouf/Html/Template/BootstrapTemplateInstaller.php @@ -71,12 +71,23 @@ public static function install(MoufManager $moufManager) $template->getProperty("templateRenderer")->setValue($bootstrapRenderer); $template->getProperty("defaultRenderer")->setValue($moufManager->getInstanceDescriptor("defaultRenderer")); - // Let's first ensure all components are created - ComponentsIntegrationService::fixAllInAppScope(); // Now, let's modify the component.bootstrap component because it does not feature the CSS files: - $bootstrapWebLibrary = $moufManager->getInstanceDescriptor("component.bootstrap"); - $bootstrapWebLibrary->getProperty("cssFiles")->setValue(array("vendor/components/bootstrap/css/bootstrap.min.css")); + $jqueryWebLibrary = InstallUtils::getOrCreateInstance("component.jquery", "Mouf\\Html\\Utils\\WebLibraryManager\\WebLibrary", $moufManager); + $jqueryWebLibrary->getProperty("jsFiles")->setValue(array("https://code.jquery.com/jquery-3.3.1.slim.min.js")); + + $popperWebLibrary = InstallUtils::getOrCreateInstance("component.popper", "Mouf\\Html\\Utils\\WebLibraryManager\\WebLibrary", $moufManager); + $popperWebLibrary->getProperty("jsFiles")->setValue(array("https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js")); + + $bootstrapWebLibrary = InstallUtils::getOrCreateInstance("component.bootstrap", "Mouf\\Html\\Utils\\WebLibraryManager\\WebLibrary", $moufManager); + $bootstrapWebLibrary->getProperty("cssFiles")->setValue(array("https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css")); + $bootstrapWebLibrary->getProperty("jsFiles")->setValue(array("https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js")); + + $webLibraryManagers = $webLibraryManager->getProperty('webLibraries')->getValue(); + $webLibraryManagers[] = $jqueryWebLibrary; + $webLibraryManagers[] = $popperWebLibrary; + $webLibraryManagers[] = $bootstrapWebLibrary; + $webLibraryManager->getProperty('webLibraries')->setValue($webLibraryManagers); // Let's rewrite the MoufComponents.php file to save the component $moufManager->rewriteMouf(); diff --git a/src/Mouf/Html/Template/Menus/BootstrapNavBar.php b/src/Mouf/Html/Template/Menus/BootstrapNavBar.php index 45d3548..783c320 100644 --- a/src/Mouf/Html/Template/Menus/BootstrapNavBar.php +++ b/src/Mouf/Html/Template/Menus/BootstrapNavBar.php @@ -46,12 +46,28 @@ class BootstrapNavBar implements HtmlElementInterface public $titleLink = ""; /** - * If checked, the navbar will be rendered in dark shades instead of bright shades. + * If checked, the navbar will be rendered in dark shades instead of bright shades. This is a shorthand for setting either : + * - navbar-dark bg-dark (TRUE) + * - navbar-light bg-light (FALSE) * * @var boolean */ public $inverted; + /** + * The mode of the Nav Bar : can be one of 'dark' or 'light'. This mainly will apply nav-bar-$mode class for inner items color. + * @Property + * @var string + */ + private $mode; + + /** + * The background of the Nav Bar : can be one of 'primary', 'secondary', 'success', 'danger', 'warning', 'info', 'light', 'dark', 'white', 'transparent'. + * @Property + * @var string + */ + private $background; + /** * Display the menu with the maximum width
* If the parameter fixed is set, this is not used @@ -80,4 +96,38 @@ public function __construct($children = array()) { $this->children = $children; } + + /** + * @return string + */ + public function getMode(): string + { + return $this->mode ?? ($this->inverted ? 'dark' : 'light'); + } + + /** + * @param string $mode + */ + public function setMode(string $mode): void + { + $this->mode = $mode; + } + + /** + * @return string + */ + public function getBackground(): string + { + return $this->background ?? ($this->inverted ? 'dark' : 'light'); + } + + /** + * @param string $background + */ + public function setBackground(string $background): void + { + $this->background = $background; + } + + } diff --git a/src/templates/Mouf/Html/Template/BootstrapTemplate.twig b/src/templates/Mouf/Html/Template/BootstrapTemplate.twig index 4001eea..30cabf0 100644 --- a/src/templates/Mouf/Html/Template/BootstrapTemplate.twig +++ b/src/templates/Mouf/Html/Template/BootstrapTemplate.twig @@ -44,7 +44,7 @@
{% if leftHtml %} -