当前位置: 首页>>代码示例>>PHP>>正文


PHP ApiBase::getImageFromCommons方法代码示例

本文整理汇总了PHP中ApiBase::getImageFromCommons方法的典型用法代码示例。如果您正苦于以下问题:PHP ApiBase::getImageFromCommons方法的具体用法?PHP ApiBase::getImageFromCommons怎么用?PHP ApiBase::getImageFromCommons使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ApiBase的用法示例。


在下文中一共展示了ApiBase::getImageFromCommons方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: writeRow

 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();
//.........这里部分代码省略.........
开发者ID:Abbe98,项目名称:ODOK,代码行数:101,代码来源:FormatKml.php


注:本文中的ApiBase::getImageFromCommons方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。