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() { |
||
63 | |||
64 | public static function onParserFirstCallInit1( Parser &$parser ) { |
||
68 | |||
69 | public static function onParserFirstCallInit2( Parser &$parser ) { |
||
73 | |||
74 | public static function onParserFirstCallInit3( Parser &$parser ) { |
||
78 | |||
79 | public static function onParserFirstCallInit4( Parser &$parser ) { |
||
83 | |||
84 | public static function onParserFirstCallInit5( Parser &$parser ) { |
||
88 | |||
89 | public static function onParserFirstCallInit6( Parser &$parser ) { |
||
93 | |||
94 | public static function onParserFirstCallInit7( Parser &$parser ) { |
||
98 | |||
99 | public static function onParserFirstCallInit8( Parser &$parser ) { |
||
103 | |||
104 | /** |
||
105 | * Initialization function for the Google Maps v3 service. |
||
106 | * |
||
107 | * @since 0.6.3 |
||
108 | * @ingroup MapsGoogleMaps3 |
||
109 | * |
||
110 | * @return boolean true |
||
111 | */ |
||
112 | public static function efMapsInitGoogleMaps3() { |
||
125 | |||
126 | public static function efMapsInitOpenLayers() { |
||
135 | |||
136 | /** |
||
137 | * Initialization function for the Leaflet service. |
||
138 | * |
||
139 | * @ingroup Leaflet |
||
140 | * |
||
141 | * @return boolean true |
||
142 | */ |
||
143 | public static function efMapsInitLeaflet() { |
||
154 | |||
155 | /** |
||
156 | * Adds a link to Admin Links page. |
||
157 | * |
||
158 | * @since 0.7 |
||
159 | * |
||
160 | * @param ALTree $admin_links_tree |
||
161 | * |
||
162 | * @return boolean |
||
163 | */ |
||
164 | public static function addToAdminLinks( ALTree &$admin_links_tree ) { |
||
179 | |||
180 | /** |
||
181 | * Intercept pages in the Layer namespace to handle them correctly. |
||
182 | * |
||
183 | * @param $title: Title |
||
184 | * @param $article: Article or null |
||
185 | * |
||
186 | * @return boolean |
||
187 | */ |
||
188 | public static function onArticleFromTitle( Title &$title, /* Article */ &$article ) { |
||
195 | |||
196 | /** |
||
197 | * Adds global JavaScript variables. |
||
198 | * |
||
199 | * @since 1.0 |
||
200 | * @see http://www.mediawiki.org/wiki/Manual:Hooks/MakeGlobalVariablesScript |
||
201 | * @param array &$vars Variables to be added into the output |
||
202 | * @param OutputPage $outputPage OutputPage instance calling the hook |
||
203 | * @return boolean true in all cases |
||
204 | */ |
||
205 | public static function onMakeGlobalVariablesScript( array &$vars, OutputPage $outputPage ) { |
||
215 | |||
216 | /** |
||
217 | * @since 0.7 |
||
218 | * |
||
219 | * @param array $list |
||
220 | * |
||
221 | * @return boolean |
||
222 | */ |
||
223 | public static function onCanonicalNamespaces( array &$list ) { |
||
228 | |||
229 | /** |
||
230 | * This will setup database tables for layer functionality. |
||
231 | * |
||
232 | * @since 3.0 |
||
233 | * |
||
234 | * @param DatabaseUpdater $updater |
||
235 | * |
||
236 | * @return true |
||
237 | */ |
||
238 | public static function onLoadExtensionSchemaUpdates( DatabaseUpdater $updater ) { |
||
251 | |||
252 | /** |
||
253 | * Make sure layer data will be stored into database when purging the page |
||
254 | * |
||
255 | * @since 3.0 |
||
256 | * |
||
257 | * @param $article WikiPage|Article (depending on MW version, WikiPage in 1.18+) |
||
258 | * @return type |
||
259 | */ |
||
260 | public static function onArticlePurge( &$article ) { |
||
264 | |||
265 | /** |
||
266 | * At the end of article parsing, in case of layer page, save layers to database |
||
267 | * |
||
268 | * @since 3.0 |
||
269 | * |
||
270 | * @param Parser &$parser |
||
271 | * @param string &$text |
||
272 | * |
||
273 | * @return true |
||
274 | */ |
||
275 | public static function onParserAfterTidy( Parser &$parser, &$text ) { |
||
293 | |||
294 | /** |
||
295 | * After article was edited and parsed, in case of layer page, save layers to database |
||
296 | * |
||
297 | * @since 3.0 |
||
298 | * |
||
299 | * @param LinksUpdate &$linksUpdate |
||
300 | * |
||
301 | * @return true |
||
302 | */ |
||
303 | public static function onLinksUpdateConstructed( LinksUpdate &$linksUpdate ) { |
||
310 | |||
311 | /** |
||
312 | * Checks whether the parser output has some layer data which should be stored of the |
||
313 | * given title and performs the task. |
||
314 | * |
||
315 | * @since 3.0 |
||
316 | * |
||
317 | * @param ParserOutput $parserOutput |
||
318 | * @param Title $title |
||
319 | */ |
||
320 | protected static function processLayersStoreCandidate( ParserOutput $parserOutput, Title $title ) { |
||
336 | |||
337 | /** |
||
338 | * If a new parser process is getting started, clear collected layer data of the |
||
339 | * previous one. |
||
340 | * |
||
341 | * @since 3.0 |
||
342 | * |
||
343 | * @param Parser $parser |
||
344 | * |
||
345 | * @return true |
||
346 | */ |
||
347 | public static function onParserClearState( Parser &$parser ) { |
||
351 | } |
||
352 | |||
353 |
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: