-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMaps.hooks.php
More file actions
134 lines (115 loc) · 3.08 KB
/
Maps.hooks.php
File metadata and controls
134 lines (115 loc) · 3.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php
/**
* Static class for hooks handled by the Maps extension.
*
* @since 0.7
*
* @file Maps.hooks.php
* @ingroup Maps
*
* @licence GNU GPL v2+
* @author Jeroen De Dauw < jeroendedauw@gmail.com >
*/
final class MapsHooks {
/**
* Adds a link to Admin Links page.
*
* @since 0.7
*
* @param ALTree $admin_links_tree
*
* @return boolean
*/
public static function addToAdminLinks( ALTree &$admin_links_tree ) {
$displaying_data_section = $admin_links_tree->getSection( wfMsg( 'smw_adminlinks_displayingdata' ) );
// Escape if SMW hasn't added links.
if ( is_null( $displaying_data_section ) ) {
return true;
}
$smw_docu_row = $displaying_data_section->getRow( 'smw' );
$maps_docu_label = wfMsg( 'adminlinks_documentation', 'Maps' );
$smw_docu_row->addItem( AlItem::newFromExternalLink( 'http://mapping.referata.com/wiki/Maps', $maps_docu_label ) );
return true;
}
/**
* Hook to add PHPUnit test cases.
* @see https://www.mediawiki.org/wiki/Manual:Hooks/UnitTestsList
*
* @since 0.7
*
* @param array &$files
*
* @return boolean
*/
public static function registerUnitTests( array &$files ) {
// @codeCoverageIgnoreStart
$testFiles = array(
'elements/Circle',
'elements/ImageOverlay',
'elements/Line',
'elements/Location',
'elements/Polygon',
'elements/Rectangle',
'parserhooks/Coordinates',
'parserhooks/DisplayMap',
'parserhooks/Distance',
'parserhooks/Finddestination',
'parserhooks/Geocode',
'parserhooks/Geodistance',
'parserhooks/MapsDoc',
'parsers/DistanceParser',
'parsers/LineParser',
'parsers/LocationParser',
'parsers/WmsOverlayParser',
'Element',
'MapsDistanceParser',
);
foreach ( $testFiles as $file ) {
$files[] = __DIR__ . '/tests/phpunit/' . $file . 'Test.php';
}
return true;
// @codeCoverageIgnoreEnd
}
/**
* Intercept pages in the Layer namespace to handle them correctly.
*
* @param $title: Title
* @param $article: Article or null
*
* @return boolean
*/
public static function onArticleFromTitle( Title &$title, /* Article */ &$article ) {
if ( $title->getNamespace() == Maps_NS_LAYER ) {
$article = new MapsLayerPage( $title );
}
return true;
}
/**
* Adds global JavaScript variables.
*
* @since 1.0
* @see http://www.mediawiki.org/wiki/Manual:Hooks/MakeGlobalVariablesScript
* @param array &$vars Variables to be added into the output
* @param OutputPage $outputPage OutputPage instance calling the hook
* @return boolean true in all cases
*/
public static function onMakeGlobalVariablesScript( array &$vars, OutputPage $outputPage ) {
global $egMapsGlobalJSVars;
$vars['egMapsDebugJS'] = $GLOBALS['egMapsDebugJS'];
$vars[ 'egMapsAvailableServices' ] = $GLOBALS['egMapsAvailableServices'];
$vars += $egMapsGlobalJSVars;
return true;
}
/**
* @since 0.7
*
* @param array $list
*
* @return boolean
*/
public static function onCanonicalNamespaces( array &$list ) {
$list[Maps_NS_LAYER] = 'Layer';
$list[Maps_NS_LAYER_TALK] = 'Layer_talk';
return true;
}
}