1 | <?php |
||
41 | class ParserOutputHelper { |
||
42 | |||
43 | /** |
||
44 | * @var string |
||
45 | */ |
||
46 | const INJECTION_PREFIX = '<!-- injected by Extension:BootstrapComponents -->'; |
||
47 | |||
48 | /** |
||
49 | * @var string |
||
50 | */ |
||
51 | const INJECTION_SUFFIX = '<!-- /injected by Extension:BootstrapComponents -->'; |
||
52 | |||
53 | /** |
||
54 | * To make sure, we only add the tracking category once. |
||
55 | * |
||
56 | * @var bool $articleTracked |
||
57 | */ |
||
58 | private $articleTracked; |
||
59 | |||
60 | /** |
||
61 | * To make sure, we only add the error tracking category once. |
||
62 | * |
||
63 | * @var bool $articleTrackedOnError |
||
64 | */ |
||
65 | private $articleTrackedOnError; |
||
66 | |||
67 | /** |
||
68 | * Here, components can store html to be added to the page at a later time. |
||
69 | * |
||
70 | * @var string $contentForLaterInjection |
||
71 | */ |
||
72 | private $contentForLaterInjection; |
||
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 | 11 | public function __construct( $parser ) { |
|
103 | |||
104 | /** |
||
105 | * Adds the error tracking category to the current page if not done already. |
||
106 | */ |
||
107 | 11 | public function addErrorTrackingCategory() { |
|
114 | |||
115 | /** |
||
116 | * Adds the supplied modules to the parser output. |
||
117 | * |
||
118 | * @param array $modulesToAdd |
||
119 | */ |
||
120 | 20 | public function addModules( $modulesToAdd ) { |
|
127 | |||
128 | /** |
||
129 | * Adds the tracking category to the current page if not done already. |
||
130 | */ |
||
131 | 18 | public function addTrackingCategory() { |
|
138 | |||
139 | /** |
||
140 | * Unless I find a solution for the integration test problem, I cannot use an instance of |
||
141 | * ParserOutputHelper in ImageModal to ascertain this. In integration tests, "we" use a |
||
142 | * different parser than the InternalParseBeforeLinks-Hook. At least, after I added |
||
143 | * Scribunto _unit_ tests. All messes up, I'm afraid. ImageModal better use global parser, and |
||
144 | * for the time being this method will be |
||
145 | * @deprecated |
||
146 | * |
||
147 | * @return bool|null |
||
148 | */ |
||
149 | public function areImageModalsSuppressed() { |
||
152 | |||
153 | /** |
||
154 | * Returns the raw html that is be inserted at the end of the page. |
||
155 | * |
||
156 | * @return string |
||
157 | */ |
||
158 | 24 | public function getContentForLaterInjection() { |
|
167 | |||
168 | /** |
||
169 | * @return string |
||
170 | */ |
||
171 | 22 | public function getNameOfActiveSkin() { |
|
174 | |||
175 | /** |
||
176 | * Allows to store html that will be added to the page at a later time. |
||
177 | * |
||
178 | * @param string $rawHtml |
||
179 | * |
||
180 | * @return ParserOutputHelper $this (fluid) |
||
181 | */ |
||
182 | 10 | public function injectLater( $rawHtml ) { |
|
188 | |||
189 | /** |
||
190 | * Adds the bootstrap modules and styles to the page, if not done already |
||
191 | */ |
||
192 | 20 | public function loadBootstrapModules() { |
|
203 | |||
204 | /** |
||
205 | * Formats a text as error text so it can be added to the output. |
||
206 | * |
||
207 | * @param string $errorMessageName |
||
208 | * |
||
209 | * @return string |
||
210 | */ |
||
211 | 10 | public function renderErrorMessage( $errorMessageName ) { |
|
222 | |||
223 | /** |
||
224 | * Returns true, if active skin is vector |
||
225 | * |
||
226 | * @return bool |
||
227 | */ |
||
228 | 21 | public function vectorSkinInUse() { |
|
231 | |||
232 | /** |
||
233 | * @return \Parser |
||
234 | */ |
||
235 | 21 | protected function getParser() { |
|
238 | |||
239 | /** |
||
240 | * @return string |
||
241 | */ |
||
242 | 11 | private function detectSkinInUse() { |
|
246 | |||
247 | /** |
||
248 | * Adds current page to the indicated tracking category, if not done already. |
||
249 | * |
||
250 | * @param String $trackingCategoryMessageName name of the message, containing the tracking category |
||
251 | */ |
||
252 | 2 | private function placeTrackingCategory( $trackingCategoryMessageName ) { |
|
266 | } |
||
267 |