Index: trunk/extensions/Maps/Maps.i18n.php |
— | — | @@ -29,6 +29,7 @@ |
30 | 30 | 'maps-layer-errors' => 'Errors', |
31 | 31 | 'maps-error-invalid-layerdef' => 'This layer definition is not valid.', |
32 | 32 | 'maps-error-invalid-layertype' => 'There are no layers of type "$1". Only {{PLURAL:$3|this type is|these types are}} supported: $2', |
| 33 | + 'maps-error-no-layertype' => 'You need to specify the layer type. {{PLURAL:$2|Only this type is|These types are}} supported: $1', |
33 | 34 | 'validation-error-invalid-layer' => 'Parameter $1 must be a valid layer.', |
34 | 35 | 'validation-error-invalid-layers' => 'Parameter $1 must be one or more valid layers.', |
35 | 36 | |
Index: trunk/extensions/Maps/includes/Maps_LayerPage.php |
— | — | @@ -53,33 +53,54 @@ |
54 | 54 | |
55 | 55 | $wgOut->setPageTitle( $this->mTitle->getPrefixedText() ); |
56 | 56 | |
57 | | - if ( MapsLayers::hasLayer( $this->getLayerType() ) ) { |
58 | | - $this->displayLayerDefinition( MapsLayers::getLayer( $this->getLayerType() ) ); |
| 57 | + if ( $this->exists() ) { |
| 58 | + $layerType = $this->getLayerType(); |
| 59 | + |
| 60 | + if ( $layerType !== false && MapsLayers::hasLayer( $layerType ) ) { |
| 61 | + $this->displayLayerDefinition(); |
| 62 | + } |
| 63 | + else { |
| 64 | + global $wgLang; |
| 65 | + $availableLayerTypes = MapsLayers::getAvailableLayers(); |
| 66 | + |
| 67 | + if ( $layerType === false ) { |
| 68 | + $wgOut->addHTML( |
| 69 | + '<span class="errorbox">' . |
| 70 | + htmlspecialchars( wfMsgExt( |
| 71 | + 'maps-error-no-layertype', |
| 72 | + 'parsemag', |
| 73 | + $wgLang->listToText( $availableLayerTypes ), |
| 74 | + count( $availableLayerTypes ) |
| 75 | + ) ) . |
| 76 | + '</span><br />' |
| 77 | + ); |
| 78 | + } |
| 79 | + else { |
| 80 | + $wgOut->addHTML( |
| 81 | + '<span class="errorbox">' . |
| 82 | + htmlspecialchars( wfMsgExt( |
| 83 | + 'maps-error-invalid-layertype', |
| 84 | + 'parsemag', |
| 85 | + $this->getLayerType(), |
| 86 | + $wgLang->listToText( $availableLayerTypes ), |
| 87 | + count( $availableLayerTypes ) |
| 88 | + ) ) . |
| 89 | + '</span><br />' |
| 90 | + ); |
| 91 | + } |
| 92 | + } |
59 | 93 | } |
60 | | - else { |
61 | | - $availableLayerTypes = MapsLayers::getAvailableLayers(); |
62 | | - $wgOut->addHTML( |
63 | | - '<span class="errorbox">' . |
64 | | - htmlspecialchars( wfMsgExt( |
65 | | - 'maps-error-invalid-layertype', |
66 | | - 'parsemag', |
67 | | - $this->getLayerType(), |
68 | | - $availableLayerTypes, |
69 | | - count( $availableLayerTypes ) |
70 | | - ) ) . |
71 | | - '</span><br />' |
72 | | - ); |
73 | | - } |
74 | 94 | } |
75 | 95 | |
76 | 96 | /** |
77 | 97 | * Displays the layer definition as a table. |
78 | 98 | * |
79 | 99 | * @since 0.7.2 |
80 | | - * |
81 | | - * @param MapsLayer $layer |
82 | 100 | */ |
83 | | - protected function displayLayerDefinition( MapsLayer $layer ) { |
| 101 | + protected function displayLayerDefinition() { |
| 102 | + global $wgOut; |
| 103 | + |
| 104 | + $layer = $this->getLayer(); |
84 | 105 | $errorHeader = ''; |
85 | 106 | |
86 | 107 | if ( !$layer->isValid() ) { |
Index: trunk/extensions/Maps/includes/Maps_Layers.php |
— | — | @@ -92,7 +92,7 @@ |
93 | 93 | */ |
94 | 94 | public static function hasLayer( $type, $service = null ) { |
95 | 95 | self::initializeLayers(); |
96 | | - |
| 96 | + |
97 | 97 | if ( array_key_exists( $type, self::$classes ) && array_key_exists( $type, self::$services ) ) { |
98 | 98 | return is_null( $service ) || in_array( $service, self::$services[$type] ); |
99 | 99 | } |