| 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 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | 	 * The global icon. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | 	 * @var string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | 	public $icon = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | 	 * The global text. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | 	 * @var string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | 	public $text = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | 	 * The global title. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | 	 * @var string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | 	public $title = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  | 	 * Make a separate link to the title or not? | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | 	 * @var boolean | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  | 	public $titleLinkSeparate = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  | 	private $queryResult; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  | 	private $outputMode; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  | 	 * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  | 	private $geoShapes = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  | 		'lines' => [], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  | 		'locations' => [], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  | 		'polygons' => [] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  | 	]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  | 	 * The template to use for the text, or false if there is none. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  | 	 * @var string|boolean false | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  | 	private $template = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  | 	 * Should link targets be made absolute (instead of relative)? | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  | 	 * @var boolean | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  | 	private $linkAbsolute; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  | 	 * The text used for the link to the page (if it's created). $1 will be replaced by the page name. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  | 	 * @var string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  | 	private $pageLinkText = '$1'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  | 	 * A separator to use between the subject and properties in the text field. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  | 	 * @var string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  | 	private $subjectSeparator = '<hr />'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  | 	 * Make the subject in the text bold or not? | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  | 	 * @var boolean | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  | 	private $boldSubject = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  | 	 * Show the subject in the text or not? | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  | 	 * @var boolean | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  | 	private $showSubject = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  | 	 * Hide the namespace or not. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  | 	 * @var boolean | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  | 	private $hideNamespace = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  | 	 * Defines which article names in the result are hyperlinked, all normally is the default | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  | 	 * none, subject, all | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  | 	private $linkStyle = 'all'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  | 	/* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  | 	 * Show headers (with links), show headers (just text) or hide them. show is default | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  | 	 * show, plain, hide | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  | 	private $headerStyle = 'show'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  | 	 * Marker icon to show when marker equals active page | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  | 	 * @var string|null | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  | 	private $activeIcon = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  | 	 * @var string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  | 	private $userParam = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  | 	 * @param SMWQueryResult $queryResult | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  | 	 * @param integer $outputMode | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  | 	 * @param boolean $linkAbsolute | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  | 	public function __construct( SMWQueryResult $queryResult, $outputMode, $linkAbsolute = false ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  | 		$this->queryResult = $queryResult; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  | 		$this->outputMode = $outputMode; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  | 		$this->linkAbsolute = $linkAbsolute; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  | 	 * Sets the template. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  | 	 * @param string $template | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  | 	public function setTemplate( $template ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  | 		$this->template = $template === '' ? false : $template; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  | 	 * @param string $userParam | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  | 	public function setUserParam( $userParam ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  | 		$this->userParam = $userParam; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  | 	 * Sets the global icon. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  | 	 * @param string $icon | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  | 	public function setIcon( $icon ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  | 		$this->icon = $icon; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  | 	 * Sets the global title. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  | 	 * @param string $title | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  | 	public function setTitle( $title ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  | 		$this->title = $title; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  | 	 * Sets the global text. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  | 	 * @param string $text | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  | 	public function setText( $text ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  | 		$this->text = $text; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  | 	 * Sets the subject separator. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  | 	 * @param string $subjectSeparator | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  | 	public function setSubjectSeparator( $subjectSeparator ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  | 		$this->subjectSeparator = $subjectSeparator; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  | 	 * Sets if the subject should be made bold in the text. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  | 	 * @param string $boldSubject | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  | 	public function setBoldSubject( $boldSubject ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  | 		$this->boldSubject = $boldSubject; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  | 	 * Sets if the subject should shown in the text. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  | 	 * @param string $showSubject | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  | 	public function setShowSubject( $showSubject ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  | 		$this->showSubject = $showSubject; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  | 	 * Sets the text for the link to the page when separate from the title. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  | 	 * @param string $text | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  | 	public function setPageLinkText( $text ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  | 		$this->pageLinkText = $text; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  | 	 * @param boolean $link | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 212 |  |  | 	 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 213 |  |  | 	public function setLinkStyle( $link ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 214 |  |  | 		$this->linkStyle = $link; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 215 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  | 	 * @param boolean $headers | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  | 	public function setHeaderStyle( $headers ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  | 		$this->headerStyle = $headers; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  | 	 * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  | 	public function getShapes() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  | 		$this->findShapes(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  | 		return $this->geoShapes; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  | 	 * @since 2.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  | 	private function findShapes() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  | 		while ( ( $row = $this->queryResult->getNext() ) !== false ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  | 			$this->handleResultRow( $row ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  | 	 * Returns the locations found in the provided result row. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  | 	 * @param SMWResultArray[] $row | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  | 	private function handleResultRow( array $row ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  | 		$locations = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  | 		$properties = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  | 		$title = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  | 		$text = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  | 		// Loop through all fields of the record. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  | 		foreach ( $row as $i => $resultArray ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  | 			$printRequest = $resultArray->getPrintRequest(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  | 			// Loop through all the parts of the field value. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  | 			while ( ( $dataValue = $resultArray->getNextDataValue() ) !== false ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  | 				if ( $dataValue->getTypeID() == '_wpg' && $i == 0 ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  | 					$title = $dataValue->getLongText( $this->outputMode, null ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  | 					$text = $this->getResultSubjectText( $dataValue ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  | 				} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  | 					if ( $dataValue->getTypeID() == '_str' && $i == 0 ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  | 						$title = $dataValue->getLongText( $this->outputMode, null ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  | 						$text = $dataValue->getLongText( $this->outputMode, smwfGetLinker() ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  | 					} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  | 						if ( $dataValue->getTypeID() == '_gpo' ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  | 							$dataItem = $dataValue->getDataItem(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  | 							$polyHandler = new PolygonHandler ( $dataItem->getString() ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  | 							$this->geoShapes[$polyHandler->getGeoType()][] = $polyHandler->shapeFromText(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  | 						} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  | 							if ( strpos( $dataValue->getTypeID(), '_rec' ) !== false ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  | 								foreach ( $dataValue->getDataItems() as $dataItem ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  | 									if ( $dataItem instanceof \SMWDIGeoCoord ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  | 										$location = Location::newFromLatLon( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  | 											$dataItem->getLatitude(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  | 											$dataItem->getLongitude() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  | 										); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  | 										$locations[] = $location; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  | 									} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  | 								} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  | 							} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  | 								if ( $dataValue->getTypeID() != '_geo' && $i != 0 && !$this->isHeadersHide() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  | 									$properties[] = $this->handleResultProperty( $dataValue, $printRequest ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  | 								} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  | 									if ( $printRequest->getMode( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  | 										) == SMWPrintRequest::PRINT_PROP && $printRequest->getTypeID( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  | 										) == '_geo' || $dataValue->getTypeID() == '_geo' ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  | 										$dataItem = $dataValue->getDataItem(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  | 										$location = Location::newFromLatLon( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  | 											$dataItem->getLatitude(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  | 											$dataItem->getLongitude() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  | 										); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  | 										$locations[] = $location; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  | 									} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  | 								} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  | 							} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  | 						} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  | 		if ( $properties !== [] && $text !== '' ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  | 			$text .= $this->subjectSeparator; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  | 		$icon = $this->getLocationIcon( $row ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  | 		$this->geoShapes['locations'] = array_merge( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 |  |  | 			$this->geoShapes['locations'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 |  |  | 			$this->buildLocationsList( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 |  |  | 				$locations, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 317 |  |  | 				$text, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 318 |  |  | 				$icon, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 319 |  |  | 				$properties, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 |  |  | 				Title::newFromText( $title ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 |  |  | 			) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 326 |  |  | 	 * Handles a SMWWikiPageValue subject value. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 327 |  |  | 	 * Gets the plain text title and creates the HTML text with headers and the like. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 328 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 329 |  |  | 	 * @param SMWWikiPageValue $object | 
            
                                                                                                            
                            
            
                                    
            
            
                | 330 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 331 |  |  | 	 * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 332 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 333 |  |  | 	private function getResultSubjectText( SMWWikiPageValue $object ): string { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 334 |  |  | 		if ( !$this->showSubject ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 335 |  |  | 			return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 336 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 337 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 338 |  |  | 		if ( $this->showArticleLink() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 339 |  |  | 			if ( !$this->titleLinkSeparate && $this->linkAbsolute ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 340 |  |  | 				$text = Html::element( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 341 |  |  | 					'a', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 342 |  |  | 					[ 'href' => $object->getTitle()->getFullUrl() ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 343 |  |  | 					$this->hideNamespace ? $object->getText() : $object->getTitle()->getFullText() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 344 |  |  | 				); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 345 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 346 |  |  | 				if ( $this->hideNamespace ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 347 |  |  | 					$text = $object->getShortHTMLText( smwfGetLinker() ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 348 |  |  | 				} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 349 |  |  | 					$text = $object->getLongHTMLText( smwfGetLinker() ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 350 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 351 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 352 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 353 |  |  | 			$text = $this->hideNamespace ? $object->getText() : $object->getTitle()->getFullText(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 354 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 355 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 356 |  |  | 		if ( $this->boldSubject ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 357 |  |  | 			$text = '<b>' . $text . '</b>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 358 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 359 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 360 |  |  | 		if ( !$this->titleLinkSeparate ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 361 |  |  | 			return $text; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 362 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 363 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 364 |  |  | 		$txt = $object->getTitle()->getText(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 365 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 366 |  |  | 		if ( $this->pageLinkText !== '' ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 367 |  |  | 			$txt = str_replace( '$1', $txt, $this->pageLinkText ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 368 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 369 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 370 |  |  | 		return $text . Html::element( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 371 |  |  | 			'a', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 372 |  |  | 			[ 'href' => $object->getTitle()->getFullUrl() ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 373 |  |  | 			$txt | 
            
                                                                                                            
                            
            
                                    
            
            
                | 374 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 375 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 376 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 377 |  |  | 	private function showArticleLink() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 378 |  |  | 		return $this->linkStyle !== 'none'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 379 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 380 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 381 |  |  | 	private function isHeadersHide() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 382 |  |  | 		return $this->headerStyle === 'hide'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 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 ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 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() ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 407 |  |  | 				$propertyName = $propertyName = Html::element( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 408 |  |  | 					'a', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 409 |  |  | 					[ 'href' => $t->getFullUrl() ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 410 |  |  | 					$printRequest->getHTMLText( null ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 411 |  |  | 				); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 412 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 413 |  |  | 				$propertyName = $titleText; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 414 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 415 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 416 |  |  | 			if ( $this->isHeadersShow() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 417 |  |  | 				$propertyName = $printRequest->getHTMLText( smwfGetLinker() ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 418 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 419 |  |  | 				if ( $this->isHeadersPlain() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 420 |  |  | 					$propertyName = $printRequest->getText( null ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 421 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 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() ], | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 437 |  |  | 					$object->getLongText( $this->outputMode, null ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 438 |  |  | 				); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 439 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 440 |  |  | 				$propertyValue = $object->getLongText( $this->outputMode, null ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 441 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 442 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 443 |  |  | 			$propertyValue = $object->getLongText( $this->outputMode, smwfGetLinker() ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 444 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 445 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 446 |  |  | 		return $propertyName . ( $propertyName === '' ? '' : ': ' ) . $propertyValue; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 447 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 448 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 449 |  |  | 	private function hasTemplate() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 450 |  |  | 		return is_string( $this->template ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 451 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 452 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 453 |  |  | 	private function isHeadersShow() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 454 |  |  | 		return $this->headerStyle === 'show'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 455 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 456 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 457 |  |  | 	private function isHeadersPlain() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 458 |  |  | 		return $this->headerStyle === 'plain'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 459 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 460 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 461 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 462 |  |  | 	 * Get the icon for a row. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 463 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 464 |  |  | 	 * @param array $row | 
            
                                                                                                            
                            
            
                                    
            
            
                | 465 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 466 |  |  | 	 * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 467 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 468 |  |  | 	private function getLocationIcon( array $row ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 469 |  |  | 		$icon = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 470 |  |  | 		$legendLabels = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 471 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 472 |  |  | 		//Check for activeicon parameter | 
            
                                                                                                            
                            
            
                                    
            
            
                | 473 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 474 |  |  | 		if ( $this->shouldGetActiveIconUrlFor( $row[0]->getResultSubject()->getTitle() ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 475 |  |  | 			$icon = MapsMapper::getFileUrl( $this->activeIcon ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 476 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 477 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 478 |  |  | 		// Look for display_options field, which can be set by Semantic Compound Queries | 
            
                                                                                                            
                            
            
                                    
            
            
                | 479 |  |  | 		// the location of this field changed in SMW 1.5 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 480 |  |  | 		$display_location = method_exists( $row[0], 'getResultSubject' ) ? $row[0]->getResultSubject() : $row[0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 481 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 482 |  |  | 		if ( property_exists( $display_location, 'display_options' ) && is_array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 483 |  |  | 				$display_location->display_options | 
            
                                                                                                            
                            
            
                                    
            
            
                | 484 |  |  | 			) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 485 |  |  | 			$display_options = $display_location->display_options; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 486 |  |  | 			if ( array_key_exists( 'icon', $display_options ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 487 |  |  | 				$icon = $display_options['icon']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 488 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 489 |  |  | 				// 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 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 490 |  |  | 				if ( array_key_exists( 'legend label', $display_options ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 491 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 492 |  |  | 					$legend_label = $display_options['legend label']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 493 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 494 |  |  | 					if ( !array_key_exists( $icon, $legendLabels ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 495 |  |  | 						$legendLabels[$icon] = $legend_label; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 496 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 497 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 498 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 499 |  |  | 		} // Icon can be set even for regular, non-compound queries If it is, though, we have to translate the name into a URL here | 
            
                                                                                                            
                            
            
                                    
            
            
                | 500 |  |  | 		elseif ( $this->icon !== '' ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 501 |  |  | 			$icon = MapsMapper::getFileUrl( $this->icon ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 502 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 503 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 504 |  |  | 		return $icon; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 505 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 506 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 507 |  |  | 	private function shouldGetActiveIconUrlFor( Title $title ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 508 |  |  | 		global $wgTitle; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 509 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 510 |  |  | 		return isset( $this->activeIcon ) && is_object( $wgTitle ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 511 |  |  | 			&& $wgTitle->equals( $title ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 512 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 513 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 514 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 515 |  |  | 	 * Builds a set of locations with the provided title, text and icon. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 516 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 517 |  |  | 	 * @param Location[] $locations | 
            
                                                                                                            
                            
            
                                    
            
            
                | 518 |  |  | 	 * @param string $text | 
            
                                                                                                            
                            
            
                                    
            
            
                | 519 |  |  | 	 * @param string $icon | 
            
                                                                                                            
                            
            
                                    
            
            
                | 520 |  |  | 	 * @param array $properties | 
            
                                                                                                            
                            
            
                                    
            
            
                | 521 |  |  | 	 * @param Title|null $title | 
            
                                                                                                            
                            
            
                                    
            
            
                | 522 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 523 |  |  | 	 * @return Location[] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 524 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 525 |  |  | 	private function buildLocationsList( array $locations, $text, $icon, array $properties, Title $title = null ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 526 |  |  | 		if ( !$this->hasTemplate() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 527 |  |  | 			$text .= implode( '<br />', $properties ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 528 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 529 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 530 |  |  | 		$titleOutput = $this->getTitleOutput( $title ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 531 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 532 |  |  | 		foreach ( $locations as &$location ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 533 |  |  | 			if ( $this->hasTemplate() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 534 |  |  | 				$segments = array_merge( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 535 |  |  | 					[ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 536 |  |  | 						$this->template, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 537 |  |  | 						'title=' . $titleOutput, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 538 |  |  | 						'latitude=' . $location->getCoordinates()->getLatitude(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 539 |  |  | 						'longitude=' . $location->getCoordinates()->getLongitude(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 540 |  |  | 						'userparam=' . $this->userParam | 
            
                                                                                                            
                            
            
                                    
            
            
                | 541 |  |  | 					], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 542 |  |  | 					$properties | 
            
                                                                                                            
                            
            
                                    
            
            
                | 543 |  |  | 				); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 544 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 545 |  |  | 				$text .= $this->getParser()->recursiveTagParseFully( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 546 |  |  | 					'{{' . implode( '|', $segments ) . '}}' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 547 |  |  | 				); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 548 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 549 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 550 |  |  | 			$location->setTitle( $titleOutput ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 551 |  |  | 			$location->setText( $text ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 552 |  |  | 			$location->setIcon( trim( $icon ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 553 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 554 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 555 |  |  | 		return $locations; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 556 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 557 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 558 |  |  | 	private function getTitleOutput( Title $title = null ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 559 |  |  | 		if ( $title === null ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 560 |  |  | 			return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 561 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 562 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 563 |  |  | 		return $this->hideNamespace ? $title->getText() : $title->getFullText(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 564 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 565 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 566 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 567 |  |  | 	 * @return \Parser | 
            
                                                                                                            
                            
            
                                    
            
            
                | 568 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 569 |  |  | 	private function getParser() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 570 |  |  | 		return $GLOBALS['wgParser']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 571 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 572 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 573 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 574 |  |  | 	 * @return boolean | 
            
                                                                                                            
                            
            
                                    
            
            
                | 575 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 576 |  |  | 	public function getHideNamespace() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 577 |  |  | 		return $this->hideNamespace; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 578 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 579 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 580 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 581 |  |  | 	 * @param boolean $hideNamespace | 
            
                                                                                                            
                            
            
                                    
            
            
                | 582 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 583 |  |  | 	public function setHideNamespace( $hideNamespace ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 584 |  |  | 		$this->hideNamespace = $hideNamespace; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 585 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 586 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 587 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 588 |  |  | 	 * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 589 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 590 |  |  | 	public function getActiveIcon() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 591 |  |  | 		return $this->activeIcon; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 592 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 593 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 594 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 595 |  |  | 	 * @param string $activeIcon | 
            
                                                                                                            
                            
            
                                    
            
            
                | 596 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 597 |  |  | 	public function setActiveIcon( $activeIcon ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 598 |  |  | 		$this->activeIcon = $activeIcon; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 599 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 600 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 601 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 602 |  |  |  | 
            
                        
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.