Example #1
0
 private function writeRow(XMLWriter $xml, $row, $muni_names)
 {
     $row = $row['hit'];
     #Ignore rows without coords
     if (!empty($row['lat']) and !empty($row['lon'])) {
         $xml->startElement('Placemark');
         $placemarkId = $row['id'];
         $xml->writeAttribute('id', htmlspecialchars($placemarkId));
         if (!empty($row['title'])) {
             $xml->startElement('title');
             if ($row['removed'] == 1) {
                 $xml->text(htmlspecialchars($row['title'] . ' (borttagen)'));
             } else {
                 $xml->text(htmlspecialchars($row['title']));
             }
             $xml->endElement();
         }
         $xml->startElement('description');
         $desc = '';
         if (!empty($row['image'])) {
             #if inside & unfree show link otherwise show image
             if ($row['inside'] == 1 and $row['free'] == 'unfree') {
                 $showImage = 'Commons-icon.svg';
             } else {
                 $showImage = $row['image'];
             }
             $imgsize = 100;
             $desc .= '<a href="http://commons.wikimedia.org/wiki/File:' . rawurlencode($row['image']) . '" target="_blank">';
             $desc .= '<img src="' . ApiBase::getImageFromCommons($showImage, $imgsize) . '" align="right" />';
             $desc .= '</a>';
             $styleUrl = '#picStyle';
         } else {
             $styleUrl = '#noPicStyle';
         }
         $desc .= '<ul>';
         if (!empty($row['title'])) {
             $desc .= '<li> ';
             #title
             $desc .= '<b>' . htmlspecialchars($row['title']) . '</b>';
             $desc .= '</li>';
         }
         $desc .= '<li> ';
         #artist - year
         $artist_info = ApiBase::getArtistInfo($row['id']);
         if (!empty($artist_info)) {
             foreach ($artist_info as $ai) {
                 if ($ai['wiki']) {
                     #$desc .= '<a href="https://wikidata.org/wiki/' . rawurlencode($ai['wiki']) . '">';
                     $desc .= '<a href="' . ApiBase::getArticleFromWikidata($ai['wiki']) . '" target="_blank">';
                     $desc .= '' . htmlspecialchars($ai['name']);
                     $desc .= '</a>';
                 } else {
                     $desc .= '' . htmlspecialchars($ai['name']);
                 }
                 $desc .= ', ';
             }
             $desc = substr($desc, 0, -2);
             #remove trailing ","
             if (!empty($row['year'])) {
                 $desc .= ' - ' . htmlspecialchars($row['year']);
             }
         } elseif (!empty($row['artist'])) {
             $desc .= htmlspecialchars($row['artist']);
             if (!empty($row['year'])) {
                 $desc .= ' - ' . htmlspecialchars($row['year']);
             }
         } elseif (!empty($row['year'])) {
             $desc .= htmlspecialchars($row['year']);
         }
         $desc .= '</li><li> ';
         #Muni - address
         $desc .= htmlspecialchars($muni_names[$row['muni']]);
         if (!empty($row['district'])) {
             $desc .= ' (' . htmlspecialchars($row['district']) . ')';
         }
         if (!empty($row['address'])) {
             $desc .= ' - ' . htmlspecialchars($row['address']);
         }
         #Description
         if (!empty($row['wiki'])) {
             #get descrition from wikipage
             $desc .= '</li><br/><li>' . ApiBase::getArticleIntro(ApiBase::getArticleFromWikidata($row['wiki'], $getUrl = false));
             $desc .= '  <a href="' . ApiBase::getArticleFromWikidata($row['wiki']) . '" target="_blank">';
             $desc .= htmlspecialchars('Läs mer om konstverket på Wikipedia');
             $desc .= '</a>.';
         } else {
             if (!empty($row['descr'])) {
                 $desc .= '</li><br/><li>' . htmlspecialchars($row['descr']);
             }
         }
         $desc .= '</li></ul>';
         $xml->writeCData($desc);
         $xml->endElement();
         $xml->startElement('styleUrl');
         $xml->text($styleUrl);
         $xml->endElement();
         $xml->startElement('Point');
         $xml->startElement('coordinates');
         $xml->text($row['lon'] . ',' . $row['lat']);
         $xml->endElement();
         $xml->endElement();
         $xml->endElement();
     }
 }