annotate mgallery.php @ 47:1e2b55775a84

Begin implementation of translated caption/title support.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 25 May 2016 18:02:33 +0300
parents bc9da3b71888
children 5a2dd41ff7ad
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 <?php
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 //
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3 // Yet Another Image Gallery
32
953b0f7636f4 Update copyrights.
Matti Hamalainen <ccr@tnsp.org>
parents: 31
diff changeset
4 // (C) Copyright 2015-2016 Tecnic Software productions (TNSP)
0
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5 //
27
b8f8e03f943b Fix site library include.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
6 require "mgeneric.inc.php";
0
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7 require "mgallery.inc.php";
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10 //
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11 // Various utility functions
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12 //
38
3f16beb79f9e Add image title string to certain images.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
13 function mgGetImageTitleStr($filename, &$data)
3f16beb79f9e Add image title string to certain images.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
14 {
3f16beb79f9e Add image title string to certain images.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
15 return
3f16beb79f9e Add image title string to certain images.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
16 chentities($filename).
3f16beb79f9e Add image title string to certain images.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
17 mgGetArr($data, "datetime", " - %1", "", "mgTimeStr");
3f16beb79f9e Add image title string to certain images.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
18 }
3f16beb79f9e Add image title string to certain images.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
19
3f16beb79f9e Add image title string to certain images.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
20
0
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
21 function mgGetImageURL()
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
22 {
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
23 global $galImageURL, $galPath;
5
1bf73b49fc91 Beautify the generated URLs by removing occurences of duplicate forward
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
24 return str_replace("//", "/", $galImageURL.$galPath."/".implode("", func_get_args()));
0
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
25 }
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
26
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
27
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
28 function mgGetURL($path, $image, $entities = TRUE)
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
29 {
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
30 global $galBaseURL, $galCleanURLS;
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
31 $amp = $entities ? "&amp;" : "&";
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
32
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
33 if ($galCleanURLS)
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34 {
5
1bf73b49fc91 Beautify the generated URLs by removing occurences of duplicate forward
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
35 $url = $galBaseURL.$path."/".($image !== FALSE ? $image : "");
0
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
36 }
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
37 else
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
38 {
5
1bf73b49fc91 Beautify the generated URLs by removing occurences of duplicate forward
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
39 $url =
0
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40 $galBaseURL.mgGetSetting("mgallery_php")."?path=".
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
41 $path.($image !== FALSE ? $amp."image=".$image : "");
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
42 }
5
1bf73b49fc91 Beautify the generated URLs by removing occurences of duplicate forward
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
43
1bf73b49fc91 Beautify the generated URLs by removing occurences of duplicate forward
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
44 return str_replace("//", "/", $url);
0
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
45 }
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
46
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
47
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
48 function mgGetNaviActive(&$galIndex, $index, $delta, &$res, &$url, $entities)
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
49 {
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
50 global $galPath;
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
51 $res = $index + $delta;
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
52 if ($res >= 0 && $res <= sizeof($galIndex) - 1)
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
53 {
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
54 $url = mgGetURL($galPath, $galIndex[$res], $entities);
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
55 return TRUE;
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
56 }
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
57 else
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
58 return FALSE;
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
59 }
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
60
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
61
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
62 function mgGetNaviControlImage(&$galIndex, $index, $class, $url)
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
63 {
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
64 global $galTNPath;
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
65
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
66 $img = "<div class=\"imageCtrl ".$class."\">";
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
67
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
68 if ($url !== FALSE)
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
69 {
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
70 $img .=
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
71 "<a href=\"".$url."\"><img src=\"".
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
72 mgGetImageURL($galTNPath, $galIndex[$index]).
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
73 "\" alt=\"".$galIndex[$index]."\" /></a>";
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
74 }
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
75
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
76 return $img."</div>\n";
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
77 }
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
78
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
79
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
80 function mgGetNaviControlImageBox(&$galIndex, $index, $class, $delta)
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
81 {
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
82 if (!mgGetNaviActive($galIndex, $index, $delta, $res, $url, TRUE))
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
83 $url = FALSE;
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
84
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
85 return mgGetNaviControlImage($galIndex, $res, $class, $url);
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
86 }
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
87
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
88
7
dec931d9e860 Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
89 function mgGetControlText($id, $active, $url, $naviFlags)
dec931d9e860 Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
90 {
dec931d9e860 Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
91 if ($naviFlags & GNAV_TEXT)
dec931d9e860 Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
92 {
dec931d9e860 Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
93 $str = chentities(mgGetSetting("navi_ctrl_".$id));
dec931d9e860 Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
94 return
dec931d9e860 Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
95 "<span class=\"naviControl ".$id."\">[".
dec931d9e860 Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
96 ($active ? "<a href=\"".$url."\">".$str."</a>" : $str).
dec931d9e860 Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
97 "]</span>";
dec931d9e860 Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
98 }
dec931d9e860 Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
99 else
dec931d9e860 Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
100 return "";
dec931d9e860 Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
101 }
dec931d9e860 Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
102
dec931d9e860 Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
103
dec931d9e860 Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
104 function mgGetControl($id, &$galIndex, $index, $delta, $naviFlags)
0
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
105 {
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
106 $active = mgGetNaviActive($galIndex, $index, $delta, $res, $url, TRUE);
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
107 if ($active && ($naviFlags & GNAV_IMG))
7
dec931d9e860 Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
108 $img = mgGetNaviControlImage($galIndex, $res, $id, $url);
0
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
109 else
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
110 $img = "";
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
111
7
dec931d9e860 Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
112 $text = mgGetControlText($id, $active, $url, $naviFlags);
0
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
113
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
114 if ($delta < 0)
7
dec931d9e860 Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
115 return $img.$text;
0
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
116 else
7
dec931d9e860 Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
117 return $text.$img;
0
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
118 }
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
119
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
120
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
121 function mgGetNaviControls(&$galIndex, $index, $naviFlags)
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
122 {
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
123 global $galPath;
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
124
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
125 return
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
126 "<div class=\"naviControls\">".
7
dec931d9e860 Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
127 mgGetControl("prev", $galIndex, $index, -1, $naviFlags).
dec931d9e860 Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
128 mgGetControlText("up", TRUE, mgGetURL($galPath, FALSE), $naviFlags).
dec931d9e860 Implement configurable navigation controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
129 mgGetControl("next", $galIndex, $index, 1, $naviFlags).
0
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
130 "</div>\n";
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
131 }
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
132
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
133
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
134 function mgPrintTable($class, &$galEntries, &$galIndex, $start, $limit)
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
135 {
19
59075f5e7a62 Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents: 17
diff changeset
136 global $galAlbumIcon, $galPath, $galTNPath, $galImageURL, $galUseCoverImages, $galUseTables;
0
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
137
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
138 $galCount = count($galIndex);
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
139 if ($start >= $galCount)
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
140 return $start;
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
141
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
142 $end = ($limit === FALSE) ? $galCount : $start + $limit;
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
143 if ($end > $galCount) $end = $galCount;
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
144
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
145 $rowLimit = mgGetSetting("album_row_limit");
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
146 $n = 0;
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
147
19
59075f5e7a62 Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents: 17
diff changeset
148 if ($galUseTables)
20
12916fcdb8b8 Improve the non-tabled mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
149 echo "<table class=\"galleryTable ".$class."\">\n";
12916fcdb8b8 Improve the non-tabled mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
150 else
12916fcdb8b8 Improve the non-tabled mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
151 echo "<div class=\"galleryTable ".$class."\">\n";
19
59075f5e7a62 Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents: 17
diff changeset
152
0
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
153 for ($index = $start; $index < $end; $index++)
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
154 {
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
155 $filename = &$galIndex[$index];
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
156 $data = &$galEntries[$filename];
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
157
19
59075f5e7a62 Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents: 17
diff changeset
158 if ($galUseTables && $n == 0) echo " <tr>\n";
0
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
159
19
59075f5e7a62 Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents: 17
diff changeset
160 if ($galUseTables)
20
12916fcdb8b8 Improve the non-tabled mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
161 echo " <td class=\"galleryEntry\" id=\"cd".$data["base"]."\">\n";
19
59075f5e7a62 Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents: 17
diff changeset
162 else
20
12916fcdb8b8 Improve the non-tabled mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
163 echo " <div class=\"galleryEntry\">\n";
0
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
164
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
165 if ($data["type"] == 0)
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
166 {
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
167 echo
38
3f16beb79f9e Add image title string to certain images.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
168 " <div class=\"imageBox\" title=\"".mgGetImageTitleStr($filename, $data).
3f16beb79f9e Add image title string to certain images.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
169 "\"><a href=\"".mgGetURL($galPath, $filename)."\">".
0
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
170 "<img src=\"".mgGetImageURL($galTNPath, $filename)."\" alt=\"".
24
7f5209a6f7e0 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
171 chentities($filename)."\"></a></div>\n".
7f5209a6f7e0 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
172 mgGetArr($data, "caption", " <div class=\"imageCaption\">%1</div>\n", "", "chentities");
0
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
173 /*
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
174 if ($mode == "")
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
175 {
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
176 echo
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
177 " <select class=\"dropdown\" id=\"dd".$data["base"]."\" name=\"dd".$data["base"].
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
178 "\" onchange=\"galPhotoDataChanged('".$data["base"]."');\">\n";
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
179
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
180 foreach ($picChoices as $name => $value)
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
181 {
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
182 echo " <option value=\"$value\"".($value == $data["id"] ? " selected=\"selected\"" : "").">".chentities($name)."</option>\n";
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
183 }
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
184 echo
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
185 " </select>\n";
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
186 }
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
187 */
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
188 }
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
189 else
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
190 {
35
985596db0f01 Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
191 if ($galUseCoverImages && isset($data["image"]))
985596db0f01 Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
192 {
985596db0f01 Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
193 // Recursively determine the album cover image
985596db0f01 Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
194 $ptmp = [$galPath, $filename];
985596db0f01 Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
195 $curr = &$data;
985596db0f01 Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
196 while (is_array($curr["image"]))
985596db0f01 Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
197 {
985596db0f01 Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
198 $curr = &$curr["image"];
985596db0f01 Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
199 $ptmp[] = $curr["base"];
985596db0f01 Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
200 }
985596db0f01 Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
201
985596db0f01 Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
202 $ptmp[] = $galTNPath;
985596db0f01 Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
203 $ptmp[] = $curr["image"];
39
c1188641c5b7 Whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
204
35
985596db0f01 Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
205 $atmp = $galImageURL.implode("/", mgCleanPathArray(TRUE, 0, count($ptmp), $ptmp));
985596db0f01 Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
206 }
985596db0f01 Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
207 else
985596db0f01 Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
208 // No album cover, use default
985596db0f01 Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
209 $atmp = $galAlbumIcon;
985596db0f01 Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
210
0
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
211 echo
24
7f5209a6f7e0 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
212 " <a href=\"".mgGetURL(mgCleanPath(TRUE, $galPath, $filename), FALSE)."\">".
47
1e2b55775a84 Begin implementation of translated caption/title support.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
213 "<img class=\"albumIcon\" src=\"".$atmp."\" alt=\"".
1e2b55775a84 Begin implementation of translated caption/title support.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
214 mgGetTrans($data["caption"], TRUE).
1e2b55775a84 Begin implementation of translated caption/title support.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
215 "\" />\n".
1e2b55775a84 Begin implementation of translated caption/title support.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
216 " <div class=\"albumTitle\">".mgGetTrans($data["caption"], TRUE)."</div></a>\n";
0
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
217 }
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
218
19
59075f5e7a62 Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents: 17
diff changeset
219 if ($galUseTables)
0
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
220 {
19
59075f5e7a62 Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents: 17
diff changeset
221 echo " </td>\n";
59075f5e7a62 Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents: 17
diff changeset
222 if (++$n >= $rowLimit)
59075f5e7a62 Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents: 17
diff changeset
223 {
59075f5e7a62 Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents: 17
diff changeset
224 echo " </tr>\n";
59075f5e7a62 Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents: 17
diff changeset
225 $n = 0;
59075f5e7a62 Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents: 17
diff changeset
226 }
0
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
227 }
19
59075f5e7a62 Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents: 17
diff changeset
228 else
59075f5e7a62 Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents: 17
diff changeset
229 echo " </div>\n";
0
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
230 }
19
59075f5e7a62 Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents: 17
diff changeset
231
59075f5e7a62 Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents: 17
diff changeset
232 if ($galUseTables)
0
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
233 {
19
59075f5e7a62 Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents: 17
diff changeset
234 if ($n > 0)
59075f5e7a62 Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents: 17
diff changeset
235 {
59075f5e7a62 Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents: 17
diff changeset
236 while ($n++ < $rowLimit)
59075f5e7a62 Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents: 17
diff changeset
237 echo " <td></td>\n";
59075f5e7a62 Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents: 17
diff changeset
238 echo " </tr>\n";
59075f5e7a62 Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents: 17
diff changeset
239 }
59075f5e7a62 Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents: 17
diff changeset
240 echo "</table>\n";
0
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
241 }
20
12916fcdb8b8 Improve the non-tabled mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
242 else
12916fcdb8b8 Improve the non-tabled mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
243 echo "</div>\n";
12916fcdb8b8 Improve the non-tabled mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
244
0
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
245 return $index;
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
246 }
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
247
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
248
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
249 function mgTimeStr($str)
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
250 {
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
251 $tmp = date_create_from_format("Y:m:d H:i:s", $str);
34
e786771dfaa5 Add seconds to outputted timestamps.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
252 return date_format($tmp, "d M Y (H:i:s)");
0
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
253 }
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
254
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
255
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
256 function mgPrintPageInfoFooter()
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
257 {
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
258 if (($str = mgGetSetting("page_info")) !== FALSE)
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
259 echo "<div class=\"pageInfoFooter\">".$str."</div>";
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
260 }
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
261
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
262
31
300396947f04 Remove slight code duplication by factoring to a helper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 29
diff changeset
263 function mgGetBreadCrump($class, &$pdata)
300396947f04 Remove slight code duplication by factoring to a helper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 29
diff changeset
264 {
300396947f04 Remove slight code duplication by factoring to a helper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 29
diff changeset
265 return
300396947f04 Remove slight code duplication by factoring to a helper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 29
diff changeset
266 "<a class=\"".$class."\" href=\"".mgGetURL($pdata["path"], FALSE)."\">".
47
1e2b55775a84 Begin implementation of translated caption/title support.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
267 mgGetTrans($pdata["caption"], TRUE).
1e2b55775a84 Begin implementation of translated caption/title support.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
268 "</a>";
31
300396947f04 Remove slight code duplication by factoring to a helper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 29
diff changeset
269 }
300396947f04 Remove slight code duplication by factoring to a helper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 29
diff changeset
270
300396947f04 Remove slight code duplication by factoring to a helper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 29
diff changeset
271
0
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
272 function mgPrintBreadCrumbs($galData)
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
273 {
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
274 $res = array();
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
275 if ($galData["caption"])
31
300396947f04 Remove slight code duplication by factoring to a helper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 29
diff changeset
276 $res[] = mgGetBreadCrump("naviBreadCrumbCurr", $galData);
0
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
277
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
278 $tmp = $galData;
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
279 while (isset($tmp["parent"]))
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
280 {
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
281 $pdata = $tmp["parent"];
31
300396947f04 Remove slight code duplication by factoring to a helper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 29
diff changeset
282 $res[] = mgGetBreadCrump("naviBreadCrumbItem", $pdata);
0
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
283 $tmp = $tmp["parent"];
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
284 }
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
285
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
286 if (count($res) > 1)
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
287 {
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
288 echo
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
289 "<div class=\"naviBreadCrumbs\">".
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
290 implode("<span class=\"naviBreadCrumbSep\"></span>", array_reverse($res)).
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
291 "</div>\n";
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
292 }
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
293 }
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
294
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
295
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
296 //
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
297 // Get gallery settings
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
298 //
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
299 mgReadSettings();
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
300
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
301 $pageCSS = mgGetSetting("css");
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
302 $pageCSSSelect = mgGetSetting("css_select");
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
303 $galBasePath = mgGetSetting("base_path");
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
304 $galBaseURL = mgGetSetting("base_url");
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
305 $galImageURL = mgGetSetting("image_url", mgGetSetting("base_url"));
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
306
17
3f7bc4202df3 Add new configuration setting 'cover_images' to disable/enable sub-album
Matti Hamalainen <ccr@tnsp.org>
parents: 13
diff changeset
307 $galUseCoverImages = mgGetSetting("cover_images");
19
59075f5e7a62 Add configuration setting to enable and disable use of HTML table elements.
Matti Hamalainen <ccr@tnsp.org>
parents: 17
diff changeset
308 $galUseTables = mgGetSetting("use_tables");
17
3f7bc4202df3 Add new configuration setting 'cover_images' to disable/enable sub-album
Matti Hamalainen <ccr@tnsp.org>
parents: 13
diff changeset
309
0
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
310 $galAlbumIcon = mgGetSetting("album_icon");
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
311 $galCleanURLS = mgGetSetting("clean_urls");
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
312 $galTNPath = mgGetSetting("tn_path");
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
313 $galMedSuffix = mgGetSetting("med_suffix");
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
314 $galTitlePrefix = mgGetSetting("title_prefix");
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
315 $galTitleSep = mgGetSetting("title_sep");
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
316
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
317 $galMode = stGetRequestItem("mode", "view", TRUE);
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
318 $galPath = stGetRequestItem("path", ".", TRUE);
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
319 $galPageIndex = intval(stGetRequestItem("index", 0, TRUE));
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
320 $galImage = stGetRequestItem("image", FALSE, TRUE);
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
321
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
322 if (is_string($galImage))
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
323 $galImage = basename($galImage);
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
324
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
325
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
326 //
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
327 // Attempt to read the data cache file
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
328 //
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
329 $filename = mgGetPath(mgCleanPath(TRUE, $galBasePath, $galPath), "cache_file");
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
330 $filename2 = mgGetPath(mgCleanPath(FALSE, $galBasePath, $galPath), "cache_file");
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
331 if ($filename == $filename2 && file_exists($filename) && ($fp = @fopen($filename, "rb")) !== FALSE)
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
332 {
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
333 if (flock($fp, LOCK_SH))
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
334 {
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
335 require($filename);
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
336 flock($fp, LOCK_UN);
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
337 }
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
338 fclose($fp);
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
339 }
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
340
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
341
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
342 // If no data available, show an error page
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
343 if (!isset($galData) || !isset($galEntries) ||
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
344 !isset($galAlbumsIndex) || !isset($galImagesIndex))
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
345 {
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
346 cmPrintPageHeader(mgGetVal(array("title_prefix", "title_sep"), "%1%2")."ERROR!");
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
347
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
348 echo
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
349 "<h1>Gallery error</h1>\n".
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
350 "<p>Gallery path <b>".chentities($galPath)."</b> does not exist or is invalid.</p>\n";
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
351
12
79987aa7ee9a Change some debugging (commented out).
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
352 //echo "<p>filename=: '".$filename."', X: galData=".intval(isset($galData)).", galEntries=".intval(isset($galEntries))."\n";
0
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
353
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
354 mgPrintPageInfoFooter();
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
355 cmPrintPageFooter(TRUE);
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
356 exit;
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
357 }
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
358
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
359
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
360 //
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
361 // Print page header, etc.
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
362 //
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
363 if (($index = array_search($galImage, $galImagesIndex)) !== FALSE)
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
364 {
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
365 //
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
366 // Single image mode
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
367 //
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
368 $naviFlags = mgGetSetting("image_navigation");
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
369 $data = $galEntries[$galImage];
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
370
47
1e2b55775a84 Begin implementation of translated caption/title support.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
371 $pageTitle = $galTitlePrefix.$galTitleSep.mgGetTrans($galData["caption"])." - ".$galImage;
0
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
372 cmPrintPageHeader($pageTitle);
44
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
373 echo
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
374 "<div id=\"imageLarge\"><img src=\"".
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
375 $galImageURL.$galPath."/".$galImage."\" alt=\"".
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
376 chentities($data["base"].$galMedSuffix.$data["ext"])."\" /></div>\n".
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
377 "<h1>".chentities($pageTitle)."</h1>\n";
0
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
378
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
379 if ($naviFlags & GNAV_BREADCRUMBS)
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
380 mgPrintBreadCrumbs($galData);
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
381
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
382 if ($naviFlags & GNAV_TOP)
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
383 echo mgGetNaviControls($galImagesIndex, $index, $naviFlags);
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
384
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
385 echo
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
386 "<div class=\"imageCBox\">\n".
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
387 mgGetNaviControlImageBox($galImagesIndex, $index, "prev", -1).
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
388 "<div class=\"imageBox\">\n".
44
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
389 "<a id=\"imageLink\" target=\"_blank\" href=\"".$galImageURL.$galPath."/".$galImage."\">".
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
390 "<img id=\"imageImage\" src=\"".mgGetImageURL($galTNPath, $data["base"].$galMedSuffix.$data["ext"])."\" alt=\"".
0
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
391 chentities($data["base"].$galMedSuffix.$data["ext"])."\"></a>\n".
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
392 "</div>\n".
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
393 mgGetNaviControlImageBox($galImagesIndex, $index, "next", 1).
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
394 "</div>\n".
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
395 "<div class=\"imageCaption\">".mgGetArr($data, "caption", "%1", "")."</div>\n";
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
396
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
397 $list = array(
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
398 mgGetArr($data, array("width", "height"), "<span class=\"infoDimensions\"><b>%1</b> x <b>%2</b> px</span>", NULL),
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
399 mgGetArr($data, "model", "<span class=\"infoModel\"><b>%1</b></span>", NULL),
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
400 mgGetArr($data, "fnumber", "<span class=\"infoFNumber\"><b>f/%1</b></span>", NULL),
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
401 mgGetArr($data, "exposure", "<span class=\"infoExposure\"><b>%1</b> sec</span>", NULL, NULL),
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
402 mgGetArr($data, "iso", "<span class=\"infoISO\">ISO <b>%1</b></span>", NULL),
29
8cf743c7ea23 Add focal length and lens model display.
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
403 mgGetArr($data, "focallength", "<span class=\"infoFocalLength\">F-L <b>%1</b>mm</span>", NULL),
8cf743c7ea23 Add focal length and lens model display.
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
404 mgGetArr($data, "lensmodel", "<span class=\"infoLensModel\"><i>%1</i></span>", NULL),
0
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
405 );
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
406
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
407 echo
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
408 "<div class=\"infoBox\">\n".
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
409 mgGetArr($data, "datetime", "<span class=\"infoDateTime\">%1</span>", "", "mgTimeStr").
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
410 implode(", ", array_filter($list, function($a) { return $a !== NULL; })).
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
411 "</div>\n";
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
412
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
413 if ($naviFlags & GNAV_BOTTOM)
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
414 echo mgGetNaviControls($galImagesIndex, $index, $naviFlags);
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
415
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
416 // Javascript navigation
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
417 if ($naviFlags & GNAV_JAVASCRIPT)
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
418 {
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
419 $prevActive = mgGetNaviActive($galImagesIndex, $index, -1, $res, $prevURL, FALSE);
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
420 $nextActive = mgGetNaviActive($galImagesIndex, $index, 1, $res, $nextURL, FALSE);
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
421 echo
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
422 "<script type=\"text/javascript\">\n".
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
423 "var mgalPrevURL = \"".($prevActive ? $prevURL : "")."\";\n".
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
424 "var mgalNextURL = \"".($nextActive ? $nextURL : "")."\";\n".
44
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
425 "var mgalExpanded = false;\n".
0
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
426 "\n";
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
427 ?>
44
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
428 function mgalExpandClose(force)
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
429 {
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
430 mgalExpanded = !mgalExpanded;
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
431 if (!force)
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
432 mgalExpanded = false;
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
433
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
434 var mlink = document.getElementById("imageLink");
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
435 var mlarge = document.getElementById("imageLarge");
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
436 if (mlink && mlarge)
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
437 {
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
438 mlink.style.visibility = mgalExpanded ? "hidden" : "visible";
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
439 mlarge.style.display = mgalExpanded ? "block" : "none";
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
440 }
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
441 return false;
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
442 }
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
443
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
444
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
445 function mgalMouseExpandClose(event, force)
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
446 {
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
447 if (!event.ctrlKey)
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
448 return mgalExpandClose(force);
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
449 else
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
450 return true;
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
451 }
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
452
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
453
0
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
454 function mgalNavigateTo(url)
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
455 {
43
fc8e6a056016 Indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 39
diff changeset
456 if (url != "")
fc8e6a056016 Indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 39
diff changeset
457 window.location = url;
0
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
458 }
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
459
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
460
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
461 function mgalProcessKeyPress(ev)
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
462 {
43
fc8e6a056016 Indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 39
diff changeset
463 ev = ev || window.event;
fc8e6a056016 Indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 39
diff changeset
464 var key = ev.keyCode ? ev.keyCode : ev.which;
fc8e6a056016 Indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 39
diff changeset
465 switch (key)
fc8e6a056016 Indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 39
diff changeset
466 {
fc8e6a056016 Indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 39
diff changeset
467 case 37:
fc8e6a056016 Indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 39
diff changeset
468 case 65:
44
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
469 case 52:
43
fc8e6a056016 Indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 39
diff changeset
470 // left
fc8e6a056016 Indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 39
diff changeset
471 mgalNavigateTo(mgalPrevURL);
fc8e6a056016 Indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 39
diff changeset
472 break;
0
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
473
43
fc8e6a056016 Indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 39
diff changeset
474 case 39:
fc8e6a056016 Indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 39
diff changeset
475 case 68:
44
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
476 case 54:
43
fc8e6a056016 Indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 39
diff changeset
477 // right
fc8e6a056016 Indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 39
diff changeset
478 mgalNavigateTo(mgalNextURL);
fc8e6a056016 Indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 39
diff changeset
479 break;
44
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
480
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
481 case 13:
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
482 case 48:
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
483 mgalExpandClose(true);
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
484 break;
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
485
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
486 case 27:
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
487 mgalExpandClose(false);
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
488 break;
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
489
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
490 default:
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
491 return true;
43
fc8e6a056016 Indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 39
diff changeset
492 }
44
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
493
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
494 ev.preventDefault();
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
495 return false;
0
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
496 }
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
497
44
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
498
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
499 document.getElementById("imageLarge").onclick = function(event) { return mgalMouseExpandClose(event, false); }
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
500 document.getElementById("imageLink").onclick = function(event) { return mgalMouseExpandClose(event, true); }
0
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
501 document.onkeypress = mgalProcessKeyPress;
44
bc9da3b71888 Implement imgur-style image zoom/de-zoom via image click/enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
502
0
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
503 <?
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
504 echo
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
505 "</script>\n";
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
506 }
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
507 }
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
508 else
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
509 {
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
510 //
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
511 // Gallery mode
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
512 //
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
513 // - needs sub-modes / handling of order shit
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
514 // - Javascript stuff for picture data updates
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
515 //
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
516 $pageTitle = $galTitlePrefix.mgGetArr($galData, "caption", " - %1", "", "chentities");
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
517 cmPrintPageHeader($pageTitle);
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
518 echo "<h1>".$pageTitle."</h1>\n";
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
519
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
520 $naviFlags = mgGetSetting("album_navigation");
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
521 if ($naviFlags & GNAV_BREADCRUMBS)
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
522 mgPrintBreadCrumbs($galData);
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
523
47
1e2b55775a84 Begin implementation of translated caption/title support.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
524 if (isset($galData["header"]) && strlen($gheader = mgGetTrans($galData["header"])) > 0)
13
951752fb1c21 Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
525 {
951752fb1c21 Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
526 // Translate relative URLs in header, if needed
951752fb1c21 Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
527 $baseURL = mgGetSetting("image_url");
951752fb1c21 Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
528
951752fb1c21 Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
529 $headerText = preg_replace_callback(
951752fb1c21 Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
530 "@href\s*=\s*\"([^\"]+)\"@i",
951752fb1c21 Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
531 function ($matches) use($galPath, $baseURL)
951752fb1c21 Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
532 {
951752fb1c21 Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
533 $mstmp = $matches[1];
951752fb1c21 Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
534 if (preg_match("@^[a-z]+://@i", $mstmp) === 0)
951752fb1c21 Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
535 {
951752fb1c21 Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
536 if ($mstmp[0] != "/")
28
2d8112d6c3bc Fix relative links re-parsing.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
537 $mstmp = $baseURL."/".$galPath."/".str_replace("//", "/", $mstmp);
13
951752fb1c21 Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
538 }
28
2d8112d6c3bc Fix relative links re-parsing.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
539 return "href=\"".$mstmp."\"";
13
951752fb1c21 Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
540 },
47
1e2b55775a84 Begin implementation of translated caption/title support.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
541 $gheader);
13
951752fb1c21 Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
542
951752fb1c21 Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
543 echo "<div class=\"albumHeaderText\">".$headerText."</div>\n";
951752fb1c21 Add translation of relative URLs in header text blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
544 }
0
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
545
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
546 mgPrintTable("albumTable", $galEntries, $galAlbumsIndex, 0, FALSE);
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
547 mgPrintTable("imageTable", $galEntries, $galImagesIndex, 0, FALSE);
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
548 }
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
549
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
550 mgPrintPageInfoFooter();
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
551 cmPrintPageFooter(TRUE);
ac688606ec4b Initial import of code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
552 ?>