Completed
Push — master ( 97d2aa...2017c0 )
by Jeroen De
11s
created

SMQueryHandler::getParser()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
use Maps\Elements\Location;
4
5
/**
6
 * Class for handling geographical SMW queries.
7
 *
8
 * @licence GNU GPL v2+
9
 * @author Jeroen De Dauw < [email protected] >
10
 */
11
class SMQueryHandler {
12
13
	private $queryResult;
14
	private $outputmode;
15
16
	/**
17
	 * @var array
18
	 */
19
	private $geoShapes = [
20
		'lines' => [],
21
		'locations' => [],
22
		'polygons' => []
23
	];
24
25
	/**
26
	 * The template to use for the text, or false if there is none.
27
	 *
28
	 * @var string|boolean false
29
	 */
30
	private $template = false;
31
32
	/**
33
	 * The global icon.
34
	 *
35
	 * @var string
36
	 */
37
	public $icon = '';
38
39
	/**
40
	 * The global text.
41
	 *
42
	 * @var string
43
	 */
44
	public $text = '';
45
46
	/**
47
	 * The global title.
48
	 *
49
	 * @var string
50
	 */
51
	public $title = '';
52
53
	/**
54
	 * Make a separate link to the title or not?
55
	 *
56
	 * @var boolean
57
	 */
58
	public $titleLinkSeparate;
59
60
	/**
61
	 * Should link targets be made absolute (instead of relative)?
62
	 *
63
	 * @var boolean
64
	 */
65
	private $linkAbsolute;
66
67
	/**
68
	 * The text used for the link to the page (if it's created). $1 will be replaced by the page name.
69
	 *
70
	 * @var string
71
	 */
72
	private $pageLinkText;
73
74
	/**
75
	 * A separator to use between the subject and properties in the text field.
76
	 *
77
	 * @var string
78
	 */
79
	private $subjectSeparator = '<hr />';
80
81
	/**
82
	 * Make the subject in the text bold or not?
83
	 *
84
	 * @var boolean
85
	 */
86
	private $boldSubject = true;
87
88
	/**
89
	 * Show the subject in the text or not?
90
	 *
91
	 * @var boolean
92
	 */
93
	private $showSubject = true;
94
95
	/**
96
	 * Hide the namespace or not.
97
	 *
98
	 * @var boolean
99
	 */
100
	private $hideNamespace = false;
101
102
103
	/**
104
	 * Defines which article names in the result are hyperlinked, all normally is the default
105
	 * none, subject, all
106
	 */
107
	private $linkStyle = 'all';
108
109
	/*
110
	 * Show headers (with links), show headers (just text) or hide them. show is default
111
	 * show, plain, hide
112
	 */
113
	private $headerStyle = 'show';
114
115
	/**
116
	 * Marker icon to show when marker equals active page
117
	 *
118
	 * @var string
119
	 */
120
	private $activeIcon;
121
122
	/**
123
	 * @var string
124
	 */
125
	private $userParam = '';
126
127
	/**
128
	 * @param SMWQueryResult $queryResult
129
	 * @param integer $outputmode
130
	 * @param boolean $linkAbsolute
131
	 * @param string $pageLinkText
132
	 * @param boolean $titleLinkSeparate
133
	 * @param string $activeIcon
134
	 */
135
	public function __construct( SMWQueryResult $queryResult, $outputmode, $linkAbsolute = false, $pageLinkText = '$1', $titleLinkSeparate = false, $hideNamespace = false, $activeIcon = null ) {
136
		$this->queryResult = $queryResult;
137
		$this->outputmode = $outputmode;
138
139
		$this->linkAbsolute = $linkAbsolute;
140
		$this->pageLinkText = $pageLinkText;
141
		$this->titleLinkSeparate = $titleLinkSeparate;
142
		$this->hideNamespace = $hideNamespace;
143
		$this->activeIcon = $activeIcon;
144
	}
145
146
	/**
147
	 * Sets the template.
148
	 *
149
	 * @param string $template
150
	 */
151
	public function setTemplate( $template ) {
152
		$this->template = $template === '' ? false : $template;
153
	}
154
155
	/**
156
	 * @param string $userParam
157
	 */
158
	public function setUserParam( $userParam ) {
159
		$this->userParam = $userParam;
160
	}
161
162
	/**
163
	 * Sets the global icon.
164
	 *
165
	 * @param string $icon
166
	 */
167
	public function setIcon( $icon ) {
168
		$this->icon = $icon;
169
	}
170
171
	/**
172
	 * Sets the global title.
173
	 *
174
	 * @param string $title
175
	 */
176
	public function setTitle( $title ) {
177
		$this->title = $title;
178
	}
179
180
	/**
181
	 * Sets the global text.
182
	 *
183
	 * @param string $text
184
	 */
185
	public function setText( $text ) {
186
		$this->text = $text;
187
	}
188
189
	/**
190
	 * Sets the subject separator.
191
	 *
192
	 * @param string $subjectSeparator
193
	 */
194
	public function setSubjectSeparator( $subjectSeparator ) {
195
		$this->subjectSeparator = $subjectSeparator;
196
	}
197
198
	/**
199
	 * Sets if the subject should be made bold in the text.
200
	 *
201
	 * @param string $boldSubject
202
	 */
203
	public function setBoldSubject( $boldSubject ) {
204
		$this->boldSubject = $boldSubject;
0 ignored issues
show
Documentation Bug introduced by
The property $boldSubject was declared of type boolean, but $boldSubject is of type string. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
205
	}
206
207
	/**
208
	 * Sets if the subject should shown in the text.
209
	 *
210
	 * @param string $showSubject
211
	 */
212
	public function setShowSubject( $showSubject ) {
213
		$this->showSubject = $showSubject;
0 ignored issues
show
Documentation Bug introduced by
The property $showSubject was declared of type boolean, but $showSubject is of type string. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
214
	}
215
216
	/**
217
	 * Sets the text for the link to the page when separate from the title.
218
	 *
219
	 * @param string $text
220
	 */
221
	public function setPageLinkText( $text ) {
222
		$this->pageLinkText = $text;
223
	}
224
225
	/**
226
	 *
227
	 * @param boolean $link
228
	 */
229
	public function setLinkStyle ( $link ) {
230
		$this->linkStyle = $link;
0 ignored issues
show
Documentation Bug introduced by
The property $linkStyle was declared of type string, but $link is of type boolean. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
231
	}
232
233
	/**
234
	 *
235
	 * @param boolean $headers
236
	 */
237
	public function setHeaderStyle ( $headers ) {
238
		$this->headerStyle = $headers;
0 ignored issues
show
Documentation Bug introduced by
The property $headerStyle was declared of type string, but $headers is of type boolean. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
239
	}
240
241
	/**
242
	 * @return array
243
	 */
244
	public function getShapes() {
245
		$this->findShapes();
246
		return $this->geoShapes;
247
	}
248
249
	/**
250
	 * @since 2.0
251
	 */
252
	private function findShapes() {
253
		while ( ( $row = $this->queryResult->getNext() ) !== false ) {
254
			$this->handleResultRow( $row );
255
		}
256
	}
257
258
	/**
259
	 * Returns the locations found in the provided result row.
260
	 *
261
	 * @param SMWResultArray[] $row
262
	 */
263
	private function handleResultRow( array $row ) {
264
		$locations = [];
265
		$properties = [];
266
267
		$title = '';
268
		$text = '';
269
270
		// Loop through all fields of the record.
271
		foreach ( $row as $i => $resultArray ) {
272
			/* SMWPrintRequest */ $printRequest = $resultArray->getPrintRequest();
273
274
			// Loop through all the parts of the field value.
275
			while ( ( /* SMWDataValue */ $dataValue = $resultArray->getNextDataValue() ) !== false ) {
276
				if ( $dataValue->getTypeID() == '_wpg' && $i == 0 ) {
277
					list( $title, $text ) = $this->handleResultSubject( $dataValue );
278
				}
279
				else if ( $dataValue->getTypeID() == '_str' && $i == 0 ) {
280
					$title = $dataValue->getLongText( $this->outputmode, null );
281
					$text = $dataValue->getLongText( $this->outputmode, smwfGetLinker() );
282
				}
283
				else if ( $dataValue->getTypeID() == '_gpo' ) {
284
					$dataItem = $dataValue->getDataItem();
285
					$polyHandler = new PolygonHandler ( $dataItem->getString() );
286
					$this->geoShapes[ $polyHandler->getGeoType() ][] = $polyHandler->shapeFromText();
287
				} else if ( strpos( $dataValue->getTypeID(), '_rec' ) !== false ) {
288
					foreach ( $dataValue->getDataItems() as $dataItem ) {
289
						if ( $dataItem instanceof \SMWDIGeoCoord ) {
0 ignored issues
show
Bug introduced by
The class SMWDIGeoCoord does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
290
							$location = Location::newFromLatLon( $dataItem->getLatitude(), $dataItem->getLongitude() );
291
							$locations[] = $location;
292
						}
293
					}
294
				}
295
				else if ( $dataValue->getTypeID() != '_geo' && $i != 0 && !$this->isHeadersHide() ) {
296
					$properties[] = $this->handleResultProperty( $dataValue, $printRequest );
297
				}
298
				else if ( $printRequest->getMode() == SMWPrintRequest::PRINT_PROP && $printRequest->getTypeID() == '_geo' || $dataValue->getTypeID() == '_geo' ) {
299
					$dataItem = $dataValue->getDataItem();
300
301
					$location = Location::newFromLatLon( $dataItem->getLatitude(), $dataItem->getLongitude() );
302
303
					$locations[] = $location;
304
				}
305
			}
306
		}
307
308
		if ( count( $properties ) > 0 && $text !== '' ) {
309
			$text .= $this->subjectSeparator;
310
		}
311
312
		$icon = $this->getLocationIcon( $row );
313
314
		$this->geoShapes['locations'] = array_merge(
315
			$this->geoShapes['locations'],
316
			$this->buildLocationsList(
317
				$locations,
318
				$text,
319
				$icon,
320
				$properties,
321
				Title::newFromText( $title )
322
			)
323
		);
324
	}
325
326
	/**
327
	 * Handles a SMWWikiPageValue subject value.
328
	 * Gets the plain text title and creates the HTML text with headers and the like.
329
	 *
330
	 * @param SMWWikiPageValue $object
331
	 *
332
	 * @return array with title and text
333
	 */
334
	private function handleResultSubject( SMWWikiPageValue $object ) {
335
		$title = $object->getLongText( $this->outputmode, null );
336
		$text = '';
337
338
		if ( $this->showSubject ) {
339
			if( !$this->showArticleLink()){
340
				$text = $this->hideNamespace ? $object->getText() : $object->getTitle()->getFullText();
341
			}else if ( !$this->titleLinkSeparate && $this->linkAbsolute ) {
342
				$text = Html::element(
343
					'a',
344
					[ 'href' => $object->getTitle()->getFullUrl() ],
345
					$this->hideNamespace ? $object->getText() : $object->getTitle()->getFullText()
346
				);
347
			}
348
			else {
349
				if($this->hideNamespace){
350
					$text = $object->getShortHTMLText(smwfGetLinker());
351
				}else{
352
					$text = $object->getLongHTMLText( smwfGetLinker() );
353
				}
354
			}
355
356
			if ( $this->boldSubject ) {
357
				$text = '<b>' . $text . '</b>';
358
			}
359
360
			if ( $this->titleLinkSeparate ) {
361
				$txt = $object->getTitle()->getText();
362
363
				if ( $this->pageLinkText !== '' ) {
364
					$txt = str_replace( '$1', $txt, $this->pageLinkText );
365
				}
366
				$text .= Html::element(
367
					'a',
368
					[ 'href' => $object->getTitle()->getFullUrl() ],
369
					$txt
370
				);
371
			}
372
		}
373
374
		return [ $title, $text ];
375
	}
376
377
	private function showArticleLink() {
378
		return $this->linkStyle !== 'none';
379
	}
380
381
	private function hasTemplate() {
382
		return is_string( $this->template );
383
	}
384
385
	/**
386
	 * Handles a single property (SMWPrintRequest) to be displayed for a record (SMWDataValue).
387
	 *
388
	 * @param SMWDataValue $object
389
	 * @param SMWPrintRequest $printRequest
390
	 *
391
	 * @return string
392
	 */
393
	private function handleResultProperty( SMWDataValue $object, SMWPrintRequest $printRequest ) {
394
		if ( $this->hasTemplate() ) {
395
			if ( $object instanceof SMWWikiPageValue ) {
0 ignored issues
show
Bug introduced by
The class SMWWikiPageValue does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
396
				return $object->getTitle()->getPrefixedText();
397
			}
398
399
			return $object->getLongText( SMW_OUTPUT_WIKI, null );
400
		}
401
402
		if ( $this->linkAbsolute ) {
403
			$titleText = $printRequest->getText( null );
404
			$t = Title::newFromText($titleText , SMW_NS_PROPERTY );
405
406
			if ($this->isHeadersShow() && $t instanceof Title && $t->exists() ) {
0 ignored issues
show
Bug introduced by
The class Title does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
407
				$propertyName = $propertyName = Html::element(
408
					'a',
409
					[ 'href' => $t->getFullUrl() ],
410
					$printRequest->getHTMLText( null )
411
				);
412
			}
413
			else {
414
				$propertyName = $titleText;
415
			}
416
		}
417
		else {
418
			if($this->isHeadersShow()){
419
				$propertyName = $printRequest->getHTMLText( smwfGetLinker() );
420
			}else if($this->isHeadersPlain()){
421
				$propertyName = $printRequest->getText(null);
422
			}
423
		}
424
425
		if ( $this->linkAbsolute ) {
426
			$hasPage = $object->getTypeID() == '_wpg';
427
428
			if ( $hasPage ) {
429
				$t = Title::newFromText( $object->getLongText( $this->outputmode, null ), NS_MAIN );
430
				$hasPage = $t !== null && $t->exists();
431
			}
432
433
			if ( $hasPage ) {
434
				$propertyValue = Html::element(
435
					'a',
436
					[ 'href' => $t->getFullUrl() ],
0 ignored issues
show
Bug introduced by
The variable $t does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
437
					$object->getLongText( $this->outputmode, null )
438
				);
439
			}
440
			else {
441
				$propertyValue = $object->getLongText( $this->outputmode, null );
442
			}
443
		}
444
		else {
445
			$propertyValue = $object->getLongText( $this->outputmode, smwfGetLinker() );
446
		}
447
448
		return $propertyName . ( $propertyName === '' ? '' : ': ' ) . $propertyValue;
0 ignored issues
show
Bug introduced by
The variable $propertyName does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
449
	}
450
451
452
	private function isHeadersShow() {
453
		return $this->headerStyle === 'show';
454
	}
455
456
	private function isHeadersHide() {
457
		return $this->headerStyle === 'hide';
458
	}
459
460
	private function isHeadersPlain() {
461
		return $this->headerStyle === 'plain';
462
	}
463
464
	/**
465
	 * Builds a set of locations with the provided title, text and icon.
466
	 *
467
	 * @param Location[] $locations
468
	 * @param string $text
469
	 * @param string $icon
470
	 * @param array $properties
471
	 * @param Title|null $title
472
	 *
473
	 * @return Location[]
474
	 */
475
	private function buildLocationsList( array $locations, $text, $icon, array $properties, Title $title = null ) {
476
		if ( !$this->hasTemplate() ) {
477
			$text .= implode( '<br />', $properties );
478
		}
479
480
		$titleOutput = $this->getTitleOutput( $title );
481
482
		foreach ( $locations as &$location ) {
483
			if ( $this->hasTemplate() ) {
484
				$segments = array_merge(
485
					[
486
						$this->template,
487
						'title=' . $titleOutput,
488
						'latitude=' . $location->getCoordinates()->getLatitude(),
489
						'longitude=' . $location->getCoordinates()->getLongitude(),
490
						'userparam=' . $this->userParam
491
					],
492
					$properties
493
				);
494
495
				$text .= $this->getParser()->recursiveTagParse(
496
					'{{' . implode( '|', $segments ) . '}}'
497
				);
498
			}
499
500
			$location->setTitle( $titleOutput );
501
			$location->setText( $text );
502
			$location->setIcon( $icon );
503
		}
504
505
		return $locations;
506
	}
507
508
	/**
509
	 * @return \Parser
510
	 */
511
	private function getParser() {
0 ignored issues
show
Coding Style introduced by
getParser uses the super-global variable $GLOBALS which is generally not recommended.

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:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
512
		return $GLOBALS['wgParser'];
513
	}
514
515
	private function getTitleOutput( Title $title = null ) {
516
		if ( $title === null ) {
517
			return '';
518
		}
519
520
		return $this->hideNamespace ? $title->getText() : $title->getFullText();
521
	}
522
523
	/**
524
	 * Get the icon for a row.
525
	 *
526
	 * @param array $row
527
	 *
528
	 * @return string
529
	 */
530
	private function getLocationIcon( array $row ) {
531
		$icon = '';
532
		$legend_labels = [];
533
534
		//Check for activeicon parameter
535
536
		if ( $this->shouldGetActiveIconUrlFor( $row[0]->getResultSubject()->getTitle() ) ){
537
			$icon = MapsMapper::getFileUrl( $this->activeIcon );
0 ignored issues
show
Deprecated Code introduced by
The method MapsMapper::getFileUrl() has been deprecated.

This method has been deprecated.

Loading history...
538
		}
539
540
		// Look for display_options field, which can be set by Semantic Compound Queries
541
		// the location of this field changed in SMW 1.5
542
		$display_location = method_exists( $row[0], 'getResultSubject' ) ? $row[0]->getResultSubject() : $row[0];
543
544
		if ( property_exists( $display_location, 'display_options' ) && is_array( $display_location->display_options ) ) {
545
			$display_options = $display_location->display_options;
546
			if ( array_key_exists( 'icon', $display_options ) ) {
547
				$icon = $display_options['icon'];
548
549
				// This is somewhat of a hack - if a legend label has been set, we're getting it for every point, instead of just once per icon
550
				if ( array_key_exists( 'legend label', $display_options ) ) {
551
552
					$legend_label = $display_options['legend label'];
553
554
					if ( ! array_key_exists( $icon, $legend_labels ) ) {
555
						$legend_labels[$icon] = $legend_label;
556
					}
557
				}
558
			}
559
		} // Icon can be set even for regular, non-compound queries If it is, though, we have to translate the name into a URL here
560
		elseif ( $this->icon !== '' ) {
561
			$icon = MapsMapper::getFileUrl( $this->icon );
0 ignored issues
show
Deprecated Code introduced by
The method MapsMapper::getFileUrl() has been deprecated.

This method has been deprecated.

Loading history...
562
		}
563
564
		return $icon;
565
	}
566
567
	private function shouldGetActiveIconUrlFor( Title $title ) {
568
		global $wgTitle;
569
570
		return isset( $this->activeIcon ) && is_object( $wgTitle )
571
			&& $wgTitle->equals( $title );
572
	}
573
574
	/**
575
	 * @param boolean $hideNamespace
576
	 */
577
	public function setHideNamespace( $hideNamespace ) {
578
		$this->hideNamespace = $hideNamespace;
579
	}
580
581
	/**
582
	 * @return boolean
583
	 */
584
	public function getHideNamespace() {
585
		return $this->hideNamespace;
586
	}
587
588
	/**
589
	 * @param string $activeIcon
590
	 */
591
	public function setActiveIcon( $activeIcon ) {
592
		$this->activeIcon = $activeIcon;
593
	}
594
595
	/**
596
	 * @return string
597
	 */
598
	public function getActiveIcon() {
599
		return $this->activeIcon;
600
	}
601
602
}
603