1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of the syntaxhighligter-bundle package. |
5
|
|
|
* |
6
|
|
|
* (c) 2017 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\SyntaxHighlighterBundle\API; |
13
|
|
|
|
14
|
|
|
use WBW\Bundle\SyntaxHighlighterBundle\Encoder\SyntaxHighlighterEncoder; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* SyntaxHighlighter config. |
18
|
|
|
* |
19
|
|
|
* @author webeweb <https://github.com/webeweb/> |
20
|
|
|
* @package WBW\Bundle\SyntaxHighlighterBundle\API |
21
|
|
|
* @final |
22
|
|
|
*/ |
23
|
|
|
final class SyntaxHighlighterConfig { |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Blogger mode. |
27
|
|
|
* |
28
|
|
|
* @var boolean |
29
|
|
|
*/ |
30
|
|
|
private $bloggerMode = false; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Strings |
34
|
|
|
* |
35
|
|
|
* @var SyntaxHighlighterStrings |
36
|
|
|
*/ |
37
|
|
|
private $strings; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Strip BRs. |
41
|
|
|
* |
42
|
|
|
* @var boolean |
43
|
|
|
*/ |
44
|
|
|
private $stripBrs = false; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Tag name. |
48
|
|
|
* |
49
|
|
|
* @var string |
50
|
|
|
*/ |
51
|
|
|
private $tagName = "pre"; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Constructor. |
55
|
|
|
*/ |
56
|
|
|
public function __construct() { |
57
|
|
|
// NOTHING TO DO. |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Convert into a string representing this instance. |
62
|
|
|
* |
63
|
|
|
* @return string Returns a string representing this instance. |
64
|
|
|
*/ |
65
|
|
|
public function __toString() { |
66
|
|
|
|
67
|
|
|
// Initialize. |
68
|
|
|
$script = "SyntaxHighlighter.config."; |
69
|
|
|
|
70
|
|
|
// Initialize the output. |
71
|
|
|
$output = []; |
72
|
|
|
|
73
|
|
|
SyntaxHighlighterEncoder::booleanToString($this->bloggerMode, $output, $script . "bloggerMode = ", ";"); |
74
|
|
|
SyntaxHighlighterEncoder::booleanToString($this->stripBrs, $output, $script . "stripBrs = ", ";"); |
75
|
|
|
SyntaxHighlighterEncoder::stringToString($this->tagName, $output, $script . "tagName = \"", "\";"); |
76
|
|
|
SyntaxHighlighterEncoder::stringToString($this->strings, $output, "", ""); |
77
|
|
|
|
78
|
|
|
// Return the output. |
79
|
|
|
return implode("\n", $output); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Get the blogger mode. |
84
|
|
|
* |
85
|
|
|
* @return boolean Returns the blogger mode. |
86
|
|
|
*/ |
87
|
|
|
public function getBloggerMode() { |
88
|
|
|
return $this->bloggerMode; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* Get the strings. |
93
|
|
|
* |
94
|
|
|
* @return SyntaxHighlighterStrings Returns the strings |
95
|
|
|
*/ |
96
|
|
|
public function getStrings() { |
97
|
|
|
return $this->strings; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* Get the strip BRs. |
102
|
|
|
* |
103
|
|
|
* @return boolean Returns the strip BRs. |
104
|
|
|
*/ |
105
|
|
|
public function getStripBrs() { |
106
|
|
|
return $this->stripBrs; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* Get the tag name. |
111
|
|
|
* |
112
|
|
|
* @return string Returns the tag name. |
113
|
|
|
*/ |
114
|
|
|
public function getTagName() { |
115
|
|
|
return $this->tagName; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* Set the blogger mode. |
120
|
|
|
* |
121
|
|
|
* @param boolean $bloggerMode The blogger mode. |
122
|
|
|
* @return SyntaxHighlighterConfig Returns the SyntaxHighlighter config. |
123
|
|
|
*/ |
124
|
|
|
public function setBloggerMode($bloggerMode = false) { |
125
|
|
|
$this->bloggerMode = $bloggerMode; |
126
|
|
|
return $this; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* Set the strings. |
131
|
|
|
* |
132
|
|
|
* @param SyntaxHighlighterStrings $strings The strings. |
133
|
|
|
* @return SyntaxHighlighterConfig Returns the SyntaxHighlighter config. |
134
|
|
|
*/ |
135
|
|
|
public function setStrings(SyntaxHighlighterStrings $strings = null) { |
136
|
|
|
$this->strings = $strings; |
137
|
|
|
return $this; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* Set the strip BRs. |
142
|
|
|
* |
143
|
|
|
* @param boolean $stripBrs The strip BRs. |
144
|
|
|
* @return SyntaxHighlighterConfig Returns the SyntaxHighlighter config. |
145
|
|
|
*/ |
146
|
|
|
public function setStripBrs($stripBrs = false) { |
147
|
|
|
$this->stripBrs = $stripBrs; |
148
|
|
|
return $this; |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* Set the tag name. |
153
|
|
|
* |
154
|
|
|
* @param string $tagName The tag name. |
155
|
|
|
* @return SyntaxHighlighterConfig Returns the SyntaxHighlighter config. |
156
|
|
|
*/ |
157
|
|
|
public function setTagName($tagName = "pre") { |
158
|
|
|
$this->tagName = $tagName; |
159
|
|
|
return $this; |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
} |
163
|
|
|
|