1 | <?php |
||
15 | class MapsImageLayer extends MapsLayer { |
||
16 | |||
17 | /** |
||
18 | * Registers the layer. |
||
19 | * |
||
20 | * @since 0.7.2 |
||
21 | */ |
||
22 | public static function register() { |
||
23 | MapsLayerTypes::registerLayerType( 'image', __CLASS__, 'openlayers' ); |
||
24 | return true; |
||
25 | } |
||
26 | |||
27 | /** |
||
28 | * @see MapsLayer::getParameterDefinitions |
||
29 | * |
||
30 | * @since 0.7.2 |
||
31 | * |
||
32 | * @return array |
||
33 | */ |
||
34 | protected function getParameterDefinitions() { |
||
89 | |||
90 | /** |
||
91 | * @see MapsLayer::getPropertyHtmlRepresentation |
||
92 | * |
||
93 | * @since 3.0 |
||
94 | * |
||
95 | * @return array |
||
96 | */ |
||
97 | protected function getPropertyHtmlRepresentation( $name, &$parser ) { |
||
98 | $value = $this->properties[ $name ]; |
||
99 | |||
100 | switch( $name ) { |
||
101 | case 'source': |
||
102 | $value = $this->originalPropertyValues['source']; // get original, non-modified value |
||
103 | |||
104 | $title = Title::newFromText( $value, NS_FILE ); |
||
105 | |||
106 | // if title has invalid characters or doesn't exist and has url-style |
||
107 | if( $title === null |
||
108 | || ( !$title->exists() && preg_match( '|^.+\://.+\..+$|', $value ) ) |
||
109 | ) { |
||
110 | // url link: |
||
111 | $value = $parser->recursiveTagParse( "[$value $value]" ); |
||
112 | } else { |
||
113 | // wikilink (can be red link to non-existant file): |
||
114 | $imgName = $title->getPrefixedText(); |
||
115 | $value = $parser->recursiveTagParse( "[[$imgName|thumb|[[:$imgName]]|left]]" ); |
||
116 | } |
||
117 | return $value; // html already |
||
118 | |||
119 | default: |
||
120 | // if we don't have any special handling here, leave it to base class: |
||
121 | return parent::getPropertyHtmlRepresentation( $name, $parser ); |
||
122 | } |
||
123 | return htmlspecialchars( $value );; |
||
124 | } |
||
125 | |||
126 | /** |
||
127 | * @see MapsLayer::doPropertiesHtmlTransform |
||
128 | * |
||
129 | * @since 3.0 |
||
130 | * |
||
131 | * @return array |
||
132 | */ |
||
133 | protected function doPropertiesHtmlTransform( &$properties ) { |
||
134 | parent::doPropertiesHtmlTransform( $properties ); |
||
135 | |||
136 | $sp = ' '; // non-breaking thin space |
||
137 | |||
138 | // image-size: |
||
139 | $properties['image-size'] = "<b>width:</b> {$properties['width']}{$sp}pixel, <b>height:</b> {$properties['height']}{$sp}pixel"; |
||
140 | unset( $properties['width'], $properties['height'] ); |
||
141 | |||
142 | // extent: |
||
143 | $unit = $properties['units']; |
||
144 | $properties['extent'] = |
||
145 | "<b>left:</b> {$properties['leftextent']}{$sp}$unit, " . |
||
146 | "<b>bottom:</b> {$properties['bottomextent']}{$sp}$unit, " . |
||
147 | "<b>right:</b> {$properties['rightextent']}{$sp}$unit, " . |
||
148 | "<b>top:</b> {$properties['topextent']}{$sp}$unit"; |
||
149 | unset( $properties['leftextent'], $properties['bottomextent'], $properties['rightextent'], $properties['topextent'] ); |
||
150 | } |
||
151 | |||
152 | /** |
||
153 | * @see MapsLayer::getJavaScriptDefinition |
||
154 | * |
||
155 | * @since 0.7.2 |
||
156 | * |
||
157 | * @return string |
||
158 | */ |
||
159 | public function getJavaScriptDefinition() { |
||
197 | |||
198 | } |
||
199 |
This method has been deprecated.