1 | <?php |
||
12 | final class MapsHooks { |
||
13 | /** |
||
14 | * Helper flag indicating whether the page has been purged. |
||
15 | * @var bool |
||
16 | * |
||
17 | * TODO: Figure out a better way to do this, not requiring this flag and make sure it works with |
||
18 | * later MW versions (purging mechanism got changed somewhat around 1.18). |
||
19 | */ |
||
20 | static $purgedBeforeStore = false; |
||
21 | |||
22 | public static function onExtensionCallback() { |
||
49 | |||
50 | public static function onExtensionFunction() { |
||
65 | |||
66 | public static function onParserFirstCallInit1( Parser &$parser ) { |
||
70 | |||
71 | public static function onParserFirstCallInit2( Parser &$parser ) { |
||
75 | |||
76 | public static function onParserFirstCallInit3( Parser &$parser ) { |
||
80 | |||
81 | public static function onParserFirstCallInit4( Parser &$parser ) { |
||
85 | |||
86 | public static function onParserFirstCallInit5( Parser &$parser ) { |
||
90 | |||
91 | public static function onParserFirstCallInit6( Parser &$parser ) { |
||
95 | |||
96 | public static function onParserFirstCallInit7( Parser &$parser ) { |
||
100 | |||
101 | public static function onParserFirstCallInit8( Parser &$parser ) { |
||
105 | |||
106 | /** |
||
107 | * Initialization function for the Google Maps v3 service. |
||
108 | * |
||
109 | * @since 0.6.3 |
||
110 | * @ingroup MapsGoogleMaps3 |
||
111 | * |
||
112 | * @return boolean true |
||
113 | */ |
||
114 | public static function efMapsInitGoogleMaps3() { |
||
127 | |||
128 | public static function efMapsInitOpenLayers() { |
||
137 | |||
138 | /** |
||
139 | * Initialization function for the Leaflet service. |
||
140 | * |
||
141 | * @ingroup Leaflet |
||
142 | * |
||
143 | * @return boolean true |
||
144 | */ |
||
145 | public static function efMapsInitLeaflet() { |
||
156 | |||
157 | /** |
||
158 | * Adds a link to Admin Links page. |
||
159 | * |
||
160 | * @since 0.7 |
||
161 | * |
||
162 | * @param ALTree $admin_links_tree |
||
163 | * |
||
164 | * @return boolean |
||
165 | */ |
||
166 | public static function addToAdminLinks( ALTree &$admin_links_tree ) { |
||
181 | |||
182 | /** |
||
183 | * Intercept pages in the Layer namespace to handle them correctly. |
||
184 | * |
||
185 | * @param $title: Title |
||
186 | * @param $article: Article or null |
||
187 | * |
||
188 | * @return boolean |
||
189 | */ |
||
190 | public static function onArticleFromTitle( Title &$title, /* Article */ &$article ) { |
||
197 | |||
198 | /** |
||
199 | * Adds global JavaScript variables. |
||
200 | * |
||
201 | * @since 1.0 |
||
202 | * @see http://www.mediawiki.org/wiki/Manual:Hooks/MakeGlobalVariablesScript |
||
203 | * @param array &$vars Variables to be added into the output |
||
204 | * @param OutputPage $outputPage OutputPage instance calling the hook |
||
205 | * @return boolean true in all cases |
||
206 | */ |
||
207 | public static function onMakeGlobalVariablesScript( array &$vars, OutputPage $outputPage ) { |
||
217 | |||
218 | /** |
||
219 | * @since 0.7 |
||
220 | * |
||
221 | * @param array $list |
||
222 | * |
||
223 | * @return boolean |
||
224 | */ |
||
225 | public static function onCanonicalNamespaces( array &$list ) { |
||
230 | |||
231 | /** |
||
232 | * This will setup database tables for layer functionality. |
||
233 | * |
||
234 | * @since 3.0 |
||
235 | * |
||
236 | * @param DatabaseUpdater $updater |
||
237 | * |
||
238 | * @return true |
||
239 | */ |
||
240 | public static function onLoadExtensionSchemaUpdates( DatabaseUpdater $updater ) { |
||
253 | |||
254 | /** |
||
255 | * Make sure layer data will be stored into database when purging the page |
||
256 | * |
||
257 | * @since 3.0 |
||
258 | * |
||
259 | * @param $article WikiPage|Article (depending on MW version, WikiPage in 1.18+) |
||
260 | * @return type |
||
261 | */ |
||
262 | public static function onArticlePurge( &$article ) { |
||
266 | |||
267 | /** |
||
268 | * At the end of article parsing, in case of layer page, save layers to database |
||
269 | * |
||
270 | * @since 3.0 |
||
271 | * |
||
272 | * @param Parser &$parser |
||
273 | * @param string &$text |
||
274 | * |
||
275 | * @return true |
||
276 | */ |
||
277 | public static function onParserAfterTidy( Parser &$parser, &$text ) { |
||
295 | |||
296 | /** |
||
297 | * After article was edited and parsed, in case of layer page, save layers to database |
||
298 | * |
||
299 | * @since 3.0 |
||
300 | * |
||
301 | * @param LinksUpdate &$linksUpdate |
||
302 | * |
||
303 | * @return true |
||
304 | */ |
||
305 | public static function onLinksUpdateConstructed( LinksUpdate &$linksUpdate ) { |
||
312 | |||
313 | /** |
||
314 | * Checks whether the parser output has some layer data which should be stored of the |
||
315 | * given title and performs the task. |
||
316 | * |
||
317 | * @since 3.0 |
||
318 | * |
||
319 | * @param ParserOutput $parserOutput |
||
320 | * @param Title $title |
||
321 | */ |
||
322 | protected static function processLayersStoreCandidate( ParserOutput $parserOutput, Title $title ) { |
||
338 | |||
339 | /** |
||
340 | * If a new parser process is getting started, clear collected layer data of the |
||
341 | * previous one. |
||
342 | * |
||
343 | * @since 3.0 |
||
344 | * |
||
345 | * @param Parser $parser |
||
346 | * |
||
347 | * @return true |
||
348 | */ |
||
349 | public static function onParserClearState( Parser &$parser ) { |
||
353 | } |
||
354 | |||
355 |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: