/** * get the thumbnail filename * @return string */ function getThumbnail($generateThumb = true) { return thumbnail_file($this->file, $generateThumb); }
/** * 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 $PGV_IMAGE_DIR, $PGV_IMAGES, $view, $MEDIA_DIRECTORY, $TEXT_DIRECTION; global $SHOW_ID_NUMBERS, $GEDCOM, $factarray, $pgv_lang, $THUMBNAIL_WIDTH, $USE_MEDIA_VIEWER; global $SEARCH_SPIDER; global $t, $n, $item, $items, $p, $edit, $SERVER_URL, $reorder, $LB_AL_THUMB_LINKS, $note, $rowm; global $LB_URL_WIDTH, $LB_URL_HEIGHT, $order1, $mediaType; 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 (!displayDetailsById($rowm['m_media'], 'OBJE') || FactViewRestricted($rowm['m_media'], $rowm['m_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 if (showFactDetails("OBJE", $pid)) { $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 (eregi("1 SOUR", $rowm['m_gedrec'])) { 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) { $mediaType = trim($match[1]); $varName = "TYPE__" . strtolower($mediaType); if (isset($pgv_lang[$varName])) { $mediaType = $pgv_lang[$varName]; } // print "\n\t\t\t<br /><span class=\"label\">".$pgv_lang["type"].": </span> <span class=\"field\">$mediaType</span>"; } print "\n" . "</td><td> </td>" . "\n"; print "<td valign=\"top\" align=\"left\">"; //print "<font color=\"blue\">"; print $rowm['m_media']; //print "</font>"; print "<b>"; print " " . $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']; print "<input type=\"hidden\" name=\"order1[{$media_data}]\" value=\"{$j}\" />"; print "</li>"; print "\n\n"; return true; }
/** * find the highlighted media object for a gedcom entity * * Rules for finding the highlighted media object: * 1. The first _PRIM Y object will be used regardless of level in gedcom record * 2. The first level 1 object will be used if there if it doesn't have _PRIM N (level 1 objects appear on the media tab on the individual page) * * @param string $pid the individual, source, or family id * @param string $indirec the gedcom record to look in * @return array an object array with indexes "thumb" and "file" for thumbnail and filename */ function find_highlighted_object($pid, $indirec) { global $MEDIA_DIRECTORY, $MEDIA_DIRECTORY_LEVELS, $PGV_IMAGE_DIR, $PGV_IMAGES, $MEDIA_EXTERNAL; global $GEDCOMS, $GEDCOM, $TBLPREFIX, $gBitDb; if (!showFactDetails("OBJE", $pid)) { return false; } $object = array(); $media = array(); //-- handle finding the media of remote objects $ct = preg_match("/(.*):(.*)/", $pid, $match); if ($ct > 0) { require_once '../classes/class_serviceclient.php'; $client = ServiceClient::getInstance($match[1]); if (!is_null($client)) { $mt = preg_match_all('/\\n\\d OBJE @(' . PGV_REGEX_XREF . ')@/', $indirec, $matches, PREG_SET_ORDER); for ($i = 0; $i < $mt; $i++) { $mediaObj = Media::getInstance($matches[$i][1]); $mrec = $mediaObj->getGedcomRecord(); if (!empty($mrec)) { $file = get_gedcom_value("FILE", 1, $mrec); $row = array($matches[$i][1], $file, $mrec, $matches[$i][0]); $media[] = $row; } } } } //-- find all of the media items for a person $media = $gBitDb->query("SELECT m_media, m_file, m_gedrec, mm_gedrec FROM {$TBLPREFIX}media, {$TBLPREFIX}media_mapping WHERE m_media=mm_media AND m_gedfile=mm_gedfile AND m_gedfile=? AND mm_gid=? ORDER BY mm_order", array($GEDCOMS[$GEDCOM]["id"], $pid)); while ($row = $media->fetchRow()) { if (displayDetailsById($row['m_media'], 'OBJE') && !FactViewRestricted($row['m_media'], $row['m_gedrec'])) { $level = 0; $ct = preg_match("/(\\d+) OBJE/", $row['mm_gedrec'], $match); if ($ct > 0) { $level = $match[1]; } if (strstr($row['mm_gedrec'], "_PRIM ")) { $thum = get_gedcom_value('_THUM', $level + 1, $row['mm_gedrec']); $prim = get_gedcom_value('_PRIM', $level + 1, $row['mm_gedrec']); } else { $thum = get_gedcom_value('_THUM', 1, $row['m_gedrec']); $prim = get_gedcom_value('_PRIM', 1, $row['m_gedrec']); } if ($prim == 'N') { continue; } // Skip _PRIM N objects if ($prim == 'Y') { // Take the first _PRIM Y object $object["file"] = check_media_depth($row['m_file']); $object["thumb"] = thumbnail_file($row['m_file'], true, false, $pid); // $object["_PRIM"] = $prim; // Not sure whether this is needed. $object["_THUM"] = $thum; // This overrides GEDCOM's "Use main image as thumbnail" option $object["level"] = $level; $object["mid"] = $row['m_media']; break; // Stop looking: we found a suitable image } if ($level == 1 && empty($object)) { // Take the first level 1 object, but keep looking for an overriding _PRIM Y $object["file"] = check_media_depth($row['m_file']); $object["thumb"] = thumbnail_file($row['m_file'], true, false, $pid); // $object["_PRIM"] = $prim; // Not sure whether this is needed. $object["_THUM"] = $thum; // This overrides GEDCOM's "Use main image as thumbnail" option $object["level"] = $level; $object["mid"] = $row['m_media']; } } } return $object; }