1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
|
<?php
// Lightbox Album module for webtrees
//
// Display media Items using Lightbox
//
// webtrees: Web based Family History software
// Copyright (C) 2011 webtrees development team.
//
// Derived from PhpGedView
// Copyright (C) 2007 to 2009 PGV Development Team. All rights reserved.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// $Id$
if (!defined('WT_WEBTREES')) {
header('HTTP/1.0 403 Forbidden');
exit;
}
/**
* print a media row in a table
* @param string $rtype whether this is a 'new', 'old', or 'normal' media row... this is used to determine if the rows should be printed with an outline color
* @param array $rowm An array with the details about this media item
* @param string $pid The record id this media item was attached to
*/
function lightbox_print_media_row($rtype, $rowm, $pid) {
global $TEXT_DIRECTION;
global $item, $sort_i, $notes;
$reorder=safe_get('reorder', '1', '0');
$mainMedia = check_media_depth($rowm['m_file'], 'NOTRUNC');
// If media file is missing from "media" directory, but is referenced in Gedcom
if (!media_exists($mainMedia)) {
if (!file_exists($rowm['m_file']) && !isset($rowm['m_file'])) {
echo '<tr>';
echo '<td valign="top" rowspan="2" >';
echo '<img src="', WT_STATIC_URL, WT_MODULES_DIR, 'lightbox/images/transp80px.gif" height="82px" alt=""></img>';
echo '</td>';
echo '<td class="description_box" valign="top" colspan="3" nowrap="nowrap">';
echo '<center><br /><img src="', WT_THEME_URL, 'images/media.gif" height="30" border="0" />';
echo '<p class="ui-state-error">', WT_I18N::translate('The file “%s” does not exist.', $rowm['m_file']), '</p>';
echo '</td>';
echo '</tr>';
} else if (!file_exists($rowm['m_file'])) {
echo '<li class="li_norm" >';
echo '<table class="pic" width="50px" border="0" >';
echo '<tr>';
echo '<td valign="top" rowspan="2" >';
echo '<img src="', WT_STATIC_URL, WT_MODULES_DIR, 'lightbox/images/transp80px.gif" height="100px" alt=""></img>';
echo '</td>';
echo '<td class="description_box" valign="top" colspan="3" nowrap="nowrap" >';
echo '<center><br /><img src="', WT_THEME_URL, 'images/media.gif" height="30" border="0" />';
echo '<p class="ui-state-error">', WT_I18N::translate('The file “%s” does not exist.', $rowm['m_file']), '</p>';
echo '</td>';
echo '</tr>';
} else {
echo '<li class="li_norm" >';
echo '<table class="pic" width="50px" border="0" >';
}
// Else Media files are present in "media" directory
} else {
//If media is linked to a 'private' person
if (!WT_Media::getInstance($rowm['m_media'])->canDisplayDetails() || !canDisplayFact($rowm['m_media'], $rowm['m_gedfile'], $rowm['mm_gedrec'])) {
return false;
} else {
// Media is NOT linked to private person
// If reorder media has been clicked
if (isset($reorder) && $reorder==1) {
echo '<li class="facts_value" style="border:0px;" id="li_', $rowm['m_media'], '" >';
// Else If reorder media has NOT been clicked
// Highlight Album Thumbnails - Changed=new (blue), Changed=old (red), Changed=no (none)
} else if ($rtype=='new') {
echo '<li class="li_new">';
} else if ($rtype=='old') {
echo '<li class="li_old">';
} else {
echo '<li class="li_norm">';
}
}
}
// Add blue or red borders
$styleadd='';
if ($rtype=='new') $styleadd = 'change_new';
if ($rtype=='old') $styleadd = 'change_old';
// NOTE Start printing the media details
if (!media_exists($mainMedia)) {
if (!media_exists($rowm['m_file'])) {
$thumbnail = '';
$isExternal = ''; // isFileExternal($thumbnail);
} else {
$thumbnail = thumbnail_file($rowm['m_file'], true, false, $pid);
$isExternal = isFileExternal($thumbnail);
}
} else {
$thumbnail = thumbnail_file($mainMedia, true, false, $pid);
$isExternal = isFileExternal($thumbnail);
// echo $thumbnail;
}
$linenum = 0;
// If Fact details can be shown --------------------------------------------------------------------------------------------
if (canDisplayFact($pid, $rowm['m_file'], $rowm['mm_gedrec'])) {
// Get the title of the media
$media=WT_Media::getInstance($rowm['m_media']);
$mediaTitle = $media->getFullName();
$mainMedia = check_media_depth($rowm['m_file'], 'NOTRUNC');
$mainFileExists = true;
$imgsize = findImageSize($mainMedia);
$imgwidth = $imgsize[0]+40;
$imgheight = $imgsize[1]+150;
// Get the tooltip link for source
$sour = WT_Source::getInstance(get_gedcom_value('SOUR', 1, $rowm['m_gedrec']));
//Get media item Notes
$haystack = $rowm['m_gedrec'];
$needle = '1 NOTE';
$before = substr($haystack, 0, strpos($haystack, $needle));
$after = substr(strstr($haystack, $needle), strlen($needle));
$final = $before.$needle.$after;
$notes = PrintReady(htmlspecialchars(print_fact_notes($final, 1, true, true), ENT_QUOTES));
// Get info on how to handle this media file
$mediaInfo = mediaFileInfo($mainMedia, $thumbnail, $rowm['m_media'], $mediaTitle, $notes);
//text alignment for Tooltips
if ($TEXT_DIRECTION=='rtl') {
$alignm = 'right';
$left = 'true';
} else {
$alignm = 'left';
$left = 'false';
}
// Tooltip Options
$tt_opts = ", BALLOON," . true ; // true=balloon, false=normal
$tt_opts .= ", LEFT," . $left;
$tt_opts .= ", ABOVE, true";
$tt_opts .= ", TEXTALIGN, '" . $alignm . "'";
$tt_opts .= ", WIDTH, -480 ";
$tt_opts .= ", BORDERCOLOR, ''";
$tt_opts .= ", TITLEBGCOLOR, ''";
$tt_opts .= ", CLOSEBTNTEXT, 'X'";
$tt_opts .= ", CLOSEBTN, false";
$tt_opts .= ", CLOSEBTNCOLORS, ['#ff0000', '#ffffff', '#ffffff', '#ff0000']";
$tt_opts .= ", OFFSETX, -30";
$tt_opts .= ", OFFSETY, 110";
$tt_opts .= ", STICKY, true";
$tt_opts .= ", PADDING, 6";
$tt_opts .= ", CLICKCLOSE, true";
$tt_opts .= ", DURATION, 8000";
$tt_opts .= ", BGCOLOR, '#f3f3f3'";
$tt_opts .= ", JUMPHORZ, 'true' ";
$tt_opts .= ", JUMPVERT, 'false' ";
$tt_opts .= ", DELAY, 0";
// Prepare Below Thumbnail menu ----------------------------------------------------
if ($TEXT_DIRECTION== 'rtl') {
$submenu_class = 'submenuitem_rtl';
$submenu_hoverclass = 'submenuitem_hover_rtl';
} else {
$submenu_class = 'submenuitem';
$submenu_hoverclass = 'submenuitem_hover';
}
$menu = new WT_Menu();
// Truncate media title to 13 chars (45 chars if Streetview) and add ellipsis
$mtitle = $mediaTitle;
if (strpos($rowm['m_file'], 'http://maps.google.')===0) {
if (utf8_strlen($mtitle)>16) {
$mtitle = utf8_substr($rowm['m_file'], 0, 45).WT_I18N::translate('…');
}
} else {
if (utf8_strlen($mtitle)>16) {
$mtitle = utf8_substr($mtitle, 0, 13).WT_I18N::translate('…');
}
}
// Continue menu construction
// If media file is missing from 'media' directory, but is referenced in Gedcom
if (!media_exists($rowm['m_file']) && !media_exists($mainMedia)) {
$menu->addLabel("<img src=\"{$thumbnail}\" style=\"display:none;\" alt=\"\" title=\"\" />" . WT_I18N::translate('Edit')." (". $rowm['m_media'].")", 'right');
} else {
$menu->addLabel("<img src=\"{$thumbnail}\" style=\"display:none;\" alt=\"\" title=\"\" />" . $mtitle, 'right');
}
// Next line removed to avoid gallery thumbnail duplication
// $menu['link'] = mediaInfo['url'];
if ($rtype=='old') {
// Do not print menu if item has changed and this is the old item
} else {
// Continue printing menu
$menu->addClass('', '', 'submenu');
// View Notes
if (strpos($rowm['m_gedrec'], "\n1 NOTE")) {
$submenu = new WT_Menu(' ' . WT_I18N::translate('View Notes') . ' ', '#', 'right');
// Notes Tooltip ----------------------------------------------------
$sonclick = 'TipTog(';
// Contents of Notes
$sonclick .= "'";
$sonclick .= "<font color=#008800><b>" . WT_I18N::translate('Notes') . ":</b></font><br />";
$sonclick .= $notes;
$sonclick .= "'";
// Notes Tooltip Parameters
$sonclick .= $tt_opts;
$sonclick .= ");";
$sonclick .= "return false;";
$submenu->addOnclick($sonclick);
$submenu->addClass($submenu_class, $submenu_hoverclass);
$menu->addSubMenu($submenu);
}
//View Details
$submenu = new WT_Menu(" " . WT_I18N::translate('View Details') . " ", WT_SERVER_NAME.WT_SCRIPT_PATH . "mediaviewer.php?mid=" . $rowm['m_media'], "right");
$submenu->addClass($submenu_class, $submenu_hoverclass);
$menu->addSubMenu($submenu);
//View Source
if ($sour && $sour->canDisplayDetails()) {
$submenu = new WT_Menu(" " . WT_I18N::translate('View Source') . " ", $sour->getHtmlUrl(), "right");
$submenu->addClass($submenu_class, $submenu_hoverclass);
$menu->addSubMenu($submenu);
}
if (WT_USER_CAN_EDIT) {
// Edit Media
$submenu = new WT_Menu(" " . WT_I18N::translate('Edit media') . " ", "#", "right");
$submenu->addOnclick("return window.open('addmedia.php?action=editmedia&pid={$rowm['m_media']}&linktoid={$rowm['mm_gid']}', '_blank', 'top=50,left=50,width=600,height=700,resizable=1,scrollbars=1');");
$submenu->addClass($submenu_class, $submenu_hoverclass);
$menu->addSubMenu($submenu);
if (WT_USER_IS_ADMIN) {
// Manage Links
if (array_key_exists('GEDFact_assistant', WT_Module::getActiveModules())) {
$submenu = new WT_Menu(" " . WT_I18N::translate('Manage links') . " ", "#", "right");
$submenu->addOnclick("return window.open('inverselink.php?mediaid={$rowm['m_media']}&linkto=manage', '_blank', 'top=50,left=50,width=570,height=650,resizable=1,scrollbars=1');");
$submenu->addClass($submenu_class, $submenu_hoverclass);
$menu->addSubMenu($submenu);
} else {
$submenu = new WT_Menu(" " . WT_I18N::translate('Set link') . " ", "#", "right", "right");
$ssubmenu = new WT_Menu(WT_I18N::translate('To Person'));
$ssubmenu->addOnclick("return window.open('inverselink.php?mediaid={$rowm['m_media']}&linkto=person', '_blank', 'top=50,left=50,width=570,height=650,resizable=1,scrollbars=1');");
$ssubmenu->addClass('submenuitem', 'submenuitem_hover', 'submenu');
$submenu->addSubMenu($ssubmenu);
$ssubmenu = new WT_Menu(WT_I18N::translate('To Family'));
$ssubmenu->addOnclick("return window.open('inverselink.php?mediaid={$rowm['m_media']}&linkto=family', '_blank', 'top=50,left=50,width=570,height=650,resizable=1,scrollbars=1');");
$ssubmenu->addClass('submenuitem', 'submenuitem_hover', 'submenu');
$submenu->addSubMenu($ssubmenu);
$ssubmenu = new WT_Menu(WT_I18N::translate('To Source'));
$ssubmenu->addOnclick("return window.open('inverselink.php?mediaid={$rowm['m_media']}&linkto=source', '_blank', 'top=50,left=50,width=570,height=650,resizable=1,scrollbars=1');");
$ssubmenu->addClass('submenuitem', 'submenuitem_hover', 'submenu');
$submenu->addSubMenu($ssubmenu);
$menu->addSubMenu($submenu);
}
// Unlink Media
$submenu = new WT_Menu(" " . WT_I18N::translate('Unlink Media') . " ", "#", "right");
$submenu->addOnclick("return delete_record('$pid', 'OBJE', '".$rowm['m_media']."');");
$submenu->addClass($submenu_class, $submenu_hoverclass);
$menu->addSubMenu($submenu);
}
}
}
// Check if allowed to View media
if ($isExternal || media_exists($thumbnail) && canDisplayFact($rowm['m_media'], $rowm['m_gedfile'], $rowm['m_gedrec'])) {
$mainFileExists = false;
// Get Media info
if ($isExternal || media_exists($rowm['m_file']) || media_exists($mainMedia)) {
$mainFileExists = true;
$imgsize = findImageSize($rowm['m_file']);
$imgwidth = $imgsize[0]+40;
$imgheight = $imgsize[1]+150;
// Start Thumbnail Enclosure table ---------------------------------------------
// Pull table up 90px if media object is a "streetview"
if (strpos($rowm['m_file'], 'http://maps.google.')===0) {
echo "<table width=\"10px\" style=\"margin-top:-90px;\" class=\"pic\" border=\"0\"><tr>";
} else {
echo "<table width=\"10px\" class=\"pic\" border=\"0\"><tr>";
}
echo "<td align=\"center\" rowspan=\"2\" >";
echo '<img src="', WT_STATIC_URL, WT_MODULES_DIR, 'lightbox/images/transp80px.gif" height="100px" alt=""></img>';
echo "</td>";
// Check for Notes associated media item
if ($reorder) {
// If reorder media has been clicked
echo "<td width=\"90% align=\"center\"><b><font size=\"2\" style=\"cursor:move;margin-bottom:2px;\">" . $rowm['m_media'] . "</font></b></td>";
echo "</tr>";
}
$item++;
echo "<td colspan=\"3\" valign=\"middle\" align=\"center\" >";
// If not reordering, enable Lightbox or popup and show thumbnail tooltip ------
if (!$reorder) {
echo '<a href="', $mediaInfo['url'], '">';
}
}
// Now finally print the thumbnail -----------------------------------------------------
$height = 78;
$size = findImageSize($mediaInfo['thumb']);
if ($size[1]<$height) $height = $size[1];
echo "<img src=\"{$mediaInfo['thumb']}\" border=\"0\" height=\"{$height}\"" ;
// print browser tooltips associated with image ----------------------------------------
echo " alt=\"\" title=\"" . Printready(strip_tags($mediaTitle)) . "\" />";
// Close anchor --------------------------------------------------------------
if ($mainFileExists) {
echo "</a>";
}
echo "</td></tr>";
//View Edit Menu ----------------------------------
if (!$reorder) {
// If not reordering media print View or View-Edit Menu
echo "<tr>";
echo "<td width=\"5px\"></td>";
echo "<td valign=\"bottom\" align=\"center\" nowrap=\"nowrap\">";
echo $menu->getMenu();
echo "</td>";
echo "<td width=\"5px\"></td>";
echo "</tr>";
}
// echo "</table>";
}
} // NOTE End If Show fact details
// If media file is missing but details are in Gedcom then add the menu as well
//if (!media_exists($rowm['m_file'])) {
if (!media_exists($mainMedia) && !media_exists($rowm['m_file'])) {
echo '<tr>';
echo '<td ></td>';
echo '<td valign="bottom" align="center" nowrap="nowrap">';
echo $menu->getMenu();
echo '</td>';
echo '<td ></td>';
echo '</tr>';
}
//close off the table
echo '</table>';
$media_data = $rowm['m_media'];
echo '<input type="hidden" name="order1[', $media_data, ']" value="', $sort_i, '" />';
$sort_i++;
echo '</li>';
return true;
}
|