Esempio n. 1
0
/**
 * print first major fact for an Individual
 *
 * @param string $key	indi pid
 */
function print_first_major_fact($key, $majorfacts = array("BIRT", "CHR", "BAPM", "DEAT", "BURI", "BAPL", "ADOP"))
{
    global $pgv_lang, $factarray, $LANGUAGE, $TEXT_DIRECTION;
    $indirec = find_person_record($key);
    if (!$indirec) {
        $indirec = find_family_record($key);
    }
    foreach ($majorfacts as $indexval => $fact) {
        $factrec = get_sub_record(1, "1 {$fact}", $indirec);
        if (strlen($factrec) > 7 and showFact("{$fact}", $key) and !FactViewRestricted($key, $factrec)) {
            print "<span dir=\"{$TEXT_DIRECTION}\">";
            echo "<br /><i>";
            //print " -- <i>";
            if (isset($pgv_lang[$fact])) {
                print $pgv_lang[$fact];
            } else {
                if (isset($factarray[$fact])) {
                    print $factarray[$fact];
                } else {
                    print $fact;
                }
            }
            print " ";
            print_fact_date($factrec);
            print_fact_place($factrec);
            print "</i>";
            print "</span>";
            break;
        }
    }
    return $fact;
}
Esempio n. 2
0
 /**
  * Check whether or not this event can be shown
  *
  * @return boolean
  */
 function canShow()
 {
     if (is_null($this->canShow)) {
         if (empty($this->gedcomRecord)) {
             $this->canShow = false;
         } else {
             if (!is_null($this->parentObject)) {
                 $this->canShow = showFact($this->tag, $this->parentObject->getXref()) && !FactViewRestricted($this->parentObject->getXref(), $this->gedcomRecord);
             } else {
                 $this->canShow = true;
             }
         }
     }
     return $this->canShow;
 }
/**
 * 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>&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'];
    print "<input type=\"hidden\" name=\"order1[{$media_data}]\" value=\"{$j}\" />";
    print "</li>";
    print "\n\n";
    return true;
}
Esempio n. 4
0
function print_yahrzeit($block = true, $config = '', $side, $index)
{
    global $pgv_lang, $factarray, $SHOW_ID_NUMBERS, $ctype, $TEXT_DIRECTION;
    global $PGV_IMAGE_DIR, $PGV_IMAGES, $PGV_BLOCKS;
    global $DAYS_TO_SHOW_LIMIT, $SHOW_MARRIED_NAMES, $SERVER_URL;
    $block = true;
    // Always restrict this block's height
    if (empty($config)) {
        $config = $PGV_BLOCKS['print_yahrzeit']['config'];
    }
    if (empty($config['infoStyle'])) {
        $config['infoStyle'] = 'style2';
    }
    if (empty($config['allowDownload'])) {
        $config['allowDownload'] = 'yes';
    }
    if (empty($config['days'])) {
        $config['days'] = $DAYS_TO_SHOW_LIMIT;
    }
    if ($config['days'] < 1) {
        $config['days'] = 1;
    }
    if ($config['days'] > $DAYS_TO_SHOW_LIMIT) {
        $config['days'] = $DAYS_TO_SHOW_LIMIT;
    }
    $startjd = server_jd();
    $endjd = $startjd + max(min($config['days'], 1), $DAYS_TO_SHOW_LIMIT) - 1;
    if (!PGV_USER_ID) {
        $allowDownload = "no";
    }
    $id = "yahrzeit";
    $title = print_help_link('yahrzeit_help', 'qm', '', false, true);
    if ($PGV_BLOCKS['print_yahrzeit']['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['yahrzeit_block'];
    $content = "";
    // The standard anniversary rules cover most of the Yahrzeit rules, we just
    // need to handle a few special cases.
    // Fetch normal anniversaries...
    $yahrzeits = array();
    $hidden = 0;
    for ($jd = $startjd - 1; $jd <= $endjd + 30; ++$jd) {
        foreach (get_anniversary_events($jd, 'DEAT _YART') as $fact) {
            // Extract hebrew dates only
            if ($fact['date']->date1->CALENDAR_ESCAPE() == '@#DHEBREW@' && $fact['date']->MinJD() == $fact['date']->MaxJD()) {
                // Apply privacy
                if (displayDetailsById($fact['id']) && showFactDetails($fact['fact'], $fact['id']) && !FactViewRestricted($fact['id'], $fact['factrec'])) {
                    $yahrzeits[] = $fact;
                } else {
                    ++$hidden;
                }
            }
        }
    }
    // ...then adjust dates
    foreach ($yahrzeits as $key => $yahrzeit) {
        if (strpos('1 DEAT', $yahrzeit['factrec']) !== false) {
            // Just DEAT, not _YART
            $today = new JewishDate($yahrzeit['jd']);
            $hd = $yahrzeit['date']->MinDate();
            $hd1 = new JewishDate($hd);
            $hd1->y += 1;
            $hd1->SetJDFromYMD();
            // Special rules.  See http://www.hebcal.com/help/anniv.html
            // Everything else is taken care of by our standard anniversary rules.
            if ($hd->d == 30 && $hd->m == 2 && $hd->y != 0 && $hd1->DaysInMonth() < 30) {
                // 30 CSH
                // Last day in CSH
                $yahrzeit[$key]['jd'] = JewishDate::YMDtoJD($today->y, 3, 1) - 1;
            }
            if ($hd->d == 30 && $hd->m == 3 && $hd->y != 0 && $hd1->DaysInMonth() < 30) {
                // 30 KSL
                // Last day in KSL
                $yahrzeit[$key]['jd'] = JewishDate::YMDtoJD($today->y, 4, 1) - 1;
            }
            if ($hd->d == 30 && $hd->m == 6 && $hd->y != 0 && $today->DaysInMonth() < 30 && !$today->IsLeapYear()) {
                // 30 ADR
                // Last day in SHV
                $yahrzeit[$key]['jd'] = JewishDate::YMDtoJD($today->y, 6, 1) - 1;
            }
        }
    }
    switch ($config['infoStyle']) {
        case "style1":
            // List style
            foreach ($yahrzeits as $yahrzeit) {
                if ($yahrzeit['jd'] >= $startjd && $yahrzeit['jd'] < $startjd + $config['days']) {
                    $ind = person::GetInstance($yahrzeit['id']);
                    //@@			$content .= "<a href=\"".encode_url($ind->getLinkUrl())."\" class=\"list_item name2\">".$ind->getFullName()."</a>".$ind->getSexImage();
                    $content .= "<a href=\"" . encode_url($ind->getLinkUrl()) . "\" class=\"list_item name2\">" . PrintReady($ind->getFullName()) . "</a>" . $ind->getSexImage();
                    $content .= "<div class=\"indent\">";
                    $content .= $yahrzeit['date']->Display(true);
                    $content .= ', ' . str_replace("#year_var#", $yahrzeit['anniv'], $pgv_lang["year_anniversary"]);
                    $content .= "</div>";
                }
            }
            break;
        case "style2":
            // Table style
            require_once PGV_ROOT . 'js/sorttable.js.htm';
            require_once PGV_ROOT . 'includes/classes/class_gedcomrecord.php';
            $table_id = "ID" . floor(microtime() * 1000000);
            // sorttable requires a unique ID
            $content .= "<table id=\"{$table_id}\" class=\"sortable list_table center\">";
            $content .= "<tr>";
            $content .= "<th class=\"list_label\">{$factarray['NAME']}</th>";
            $content .= "<th style=\"display:none\">GIVN</th>";
            $content .= "<th class=\"list_label\">{$factarray['DATE']}</th>";
            $content .= "<th class=\"list_label\"><img src=\"./images/reminder.gif\" alt=\"{$pgv_lang['anniversary']}\" title=\"{$pgv_lang['anniversary']}\" border=\"0\" /></th>";
            $content .= "<th class=\"list_label\">{$factarray['_YART']}</th>";
            $content .= "</tr>";
            $count = 0;
            foreach ($yahrzeits as $yahrzeit) {
                if ($yahrzeit['jd'] >= $startjd && $yahrzeit['jd'] < $startjd + $config['days']) {
                    ++$count;
                    $ind = person::GetInstance($yahrzeit['id']);
                    $content .= "<tr class=\"vevent\">";
                    // hCalendar:vevent
                    // Record name(s)
                    $name = $ind->getFullName();
                    $url = $ind->getLinkUrl();
                    $content .= "<td class=\"list_value_wrap\" align=\"" . get_align($name) . "\">";
                    $content .= "<a href=\"" . encode_url($ind->getLinkUrl()) . "\" class=\"list_item name2\" dir=\"" . $TEXT_DIRECTION . "\">" . PrintReady($name) . "</a>";
                    $content .= $ind->getSexImage();
                    $addname = $ind->getAddName();
                    if ($addname) {
                        $content .= "<br /><a href=\"" . encode_url($url) . "\" class=\"list_item\">" . PrintReady($addname) . "</a>";
                    }
                    $content .= "</td>";
                    // GIVN for sorting
                    $content .= "<td style=\"display:none\">";
                    $exp = explode(",", str_replace('<', ',', $name) . ",");
                    $content .= $exp[1];
                    $content .= "</td>";
                    $today = new JewishDate($yahrzeit['jd']);
                    $td = new GedcomDate($today->Format('@ A O E'));
                    // death/yahrzeit event date
                    $content .= "<td class=\"list_value_wrap\">";
                    $content .= "<a name='{$yahrzeit['jd']}'>" . $yahrzeit['date']->Display(true, NULL, array()) . "</a>";
                    $content .= "</td>";
                    // Anniversary
                    $content .= "<td class=\"list_value_wrap rela\">";
                    $anniv = $yahrzeit['anniv'];
                    if ($anniv == 0) {
                        $content .= '<a name="0">&nbsp;</a>';
                    } else {
                        $content .= "<a name=\"{$anniv}\">{$anniv}</a>";
                    }
                    if ($config['allowDownload'] == 'yes') {
                        // hCalendar:dtstart and hCalendar:summary
                        //TODO does this work??
                        $content .= "<abbr class=\"dtstart\" title=\"" . strip_tags($yahrzeit['date']->Display(false, 'Ymd', array())) . "\"></abbr>";
                        $content .= "<abbr class=\"summary\" title=\"" . $pgv_lang["anniversary"] . " #{$anniv} " . $factarray[$yahrzeit['fact']] . " : " . PrintReady(strip_tags($ind->getFullName())) . "\"></abbr>";
                    }
                    // upcomming yahrzeit dates
                    $content .= "<td class=\"list_value_wrap\">";
                    $content .= "<a href=\"" . $url . "\" class=\"list_item url\">" . $td->Display(true, NULL, array('gregorian')) . "</a>";
                    // hCalendar:url
                    $content .= "&nbsp;</td>";
                    $content .= "</tr>";
                }
            }
            // table footer
            $content .= "<tr class=\"sortbottom\">";
            $content .= "<td class=\"list_label\">";
            $content .= '<a href="javascript:;" onclick="sortByOtherCol(this,1)"><img src="images/topdown.gif" alt="" border="0" /> ' . $factarray["GIVN"] . '</a><br />';
            $content .= $pgv_lang["total_names"] . ": " . $count;
            if ($hidden) {
                $content .= "<br /><span class=\"warning\">{$pgv_lang['hidden']} : {$hidden}</span>";
            }
            $content .= "</td>";
            $content .= "<td style=\"display:none\">GIVN</td>";
            $content .= "<td>";
            if ($config['allowDownload'] == 'yes') {
                $uri = $SERVER_URL . basename($_SERVER['REQUEST_URI']);
                global $whichFile;
                $whichFile = 'hCal-events.ics';
                $alt = print_text('download_file', 0, 1);
                if (count($yahrzeits)) {
                    $content .= "<a href=\"http://feeds.technorati.com/events/{$uri}\"><img src=\"images/hcal.png\" border=\"0\" alt=\"{$alt}\" title=\"{$alt}\" /></a>";
                }
            }
            $content .= '</td><td>&nbsp;</td><td>&nbsp;</td></tr>';
            $content .= '</table>';
            break;
    }
    global $THEME_DIR;
    if ($block) {
        require $THEME_DIR . 'templates/block_small_temp.php';
    } else {
        require $THEME_DIR . 'templates/block_main_temp.php';
    }
}
Esempio n. 5
0
/**
 * 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;
}
Esempio n. 6
0
    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';
        }
    }
Esempio n. 7
0
function get_calendar_events($jd1, $jd2, $facts = '', $ged_id = PGV_GED_ID)
{
    global $TBLPREFIX, $gBitDb;
    // If no facts specified, get all except these
    $skipfacts = "CHAN,BAPL,SLGC,SLGS,ENDL,CENS,RESI,NOTE,ADDR,OBJE,SOUR,PAGE,DATA,TEXT";
    if ($facts != '_TODO') {
        $skipfacts .= ',_TODO';
    }
    $found_facts = array();
    // This where clause gives events that start/end/overlap the period
    // e.g. 1914-1918 would show up on 1916
    //$where="WHERE d_julianday1 <={$jd2} AND d_julianday2>={$jd1}";
    // This where clause gives only events that start/end during the period
    $where = "WHERE (d_julianday1>={$jd1} AND d_julianday1<={$jd2} OR d_julianday2>={$jd1} AND d_julianday2<={$jd2})";
    // Restrict to certain types of fact
    if (empty($facts)) {
        $excl_facts = "'" . preg_replace('/\\W+/', "','", $skipfacts) . "'";
        $where .= " AND d_fact NOT IN ({$excl_facts})";
    } else {
        $incl_facts = "'" . preg_replace('/\\W+/', "','", $facts) . "'";
        $where .= " AND d_fact IN ({$incl_facts})";
    }
    // Only get events from the current gedcom
    $where .= " AND d_file=" . $ged_id;
    // Now fetch these events
    $ind_sql = "SELECT d_gid, i_gedcom, 'INDI', d_type, d_day, d_month, d_year, d_fact, d_type FROM {$TBLPREFIX}dates, {$TBLPREFIX}individuals {$where} AND d_gid=i_id AND d_file=i_file ORDER BY d_julianday1";
    $fam_sql = "SELECT d_gid, f_gedcom, 'FAM',  d_type, d_day, d_month, d_year, d_fact, d_type FROM {$TBLPREFIX}dates, {$TBLPREFIX}families    {$where} AND d_gid=f_id AND d_file=f_file ORDER BY d_julianday1";
    foreach (array($ind_sql, $fam_sql) as $sql) {
        $rows = $gBitDb->getAll->fetchAll($sql);
        foreach ($rows as $row) {
            // Generate a regex to match the retrieved date - so we can find it in the original gedcom record.
            // TODO having to go back to the original gedcom is lame.  This is why it is so slow, and needs
            // to be cached.  We should store the level1 fact here (or somewhere)
            if ($row[8] == '@#DJULIAN@') {
                if ($row[6] < 0) {
                    $year_regex = $row[6] . " ?[Bb]\\.? ?[Cc]\\.\\ ?";
                } else {
                    $year_regex = "({$row[6]}|" . ($row[6] - 1) . "\\/" . $row[6] % 100 . ")";
                }
            } else {
                $year_regex = "0*" . $row[6];
            }
            $ged_date_regex = "/2 DATE.*(" . ($row[4] > 0 ? "0?{$row[4]}\\s*" : "") . $row[5] . "\\s*" . ($row[6] != 0 ? $year_regex : "") . ")/i";
            foreach (get_all_subrecords($row[1], $skipfacts, false, false) as $factrec) {
                if (preg_match("/(^1 {$row[7]}|^1 (FACT|EVEN).*\n2 TYPE {$row[7]})/s", $factrec) && preg_match($ged_date_regex, $factrec) && preg_match('/2 DATE (.+)/', $factrec, $match)) {
                    $date = new GedcomDate($match[1]);
                    if (preg_match('/2 PLAC (.+)/', $factrec, $match)) {
                        $plac = $match[1];
                    } else {
                        $plac = '';
                    }
                    if (showFactDetails($row[7], $row[0]) && !FactViewRestricted($row[0], $factrec)) {
                        $found_facts[] = array('id' => $row[0], 'objtype' => $row[2], 'fact' => $row[7], 'factrec' => $factrec, 'jd' => $jd1, 'anniv' => 0, 'date' => $date, 'plac' => $plac);
                    }
                }
            }
        }
    }
    return $found_facts;
}