1<?php
2/**
3 * DokuWiki Bootstrap3 Template: Image Detail Page
4 *
5 * @link     http://dokuwiki.org/template:bootstrap3
6 * @author   Andreas Gohr <andi@splitbrain.org>
7 * @author   Anika Henke <anika@selfthinker.org>
8 * @author   Giuseppe Di Terlizzi <giuseppe.diterlizzi@gmail.com>
9 * @license  GPL 2 (http://www.gnu.org/licenses/gpl.html)
10 */
11
12if (!defined('DOKU_INC')) die(); // must be run from within DokuWiki
13
14require_once('tpl/global.php');
15require_once('tpl/functions.php');
16
17global $ACT;
18global $conf;
19global $ERROR;
20global $IMG;
21global $INPUT;
22global $lang;
23global $TPL;
24global $REV;
25
26header('X-UA-Compatible: IE=edge,chrome=1');
27
28
29$metadata = array(
30
31    'exif' => array(
32        'Exif.ImageDescription',
33        'Exif.Make',
34        'Exif.Model',
35        'Exif.Orientation',
36        'Exif.XResolution',
37        'Exif.YResolution',
38        'Exif.ResolutionUnit',
39        'Exif.Software',
40        'Exif.DateTime',
41        'Exif.Artist',
42        'Exif.WhitePoint',
43        'Exif.PrimaryChromaticities',
44        'Exif.YCbCrCoefficients',
45        'Exif.YCbCrSubSampling',
46        'Exif.YCbCrPositioning',
47        'Exif.ReferenceBlackWhite',
48        'Exif.Copyright',
49        'Exif.ExifIFDOffset',
50        'Exif.GPSIFDOffset',
51        'Exif.TIFFNewSubfileType',
52        'Exif.TIFFSubfileType',
53        'Exif.TIFFImageWidth',
54        'Exif.TIFFImageHeight',
55        'Exif.TIFFBitsPerSample',
56        'Exif.TIFFCompression',
57        'Exif.TIFFPhotometricInterpretation',
58        'Exif.TIFFThreshholding',
59        'Exif.TIFFCellWidth',
60        'Exif.TIFFCellLength',
61        'Exif.TIFFFillOrder',
62        'Exif.TIFFImageDescription',
63        'Exif.TIFFMake',
64        'Exif.TIFFModel',
65        'Exif.TIFFStripOffsets',
66        'Exif.TIFFOrientation',
67        'Exif.TIFFSamplesPerPixel',
68        'Exif.TIFFRowsPerStrip',
69        'Exif.TIFFStripByteCounts',
70        'Exif.TIFFMinSampleValue',
71        'Exif.TIFFMaxSampleValue',
72        'Exif.TIFFXResolution',
73        'Exif.TIFFYResolution',
74        'Exif.TIFFPlanarConfiguration',
75        'Exif.TIFFGrayResponseUnit',
76        'Exif.TIFFGrayResponseCurve',
77        'Exif.TIFFResolutionUnit',
78        'Exif.TIFFSoftware',
79        'Exif.TIFFDateTime',
80        'Exif.TIFFArtist',
81        'Exif.TIFFHostComputer',
82        'Exif.TIFFColorMap',
83        'Exif.TIFFExtraSamples',
84        'Exif.TIFFJFIFOffset',
85        'Exif.TIFFJFIFLength',
86        'Exif.TIFFYCbCrCoefficients',
87        'Exif.TIFFYCbCrSubSampling',
88        'Exif.YCbCrPositioning',
89        'Exif.ReferenceBlackWhite',
90        'Exif.Copyright',
91        'Exif.ExifIFDOffset',
92        'Exif.GPSIFDOffset',
93        'Exif.TIFFNewSubfileType',
94        'Exif.TIFFSubfileType',
95        'Exif.TIFFImageWidth',
96        'Exif.TIFFImageHeight',
97        'Exif.TIFFBitsPerSample',
98        'Exif.TIFFCompression',
99        'Exif.TIFFPhotometricInterpretation',
100        'Exif.TIFFThreshholding',
101        'Exif.TIFFCellWidth',
102        'Exif.TIFFCellLength',
103        'Exif.TIFFFillOrder',
104        'Exif.TIFFImageDescription',
105        'Exif.TIFFMake',
106        'Exif.TIFFModel',
107        'Exif.TIFFStripOffsets',
108        'Exif.TIFFOrientation',
109        'Exif.TIFFSamplesPerPixel',
110        'Exif.TIFFRowsPerStrip',
111        'Exif.TIFFStripByteCounts',
112        'Exif.TIFFMinSampleValue',
113        'Exif.TIFFMaxSampleValue',
114        'Exif.TIFFXResolution',
115        'Exif.TIFFYResolution',
116        'Exif.TIFFPlanarConfiguration',
117        'Exif.TIFFGrayResponseUnit',
118        'Exif.TIFFGrayResponseCurve',
119        'Exif.TIFFResolutionUnit',
120        'Exif.TIFFSoftware',
121        'Exif.TIFFDateTime',
122        'Exif.TIFFArtist',
123        'Exif.TIFFHostComputer',
124        'Exif.TIFFColorMap',
125        'Exif.TIFFExtraSamples',
126        'Exif.TIFFJFIFOffset',
127        'Exif.TIFFJFIFLength',
128        'Exif.TIFFYCbCrCoefficients',
129        'Exif.TIFFYCbCrSubSampling',
130        'Exif.TIFFYCbCrPositioning',
131        'Exif.TIFFReferenceBlackWhite',
132        'Exif.TIFFCopyright',
133        'Exif.TIFFUserComment',
134        'Exif.ExposureTime',
135        'Exif.FNumber',
136        'Exif.ExposureProgram',
137        'Exif.SpectralSensitivity',
138        'Exif.ISOSpeedRatings',
139        'Exif.OECF',
140        'Exif.EXIFVersion',
141        'Exif.DatetimeOriginal',
142        'Exif.DatetimeDigitized',
143        'Exif.ComponentsConfiguration',
144        'Exif.CompressedBitsPerPixel',
145        'Exif.ShutterSpeedValue',
146        'Exif.ApertureValue',
147        'Exif.BrightnessValue',
148        'Exif.ExposureBiasValue',
149        'Exif.MaxApertureValue',
150        'Exif.SubjectDistance',
151        'Exif.MeteringMode',
152        'Exif.LightSource',
153        'Exif.Flash',
154        'Exif.FocalLength',
155        //'Exif.MakerNote',
156        'Exif.UserComment',
157        'Exif.SubSecTime',
158        'Exif.SubSecTimeOriginal',
159        'Exif.SubSecTimeDigitized',
160        'Exif.FlashPixVersion',
161        'Exif.ColorSpace',
162        'Exif.PixelXDimension',
163        'Exif.PixelYDimension',
164        'Exif.RelatedSoundFile',
165        'Exif.InteropIFDOffset',
166        'Exif.FlashEnergy',
167        'Exif.SpatialFrequencyResponse',
168        'Exif.FocalPlaneXResolution',
169        'Exif.FocalPlaneYResolution',
170        'Exif.FocalPlaneResolutionUnit',
171        'Exif.SubjectLocation',
172        'Exif.ExposureIndex',
173        'Exif.SensingMethod',
174        'Exif.FileSource',
175        'Exif.SceneType',
176        'Exif.CFAPattern',
177        'Exif.InteroperabilityIndex',
178        'Exif.InteroperabilityVersion',
179        'Exif.RelatedImageFileFormat',
180        'Exif.RelatedImageWidth',
181        'Exif.RelatedImageLength',
182        'Exif.GPSVersionID',
183        'Exif.GPSLatitudeRef',
184        'Exif.GPSLatitude',
185        'Exif.GPSLongitudeRef',
186        'Exif.GPSLongitude',
187        'Exif.GPSAltitudeRef',
188        'Exif.GPSAltitude',
189        'Exif.GPSTimeStamp',
190        'Exif.GPSSatellites',
191        'Exif.GPSStatus',
192        'Exif.GPSMeasureMode',
193        'Exif.GPSDOP',
194        'Exif.GPSSpeedRef',
195        'Exif.GPSSpeed',
196        'Exif.GPSTrackRef',
197        'Exif.GPSTrack',
198        'Exif.GPSImgDirectionRef',
199        'Exif.GPSImgDirection',
200        'Exif.GPSMapDatum',
201        'Exif.GPSDestLatitudeRef',
202        'Exif.GPSDestLatitude',
203        'Exif.GPSDestLongitudeRef',
204        'Exif.GPSDestLongitude',
205        'Exif.GPSDestBearingRef',
206        'Exif.GPSDestBearing',
207        'Exif.GPSDestDistanceRef',
208        'Exif.GPSDestDistance',
209    ),
210
211    'iptc' => array(
212        'Iptc.SuplementalCategories',
213        'Iptc.Keywords',
214        'Iptc.Caption',
215        'Iptc.CaptionWriter',
216        'Iptc.Headline',
217        'Iptc.SpecialInstructions',
218        'Iptc.Category',
219        'Iptc.Byline',
220        'Iptc.BylineTitle',
221        'Iptc.Credit',
222        'Iptc.Source',
223        'Iptc.CopyrightNotice',
224        'Iptc.ObjectName',
225        'Iptc.City',
226        'Iptc.Province State',
227        'Iptc.CountryName',
228        'Iptc.OriginalTransmissionReference',
229        'Iptc.DateCreated',
230        'Iptc.CopyrightFlag',
231    ),
232);
233
234
235$maxwidth  = 800;
236$maxheight = 600;
237
238$originalwidth  = $w = (int) tpl_img_getTag('File.Width');
239$originalheight = $h = (int) tpl_img_getTag('File.Height');
240
241//resize to given max values
242$ratio = 1;
243
244if ($w >= $h) {
245    if ($maxwidth && $w >= $maxwidth) {
246        $ratio = $maxwidth / $w;
247    } elseif ($maxheight && $h > $maxheight) {
248        $ratio = $maxheight / $h;
249    }
250} else {
251    if ($maxheight && $h >= $maxheight) {
252        $ratio = $maxheight / $h;
253    } elseif ($maxwidth && $w > $maxwidth) {
254        $ratio = $maxwidth / $w;
255    }
256}
257
258if ($ratio) {
259    $w = floor($ratio * $w);
260    $h = floor($ratio * $h);
261}
262
263$other_sizes = array();
264
265foreach (array(0.1, 0.25, 0.5, 0.75, 1) as $ratio) {
266    $other_sizes[] = array(
267        'w'     => floor($ratio * $originalwidth),
268        'h'     => floor($ratio * $originalheight),
269        'ratio' => $ratio,
270    );
271}
272
273$show_metadata = false;
274
275?><!DOCTYPE html>
276<html xmlns="http://www.w3.org/1999/xhtml" lang="<?php echo $conf['lang']?>" dir="<?php echo $lang['direction'] ?>" class="no-js">
277<head>
278    <meta charset="UTF-8" />
279    <title><?php echo hsc(tpl_img_getTag('IPTC.Headline',$IMG))?> [<?php echo strip_tags($conf['title'])?>]</title>
280    <script>(function(H){H.className=H.className.replace(/\bno-js\b/,'js')})(document.documentElement)</script>
281    <meta name="viewport" content="width=device-width,initial-scale=1" />
282    <?php
283
284        if ($TPL->getConf('themeByNamespace')) {
285            echo '<link href="' . tpl_basedir() . 'css.php?id='. $ID .'" rel="stylesheet" />';
286        }
287
288        echo tpl_favicon(array('favicon', 'mobile'));
289        tpl_includeFile('meta.html');
290        tpl_metaheaders();
291
292    ?>
293    <!--[if lt IE 9]>
294    <script type="text/javascript" src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
295    <script type="text/javascript" src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
296    <![endif]-->
297</head>
298
299<body class="<?php echo $TPL->getClasses() ?>" data-img-id="<?php echo $IMG ?>"><div class="dokuwiki"><?php /* CSS class for Plugins and user styles */ ?>
300
301    <header id="dokuwiki__header" class="dw-container dokuwiki container<?php echo ($TPL->getConf('fluidContainer')) ? '-fluid' : '' ?>">
302        <?php
303
304            tpl_includeFile('topheader.html');
305
306            // Top-Header DokuWiki page
307            if ($ACT == 'show') echo $TPL->includePage('topheader');
308
309            require_once('tpl/navbar.php');
310
311            tpl_includeFile('header.html');
312
313            // Header DokuWiki page
314            if ($ACT == 'show') echo $TPL->includePage('header');
315
316        ?>
317    </header>
318
319    <a name="dokuwiki__top" id="dokuwiki__top"></a>
320
321    <main role="main" class="dw-container pb-5 dokuwiki container<?php echo ($TPL->getConf('fluidContainer')) ? '-fluid mx-5' : '' ?>">
322
323        <div id="dokuwiki__pageheader">
324
325            <?php tpl_includeFile('social.html') ?>
326
327            <?php require_once('tpl/breadcrumbs.php'); ?>
328
329            <p class="text-right">
330                <?php if($TPL->getConf('showPageId')): ?>
331                    <span class="pageId ml-1 label label-primary"><?php echo hsc(tpl_img_getTag('IPTC.Headline',$IMG)); ?></span>
332                <?php endif; ?>
333            </p>
334
335            <div id="dw__msgarea" class="small">
336                <?php $TPL->getMessageArea() ?>
337            </div>
338
339        </div>
340
341        <div class="">
342
343            <article id="dokuwiki__detail">
344
345                <?php require_once('tpl/page-tools.php'); // Page Tools ?>
346
347                <div class="dokuwiki panel panel-default">
348
349                    <div class="panel-heading">
350                        <h3 class="panel-title">
351                            <?php echo iconify('mdi:image', array('class' => 'text-muted')) ?> <?php echo nl2br(hsc(tpl_img_getTag('simple.title'))); ?>
352                        </h3>
353                    </div>
354
355                    <div class="page panel-body">
356
357                        <?php require_once('tpl/page-icons.php'); ?>
358
359                        <?php if ($ERROR): print '<h1>' . iconify('mdi:alert', array('class' => 'mr-2', 'style' => 'color:orange')) . $ERROR . '</h1>'; ?>
360                        <?php else: ?>
361                        <?php if ($REV) echo p_locale_xhtml('showrev'); ?>
362
363                        <div class="row">
364                            <div class="col-sm-8">
365
366                                <p class="px-2">
367                                    <?php tpl_img($maxwidth, $maxheight); /* the image; parameters: maximum width, maximum height (and more) */ ?>
368                                </p>
369
370                                <p class="small my-2">
371                                    <?php echo iconify('mdi:image-size-select-large'); ?> <?php echo tpl_getLang('preview_size') ?>: <a href="<?php echo ml($IMG, array('cache' => $INPUT->str('cache'), 'rev' => $REV, 'w' => $w, 'h' => $h), true, '&'); ?>"><?php echo $w; ?> × <?php echo $h; ?></a> pixels.
372                                    <?php echo tpl_getLang('other_resolutions') ?>: <?php foreach ($other_sizes as $size): ?> <a href="<?php echo ml($IMG, array('cache' => $INPUT->str('cache'), 'rev' => $REV, 'w' => $size['w'], 'h' => $size['h']), true, '&'); ?>" title="<?php echo floor($size['ratio'] * 100); ?>%"><?php echo $size['w']; ?> × <?php echo $size['h']; ?></a> pixels &nbsp; <?php endforeach; ?>
373                                </p>
374
375                                <p class="image-info my-3">
376                                    <?php echo iconify('mdi:image'); ?> <a href="<?php echo ml($IMG, array('cache'=> $INPUT->str('cache'),'rev'=>$REV), true, '&'); ?>" target="_blank" title="<?php echo $lang['js']['mediadirect']; ?>"><?php echo hsc(tpl_img_getTag('IPTC.Headline',$IMG)); ?></a> ( <?php echo tpl_img_getTag('File.Width'); ?> × <?php echo tpl_img_getTag('File.Height'); ?> pixels )
377                                </p>
378                            </div>
379                            <div class="col-sm-4">
380
381                                <div class="image-information">
382
383                                    <h3 class="pb-4">
384                                        <?php echo iconify('mdi:information', array('class' => 'text-primary')) ?> Information
385                                    </h3>
386
387                                    <div class="table-responsive">
388                                        <table class="table table-condensed table-striped">
389                                            <tbody>
390                                                <?php
391                                                    $tags = tpl_get_img_meta();
392
393                                                    foreach($tags as $tag) {
394
395                                                        $label = $lang[$tag['langkey']];
396                                                        if(!$label) $label = $tag['langkey'] . ':';
397
398                                                        echo '<tr><th>'.$label.'</th><td>';
399                                                        if ($tag['type'] == 'date') {
400                                                            echo dformat($tag['value']);
401                                                        } else {
402                                                            echo hsc($tag['value']);
403                                                        }
404                                                        echo '</td></tr>';
405                                                    }
406                                                ?>
407                                            </tbody>
408                                        </table>
409                                    </div>
410
411                                    <?php
412                                        //Comment in for Debug
413                                        //dbg(tpl_img_getTag('Simple.Raw'));
414                                    ?>
415
416                                </div>
417
418                                <div class="image-reference pt-4">
419
420                                    <h3 class="pb-4">
421                                        <?php echo iconify('mdi:link-variant'); ?> <?php echo $lang['reference']; ?>
422                                    </h3>
423                                    <?php
424                                        $media_usage = ft_mediause($IMG, true);
425                                        if (count($media_usage) > 0) {
426                                            echo '<ul>';
427                                            foreach($media_usage as $path){
428                                                echo '<li>'.html_wikilink($path).'</li>';
429                                            }
430                                            echo '</ul>';
431                                        } else {
432                                            echo '<p>'.$lang['nothingfound'].'</p>';
433                                        }
434                                    ?>
435
436                                    <?php if (isset($lang['media_acl_warning'])): // This message is available from release 2015-08-10 "Detritus" ?>
437                                    <div class="alert alert-warning">
438                                        <?php echo iconify('mdi:alert'); ?> <?php echo $lang['media_acl_warning']; ?>
439                                    </div>
440                                    <?php endif; ?>
441
442                                </div>
443
444                                <div class="image-metadata pt-4 hide">
445
446                                    <h3 class="pb-4">
447                                        <?php echo iconify('mdi:code-tags', array('class' => 'text-success')); ?> Metadata
448                                    </h3>
449
450                                    <div class="metadata">
451                                        <ul class="nav nav-tabs">
452                                            <li class="active"><a data-toggle="tab" href="#exif">Exif</a></li>
453                                            <li><a data-toggle="tab" href="#iptc">IPTC</a></li>
454                                        </ul>
455                                        <div class="tab-content">
456                                            <?php $active = 'active in'; foreach ($metadata as $section => $items): ?>
457                                            <div id="<?php echo $section; ?>" class="tab-pane fade <?php echo $active; ?>">
458                                                <div class="table-responsive">
459                                                    <table class="table table-condensed table-striped">
460                                                        <?php
461                                                            foreach ($items as $tag) {
462
463                                                                $value = tpl_img_getTag($tag);
464                                                                $name  = str_ireplace("$section.", '', $tag);
465
466                                                                if ($value !== '') {
467                                                                    echo "<tr><th title='$tag'>$name</th><td>$value</td></tr>";
468                                                                    $show_metadata = true;
469                                                                }
470
471                                                            }
472
473                                                            $active = '';
474
475                                                        ?>
476                                                    </table>
477                                                </div>
478                                            </div>
479                                            <?php endforeach; ?>
480                                        </div>
481                                    </div>
482
483                                    <?php if ($show_metadata): ?>
484                                    <script>
485                                        window.addEventListener('DOMContentLoaded', function() {
486                                            jQuery('.image-metadata').removeClass('hide');
487                                        });
488                                    </script>
489                                    <?php endif; ?>
490
491                                </div>
492
493                            </div>
494                        </div>
495
496                        <?php endif; ?>
497
498                    </div>
499                </div>
500
501                <div class="small text-right">
502
503                    <?php if ($TPL->getConf('showPageInfo')): ?>
504                    <span class="docInfo">
505                        <?php $TPL->getPageInfo() /* 'Last modified' etc */ ?>
506                    </span>
507                    <?php endif ?>
508
509                    <?php if ($TPL->getConf('showLoginOnFooter')): ?>
510                    <span class="loginLink hidden-print">
511                        <?php
512                            if ($login_item = $TPL->getToolMenuItem('user', 'login')) {
513                                echo '<a '. buildAttributes($login_item->getLinkAttributes()) .'>'. inlineSVG($login_item->getSvg()) . ' ' . hsc($login_item->getLabel()) .'</a>';
514                            }
515                        ?>
516                    </span>
517                    <?php endif; ?>
518
519                </div>
520
521            </article>
522        </div>
523
524    </main>
525
526    <footer id="dw__footer" class="dw-container py-5 dokuwiki container<?php echo ($TPL->getConf('fluidContainer')) ? '-fluid' : '' ?>">
527        <?php
528            // Footer hook
529            tpl_includeFile('footer.html');
530
531            // Footer DokuWiki page
532            require_once('tpl/footer.php');
533
534            // Cookie-Law banner
535            require_once('tpl/cookielaw.php');
536        ?>
537    </footer>
538
539    <a href="#dokuwiki__top" class="back-to-top hidden-print btn btn-default btn-sm" title="<?php echo $lang['skip_to_content'] ?>" accesskey="t">
540        <?php echo iconify('mdi:chevron-up'); ?>
541    </a>
542
543    <div id="screen__mode"><?php /* helper to detect CSS media query in script.js */ ?>
544        <span class="visible-xs-block"></span>
545        <span class="visible-sm-block"></span>
546        <span class="visible-md-block"></span>
547        <span class="visible-lg-block"></span>
548    </div>
549
550</div>
551
552</body>
553</html>
554