1<?php
2/**
3 * DokuWiki Image Detail Page.
4 * Based on the source of the detail.php from the dokuwiki template
5 * written by Andreas Gohr and Anika Henke.
6 *
7 * @author   Andreas Gohr <andi@splitbrain.org>
8 * @author   Anika Henke <anika@selfthinker.org>
9 * @author   Martin Schulte <lebowski[at]corvus[dot]uberspace[dot]de>
10 * @license  GPL 2 (http://www.gnu.org/licenses/gpl.html)
11 */
12
13// must be run from within DokuWiki
14if (!defined('DOKU_INC')) die();
15$fileid = -1;
16
17
18?><!DOCTYPE html>
19<html lang="<?php echo $conf['lang']?>" dir="<?php echo $lang['direction'] ?>" class="no-js">
20<head>
21    <meta charset="utf-8" />
22    <!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /><![endif]-->
23    <title>
24        <?php echo hsc(tpl_img_getTag('IPTC.Headline',$IMG))?>
25        [<?php echo strip_tags($conf['title'])?>]
26    </title>
27    <script>(function(H){H.className=H.className.replace(/\bno-js\b/,'js')})(document.documentElement)</script>
28    <?php tpl_metaheaders()?>
29    <meta name="viewport" content="width=device-width,initial-scale=1" />
30    <?php echo tpl_favicon(array('favicon', 'mobile')) ?>
31    <?php tpl_includeFile('meta.html') ?>
32</head>
33
34<body>
35    <!--[if lte IE 7 ]><div id="IE7"><![endif]--><!--[if IE 8 ]><div id="IE8"><![endif]-->
36    <div id="dokuwiki__site"><div id="dokuwiki__top"
37        class="dokuwiki site mode_<?php echo $ACT ?>">
38
39        <?php include('tpl_header.php') ?>
40
41        <div class="wrapper group" id="dokuwiki__detail">
42
43            <!-- ********** CONTENT ********** -->
44            <div id="dokuwiki__content"><div class="pad group">
45
46                <?php if(!$ERROR): ?>
47                    <div class="pageId"><span><?php echo hsc(tpl_img_getTag('IPTC.Headline',$IMG)); ?></span></div>
48                <?php endif; ?>
49
50                <div class="page group">
51                    <?php tpl_flush() ?>
52                    <?php tpl_includeFile('pageheader.html') ?>
53                    <!-- detail start -->
54                    <?php
55                    if($ERROR):
56                        echo '<h1>'.$ERROR.'</h1>';
57                    else: ?>
58
59                        <h1><?php
60                        $helper = new helper_plugin_owncloud();
61						$path = $helper->wikiIDToPath($IMG);
62						$dir = dirname($path);
63                        $isDir = $helper->isMediaDir($path);
64
65                        if(!$isDir) echo nl2br(hsc(tpl_img_getTag('simple.title')));
66                        else echo nl2br(hsc('/'.$path));
67                        ?></h1>
68
69
70                        <?php
71
72                        if(!$isDir){
73							list($ext,$mime,$dl) = mimetype(noNS($IMG),false);
74							if(substr($mime,0,5) == 'image'){
75								tpl_img(900,700); /* parameters: maximum width, maximum height (and more) */
76							}else{
77								echo $helper->internalmedia($_GET['fileid'],$IMG,$helper->getLang('download'),NULL,NULL,NULL,NULL,'direct')."<br/><br/>";
78								$type = trim(strstr($mime, '/'),'/'); // without application/ , text/, ...
79							}
80						}
81                        ?>
82
83                        <div class="img_detail">
84                            <dl>
85                                <?php
86									global $lang;
87									if(isset($_GET['fileid'])){
88											$fileid = $_GET['fileid'];
89									}else{
90											$fileid = $helper->getIDForFilename($helper->wikiIDToPath($IMG));
91									}
92									if(!$isDir){
93										// @todo: logic should be transferred to backend
94										$config_files = getConfigFiles('mediameta');
95										foreach ($config_files as $config_file) {
96											if(@file_exists($config_file)) {
97												include($config_file);
98											}
99										}
100
101										foreach($fields as $key => $tag){
102											$t = array();
103											if (!empty($tag[0])) {
104												$t = array($tag[0]);
105											}
106											if(is_array($tag[3])) {
107												$t = array_merge($t,$tag[3]);
108											}
109											$value = tpl_img_getTag($t);
110											if ($value) {
111												echo '<dt>'.$lang[$tag[1]].':</dt><dd>';
112												if ($tag[2] == 'date') {
113													echo dformat($value);
114												} else {
115													echo hsc($value);
116												}
117												echo '</dd>';
118											}
119										}
120										if(isset($type) && !empty($type)) echo "<dt>".$lang['img_format'].":</dt><dd>$type</dd>";
121										echo "<dt>".$helper->getLang('path').':</dt><dd><a href="'.$helper->getConf('owncloudurl').'/index.php/apps/files?dir=//'.$helper->wiki.'/'.$dir.'"target="_blank">/'.$path.'</a>&nbsp;&nbsp(';
122									}else{
123										echo $helper->filelist($fileid,'');
124									}
125									if($dir == "." || $dir == "") $dir=":";// We are at the top
126									echo $helper->internalmedia('',$helper->pathToWikiID($dir),$helper->getLang('parentFolder'));
127									if(!$isDir) echo ")</dd>";
128                                ?>
129                            </dl>
130                        </div>
131                        <?php
132                        if(!$isDir){
133							echo $helper->mediaMetaStart($path);
134							echo $helper->mediaInUse($fileid);
135						}
136
137                        ?>
138                        <?php   //dbg(tpl_img_getTag('Simple.Raw'));?>
139                    <?php endif; ?>
140                </div>
141                <!-- detail stop -->
142                <?php tpl_includeFile('pagefooter.html') ?>
143                <?php tpl_flush() ?>
144
145                <?php /* doesn't make sense like this; @todo: maybe add tpl_imginfo()?
146                <div class="docInfo"><?php tpl_pageinfo(); ?></div>
147                */ ?>
148
149            </div></div><!-- /content -->
150
151            <hr class="a11y" />
152
153            <!-- PAGE ACTIONS -->
154            <?php if (!$ERROR): ?>
155                <div id="dokuwiki__pagetools">
156                    <h3 class="a11y"><?php echo $lang['page_tools']; ?></h3>
157                    <div class="tools">
158                        <ul>
159                            <?php // View in media manager; @todo: transfer logic to backend
160                                $imgNS = getNS($IMG);
161                                $authNS = auth_quickaclcheck("$imgNS:*");
162                                if (($authNS >= AUTH_UPLOAD) && function_exists('media_managerURL')) {
163                                    $mmURL = media_managerURL(array('ns' => $imgNS, 'image' => $IMG));
164                                    echo '<li><a href="'.$mmURL.'" class="mediaManager"><span>'.$lang['img_manager'].'</span></a></li>';
165                                }
166                            ?>
167                            <?php // Back to [ID]; @todo: transfer logic to backend
168                                echo '<li><a href="'.wl($ID).'" class="back"><span>'.$lang['img_backto'].' '.$ID.'</span></a></li>';
169                            ?>
170                        </ul>
171                    </div>
172                </div>
173            <?php endif; ?>
174        </div><!-- /wrapper -->
175
176        <?php include('tpl_footer.php') ?>
177    </div></div><!-- /site -->
178
179    <!--[if ( lte IE 7 | IE 8 ) ]></div><![endif]-->
180</body>
181</html>
182