1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of the bootstrap-bundle package. |
5
|
|
|
* |
6
|
|
|
* (c) 2018 NdC/WBW |
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\StringUtility; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Abstract typography Twig extension. |
19
|
|
|
* |
20
|
|
|
* @author NdC/WBW <https://github.com/webeweb/> |
21
|
|
|
* @package WBW\Bundle\BootstrapBundle\Twig\Extension\Typography |
22
|
|
|
* @abstract |
23
|
|
|
*/ |
24
|
|
|
abstract class AbstractTypographyTwigExtension extends AbstractBootstrapTwigExtension { |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Displays a Bootstrap deleted text. |
28
|
|
|
* |
29
|
|
|
* @param string $content The mark content. |
30
|
|
|
* @return string Returns the Bootstrap deleted text. |
31
|
|
|
*/ |
32
|
|
|
final protected function bootstrapDeleted($content) { |
33
|
|
|
|
34
|
|
|
// Initialize the template. |
35
|
|
|
$template = "<del>%innerHTML%</del>"; |
36
|
|
|
|
37
|
|
|
// Initialize the parameters. |
38
|
|
|
$innerHTML = null !== $content ? $content : ""; |
39
|
|
|
|
40
|
|
|
// Return the HTML. |
41
|
|
|
return StringUtility::replace($template, ["%innerHTML%"], [$innerHTML]); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Displays a Bootstrap heading. |
46
|
|
|
* |
47
|
|
|
* @param integer $size The heading size. |
48
|
|
|
* @param string $content The heading content. |
49
|
|
|
* @param string $description The heading description. |
50
|
|
|
* @param string $class The heading class. |
51
|
|
|
* @return string Returns the Bootstrap heading. |
52
|
|
|
*/ |
53
|
|
|
final protected function bootstrapHeading($size, $content, $description, $class) { |
54
|
|
|
|
55
|
|
|
// Initialize the template. |
56
|
|
|
$template = "<h%size%%attributes%>%innerHTML%</h%size%>"; |
57
|
|
|
|
58
|
|
|
// Initialize the attributes. |
59
|
|
|
$attributes = []; |
60
|
|
|
|
61
|
|
|
$attributes[" class"] = [$class]; |
62
|
|
|
|
63
|
|
|
// Initialize the parameters. |
64
|
|
|
$secondary = null !== $description ? " <small>" . $description . "</small>" : ""; |
65
|
|
|
$innerSize = true === in_array($size, [1, 2, 3, 4, 5, 6]) ? $size : 1; |
66
|
|
|
$innerHTML = (null !== $content ? $content : "") . $secondary; |
67
|
|
|
|
68
|
|
|
// Return the HTML. |
69
|
|
|
return StringUtility::replace($template, ["%size%", "%attributes%", "%innerHTML%"], [$innerSize, StringUtility::parseArray($attributes), trim($innerHTML)]); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Displays a Bootstrap inserted text. |
74
|
|
|
* |
75
|
|
|
* @param string $content The mark content. |
76
|
|
|
* @return string Returns the Bootstrap inserted text. |
77
|
|
|
*/ |
78
|
|
|
final protected function bootstrapInserted($content) { |
79
|
|
|
|
80
|
|
|
// Initialize the template. |
81
|
|
|
$template = "<ins>%innerHTML%</ins>"; |
82
|
|
|
|
83
|
|
|
// Initialize the parameters. |
84
|
|
|
$innerHTML = null !== $content ? $content : ""; |
85
|
|
|
|
86
|
|
|
// Return the HTML. |
87
|
|
|
return StringUtility::replace($template, ["%innerHTML%"], [$innerHTML]); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
/** |
92
|
|
|
* Displays a Bootstrap italic text. |
93
|
|
|
* |
94
|
|
|
* @param string $content The mark content. |
95
|
|
|
* @return string Returns the Bootstrap italic text. |
96
|
|
|
*/ |
97
|
|
|
final protected function bootstrapItalic($content) { |
98
|
|
|
|
99
|
|
|
// Initialize the template. |
100
|
|
|
$template = "<em>%innerHTML%</em>"; |
101
|
|
|
|
102
|
|
|
// Initialize the parameters. |
103
|
|
|
$innerHTML = null !== $content ? $content : ""; |
104
|
|
|
|
105
|
|
|
// Return the HTML. |
106
|
|
|
return StringUtility::replace($template, ["%innerHTML%"], [$innerHTML]); |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
/** |
111
|
|
|
* Displays a Bootstrap marked text. |
112
|
|
|
* |
113
|
|
|
* @param string $content The mark content. |
114
|
|
|
* @return string Returns the Bootstrap marked text. |
115
|
|
|
*/ |
116
|
|
|
final protected function bootstrapMarked($content) { |
117
|
|
|
|
118
|
|
|
// Initialize the template. |
119
|
|
|
$template = "<mark>%innerHTML%</mark>"; |
120
|
|
|
|
121
|
|
|
// Initialize the parameters. |
122
|
|
|
$innerHTML = null !== $content ? $content : ""; |
123
|
|
|
|
124
|
|
|
// Return the HTML. |
125
|
|
|
return StringUtility::replace($template, ["%innerHTML%"], [$innerHTML]); |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* Displays a Bootstrap strike through text. |
130
|
|
|
* |
131
|
|
|
* @param string $content The mark content. |
132
|
|
|
* @return string Returns the Bootstrap strike through text. |
133
|
|
|
*/ |
134
|
|
|
final protected function bootstrapStrikeThrough($content) { |
135
|
|
|
|
136
|
|
|
// Initialize the template. |
137
|
|
|
$template = "<s>%innerHTML%</s>"; |
138
|
|
|
|
139
|
|
|
// Initialize the parameters. |
140
|
|
|
$innerHTML = null !== $content ? $content : ""; |
141
|
|
|
|
142
|
|
|
// Return the HTML. |
143
|
|
|
return StringUtility::replace($template, ["%innerHTML%"], [$innerHTML]); |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
/** |
147
|
|
|
* Displays a Bootstrap small text. |
148
|
|
|
* |
149
|
|
|
* @param string $content The mark content. |
150
|
|
|
* @return string Returns the Bootstrap small text. |
151
|
|
|
*/ |
152
|
|
|
final protected function bootstrapSmall($content) { |
153
|
|
|
|
154
|
|
|
// Initialize the template. |
155
|
|
|
$template = "<small>%innerHTML%</small>"; |
156
|
|
|
|
157
|
|
|
// Initialize the parameters. |
158
|
|
|
$innerHTML = null !== $content ? $content : ""; |
159
|
|
|
|
160
|
|
|
// Return the HTML. |
161
|
|
|
return StringUtility::replace($template, ["%innerHTML%"], [$innerHTML]); |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
/** |
165
|
|
|
* Displays a Bootstrap bold text. |
166
|
|
|
* |
167
|
|
|
* @param string $content The mark content. |
168
|
|
|
* @return string Returns the Bootstrap bold text. |
169
|
|
|
*/ |
170
|
|
|
final protected function bootstrapStrong($content) { |
171
|
|
|
|
172
|
|
|
// Initialize the template. |
173
|
|
|
$template = "<strong>%innerHTML%</strong>"; |
174
|
|
|
|
175
|
|
|
// Initialize the parameters. |
176
|
|
|
$innerHTML = null !== $content ? $content : ""; |
177
|
|
|
|
178
|
|
|
// Return the HTML. |
179
|
|
|
return StringUtility::replace($template, ["%innerHTML%"], [$innerHTML]); |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
/** |
183
|
|
|
* Displays a Bootstrap underlined text. |
184
|
|
|
* |
185
|
|
|
* @param string $content The mark content. |
186
|
|
|
* @return string Returns the Bootstrap underlined text. |
187
|
|
|
*/ |
188
|
|
|
final protected function bootstrapUnderlined($content) { |
189
|
|
|
|
190
|
|
|
// Initialize the template. |
191
|
|
|
$template = "<u>%innerHTML%</u>"; |
192
|
|
|
|
193
|
|
|
// Initialize the parameters. |
194
|
|
|
$innerHTML = null !== $content ? $content : ""; |
195
|
|
|
|
196
|
|
|
// Return the HTML. |
197
|
|
|
return StringUtility::replace($template, ["%innerHTML%"], [$innerHTML]); |
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
} |
201
|
|
|
|