1 | <?php |
||
43 | class ParserOutputHelper { |
||
44 | |||
45 | /** |
||
46 | * @var string |
||
47 | */ |
||
48 | const INJECTION_PREFIX = '<!-- injected by Extension:BootstrapComponents -->'; |
||
49 | |||
50 | /** |
||
51 | * @var string |
||
52 | */ |
||
53 | const INJECTION_SUFFIX = '<!-- /injected by Extension:BootstrapComponents -->'; |
||
54 | |||
55 | /** |
||
56 | * To make sure, we only add the tracking category once. |
||
57 | * |
||
58 | * @var bool $articleTracked |
||
59 | */ |
||
60 | private $articleTracked; |
||
61 | |||
62 | /** |
||
63 | * To make sure, we only add the error tracking category once. |
||
64 | * |
||
65 | * @var bool $articleTrackedOnError |
||
66 | */ |
||
67 | private $articleTrackedOnError; |
||
68 | |||
69 | /** |
||
70 | * Here, components can store html to be added to the page at a later time. |
||
71 | * |
||
72 | * @var string $contentForLaterInjection |
||
73 | */ |
||
74 | private $contentForLaterInjection; |
||
75 | |||
76 | /** |
||
77 | * Holds the name of the skin we use (or false, if there is no skin). |
||
78 | * |
||
79 | * @var string $nameOfActiveSkin |
||
80 | */ |
||
81 | private $nameOfActiveSkin; |
||
82 | |||
83 | /** |
||
84 | * @var \Parser $parser |
||
85 | */ |
||
86 | private $parser; |
||
87 | |||
88 | |||
89 | /** |
||
90 | * ParserOutputHelper constructor. |
||
91 | * |
||
92 | * Do not instantiate directly, but use {@see ApplicationFactory::getParserOutputHelper} instead. |
||
93 | * |
||
94 | * @param \Parser $parser |
||
95 | * |
||
96 | * @see ApplicationFactory::getParserOutputHelper |
||
97 | */ |
||
98 | 18 | public function __construct( $parser ) { |
|
107 | |||
108 | /** |
||
109 | * Adds the error tracking category to the current page if not done already. |
||
110 | */ |
||
111 | 13 | public function addErrorTrackingCategory() { |
|
118 | |||
119 | /** |
||
120 | * Adds the supplied modules to the parser output. |
||
121 | * |
||
122 | * @param array $modulesToAdd |
||
123 | */ |
||
124 | 20 | public function addModules( $modulesToAdd ) { |
|
131 | |||
132 | /** |
||
133 | * Adds the tracking category to the current page if not done already. |
||
134 | */ |
||
135 | 18 | public function addTrackingCategory() { |
|
142 | |||
143 | /** |
||
144 | * Unless I find a solution for the integration test problem, I cannot use an instance of |
||
145 | * ParserOutputHelper in ImageModal to ascertain this. In integration tests, "we" use a |
||
146 | * different parser than the InternalParseBeforeLinks-Hook. At least, after I added |
||
147 | * Scribunto _unit_ tests. All messes up, I'm afraid. ImageModal better use global parser, and |
||
148 | * for the time being this method will be |
||
149 | * @deprecated |
||
150 | * |
||
151 | * @return bool|null |
||
152 | */ |
||
153 | public function areImageModalsSuppressed() { |
||
156 | |||
157 | /** |
||
158 | * Returns the raw html that is be inserted at the end of the page. |
||
159 | * |
||
160 | * @return string |
||
161 | */ |
||
162 | 24 | public function getContentForLaterInjection() { |
|
171 | |||
172 | /** |
||
173 | * @return string |
||
174 | */ |
||
175 | 22 | public function getNameOfActiveSkin() { |
|
178 | |||
179 | /** |
||
180 | * Allows to store html that will be added to the page at a later time. |
||
181 | * |
||
182 | * @param string $rawHtml |
||
183 | * |
||
184 | * @return ParserOutputHelper $this (fluid) |
||
185 | */ |
||
186 | 10 | public function injectLater( $rawHtml ) { |
|
192 | |||
193 | /** |
||
194 | * Adds the bootstrap modules and styles to the page, if not done already |
||
195 | */ |
||
196 | 20 | public function loadBootstrapModules() { |
|
207 | |||
208 | /** |
||
209 | * Formats a text as error text so it can be added to the output. |
||
210 | * |
||
211 | * @param string $errorMessageName |
||
212 | * |
||
213 | * @return string |
||
214 | */ |
||
215 | 16 | public function renderErrorMessage( $errorMessageName ) { |
|
226 | |||
227 | /** |
||
228 | * Returns true, if active skin is vector |
||
229 | * |
||
230 | * @return bool |
||
231 | */ |
||
232 | 21 | public function vectorSkinInUse() { |
|
235 | |||
236 | /** |
||
237 | * @return \Parser |
||
238 | */ |
||
239 | 21 | protected function getParser() { |
|
242 | |||
243 | /** |
||
244 | * @param bool $useConfig set to true, if we can't rely on {@see \RequestContext::getSkin} |
||
245 | * |
||
246 | * @return string |
||
247 | */ |
||
248 | 18 | private function detectSkinInUse( $useConfig = false ) { |
|
263 | |||
264 | /** |
||
265 | * Adds current page to the indicated tracking category, if not done already. |
||
266 | * |
||
267 | * @param String $trackingCategoryMessageName name of the message, containing the tracking category |
||
268 | */ |
||
269 | 4 | private function placeTrackingCategory( $trackingCategoryMessageName ) { |
|
283 | } |
||
284 |