i18n::translate('Random Media'), 'type'=>'both', 'descr'=>i18n::translate('The Random Media block randomly selects a photo or other media item from the currently active database and displays it to the user.

The administrator determines whether this block can show media items associated with persons or events.'), 'canconfig'=>true, 'config'=>array( 'cache' =>0, 'filter' =>'all', 'controls'=>'yes', 'start' =>'no', 'filter_avi' =>'no', 'filter_bmp' =>'yes', 'filter_gif' =>'yes', 'filter_jpeg' =>'yes', 'filter_mp3' =>'no', 'filter_ole' =>'yes', 'filter_pcx' =>'yes', 'filter_pdf' =>'no', 'filter_png' =>'yes', 'filter_tiff' =>'yes', 'filter_wav' =>'no', 'filter_audio' =>'no', 'filter_book' =>'yes', 'filter_card' =>'yes', 'filter_certificate'=>'yes', 'filter_coat' =>'yes', 'filter_document' =>'yes', 'filter_electronic' =>'yes', 'filter_fiche' =>'yes', 'filter_film' =>'yes', 'filter_magazine' =>'yes', 'filter_manuscript' =>'yes', 'filter_map' =>'yes', 'filter_newspaper' =>'yes', 'filter_other' =>'yes', 'filter_painting' =>'yes', 'filter_photo' =>'yes', 'filter_tombstone' =>'yes', 'filter_video' =>'no' ) ); require_once WT_ROOT.'includes/functions/functions_print_facts.php'; //-- function to display a random picture from the gedcom function print_random_media($block = true, $config="", $side, $index) { global $foundlist, $MULTI_MEDIA, $TEXT_DIRECTION, $WT_IMAGE_DIR, $WT_IMAGES; global $MEDIA_EXTERNAL, $MEDIA_DIRECTORY, $SHOW_SOURCES; global $MEDIATYPE, $THUMBNAIL_WIDTH, $USE_MEDIA_VIEWER; global $WT_BLOCKS, $ctype, $action; global $WT_IMAGE_DIR, $WT_IMAGES; if (!$MULTI_MEDIA) return; if (empty($config)) $config = $WT_BLOCKS["print_random_media"]["config"]; if (isset($config["filter"])) $filter = $config["filter"]; // indi, event, or all 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 (WT_DEBUG) { print "
";print_r($medialist[$value]);print "
"; print "Trying ".$medialist[$value]["XREF"]."
"; } $links = $medialist[$value]["LINKS"]; $disp = ($medialist[$value]["EXISTS"]>0) && $medialist[$value]["LINKED"] && $medialist[$value]["CHANGE"]!="delete" ; if (WT_DEBUG && !$disp && !$error) {$error = true; print "".$medialist[$value]["XREF"]." File does not exist, or is not linked to anyone, or is marked for deletion.
";} $disp &= displayDetailsById($medialist[$value]["XREF"], "OBJE"); $disp &= !FactViewRestricted($medialist[$value]["XREF"], $medialist[$value]["GEDCOM"]); if (WT_DEBUG && !$disp && !$error) {$error = true; print "".$medialist[$value]["XREF"]." Failed to pass privacy
";} $isExternal = isFileExternal($medialist[$value]["FILE"]); if ($block && !$isExternal) $disp &= ($medialist[$value]["THUMBEXISTS"]>0); if (WT_DEBUG && !$disp && !$error) {$error = true; print "".$medialist[$value]["XREF"]." thumbnail file could not be found
";} // 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 (WT_DEBUG && !$disp && !$error) {$error = true; print "".$medialist[$value]["XREF"]." failed Format or Type filters
";} if ($disp && count($links) != 0){ /** link privacy allready checked in displayDetailsById foreach($links as $key=>$type) { $gedrec = find_gedcom_record($key, WT_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 (WT_DEBUG && !$disp && !$error) {$error = true; print "".$medialist[$value]["XREF"]." failed link privacy
";} */ 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, WT_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 (WT_DEBUG && !$disp && !$error) {$error = true; print "".$medialist[$value]["XREF"]." failed to pass config filter
";} } else $disp = false; } } } //-- leave the loop if we find an image that works if ($disp) { break; } //-- otherwise remove the private media item from the list else { if (WT_DEBUG) print "".$medialist[$value]["XREF"]." Will not be shown
"; 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=''; if ($WT_BLOCKS["print_random_media"]["canconfig"]) { if ($ctype=="gedcom" && WT_USER_GEDCOM_ADMIN || $ctype=="user" && WT_USER_ID) { if ($ctype=="gedcom") { $name = WT_GEDCOM; } else { $name = WT_USER_NAME; } $title .= ""; $title .= "\"".i18n::translate('Configure')."\""; } } $title .= i18n::translate('Random Picture'); $title .= help_link('index_media'); $content = "
"; if ($config['controls']=='yes') { if ($config['start']=='yes' || (isset($_COOKIE['rmblockplay'])&&$_COOKIE['rmblockplay']=='true')) $image = "stop"; else $image = "rarrow"; $linkNextImage = "\"".i18n::translate('Next"; $content .= "

"; if ($TEXT_DIRECTION=="rtl") $content .= $linkNextImage; $content .= ""; if (isset($WT_IMAGES[$image]['other'])) $content .= "\"".i18n::translate('Play')."/".i18n::translate('Stop')."\""; else $content .= i18n::translate('Play')."/".i18n::translate('Stop'); $content .= ""; if ($TEXT_DIRECTION=="ltr") $content .= $linkNextImage; $content .= '
'; } if ($config['start']=='yes') { $content .= ' '; } $content .= "
"; $imgsize = findImageSize($medialist[$value]["FILE"]); $imgwidth = $imgsize[0]+40; $imgheight = $imgsize[1]+150; $content .= "
"; // $content .= " >"; // $content .= ">" . "\n"; $content .= " >"; }else // --------------------------------------------------------------------------------------------- if ($USE_MEDIA_VIEWER) { $content .= " >"; } else { $content .= " >"; } $mediaTitle = ""; if (!empty($medialist[$value]["TITL"])) { $mediaTitle = PrintReady($medialist[$value]["TITL"]); } else $mediaTitle = basename($medialist[$value]["FILE"]); if ($block) { $content .= " 175) $content .= "width=\"175\" "; } $content .= " alt=\"{$mediaTitle}\" title=\"{$mediaTitle}\" />"; $content .= ""; if ($block) $content .= "
"; else $content .= "
"; $content .= ""; $content .= "". $mediaTitle .""; $content .= "
"; ob_start(); PrintMediaLinks($medialist[$value]["LINKS"], "normal"); $content .= ob_get_clean(); $content .= "
"; $content .= print_fact_notes($medialist[$value]["GEDCOM"], "1", false, true); $content .= "
"; $content .= "
"; $content .= "
"; // random_picture_content $content .= "
"; // random_picture_container global $THEME_DIR; require $THEME_DIR.'templates/block_main_temp.php'; } } function print_random_media_config($config) { global $WT_BLOCKS, $TEXT_DIRECTION; $defaultConfig = $WT_BLOCKS['print_random_media']['config']; if (empty($config)) $config = $defaultConfig; // Add options missing from old block configurations foreach ($defaultConfig as $option => $setting) { if (!isset($config[$option])) $config[$option] = $setting; } print ""; print i18n::translate('Show only persons, events, or all?'); print help_link('random_media_persons_or_all'); print ""; ?>
/>  avi   />  bmp   />  gif  
/>  jpeg   />  mp3   />  ole  
/>  pcx   />  pdf   />  png  
/>  tiff   />  wav      

$typeValue) { $i++; if ($i > 3) { $i = 1; print ""; } print ""; } ?>
  ".$typeValue."