Exemple #1
0
         usort($myfamlist, array('GedcomRecord', 'Compare'));
         foreach ($myfamlist as $family) {
             echo $family->format_list('li', true);
         }
         echo '</ul></td></tr><tr><td class="list_label">', $pgv_lang['total_fams'], ' ', count($myfamlist), '</tr></td>';
     } else {
         echo "<td class=\"list_value_wrap\">";
         echo $pgv_lang["no_results"];
         echo "</td></tr>";
     }
     echo "</table>";
 }
 // Output Media
 if ($type == "media") {
     global $dirs;
     $medialist = get_medialist(true, $directory);
     echo "<table class=\"tabs_table {$TEXT_DIRECTION} width90\">";
     // Show link to previous folder
     if ($level > 0) {
         $levels = explode("/", $directory);
         $pdir = "";
         for ($i = 0; $i < count($levels) - 2; $i++) {
             $pdir .= $levels[$i] . "/";
         }
         $levels = explode("/", $thumbdir);
         $pthumb = "";
         for ($i = 0; $i < count($levels) - 2; $i++) {
             $pthumb .= $levels[$i] . "/";
         }
         $uplink = "<a href=\"" . encode_url("find.php?directory={$pdir}&thumbdir={$pthumb}&level=" . ($level - 1) . "{$thumbget}&type=media&choose={$choose}") . "\">&nbsp;&nbsp;&nbsp;&lt;-- <span dir=\"ltr\">" . $pdir . "</span>&nbsp;&nbsp;&nbsp;</a><br />";
     }
    function print_random_media($block = true, $config = "", $side, $index)
    {
        global $pgv_lang, $foundlist, $MULTI_MEDIA, $TEXT_DIRECTION, $PGV_IMAGE_DIR, $PGV_IMAGES;
        global $MEDIA_EXTERNAL, $MEDIA_DIRECTORY, $SHOW_SOURCES;
        global $MEDIATYPE, $THUMBNAIL_WIDTH, $USE_MEDIA_VIEWER;
        global $PGV_BLOCKS, $ctype, $action;
        global $PGV_IMAGE_DIR, $PGV_IMAGES;
        if (!$MULTI_MEDIA) {
            return;
        }
        if (empty($config)) {
            $config = $PGV_BLOCKS["print_random_media"]["config"];
        }
        if (isset($config["filter"])) {
            $filter = $config["filter"];
        } else {
            $filter = "all";
        }
        if (!isset($config['controls'])) {
            $config['controls'] = "yes";
        }
        if (!isset($config['start'])) {
            $config['start'] = "no";
        }
        $medialist = array();
        $foundlist = array();
        $medialist = get_medialist(false, '', true, true);
        $ct = count($medialist);
        if ($ct > 0) {
            $i = 0;
            $disp = false;
            //-- try up to 40 times to get a media to display
            while ($i < 40) {
                $error = false;
                $value = array_rand($medialist);
                if (PGV_DEBUG) {
                    print "<br />";
                    print_r($medialist[$value]);
                    print "<br />";
                    print "Trying " . $medialist[$value]["XREF"] . "<br />";
                }
                $links = $medialist[$value]["LINKS"];
                $disp = $medialist[$value]["EXISTS"] > 0 && $medialist[$value]["LINKED"] && $medialist[$value]["CHANGE"] != "delete";
                if (PGV_DEBUG && !$disp && !$error) {
                    $error = true;
                    print "<span class=\"error\">" . $medialist[$value]["XREF"] . " File does not exist, or is not linked to anyone, or is marked for deletion.</span><br />";
                }
                $disp &= displayDetailsById($medialist[$value]["XREF"], "OBJE");
                $disp &= !FactViewRestricted($medialist[$value]["XREF"], $medialist[$value]["GEDCOM"]);
                if (PGV_DEBUG && !$disp && !$error) {
                    $error = true;
                    print "<span class=\"error\">" . $medialist[$value]["XREF"] . " Failed to pass privacy</span><br />";
                }
                $isExternal = isFileExternal($medialist[$value]["FILE"]);
                if ($block && !$isExternal) {
                    $disp &= $medialist[$value]["THUMBEXISTS"] > 0;
                }
                if (PGV_DEBUG && !$disp && !$error) {
                    $error = true;
                    print "<span class=\"error\">" . $medialist[$value]["XREF"] . " thumbnail file could not be found</span><br />";
                }
                // Filter according to format and type  (Default: unless configured otherwise, don't filter)
                if (!empty($medialist[$value]["FORM"]) && isset($config["filter_" . $medialist[$value]["FORM"]]) && $config["filter_" . $medialist[$value]["FORM"]] != "yes") {
                    $disp = false;
                }
                if (!empty($medialist[$value]["TYPE"]) && isset($config["filter_" . $medialist[$value]["TYPE"]]) && $config["filter_" . $medialist[$value]["TYPE"]] != "yes") {
                    $disp = false;
                }
                if (PGV_DEBUG && !$disp && !$error) {
                    $error = true;
                    print "<span class=\"error\">" . $medialist[$value]["XREF"] . " failed Format or Type filters</span><br />";
                }
                if ($disp && count($links) != 0) {
                    /** link privacy allready checked in displayDetailsById
                    				foreach($links as $key=>$type) {
                    					$gedrec = find_gedcom_record($key, PGV_GED_ID);
                    					$disp &= !empty($gedrec);
                    					//-- source privacy is now available through the display details by id method
                    					// $disp &= $type!="SOUR";
                    					$disp &= displayDetailsById($key, $type);
                    				}
                    				if (PGV_DEBUG && !$disp && !$error) {$error = true; print "<span class=\"error\">".$medialist[$value]["XREF"]." failed link privacy</span><br />";}
                    				*/
                    if ($disp && $filter != "all") {
                        // Apply filter criteria
                        $ct = preg_match("/0\\s(@.*@)\\sOBJE/", $medialist[$value]["GEDCOM"], $match);
                        $objectID = $match[1];
                        //-- we could probably use the database for this filter
                        foreach ($links as $key => $type) {
                            $gedrec = find_gedcom_record($key, PGV_GED_ID);
                            $ct2 = preg_match("/(\\d)\\sOBJE\\s{$objectID}/", $gedrec, $match2);
                            if ($ct2 > 0) {
                                $objectRefLevel = $match2[1];
                                if ($filter == "indi" && $objectRefLevel != "1") {
                                    $disp = false;
                                }
                                if ($filter == "event" && $objectRefLevel == "1") {
                                    $disp = false;
                                }
                                if (PGV_DEBUG && !$disp && !$error) {
                                    $error = true;
                                    print "<span class=\"error\">" . $medialist[$value]["XREF"] . " failed to pass config filter</span><br />";
                                }
                            } else {
                                $disp = false;
                            }
                        }
                    }
                }
                //-- leave the loop if we find an image that works
                if ($disp) {
                    break;
                } else {
                    if (PGV_DEBUG) {
                        print "<span class=\"error\">" . $medialist[$value]["XREF"] . " Will not be shown</span><br />";
                    }
                    unset($medialist[$value]);
                }
                //-- if there are no more media items, then try to get some more
                if (count($medialist) == 0) {
                    $medialist = get_medialist(false, '', true, true);
                }
                $i++;
            }
            if (!$disp) {
                return false;
            }
            $content = "";
            $id = "";
            $id = "random_picture{$index}";
            $title = print_help_link("index_media_help", "qm", "random_picture", false, true);
            if ($PGV_BLOCKS["print_random_media"]["canconfig"]) {
                if ($ctype == "gedcom" && PGV_USER_GEDCOM_ADMIN || $ctype == "user" && PGV_USER_ID) {
                    if ($ctype == "gedcom") {
                        $name = PGV_GEDCOM;
                    } else {
                        $name = PGV_USER_NAME;
                    }
                    $title .= "<a href=\"javascript: configure block\" onclick=\"window.open('" . encode_url("index_edit.php?name={$name}&ctype={$ctype}&action=configure&side={$side}&index={$index}") . "', '_blank', 'top=50,left=50,width=600,height=350,scrollbars=1,resizable=1'); return false;\">";
                    $title .= "<img class=\"adminicon\" src=\"{$PGV_IMAGE_DIR}/{$PGV_IMAGES['admin']['small']}\" width=\"15\" height=\"15\" border=\"0\" alt=\"{$pgv_lang['config_block']}\" /></a>";
                }
            }
            $title .= $pgv_lang["random_picture"];
            $content = "<div id=\"random_picture_container{$index}\">";
            if ($config['controls'] == 'yes') {
                if ($config['start'] == 'yes' || isset($_COOKIE['rmblockplay']) && $_COOKIE['rmblockplay'] == 'true') {
                    $image = "stop";
                } else {
                    $image = "rarrow";
                }
                $linkNextImage = "<a href=\"javascript: " . $pgv_lang["next_image"] . "\" onclick=\"return ajaxBlock('random_picture{$index}', 'print_random_media', '{$side}', {$index}, '{$ctype}', true);\"><img src=\"{$PGV_IMAGE_DIR}/{$PGV_IMAGES['rdarrow']['other']}\" border=\"0\" alt=\"{$pgv_lang['next_image']}\" title=\"{$pgv_lang['next_image']}\" /></a>";
                $content .= "<div class=\"center\" id=\"random_picture_controls{$index}\"><br />";
                if ($TEXT_DIRECTION == "rtl") {
                    $content .= $linkNextImage;
                }
                $content .= "<a href=\"javascript: " . $pgv_lang["play"] . "/" . $pgv_lang["stop"] . "\" onclick=\"togglePlay(); return false;\">";
                if (isset($PGV_IMAGES[$image]['other'])) {
                    $content .= "<img id=\"play_stop\" src=\"{$PGV_IMAGE_DIR}/{$PGV_IMAGES[$image]['other']}\" border=\"0\" alt=\"{$pgv_lang['play']}/{$pgv_lang['stop']}\" title=\"{$pgv_lang['play']}/{$pgv_lang['stop']}\" />";
                } else {
                    $content .= $pgv_lang["play"] . "/" . $pgv_lang["stop"];
                }
                $content .= "</a>";
                if ($TEXT_DIRECTION == "ltr") {
                    $content .= $linkNextImage;
                }
                $content .= '
					</div>
					<script language="JavaScript" type="text/javascript">
					<!--
						var play = false;
						function togglePlay() {
							if (play) {
								play = false;
								imgid = document.getElementById("play_stop");
								imgid.src = \'' . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["rarrow"]['other'] . '\';
							}
							else {
								play = true;
								playSlideShow();
								imgid = document.getElementById("play_stop");
								imgid.src = \'' . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["stop"]['other'] . '\';
							}
						}

						function playSlideShow() {
							if (play) {
								ajaxBlock(\'random_picture' . $index . '\', \'print_random_media\', \'' . $side . '\', ' . $index . ', \'' . $ctype . '\', false);
								window.setTimeout(\'playSlideShow()\', 6000);
							}
						}
					//-->
					</script>';
            }
            if ($config['start'] == 'yes') {
                $content .= '
					<script language="JavaScript" type="text/javascript">
					<!--
						play = true;
						imgid = document.getElementById("play_stop");
						imgid.src = \'' . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["stop"]['other'] . '\';
						window.setTimeout("playSlideShow()", 6000);
					//-->
					</script>';
            }
            $content .= "<div class=\"center\" id=\"random_picture_content{$index}\">";
            $imgsize = findImageSize($medialist[$value]["FILE"]);
            $imgwidth = $imgsize[0] + 40;
            $imgheight = $imgsize[1] + 150;
            $content .= "<table id=\"random_picture_box\" width=\"100%\"><tr><td valign=\"top\"";
            if ($block) {
                $content .= " align=\"center\" class=\"details1\"";
            } else {
                $content .= " class=\"details2\"";
            }
            $mediaid = $medialist[$value]["XREF"];
            //LBox --------  change for Lightbox Album --------------------------------------------
            ?>
<script language="JavaScript" type="text/javascript">
<!--
function openPic(filename, width, height) {
		height=height+50;
		screenW = screen.width;
	 	screenH = screen.height;
	 	if (width>screenW-100) width=screenW-100;
	 	if (height>screenH-110) height=screenH-120;
		if ((filename.search(/\.je?pg$/gi)!=-1)||(filename.search(/\.gif$/gi)!=-1)||(filename.search(/\.png$/gi)!=-1)||(filename.search(/\.bmp$/gi)!=-1))
			win02 = window.open('imageview.php?filename='+filename,'win02','top=50,left=150,height='+height+',width='+width+',scrollbars=1,resizable=1');
			// win03.resizeTo(winWidth 2,winHeight 30);
		else window.open(unescape(filename),'win02','top=50,left=150,height='+height+',width='+width+',scrollbars=1,resizable=1');
		win02.focus();
	}
-->
</script><?php 
            if (PGV_USE_LIGHTBOX) {
                // $content .= " ><a href=\"javascript:;\" onclick=\"return openPic('".$medialist[$value]["FILE"]."', $imgwidth, $imgheight);\">";
                // $content .= " ><a href=\"javascript:;\" onclick=\"return openImage('".$medialist[$value]["FILE"]."', $imgwidth, $imgheight);\">";
                // $content .= "><a href=\"" . $medialist[$value]["FILE"] . "\" rel=\"clearbox[general_4]\" title=\"" . $mediaid . "\">" . "\n";
                $content .= " ><a href=\"mediaviewer.php?mid=" . $mediaid . "\">";
            } else {
                // ---------------------------------------------------------------------------------------------
                if ($USE_MEDIA_VIEWER) {
                    $content .= " ><a href=\"mediaviewer.php?mid=" . $mediaid . "\">";
                } else {
                    $content .= " ><a href=\"javascript:;\" onclick=\"return openImage('" . $medialist[$value]["FILE"] . "', {$imgwidth}, {$imgheight});\">";
                }
            }
            $mediaTitle = "";
            if (!empty($medialist[$value]["TITL"])) {
                $mediaTitle = PrintReady($medialist[$value]["TITL"]);
            } else {
                $mediaTitle = basename($medialist[$value]["FILE"]);
            }
            if ($block) {
                $content .= "<img src=\"" . $medialist[$value]["THUMB"] . "\" border=\"0\" class=\"thumbnail\"";
                if ($isExternal) {
                    $content .= " width=\"" . $THUMBNAIL_WIDTH . "\"";
                }
            } else {
                $content .= "<img src=\"" . $medialist[$value]["FILE"] . "\" border=\"0\" class=\"thumbnail\" ";
                $imgsize = findImageSize($medialist[$value]["FILE"]);
                if ($imgsize[0] > 175) {
                    $content .= "width=\"175\" ";
                }
            }
            $content .= " alt=\"{$mediaTitle}\" title=\"{$mediaTitle}\" />";
            $content .= "</a>";
            if ($block) {
                $content .= "<br />";
            } else {
                $content .= "</td><td class=\"details2\">";
            }
            $content .= "<a href=\"mediaviewer.php?mid=" . $mediaid . "\">";
            $content .= "<b>" . $mediaTitle . "</b>";
            $content .= "</a><br />";
            ob_start();
            PrintMediaLinks($medialist[$value]["LINKS"], "normal");
            $content .= ob_get_clean();
            $content .= "<br /><div class=\"indent" . ($TEXT_DIRECTION == "rtl" ? "_rtl" : "") . "\">";
            $content .= print_fact_notes($medialist[$value]["GEDCOM"], "1", false, true);
            $content .= "</div>";
            $content .= "</td></tr></table>";
            $content .= "</div>";
            // random_picture_content
            $content .= "</div>";
            // random_picture_container
            global $THEME_DIR;
            require $THEME_DIR . 'templates/block_main_temp.php';
        }
    }