1 | <?php |
||
43 | class ParserOutputHelper { |
||
44 | |||
45 | /** |
||
46 | * @var string |
||
47 | */ |
||
48 | const EXTENSION_DATA_DEFERRED_CONTENT_KEY = 'bsc_deferredContent'; |
||
49 | |||
50 | /** |
||
51 | * @var string |
||
52 | */ |
||
53 | const INJECTION_PREFIX = '<!-- injected by Extension:BootstrapComponents -->'; |
||
54 | |||
55 | /** |
||
56 | * @var string |
||
57 | */ |
||
58 | const INJECTION_SUFFIX = '<!-- /injected by Extension:BootstrapComponents -->'; |
||
59 | |||
60 | /** |
||
61 | * To make sure, we only add the tracking category once. |
||
62 | * |
||
63 | * @var bool $articleTracked |
||
64 | */ |
||
65 | private $articleTracked; |
||
66 | |||
67 | /** |
||
68 | * To make sure, we only add the error tracking category once. |
||
69 | * |
||
70 | * @var bool $articleTrackedOnError |
||
71 | */ |
||
72 | private $articleTrackedOnError; |
||
73 | |||
74 | /** |
||
75 | * Holds the name of the skin we use (or false, if there is no skin). |
||
76 | * |
||
77 | * @var string $nameOfActiveSkin |
||
78 | */ |
||
79 | private $nameOfActiveSkin; |
||
80 | |||
81 | /** |
||
82 | * @var \Parser $parser |
||
83 | */ |
||
84 | private $parser; |
||
85 | |||
86 | |||
87 | /** |
||
88 | * ParserOutputHelper constructor. |
||
89 | * |
||
90 | * Do not instantiate directly, but use {@see ApplicationFactory::getParserOutputHelper} instead. |
||
91 | * |
||
92 | * @param \Parser $parser |
||
93 | * |
||
94 | * @see ApplicationFactory::getParserOutputHelper |
||
95 | */ |
||
96 | 38 | public function __construct( $parser ) { |
|
104 | |||
105 | /** |
||
106 | * Adds the error tracking category to the current page if not done already. |
||
107 | */ |
||
108 | 13 | public function addErrorTrackingCategory() { |
|
115 | |||
116 | /** |
||
117 | * Adds the supplied modules to the parser output. |
||
118 | * |
||
119 | * @param array $modulesToAdd |
||
120 | */ |
||
121 | 20 | public function addModules( $modulesToAdd ) { |
|
128 | |||
129 | /** |
||
130 | * Adds the tracking category to the current page if not done already. |
||
131 | */ |
||
132 | 18 | public function addTrackingCategory() { |
|
139 | |||
140 | /** |
||
141 | * Unless I find a solution for the integration test problem, I cannot use an instance of |
||
142 | * ParserOutputHelper in ImageModal to ascertain this. In integration tests, "we" use a |
||
143 | * different parser than the InternalParseBeforeLinks-Hook. At least, after I added |
||
144 | * Scribunto _unit_ tests. All messes up, I'm afraid. ImageModal better use global parser, and |
||
145 | * for the time being this method will be |
||
146 | * @deprecated |
||
147 | * |
||
148 | * @return bool|null |
||
149 | */ |
||
150 | public function areImageModalsSuppressed() { |
||
153 | |||
154 | /** |
||
155 | * Returns the raw html that is be inserted at the end of the page. |
||
156 | * |
||
157 | * @param \ParserOutput $parserOutput |
||
158 | * |
||
159 | * @return string |
||
160 | */ |
||
161 | 24 | public function getContentForLaterInjection( \ParserOutput $parserOutput ) { |
|
172 | |||
173 | /** |
||
174 | * @return string |
||
175 | */ |
||
176 | 22 | public function getNameOfActiveSkin() { |
|
179 | |||
180 | /** |
||
181 | * Allows for html fragments for a given container id to be stored, so that it can be added to the page at a later time. |
||
182 | * |
||
183 | * @param string $id |
||
184 | * @param string $rawHtml |
||
185 | * |
||
186 | * @return ParserOutputHelper $this (fluid) |
||
187 | */ |
||
188 | 10 | public function injectLater( $id, $rawHtml ) { |
|
199 | |||
200 | /** |
||
201 | * Adds the bootstrap modules and styles to the page, if not done already |
||
202 | */ |
||
203 | 20 | public function loadBootstrapModules() { |
|
214 | |||
215 | /** |
||
216 | * Formats a text as error text so it can be added to the output. |
||
217 | * |
||
218 | * @param string $errorMessageName |
||
219 | * |
||
220 | * @return string |
||
221 | */ |
||
222 | 16 | public function renderErrorMessage( $errorMessageName ) { |
|
233 | |||
234 | /** |
||
235 | * Returns true, if active skin is vector |
||
236 | * |
||
237 | * @return bool |
||
238 | */ |
||
239 | 21 | public function vectorSkinInUse() { |
|
242 | |||
243 | /** |
||
244 | * @return \Parser |
||
245 | */ |
||
246 | 22 | protected function getParser() { |
|
249 | |||
250 | /** |
||
251 | * @param bool $useConfig set to true, if we can't rely on {@see \RequestContext::getSkin} |
||
252 | * |
||
253 | * @return string |
||
254 | */ |
||
255 | 38 | private function detectSkinInUse( $useConfig = false ) { |
|
270 | |||
271 | /** |
||
272 | * Adds current page to the indicated tracking category, if not done already. |
||
273 | * |
||
274 | * @param String $trackingCategoryMessageName name of the message, containing the tracking category |
||
275 | */ |
||
276 | 21 | private function placeTrackingCategory( $trackingCategoryMessageName ) { |
|
290 | } |
||
291 |