1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the adminbsb-material-design-bundle package. |
5
|
|
|
* |
6
|
|
|
* (c) 2018 WEBEWEB |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace WBW\Bundle\AdminBSBBundle\Twig\Extension\UI; |
13
|
|
|
|
14
|
|
|
use WBW\Bundle\AdminBSBBundle\Twig\Extension\AdminBSBRendererTwigExtension; |
15
|
|
|
use WBW\Bundle\AdminBSBBundle\Twig\Extension\RendererTwigExtension; |
16
|
|
|
use WBW\Bundle\BootstrapBundle\Twig\Extension\CSS\ButtonTwigExtension as BaseTwigExtension; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Abstract button Twig extension. |
20
|
|
|
* |
21
|
|
|
* @author webeweb <https://github.com/webeweb/> |
22
|
|
|
* @package WBW\Bundle\AdminBSBBundle\Twig\Extension\UI |
23
|
|
|
* @abstract |
24
|
|
|
*/ |
25
|
|
|
abstract class AbstractButtonTwigExtension extends BaseTwigExtension { |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Displays an AdminBSB button. |
29
|
|
|
* |
30
|
|
|
* @param string $content The button content. |
31
|
|
|
* @param string $title The button title. |
32
|
|
|
* @param string $size The button size. |
33
|
|
|
* @param bool $block Block button ? |
34
|
|
|
* @param bool $disable Disable button ? |
35
|
|
|
* @param string $class The button class. |
36
|
|
|
* @param string $icon The button icon. |
37
|
|
|
* @param bool $circle Circle button ? |
38
|
|
|
* @return string Returns the AdminBSB button. |
39
|
|
|
*/ |
40
|
|
|
protected function adminBSBButton($content, $title, $size, $block, $disable, $class, $icon, $circle) { |
41
|
|
|
|
42
|
|
|
// Disable the parameters. |
43
|
|
|
$circle = null !== $content ? false : $circle; |
44
|
|
|
$style = null !== $content ? "margin: -4px 2px 0; vertical-align: sub;" : ""; |
45
|
|
|
|
46
|
|
|
// Initialize the values. |
47
|
|
|
$sizes = ["lg", "sm", "xs"]; |
48
|
|
|
|
49
|
|
|
// Initialize the attributes. |
50
|
|
|
$attributes = []; |
51
|
|
|
|
52
|
|
|
$attributes["class"] = ["btn", $class, "waves-effect"]; |
53
|
|
|
$attributes["class"][] = true === $block ? "btn-block" : null; |
54
|
|
|
$attributes["class"][] = true === $circle ? "btn-circle" . ("lg" === $size ? "-lg" : "") . " waves-circle waves-float" : null; |
55
|
|
|
$attributes["class"][] = true !== $circle && true === in_array($size, $sizes) ? "btn-" . $size : null; |
56
|
|
|
$attributes["title"] = $title; |
57
|
|
|
$attributes["type"] = "button"; |
58
|
|
|
$attributes["data-toggle"] = null !== $title ? "tooltip" : null; |
59
|
|
|
$attributes["disabled"] = true === $disable ? "disabled" : null; |
60
|
|
|
|
61
|
|
|
// Handle the parameters. |
62
|
|
|
$glyphicon = null !== $icon ? RendererTwigExtension::renderIcon($this->getTwigEnvironment(), $icon, $style) : ""; |
63
|
|
|
$innerHTML = null !== $content ? $content : ""; |
64
|
|
|
|
65
|
|
|
// Return the HTML. |
66
|
|
|
return static::coreHTMLElement("button", $glyphicon . $innerHTML, $attributes); |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|