summaryrefslogtreecommitdiff
path: root/includes/functions/functions_media_reorder.php
blob: fe0fc4c75f089b2698c4792ff957fbd3325191e4 (plain)
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
<?php
/**
 * Reorder media Items using drag and drop
 *
 * webtrees: Web based Family History software
 * Copyright (C) 2010 webtrees development team.
 *
 * Derived from PhpGedView
 * Copyright (C) 2002 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
 *
 * @package webtrees
 * @subpackage Module
 * @version $Id$
 * @author Brian Holland
 */

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 media_reorder_row($rtype, $rowm, $pid) {
	global $WT_IMAGES, $MEDIA_DIRECTORY, $TEXT_DIRECTION;
	global $GEDCOM, $THUMBNAIL_WIDTH, $USE_MEDIA_VIEWER;
	global $SEARCH_SPIDER;
	global $t, $n, $item, $items, $p, $edit, $reorder, $LB_AL_THUMB_LINKS, $note, $rowm;
	global $LB_URL_WIDTH, $LB_URL_HEIGHT, $order1, $mediaType;
	global $MEDIA_TYPES;

	if (!isset($rowm)) {
		$rowm=$row;
	}
	print "<li class=\"facts_value\" style=\"list-style:none;cursor:move;margin-bottom:2px;\" id=\"li_" . $rowm['m_media'] . "\" >";

    //print $rtype." ".$rowm["m_media"]." ".$pid;
    if (!canDisplayRecord($rowm['m_gedfile'], $rowm['m_gedrec']) || !canDisplayFact($rowm['m_media'], $rowm['m_gedfile'], $rowm['mm_gedrec'])) {
        //print $rowm['m_media']." no privacy ";
        return false;
    }

    $styleadd="";
    if ($rtype=='new') $styleadd = "change_new";
    if ($rtype=='old') $styleadd = "change_old";

    // NOTE Start printing the media details

    $thumbnail = thumbnail_file($rowm["m_file"], true, false, $pid);
    // $isExternal = stristr($thumbnail,"://");
	$isExternal = isFileExternal($thumbnail);

    $linenum = 0;



    // NOTE Get the title of the media
    $mediaTitle = $rowm["m_titl"];
    $subtitle = get_gedcom_value("TITL", 2, $rowm["mm_gedrec"]);

    if (!empty($subtitle)) $mediaTitle = $subtitle;
		$mainMedia = check_media_depth($rowm["m_file"], "NOTRUNC");
    if ($mediaTitle=="") $mediaTitle = basename($rowm["m_file"]);

		print "\n" . "<table class=\"pic\"><tr>" . "\n";
		print "<td width=\"80\" valign=\"top\" align=\"center\" >". "\n";

		// Get info on how to handle this media file
		$mediaInfo = mediaFileInfo($mainMedia, $thumbnail, $rowm["m_media"], $mediaTitle, '');

		//-- Thumbnail field
		print "<img src=\"".$mediaInfo['thumb']."\" height=\"38\" border=\"0\" " ;

		if ( strpos($rowm['m_gedrec'], "1 SOUR")!==false) {
			print " alt=\"" . PrintReady($mediaTitle) . "\" title=\"" . PrintReady($mediaTitle) . "\nSource info available\" />";
		}else{
			print " alt=\"" . PrintReady($mediaTitle) . "\" title=\"" . PrintReady($mediaTitle) . "\" />";
		}

		//print media info
		$ttype2 = preg_match("/\d TYPE (.*)/", $rowm["m_gedrec"], $match);
		if ($ttype2>0) {
			$varName = strtolower($match[1]);
			if (array_key_exists($varName, $MEDIA_TYPES)) {
				$mediaType = $MEDIA_TYPES[$varName];
			} else {
				$mediaType = i18n::translate('Other');
			}
			// print "<br /><span class=\"label\">".i18n::translate('Type').": </span> <span class=\"field\">$mediaType</span>";
		}

		print "\n" . "</td><td>&nbsp;</td>" . "\n";
		print "<td valign=\"top\" align=\"left\">";
		//print "<font color=\"blue\">";
		print $rowm['m_media'];
		//print "</font>";

		print "<b>";
		print "&nbsp;&nbsp;" . $mediaType;
		print "</b>";

 		print "<br>" . "\n";
		print $mediaTitle . "\n";

		print "</td>" . "\n";
		print "</tr>";
		print "</table>" . "\n";
	if (!isset($j)) {
		$j=0;
	}else{
		$j=$j;
	}
	$media_data = $rowm['m_media'];
	echo "<input type=\"hidden\" name=\"order1[", $media_data, "]\" value=\"", $j, "\" />";

    echo "</li>";
    echo "\n\n";
    return true;

}
?>