예제 #1
0
/**
 * print a simple form of the fact
 *
 * function to print the details of a fact in a simple format
 * @param string $indirec the gedcom record to get the fact from
 * @param string $fact the fact to print
 * @param string $pid the id of the individual to print, required to check privacy
 */
function print_simple_fact($indirec, $fact, $pid)
{
    global $pgv_lang, $SHOW_PEDIGREE_PLACES, $factarray, $ABBREVIATE_CHART_LABELS;
    $emptyfacts = array("BIRT", "CHR", "DEAT", "BURI", "CREM", "ADOP", "BAPM", "BARM", "BASM", "BLES", "CHRA", "CONF", "FCOM", "ORDN", "NATU", "EMIG", "IMMI", "CENS", "PROB", "WILL", "GRAD", "RETI", "BAPL", "CONL", "ENDL", "SLGC", "EVEN", "MARR", "SLGS", "MARL", "ANUL", "CENS", "DIV", "DIVF", "ENGA", "MARB", "MARC", "MARS", "OBJE", "CHAN", "_SEPR", "RESI", "DATA", "MAP");
    $factrec = get_sub_record(1, "1 {$fact}", $indirec);
    if (empty($factrec) || FactViewRestricted($pid, $factrec)) {
        return;
    }
    $label = "";
    if (isset($pgv_lang[$fact])) {
        $label = $pgv_lang[$fact];
    } else {
        if (isset($factarray[$fact])) {
            $label = $factarray[$fact];
        }
    }
    if ($ABBREVIATE_CHART_LABELS) {
        $label = get_first_letter($label);
    }
    // RFE [ 1229233 ] "DEAT" vs "DEAT Y"
    // The check $factrec != "1 DEAT" will not show any records that only have 1 DEAT in them
    if (trim($factrec) != "1 DEAT") {
        print "<span class=\"details_label\">" . $label . "</span> ";
    }
    if (showFactDetails($fact, $pid)) {
        if (!in_array($fact, $emptyfacts)) {
            $ct = preg_match("/1 {$fact}(.*)/", $factrec, $match);
            if ($ct > 0) {
                print PrintReady(trim($match[1]));
            }
        }
        // 1 DEAT Y with no DATE => print YES
        // 1 DEAT N is not allowed
        // It is not proper GEDCOM form to use a N(o) value with an event tag to infer that it did not happen.
        /*-- handled by print_fact_date()
        		 * if (get_sub_record(2, "2 DATE", $factrec)=="") {
        			if (strtoupper(trim(substr($factrec,6,2)))=="Y") print $pgv_lang["yes"];
        		}*/
        print_fact_date($factrec, false, false, $fact, $pid, $indirec);
        print_fact_place($factrec);
    }
    print "<br />\n";
}
예제 #2
0
 /**
  * Check whether or not the details of this event can be shown
  *
  * @return boolean
  */
 function canShowDetails()
 {
     if (!$this->canShow()) {
         return false;
     }
     if (is_null($this->canShowDetails)) {
         if (!is_null($this->parentObject)) {
             $this->canShowDetails = showFactDetails($this->tag, $this->parentObject->getXref());
         } else {
             $this->canShowDetails = true;
         }
     }
     return $this->canShowDetails;
 }
/**
 * 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;
}
예제 #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';
    }
}
예제 #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;
}
예제 #6
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;
}
예제 #7
0
/**
* @see PGVRRepeatTagEHandler()
* @todo add info
* @param array $attrs an array of key value pairs for the attributes
*/
function PGVRRepeatTagSHandler($attrs)
{
    global $repeats, $repeatsStack, $gedrec, $repeatBytes, $parser, $parserStack, $processRepeats, $fact, $desc;
    $processRepeats++;
    if ($processRepeats > 1) {
        return;
    }
    $id = "";
    $gmatch = array();
    $gt = preg_match("/0 @(.+)@/", $gedrec, $gmatch);
    if ($gt > 0) {
        $id = $gmatch[1];
    }
    array_push($repeatsStack, array($repeats, $repeatBytes));
    $repeats = array();
    $repeatBytes = xml_get_current_line_number($parser);
    $tag = "";
    if (isset($attrs["tag"])) {
        $tag = $attrs["tag"];
    }
    if (!empty($tag)) {
        if ($tag == "@desc") {
            if (showFact($fact, $id) and showFactDetails($fact, $id)) {
                $value = $desc;
            } else {
                $value = "";
            }
            $value = trim($value);
            $currentElement->addText($value);
        } else {
            $tag = preg_replace("/@fact/", $fact, $tag);
            $tags = explode(':', $tag);
            $temp = explode(' ', trim($gedrec));
            $level = $temp[0];
            if ($level == 0) {
                $level++;
            }
            $subrec = $gedrec;
            $t = $tag;
            for ($i = 0; $i < count($tags); $i++) {
                $t = $tags[$i];
                if (!empty($t)) {
                    if ($level == 1 && strstr("CHIL,FAMS,FAMC", $t) === false and (!showFact($t, $id) or !showFactDetails($t, $id))) {
                        return;
                    }
                    if ($i < count($tags) - 1) {
                        $subrec = get_sub_record($level, "{$level} {$t}", $subrec);
                        if (empty($subrec)) {
                            $level--;
                            $subrec = get_sub_record($level, "@ {$t}", $gedrec);
                            if (empty($subrec)) {
                                return;
                            }
                        }
                    }
                    //print "[$level $t] ";
                    $level++;
                }
            }
            $level--;
            if ($level != 1 || strstr("CHIL,FAMS,FAMC", $t) !== false || showFact($t, $id) && showFactDetails($t, $id)) {
                $match = array();
                $ct = preg_match_all("/{$level} {$t}(.*)/", $subrec, $match, PREG_SET_ORDER);
                //print "$ct $subrec";
                for ($i = 0; $i < $ct; $i++) {
                    $rec = get_sub_record($level, "{$level} {$t}", $gedrec, $i + 1);
                    $repeats[] = $rec;
                }
                //$repeats = array_reverse($repeats);
                //print_r($repeats);
            }
        }
    }
}