1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of the bootstrap-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\BootstrapBundle\Twig\Extension\Typography; |
13
|
|
|
|
14
|
|
|
use WBW\Bundle\BootstrapBundle\Twig\Extension\AbstractBootstrapTwigExtension; |
15
|
|
|
use WBW\Library\Core\Utility\Argument\StringUtility; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Abstract typography Twig extension. |
19
|
|
|
* |
20
|
|
|
* @author webeweb <https://github.com/webeweb/> |
21
|
|
|
* @package WBW\Bundle\BootstrapBundle\Twig\Extension\Typography |
22
|
|
|
* @abstract |
23
|
|
|
*/ |
24
|
|
|
abstract class AbstractTypographyTwigExtension extends AbstractBootstrapTwigExtension { |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Constructor. |
28
|
|
|
*/ |
29
|
|
|
protected function __construct() { |
30
|
|
|
parent::__construct(); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Displays a Bootstrap bold text. |
35
|
|
|
* |
36
|
|
|
* @param string $content The bold text content. |
37
|
|
|
* @return string Returns the Bootstrap bold text. |
38
|
|
|
*/ |
39
|
|
|
protected function bootstrapBold($content) { |
40
|
|
|
return $this->bootstrapSimpleTag("strong", $content); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Displays a Bootstrap deleted text. |
45
|
|
|
* |
46
|
|
|
* @param string $content The deleted text content. |
47
|
|
|
* @return string Returns the Bootstrap deleted text. |
48
|
|
|
*/ |
49
|
|
|
protected function bootstrapDeleted($content) { |
50
|
|
|
return $this->bootstrapSimpleTag("del", $content); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Displays a Bootstrap heading. |
55
|
|
|
* |
56
|
|
|
* @param integer $size The heading size. |
57
|
|
|
* @param string $content The heading content. |
58
|
|
|
* @param string $description The heading description. |
59
|
|
|
* @param string $class The heading class. |
60
|
|
|
* @return string Returns the Bootstrap heading. |
61
|
|
|
*/ |
62
|
|
|
protected function bootstrapHeading($size, $content, $description, $class) { |
63
|
|
|
|
64
|
|
|
// Initialize the template. |
65
|
|
|
$template = "<h%size%%attributes%>%innerHTML%</h%size%>"; |
66
|
|
|
|
67
|
|
|
// Initialize the attributes. |
68
|
|
|
$attributes = []; |
69
|
|
|
|
70
|
|
|
$attributes[" class"] = [$class]; |
71
|
|
|
|
72
|
|
|
// Initialize the parameters. |
73
|
|
|
$secondary = null !== $description ? " <small>" . $description . "</small>" : ""; |
74
|
|
|
$innerSize = true === in_array($size, [1, 2, 3, 4, 5, 6]) ? $size : 1; |
75
|
|
|
$innerHTML = (null !== $content ? $content : "") . $secondary; |
76
|
|
|
|
77
|
|
|
// Return the HTML. |
78
|
|
|
return StringUtility::replace($template, ["%size%", "%attributes%", "%innerHTML%"], [$innerSize, StringUtility::parseArray($attributes), trim($innerHTML)]); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Displays a Bootstrap inserted text. |
83
|
|
|
* |
84
|
|
|
* @param string $content The inserted text content. |
85
|
|
|
* @return string Returns the Bootstrap inserted text. |
86
|
|
|
*/ |
87
|
|
|
protected function bootstrapInserted($content) { |
88
|
|
|
return $this->bootstrapSimpleTag("ins", $content); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* Displays a Bootstrap italic text. |
93
|
|
|
* |
94
|
|
|
* @param string $content The italic text content. |
95
|
|
|
* @return string Returns the Bootstrap italic text. |
96
|
|
|
*/ |
97
|
|
|
protected function bootstrapItalic($content) { |
98
|
|
|
return $this->bootstrapSimpleTag("em", $content); |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* Displays a Bootstrap marked text. |
103
|
|
|
* |
104
|
|
|
* @param string $content The marked text content. |
105
|
|
|
* @return string Returns the Bootstrap marked text. |
106
|
|
|
*/ |
107
|
|
|
protected function bootstrapMarked($content) { |
108
|
|
|
return $this->bootstrapSimpleTag("mark", $content); |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* Displays a Bootstrap strike through text. |
113
|
|
|
* |
114
|
|
|
* @param string $content The strike through content. |
115
|
|
|
* @return string Returns the Bootstrap strike through text. |
116
|
|
|
*/ |
117
|
|
|
protected function bootstrapStrikeThrough($content) { |
118
|
|
|
return $this->bootstrapSimpleTag("s", $content); |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* Displays a Bootstrap small text. |
123
|
|
|
* |
124
|
|
|
* @param string $content The small text content. |
125
|
|
|
* @return string Returns the Bootstrap small text. |
126
|
|
|
*/ |
127
|
|
|
protected function bootstrapSmall($content) { |
128
|
|
|
return $this->bootstrapSimpleTag("small", $content); |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* Displays a Bootstrap underlined text. |
133
|
|
|
* |
134
|
|
|
* @param string $content The underlined text content. |
135
|
|
|
* @return string Returns the Bootstrap underlined text. |
136
|
|
|
*/ |
137
|
|
|
protected function bootstrapUnderlined($content) { |
138
|
|
|
return $this->bootstrapSimpleTag("u", $content); |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
} |
142
|
|
|
|