Ejemplo n.º 1
0
 /**
  * Does this module display a particular fact
  *
  * @param Fact $fact
  *
  * @return bool
  */
 public static function showFact(Fact $fact)
 {
     switch ($fact->getTag()) {
         case 'AFN':
         case 'CHAN':
         case 'IDNO':
         case 'REFN':
         case 'RFN':
         case 'RIN':
         case 'SSN':
         case '_UID':
             return true;
         default:
             return false;
     }
 }
Ejemplo n.º 2
0
 /**
  * print fact PLACe TEMPle STATus
  *
  * @param Fact $event gedcom fact record
  * @param bool $anchor to print a link to placelist
  * @param bool $sub_records to print place subrecords
  * @param bool $lds to print LDS TEMPle and STATus
  *
  * @return string HTML
  */
 public static function formatFactPlace(Fact $event, $anchor = false, $sub_records = false, $lds = false)
 {
     if ($anchor) {
         // Show the full place name, for facts/events tab
         $html = '<a href="' . $event->getPlace()->getURL() . '">' . $event->getPlace()->getFullName() . '</a>';
     } else {
         // Abbreviate the place name, for chart boxes
         return ' - ' . $event->getPlace()->getShortName();
     }
     if ($sub_records) {
         $placerec = Functions::getSubRecord(2, '2 PLAC', $event->getGedcom());
         if (!empty($placerec)) {
             if (preg_match_all('/\\n3 (?:_HEB|ROMN) (.+)/', $placerec, $matches)) {
                 foreach ($matches[1] as $match) {
                     $wt_place = new Place($match, $event->getParent()->getTree());
                     $html .= ' - ' . $wt_place->getFullName();
                 }
             }
             $map_lati = "";
             $cts = preg_match('/\\d LATI (.*)/', $placerec, $match);
             if ($cts > 0) {
                 $map_lati = $match[1];
                 $html .= '<br><span class="label">' . GedcomTag::getLabel('LATI') . ': </span>' . $map_lati;
             }
             $map_long = '';
             $cts = preg_match('/\\d LONG (.*)/', $placerec, $match);
             if ($cts > 0) {
                 $map_long = $match[1];
                 $html .= ' <span class="label">' . GedcomTag::getLabel('LONG') . ': </span>' . $map_long;
             }
             if ($map_lati && $map_long) {
                 $map_lati = trim(strtr($map_lati, "NSEW,�", " - -. "));
                 // S5,6789 ==> -5.6789
                 $map_long = trim(strtr($map_long, "NSEW,�", " - -. "));
                 // E3.456� ==> 3.456
                 $html .= ' <a rel="nofollow" href="https://maps.google.com/maps?q=' . $map_lati . ',' . $map_long . '" class="icon-googlemaps" title="' . I18N::translate('Google Maps™') . '"></a>';
                 $html .= ' <a rel="nofollow" href="https://www.bing.com/maps/?lvl=15&cp=' . $map_lati . '~' . $map_long . '" class="icon-bing" title="' . I18N::translate('Bing Maps™') . '"></a>';
                 $html .= ' <a rel="nofollow" href="https://www.openstreetmap.org/#map=15/' . $map_lati . '/' . $map_long . '" class="icon-osm" title="' . I18N::translate('OpenStreetMap™') . '"></a>';
             }
             if (preg_match('/\\d NOTE (.*)/', $placerec, $match)) {
                 $html .= '<br>' . self::printFactNotes($placerec, 3);
             }
         }
     }
     if ($lds) {
         if (preg_match('/2 TEMP (.*)/', $event->getGedcom(), $match)) {
             $html .= '<br>' . I18N::translate('LDS temple') . ': ' . GedcomCodeTemp::templeName($match[1]);
         }
         if (preg_match('/2 STAT (.*)/', $event->getGedcom(), $match)) {
             $html .= '<br>' . I18N::translate('Status') . ': ' . GedcomCodeStat::statusName($match[1]);
             if (preg_match('/3 DATE (.*)/', $event->getGedcom(), $match)) {
                 $date = new Date($match[1]);
                 $html .= ', ' . GedcomTag::getLabel('STAT:DATE') . ': ' . $date->display();
             }
         }
     }
     return $html;
 }
Ejemplo n.º 3
0
/**
 * Print a form to add an individual or edit an individual’s name
 *
 * @param string     $nextaction
 * @param Individual $person
 * @param Family     $family
 * @param Fact       $name_fact
 * @param string     $famtag
 * @param string     $gender
 */
function print_indi_form($nextaction, Individual $person = null, Family $family = null, Fact $name_fact = null, $famtag = 'CHIL', $gender = 'U')
{
    global $WT_TREE, $bdm, $controller;
    if ($person) {
        $xref = $person->getXref();
    } elseif ($family) {
        $xref = $family->getXref();
    } else {
        $xref = 'new';
    }
    // Different cultures do surnames differently
    $surname_tradition = SurnameTradition::create($WT_TREE->getPreference('SURNAME_TRADITION'));
    $name_fields = array();
    if ($name_fact) {
        // Editing an existing name
        $name_fact_id = $name_fact->getFactId();
        $name_type = $name_fact->getAttribute('TYPE');
        $namerec = $name_fact->getGedcom();
        foreach (Config::standardNameFacts() as $tag) {
            if ($tag === 'NAME') {
                $name_fields[$tag] = $name_fact->getValue();
            } else {
                $name_fields[$tag] = $name_fact->getAttribute($tag);
            }
        }
        // Populate any missing 2 XXXX fields from the 1 NAME field
        $npfx_accept = implode('|', Config::namePrefixes());
        if (preg_match('/(((' . $npfx_accept . ')\\.? +)*)([^\\n\\/"]*)("(.*)")? *\\/(([a-z]{2,3} +)*)(.*)\\/ *(.*)/i', $name_fields['NAME'], $name_bits)) {
            if (empty($name_fields['NPFX'])) {
                $name_fields['NPFX'] = $name_bits[1];
            }
            if (empty($name_fields['SPFX']) && empty($name_fields['SURN'])) {
                $name_fields['SPFX'] = trim($name_bits[7]);
                // For names with two surnames, there will be four slashes.
                // Turn them into a list
                $name_fields['SURN'] = preg_replace('~/[^/]*/~', ',', $name_bits[9]);
            }
            if (empty($name_fields['GIVN'])) {
                $name_fields['GIVN'] = $name_bits[4];
            }
            if (empty($name_fields['NICK']) && !empty($name_bits[6]) && !preg_match('/^2 NICK/m', $namerec)) {
                $name_fields['NICK'] = $name_bits[6];
            }
        }
    } else {
        // Creating a new name
        $name_fact_id = null;
        $name_type = null;
        $namerec = null;
        // Populate the standard NAME field and subfields
        foreach (Config::standardNameFacts() as $tag) {
            $name_fields[$tag] = '';
        }
        // Inherit surname from parents, spouse or child
        if ($family) {
            $father = $family->getHusband();
            if ($father && $father->getFirstFact('NAME')) {
                $father_name = $father->getFirstFact('NAME')->getValue();
            } else {
                $father_name = '';
            }
            $mother = $family->getWife();
            if ($mother && $mother->getFirstFact('NAME')) {
                $mother_name = $mother->getFirstFact('NAME')->getValue();
            } else {
                $mother_name = '';
            }
        } else {
            $father = null;
            $mother = null;
            $father_name = '';
            $mother_name = '';
        }
        if ($person && $person->getFirstFact('NAME')) {
            $indi_name = $person->getFirstFact('NAME')->getValue();
        } else {
            $indi_name = '';
        }
        switch ($nextaction) {
            case 'add_child_to_family_action':
                $name_fields = $surname_tradition->newChildNames($father_name, $mother_name, $gender) + $name_fields;
                break;
            case 'add_child_to_individual_action':
                if ($person->getSex() === 'F') {
                    $name_fields = $surname_tradition->newChildNames('', $indi_name, $gender) + $name_fields;
                } else {
                    $name_fields = $surname_tradition->newChildNames($indi_name, '', $gender) + $name_fields;
                }
                break;
            case 'add_parent_to_individual_action':
                $name_fields = $surname_tradition->newParentNames($indi_name, $gender) + $name_fields;
                break;
            case 'add_spouse_to_family_action':
                if ($father) {
                    $name_fields = $surname_tradition->newSpouseNames($father_name, $gender) + $name_fields;
                } else {
                    $name_fields = $surname_tradition->newSpouseNames($mother_name, $gender) + $name_fields;
                }
                break;
            case 'add_spouse_to_individual_action':
                $name_fields = $surname_tradition->newSpouseNames($indi_name, $gender) + $name_fields;
                break;
            case 'add_unlinked_indi_action':
            case 'update':
                if ($surname_tradition->hasSurnames()) {
                    $name_fields['NAME'] = '//';
                }
                break;
        }
    }
    $bdm = '';
    // used to copy '1 SOUR' to '2 SOUR' for BIRT DEAT MARR
    echo '<div id="edit_interface-page">';
    echo '<h4>', $controller->getPageTitle(), '</h4>';
    FunctionsPrint::initializeCalendarPopup();
    echo '<form method="post" name="addchildform" onsubmit="return checkform();">';
    echo '<input type="hidden" name="ged" value="', $WT_TREE->getNameHtml(), '">';
    echo '<input type="hidden" name="action" value="', $nextaction, '">';
    echo '<input type="hidden" name="fact_id" value="', $name_fact_id, '">';
    echo '<input type="hidden" name="xref" value="', $xref, '">';
    echo '<input type="hidden" name="famtag" value="', $famtag, '">';
    echo '<input type="hidden" name="gender" value="', $gender, '">';
    echo '<input type="hidden" name="goto" value="">';
    // set by javascript
    echo Filter::getCsrf();
    echo '<table class="facts_table">';
    switch ($nextaction) {
        case 'add_child_to_family_action':
        case 'add_child_to_individual_action':
            // When adding a new child, specify the pedigree
            FunctionsEdit::addSimpleTag('0 PEDI');
            break;
        case 'update':
            // When adding/editing a name, specify the type
            FunctionsEdit::addSimpleTag('0 TYPE ' . $name_type, '', '', null, $person);
            break;
    }
    // First - new/existing standard name fields
    foreach ($name_fields as $tag => $value) {
        if (substr_compare($tag, '_', 0, 1) !== 0) {
            FunctionsEdit::addSimpleTag('0 ' . $tag . ' ' . $value);
        }
    }
    // Second - new/existing advanced name fields
    if ($surname_tradition->hasMarriedNames() || preg_match('/\\n2 _MARNM /', $namerec)) {
        $adv_name_fields = array('_MARNM' => '');
    } else {
        $adv_name_fields = array();
    }
    if (preg_match_all('/(' . WT_REGEX_TAG . ')/', $WT_TREE->getPreference('ADVANCED_NAME_FACTS'), $match)) {
        foreach ($match[1] as $tag) {
            $adv_name_fields[$tag] = '';
        }
    }
    foreach (array_keys($adv_name_fields) as $tag) {
        // Edit existing tags, grouped together
        if (preg_match_all('/2 ' . $tag . ' (.+)/', $namerec, $match)) {
            foreach ($match[1] as $value) {
                FunctionsEdit::addSimpleTag('2 ' . $tag . ' ' . $value, '', GedcomTag::getLabel('NAME:' . $tag, $person));
                if ($tag === '_MARNM') {
                    preg_match_all('/\\/([^\\/]*)\\//', $value, $matches);
                    FunctionsEdit::addSimpleTag('2 _MARNM_SURN ' . implode(',', $matches[1]));
                }
            }
        }
        // Allow a new tag to be entered
        if (!array_key_exists($tag, $name_fields)) {
            FunctionsEdit::addSimpleTag('0 ' . $tag, '', GedcomTag::getLabel('NAME:' . $tag, $person));
            if ($tag === '_MARNM') {
                FunctionsEdit::addSimpleTag('0 _MARNM_SURN');
            }
        }
    }
    // Third - new/existing custom name fields
    foreach ($name_fields as $tag => $value) {
        if (substr_compare($tag, '_', 0, 1) === 0) {
            FunctionsEdit::addSimpleTag('0 ' . $tag . ' ' . $value);
            if ($tag === '_MARNM') {
                preg_match_all('/\\/([^\\/]*)\\//', $value, $matches);
                FunctionsEdit::addSimpleTag('2 _MARNM_SURN ' . implode(',', $matches[1]));
            }
        }
    }
    // Fourth - SOUR, NOTE, _CUSTOM, etc.
    if ($namerec) {
        $gedlines = explode("\n", $namerec);
        // -- find the number of lines in the record
        $fields = explode(' ', $gedlines[0]);
        $glevel = $fields[0];
        $level = $glevel;
        $type = trim($fields[1]);
        $tags = array();
        $i = 0;
        do {
            if ($type !== 'TYPE' && !array_key_exists($type, $name_fields) && !array_key_exists($type, $adv_name_fields)) {
                $text = '';
                for ($j = 2; $j < count($fields); $j++) {
                    if ($j > 2) {
                        $text .= ' ';
                    }
                    $text .= $fields[$j];
                }
                while ($i + 1 < count($gedlines) && preg_match('/' . ($level + 1) . ' CONT ?(.*)/', $gedlines[$i + 1], $cmatch) > 0) {
                    $text .= "\n" . $cmatch[2];
                    $i++;
                }
                FunctionsEdit::addSimpleTag($level . ' ' . $type . ' ' . $text);
            }
            $tags[] = $type;
            $i++;
            if (isset($gedlines[$i])) {
                $fields = explode(' ', $gedlines[$i]);
                $level = $fields[0];
                if (isset($fields[1])) {
                    $type = $fields[1];
                }
            }
        } while ($level > $glevel && $i < count($gedlines));
    }
    // If we are adding a new individual, add the basic details
    if ($nextaction !== 'update') {
        echo '</table><br><table class="facts_table">';
        // 1 SEX
        if ($famtag === 'HUSB' || $gender === 'M') {
            FunctionsEdit::addSimpleTag("0 SEX M");
        } elseif ($famtag === 'WIFE' || $gender === 'F') {
            FunctionsEdit::addSimpleTag('0 SEX F');
        } else {
            FunctionsEdit::addSimpleTag('0 SEX');
        }
        $bdm = 'BD';
        if (preg_match_all('/(' . WT_REGEX_TAG . ')/', $WT_TREE->getPreference('QUICK_REQUIRED_FACTS'), $matches)) {
            foreach ($matches[1] as $match) {
                if (!in_array($match, explode('|', WT_EVENTS_DEAT))) {
                    FunctionsEdit::addSimpleTags($match);
                }
            }
        }
        //-- if adding a spouse add the option to add a marriage fact to the new family
        if ($nextaction === 'add_spouse_to_individual_action' || $nextaction === 'add_spouse_to_family_action') {
            $bdm .= 'M';
            if (preg_match_all('/(' . WT_REGEX_TAG . ')/', $WT_TREE->getPreference('QUICK_REQUIRED_FAMFACTS'), $matches)) {
                foreach ($matches[1] as $match) {
                    FunctionsEdit::addSimpleTags($match);
                }
            }
        }
        if (preg_match_all('/(' . WT_REGEX_TAG . ')/', $WT_TREE->getPreference('QUICK_REQUIRED_FACTS'), $matches)) {
            foreach ($matches[1] as $match) {
                if (in_array($match, explode('|', WT_EVENTS_DEAT))) {
                    FunctionsEdit::addSimpleTags($match);
                }
            }
        }
    }
    echo keep_chan($person);
    echo '</table>';
    if ($nextaction === 'update') {
        // GEDCOM 5.5.1 spec says NAME doesn’t get a OBJE
        FunctionsEdit::printAddLayer('SOUR');
        FunctionsEdit::printAddLayer('NOTE');
        FunctionsEdit::printAddLayer('SHARED_NOTE');
        FunctionsEdit::printAddLayer('RESN');
    } else {
        FunctionsEdit::printAddLayer('SOUR', 1);
        FunctionsEdit::printAddLayer('NOTE', 1);
        FunctionsEdit::printAddLayer('SHARED_NOTE', 1);
        FunctionsEdit::printAddLayer('RESN', 1);
    }
    // If we are editing an existing name, allow raw GEDCOM editing
    if ($name_fact && (Auth::isAdmin() || $WT_TREE->getPreference('SHOW_GEDCOM_RECORD'))) {
        echo '<br><br><a href="edit_interface.php?action=editrawfact&amp;xref=', $xref, '&amp;fact_id=', $name_fact->getFactId(), '&amp;ged=', $WT_TREE->getNameUrl(), '">', I18N::translate('Edit raw GEDCOM'), '</a>';
    }
    echo '<p id="save-cancel">';
    echo '<input type="submit" class="save" value="', I18N::translate('save'), '">';
    if (preg_match('/^add_(child|spouse|parent|unlinked_indi)/', $nextaction)) {
        echo '<input type="submit" class="save" value="', I18N::translate('go to new individual'), '" onclick="document.addchildform.goto.value=\'new\';">';
    }
    echo '<input type="button" class="cancel" value="', I18N::translate('close'), '" onclick="window.close();">';
    echo '</p>';
    echo '</form>';
    $controller->addInlineJavascript('
	SURNAME_TRADITION="' . $WT_TREE->getPreference('SURNAME_TRADITION') . '";
	gender="' . $gender . '";
	famtag="' . $famtag . '";
	function trim(str) {
		str=str.replace(/\\s\\s+/g, " ");
		return str.replace(/(^\\s+)|(\\s+$)/g, "");
	}

	function lang_class(str) {
		if (str.match(/[\\u0370-\\u03FF]/)) return "greek";
		if (str.match(/[\\u0400-\\u04FF]/)) return "cyrillic";
		if (str.match(/[\\u0590-\\u05FF]/)) return "hebrew";
		if (str.match(/[\\u0600-\\u06FF]/)) return "arabic";
		return "latin"; // No matched text implies latin :-)
	}

	// Generate a full name from the name components
	function generate_name() {
		var npfx = jQuery("#NPFX").val();
		var givn = jQuery("#GIVN").val();
		var spfx = jQuery("#SPFX").val();
		var surn = jQuery("#SURN").val();
		var nsfx = jQuery("#NSFX").val();
		if (SURNAME_TRADITION === "polish" && (gender === "F" || famtag === "WIFE")) {
			surn = surn.replace(/ski$/, "ska");
			surn = surn.replace(/cki$/, "cka");
			surn = surn.replace(/dzki$/, "dzka");
			surn = surn.replace(/żki$/, "żka");
		}
		// Commas are used in the GIVN and SURN field to separate lists of surnames.
		// For example, to differentiate the two Spanish surnames from an English
		// double-barred name.
		// Commas *may* be used in other fields, and will form part of the NAME.
		if (WT_LOCALE=="vi" || WT_LOCALE=="hu") {
			// Default format: /SURN/ GIVN
			return trim(npfx+" /"+trim(spfx+" "+surn).replace(/ *, */g, " ")+"/ "+givn.replace(/ *, */g, " ")+" "+nsfx);
		} else if (WT_LOCALE=="zh") {
			// Default format: /SURN/GIVN
			return trim(npfx+" /"+trim(spfx+" "+surn).replace(/ *, */g, " ")+"/"+givn.replace(/ *, */g, " ")+" "+nsfx);
		} else {
			// Default format: GIVN /SURN/
			return trim(npfx+" "+givn.replace(/ *, */g, " ")+" /"+trim(spfx+" "+surn).replace(/ *, */g, " ")+"/ "+nsfx);
		}
	}

	// Update the NAME and _MARNM fields from the name components
	// and also display the value in read-only "gedcom" format.
	function updatewholename() {
		// Don’t update the name if the user manually changed it
		if (manualChange) {
			return;
		}
		var npfx = jQuery("#NPFX").val();
		var givn = jQuery("#GIVN").val();
		var spfx = jQuery("#SPFX").val();
		var surn = jQuery("#SURN").val();
		var nsfx = jQuery("#NSFX").val();
		var name = generate_name();
		jQuery("#NAME").val(name);
		jQuery("#NAME_display").text(name);
		// Married names inherit some NSFX values, but not these
		nsfx = nsfx.replace(/^(I|II|III|IV|V|VI|Junior|Jr\\.?|Senior|Sr\\.?)$/i, "");
		// Update _MARNM field from _MARNM_SURN field and display it
		// Be careful of mixing latin/hebrew/etc. character sets.
		var ip = document.getElementsByTagName("input");
		var marnm_id = "";
		var romn = "";
		var heb = "";
		for (var i = 0; i < ip.length; i++) {
			var val = trim(ip[i].value);
			if (ip[i].id.indexOf("_HEB") === 0)
				heb = val;
			if (ip[i].id.indexOf("ROMN") === 0)
				romn = val;
			if (ip[i].id.indexOf("_MARNM") === 0) {
				if (ip[i].id.indexOf("_MARNM_SURN") === 0) {
					var msurn = "";
					if (val !== "") {
						var lc = lang_class(document.getElementById(ip[i].id).value);
						if (lang_class(name) === lc)
							msurn = trim(npfx + " " + givn + " /" + val + "/ " + nsfx);
						else if (lc === "hebrew")
							msurn = heb.replace(/\\/.*\\//, "/" + val + "/");
						else if (lang_class(romn) === lc)
							msurn = romn.replace(/\\/.*\\//, "/" + val + "/");
					}
					document.getElementById(marnm_id).value = msurn;
					document.getElementById(marnm_id+"_display").innerHTML = msurn;
				} else {
					marnm_id = ip[i].id;
				}
			}
		}
	}

	// Toggle the name editor fields between
	// <input type="hidden"> <span style="display:inline">
	// <input type="text">   <span style="display:hidden">
	var oldName = "";

	// Calls to generate_name() trigger an update - hence need to
	// set the manual change to true first.  We are probably
	// listening to the wrong events on the input fields...
	var manualChange = true;
	manualChange = generate_name() !== jQuery("#NAME").val();

	function convertHidden(eid) {
		var input1 = jQuery("#" + eid);
		var input2 = jQuery("#" + eid + "_display");
		// Note that IE does not allow us to change the type of an input, so we must create a new one.
		if (input1.attr("type")=="hidden") {
			input1.replaceWith(input1.clone().attr("type", "text"));
			input2.hide();
		} else {
			input1.replaceWith(input1.clone().attr("type", "hidden"));
			input2.show();
		}
	}

	/**
	 * if the user manually changed the NAME field, then update the textual
	 * HTML representation of it
	 * If the value changed set manualChange to true so that changing
	 * the other fields doesn’t change the NAME line
	 */
	function updateTextName(eid) {
		var element = document.getElementById(eid);
		if (element) {
			if (element.value!=oldName) manualChange = true;
			var delement = document.getElementById(eid+"_display");
			if (delement) {
				delement.innerHTML = element.value;
			}
		}
	}

	function checkform() {
		var ip=document.getElementsByTagName("input");
		for (var i=0; i<ip.length; i++) {
			// ADD slashes to _HEB and _AKA names
			if (ip[i].id.indexOf("_AKA")==0 || ip[i].id.indexOf("_HEB")==0 || ip[i].id.indexOf("ROMN")==0)
				if (ip[i].value.indexOf("/")<0 && ip[i].value!="")
					ip[i].value=ip[i].value.replace(/([^\\s]+)\\s*$/, "/$1/");
			// Blank out temporary _MARNM_SURN
			if (ip[i].id.indexOf("_MARNM_SURN")==0)
					ip[i].value="";
			// Convert "xxx yyy" and "xxx y yyy" surnames to "xxx,yyy"
			if ((SURNAME_TRADITION=="spanish" || "SURNAME_TRADITION"=="portuguese") && ip[i].id.indexOf("SURN")==0) {
				ip[i].value=document.forms[0].SURN.value.replace(/^\\s*([^\\s,]{2,})\\s+([iIyY] +)?([^\\s,]{2,})\\s*$/, "$1,$3");
			}
		}
		return true;
	}

	// If the name isn’t initially formed from the components in a standard way,
	// then don’t automatically update it.
	if (document.getElementById("NAME").value!=generate_name() && document.getElementById("NAME").value!="//") {
		convertHidden("NAME");
	}
	');
    echo '</div>';
}
Ejemplo n.º 4
0
 /**
  * A multi-key sort
  * 1. First divide the facts into two arrays one set with dates and one set without dates
  * 2. Sort each of the two new arrays, the date using the compare date function, the non-dated
  * using the compare type function
  * 3. Then merge the arrays back into the original array using the compare type function
  *
  * @param Fact[] $arr
  */
 public static function sortFacts(&$arr)
 {
     $dated = array();
     $nondated = array();
     //-- split the array into dated and non-dated arrays
     $order = 0;
     foreach ($arr as $event) {
         $event->sortOrder = $order;
         $order++;
         if ($event->getDate()->isOk()) {
             $dated[] = $event;
         } else {
             $nondated[] = $event;
         }
     }
     //-- sort each type of array
     usort($dated, '\\Fisharebest\\Webtrees\\Fact::compareDate');
     usort($nondated, '\\Fisharebest\\Webtrees\\Fact::compareType');
     //-- merge the arrays back together comparing by Facts
     $dc = count($dated);
     $nc = count($nondated);
     $i = 0;
     $j = 0;
     $k = 0;
     // while there is anything in the dated array continue merging
     while ($i < $dc) {
         // compare each fact by type to merge them in order
         if ($j < $nc && Fact::compareType($dated[$i], $nondated[$j]) > 0) {
             $arr[$k] = $nondated[$j];
             $j++;
         } else {
             $arr[$k] = $dated[$i];
             $i++;
         }
         $k++;
     }
     // get anything that might be left in the nondated array
     while ($j < $nc) {
         $arr[$k] = $nondated[$j];
         $j++;
         $k++;
     }
 }
Ejemplo n.º 5
0
 /**
  * Print a fact for an individual.
  *
  * @param Fact $event
  */
 public function printTimeFact(Fact $event)
 {
     global $basexoffset, $baseyoffset, $factcount, $placements;
     $desc = $event->getValue();
     // check if this is a family fact
     $gdate = $event->getDate();
     $date = $gdate->minimumDate();
     $date = $date->convertToCalendar('gregorian');
     $year = $date->y;
     $month = max(1, $date->m);
     $day = max(1, $date->d);
     $xoffset = $basexoffset + 22;
     $yoffset = $baseyoffset + ($year - $this->baseyear) * $this->scale - $this->scale;
     $yoffset = $yoffset + $month / 12 * $this->scale;
     $yoffset = $yoffset + $day / 30 * ($this->scale / 12);
     $yoffset = (int) $yoffset;
     $place = (int) ($yoffset / $this->bheight);
     $i = 1;
     $j = 0;
     $tyoffset = 0;
     while (isset($placements[$place])) {
         if ($i === $j) {
             $tyoffset = $this->bheight * $i;
             $i++;
         } else {
             $tyoffset = -1 * $this->bheight * $j;
             $j++;
         }
         $place = (int) (($yoffset + $tyoffset) / $this->bheight);
     }
     $yoffset += $tyoffset;
     $xoffset += abs($tyoffset);
     $placements[$place] = $yoffset;
     echo "<div id=\"fact{$factcount}\" style=\"position:absolute; " . (I18N::direction() === 'ltr' ? 'left: ' . $xoffset : 'right: ' . $xoffset) . 'px; top:' . $yoffset . "px; font-size: 8pt; height: " . $this->bheight . "px;\" onmousedown=\"factMouseDown(this, '" . $factcount . "', " . ($yoffset - $tyoffset) . ");\">";
     echo '<table cellspacing="0" cellpadding="0" border="0" style="cursor: hand;"><tr><td>';
     echo '<img src="' . Theme::theme()->parameter('image-hline') . '" name="boxline' . $factcount . '" id="boxline' . $factcount . '" height="3" width="10" style="padding-';
     if (I18N::direction() === 'ltr') {
         echo 'left: 3px;">';
     } else {
         echo 'right: 3px;">';
     }
     $col = array_search($event->getParent(), $this->people);
     if ($col === false) {
         // Marriage event - use the color of the husband
         $col = array_search($event->getParent()->getHusband(), $this->people);
     }
     if ($col === false) {
         // Marriage event - use the color of the wife
         $col = array_search($event->getParent()->getWife(), $this->people);
     }
     $col = $col % 6;
     echo '</td><td class="person' . $col . '">';
     if (count($this->people) > 6) {
         // We only have six colours, so show naes if more than this number
         echo $event->getParent()->getFullName() . ' — ';
     }
     $record = $event->getParent();
     echo $event->getLabel();
     echo ' — ';
     if ($record instanceof Individual) {
         echo FunctionsPrint::formatFactDate($event, $record, false, false);
     } elseif ($record instanceof Family) {
         echo $gdate->display();
         if ($record->getHusband() && $record->getHusband()->getBirthDate()->isOK()) {
             $ageh = FunctionsDate::getAgeAtEvent(Date::getAgeGedcom($record->getHusband()->getBirthDate(), $gdate));
         } else {
             $ageh = null;
         }
         if ($record->getWife() && $record->getWife()->getBirthDate()->isOK()) {
             $agew = FunctionsDate::getAgeAtEvent(Date::getAgeGedcom($record->getWife()->getBirthDate(), $gdate));
         } else {
             $agew = null;
         }
         if ($ageh && $agew) {
             echo '<span class="age"> ', I18N::translate('Husband’s age'), ' ', $ageh, ' ', I18N::translate('Wife’s age'), ' ', $agew, '</span>';
         } elseif ($ageh) {
             echo '<span class="age"> ', I18N::translate('Age'), ' ', $ageh, '</span>';
         } elseif ($agew) {
             echo '<span class="age"> ', I18N::translate('Age'), ' ', $ageh, '</span>';
         }
     }
     echo ' ' . Filter::escapeHtml($desc);
     if (!$event->getPlace()->isEmpty()) {
         echo ' — ' . $event->getPlace()->getShortName();
     }
     // Print spouses names for family events
     if ($event->getParent() instanceof Family) {
         echo ' — <a href="', $event->getParent()->getHtmlUrl(), '">', $event->getParent()->getFullName(), '</a>';
     }
     echo '</td></tr></table>';
     echo '</div>';
     if (I18N::direction() === 'ltr') {
         $img = 'image-dline2';
         $ypos = '0%';
     } else {
         $img = 'image-dline';
         $ypos = '100%';
     }
     $dyoffset = $yoffset - $tyoffset + $this->bheight / 3;
     if ($tyoffset < 0) {
         $dyoffset = $yoffset + $this->bheight / 3;
         if (I18N::direction() === 'ltr') {
             $img = 'image-dline';
             $ypos = '100%';
         } else {
             $img = 'image-dline2';
             $ypos = '0%';
         }
     }
     // Print the diagonal line
     echo '<div id="dbox' . $factcount . '" style="position:absolute; ' . (I18N::direction() === 'ltr' ? 'left: ' . ($basexoffset + 25) : 'right: ' . ($basexoffset + 25)) . 'px; top:' . $dyoffset . 'px; font-size: 8pt; height: ' . abs($tyoffset) . 'px; width: ' . abs($tyoffset) . 'px;';
     echo ' background-image: url(\'' . Theme::theme()->parameter($img) . '\');';
     echo ' background-position: 0% ' . $ypos . ';">';
     echo '</div>';
 }
Ejemplo n.º 6
0
 /**
  * Function checkFact
  *
  * Does this fact meet the search criteria?
  *
  * @todo This function is public to support the PHP5.3 closure workaround.
  *
  * @param  Fact $fact
  *
  * @return bool
  */
 public function checkFact(Fact $fact)
 {
     $valid = !in_array($fact->getTag(), $this->nonfacts);
     if ($valid && $this->place_obj) {
         $valid = stripos($fact->getPlace()->getGedcomName(), $this->place_obj->getGedcomName()) !== false;
     }
     if ($valid && $this->startDate) {
         if ($this->strictDate && $this->calendar !== $this->defaultCalendar) {
             $valid = stripos($fact->getAttribute('DATE'), $this->calendar) !== false;
         }
         if ($valid) {
             $date = $fact->getDate();
             $valid = $date->isOK() && Date::compare($date, $this->startDate) >= 0 && Date::compare($date, $this->endDate) <= 0;
         }
     }
     return $valid;
 }
Ejemplo n.º 7
0
 /**
  * Format fact place to display short
  *
  * @param \Fisharebest\Webtrees\Fact $eventObj Fact to display date
  * @param string $format Format of the place
  * @param boolean $anchor option to print a link to placelist
  * @return string HTML code for short place
  */
 public static function formatFactPlaceShort(\Fisharebest\Webtrees\Fact $fact, $format, $anchor = false)
 {
     $html = '';
     if ($fact === null) {
         return $html;
     }
     $place = $fact->getPlace();
     if ($place) {
         $dplace = new Place($place);
         $html .= $dplace->htmlFormattedName($format, $anchor);
     }
     return $html;
 }
 /**
  * Get any historical events.
  *
  * @param Individual $person
  *
  * @return Fact[]
  */
 private static function historicalFacts(Individual $person)
 {
     $SHOW_RELATIVES_EVENTS = $person->getTree()->getPreference('SHOW_RELATIVES_EVENTS');
     $facts = array();
     if ($SHOW_RELATIVES_EVENTS) {
         // Only include events between birth and death
         $birt_date = $person->getEstimatedBirthDate();
         $deat_date = $person->getEstimatedDeathDate();
         if (file_exists(Site::getPreference('INDEX_DIRECTORY') . 'histo.' . WT_LOCALE . '.php')) {
             $histo = array();
             require Site::getPreference('INDEX_DIRECTORY') . 'histo.' . WT_LOCALE . '.php';
             foreach ($histo as $hist) {
                 // Earlier versions of the WIKI encouraged people to use HTML entities,
                 // rather than UTF8 encoding.
                 $hist = html_entity_decode($hist, ENT_QUOTES, 'UTF-8');
                 $fact = new Fact($hist, $person, 'histo');
                 $sdate = $fact->getDate();
                 if ($sdate->isOK() && Date::compare($birt_date, $sdate) <= 0 && Date::compare($sdate, $deat_date) <= 0) {
                     $facts[] = $fact;
                 }
             }
         }
     }
     return $facts;
 }
Ejemplo n.º 9
0
 /**
  * Static method to compare two events by their type.
  *
  * @param Fact $a Fact one
  * @param Fact $b Fact two
  *
  * @return int
  */
 public static function compareType(Fact $a, Fact $b)
 {
     global $factsort;
     if (empty($factsort)) {
         $factsort = array_flip(array('BIRT', '_HNM', 'ALIA', '_AKA', '_AKAN', 'ADOP', '_ADPF', '_ADPF', '_BRTM', 'CHR', 'BAPM', 'FCOM', 'CONF', 'BARM', 'BASM', 'EDUC', 'GRAD', '_DEG', 'EMIG', 'IMMI', 'NATU', '_MILI', '_MILT', 'ENGA', 'MARB', 'MARC', 'MARL', '_MARI', '_MBON', 'MARR', 'MARR_CIVIL', 'MARR_RELIGIOUS', 'MARR_PARTNERS', 'MARR_UNKNOWN', '_COML', '_STAT', '_SEPR', 'DIVF', 'MARS', '_BIRT_CHIL', 'DIV', 'ANUL', '_BIRT_', '_MARR_', '_DEAT_', '_BURI_', 'CENS', 'OCCU', 'RESI', 'PROP', 'CHRA', 'RETI', 'FACT', 'EVEN', '_NMR', '_NMAR', 'NMR', 'NCHI', 'WILL', '_HOL', '_????_', 'DEAT', '_FNRL', 'CREM', 'BURI', '_INTE', '_YART', '_NLIV', 'PROB', 'TITL', 'COMM', 'NATI', 'CITN', 'CAST', 'RELI', 'SSN', 'IDNO', 'TEMP', 'SLGC', 'BAPL', 'CONL', 'ENDL', 'SLGS', 'ADDR', 'PHON', 'EMAIL', '_EMAIL', 'EMAL', 'FAX', 'WWW', 'URL', '_URL', 'FILE', 'AFN', 'REFN', '_PRMN', 'REF', 'RIN', '_UID', 'OBJE', 'NOTE', 'SOUR', 'CHAN', '_TODO'));
     }
     // Facts from same families stay grouped together
     // Keep MARR and DIV from the same families from mixing with events from other FAMs
     // Use the original order in which the facts were added
     if ($a->parent instanceof Family && $b->parent instanceof Family && $a->parent !== $b->parent) {
         return $a->sortOrder - $b->sortOrder;
     }
     $atag = $a->getTag();
     $btag = $b->getTag();
     // Events not in the above list get mapped onto one that is.
     if (!array_key_exists($atag, $factsort)) {
         if (preg_match('/^(_(BIRT|MARR|DEAT|BURI)_)/', $atag, $match)) {
             $atag = $match[1];
         } else {
             $atag = "_????_";
         }
     }
     if (!array_key_exists($btag, $factsort)) {
         if (preg_match('/^(_(BIRT|MARR|DEAT|BURI)_)/', $btag, $match)) {
             $btag = $match[1];
         } else {
             $btag = "_????_";
         }
     }
     // - Don't let dated after DEAT/BURI facts sort non-dated facts before DEAT/BURI
     // - Treat dated after BURI facts as BURI instead
     if ($a->getAttribute('DATE') !== null && $factsort[$atag] > $factsort['BURI'] && $factsort[$atag] < $factsort['CHAN']) {
         $atag = 'BURI';
     }
     if ($b->getAttribute('DATE') !== null && $factsort[$btag] > $factsort['BURI'] && $factsort[$btag] < $factsort['CHAN']) {
         $btag = 'BURI';
     }
     $ret = $factsort[$atag] - $factsort[$btag];
     // If facts are the same then put dated facts before non-dated facts
     if ($ret == 0) {
         if ($a->getAttribute('DATE') !== null && $b->getAttribute('DATE') === null) {
             return -1;
         }
         if ($b->getAttribute('DATE') !== null && $a->getAttribute('DATE') === null) {
             return 1;
         }
         // If no sorting preference, then keep original ordering
         $ret = $a->sortOrder - $b->sortOrder;
     }
     return $ret;
 }
Ejemplo n.º 10
0
 /**
  * Split the record into facts
  */
 private function parseFacts()
 {
     // Split the record into facts
     if ($this->gedcom) {
         $gedcom_facts = preg_split('/\\n(?=1)/s', $this->gedcom);
         array_shift($gedcom_facts);
     } else {
         $gedcom_facts = array();
     }
     if ($this->pending) {
         $pending_facts = preg_split('/\\n(?=1)/s', $this->pending);
         array_shift($pending_facts);
     } else {
         $pending_facts = array();
     }
     $this->facts = array();
     foreach ($gedcom_facts as $gedcom_fact) {
         $fact = new Fact($gedcom_fact, $this, md5($gedcom_fact));
         if ($this->pending !== null && !in_array($gedcom_fact, $pending_facts)) {
             $fact->setPendingDeletion();
         }
         $this->facts[] = $fact;
     }
     foreach ($pending_facts as $pending_fact) {
         if (!in_array($pending_fact, $gedcom_facts)) {
             $fact = new Fact($pending_fact, $this, md5($pending_fact));
             $fact->setPendingAddition();
             $this->facts[] = $fact;
         }
     }
 }
Ejemplo n.º 11
0
 /**
  * Display an icon for this fact.
  *
  * @param Fact $fact
  *
  * @return string
  */
 public function icon(Fact $fact)
 {
     $icon = 'images/facts/' . $fact->getTag() . '.png';
     $dir = substr($this->assetUrl(), strlen(WT_STATIC_URL));
     if (file_exists($dir . $icon)) {
         return '<img src="' . $this->assetUrl() . $icon . '" title="' . GedcomTag::getLabel($fact->getTag()) . '">';
     } elseif (file_exists($dir . 'images/facts/NULL.png')) {
         // Spacer image - for alignment - until we move to a sprite.
         return '<img src="' . Theme::theme()->assetUrl() . 'images/facts/NULL.png">';
     } else {
         return '';
     }
 }
 /**
  * Based on function print_name_record() in /app/Controller/IndividualController.php
  * 
  * @param Fact $event
  * @return array
  */
 protected function getPrimaryName(Fact $event)
 {
     $factrec = $event->getGedCom();
     // Create a dummy record, so we can extract the formatted NAME value from the event.
     $dummy = new Individual('xref', "0 @xref@ INDI\n1 DEAT Y\n" . $factrec, null, $event->getParent()->getTree());
     $all_names = $dummy->getAllNames();
     return $all_names[0];
 }
Ejemplo n.º 13
0
 /**
  * @param Fact $fact
  *
  * @return array
  */
 private function getPlaceData(Fact $fact)
 {
     $result = array();
     $has_latitude = preg_match('/\\n4 LATI (.+)/', $fact->getGedcom(), $match1);
     $has_longitude = preg_match('/\\n4 LONG (.+)/', $fact->getGedcom(), $match2);
     // If co-ordinates are stored in the GEDCOM then use them
     if ($has_latitude && $has_longitude) {
         $result = array('index' => 'ID' . $match1[1] . $match2[1], 'mapdata' => array('class' => 'optionbox', 'place' => $fact->getPlace()->getFullName(), 'tooltip' => $fact->getPlace()->getGedcomName(), 'lat' => strtr($match1[1], array('N' => '', 'S' => '-', ',' => '.')), 'lng' => strtr($match2[1], array('E' => '', 'W' => '-', ',' => '.')), 'pl_icon' => '', 'pl_zoom' => '0', 'sv_bearing' => '0', 'sv_elevation' => '0', 'sv_lati' => '0', 'sv_long' => '0', 'sv_zoom' => '0', 'events' => ''));
     } else {
         $place_location = $this->getLatitudeAndLongitudeFromPlaceLocation($fact->getPlace()->getGedcomName());
         if ($place_location && $place_location->pl_lati && $place_location->pl_long) {
             $result = array('index' => 'ID' . $place_location->pl_lati . $place_location->pl_long, 'mapdata' => array('class' => 'optionbox', 'place' => $fact->getPlace()->getFullName(), 'tooltip' => $fact->getPlace()->getGedcomName(), 'lat' => strtr($place_location->pl_lati, array('N' => '', 'S' => '-', ',' => '.')), 'lng' => strtr($place_location->pl_long, array('E' => '', 'W' => '-', ',' => '.')), 'pl_icon' => $place_location->pl_icon, 'pl_zoom' => $place_location->pl_zoom, 'sv_bearing' => $place_location->sv_bearing, 'sv_elevation' => $place_location->sv_elevation, 'sv_lati' => $place_location->sv_lati, 'sv_long' => $place_location->sv_long, 'sv_zoom' => $place_location->sv_zoom, 'events' => ''));
         }
     }
     return $result;
 }
Ejemplo n.º 14
0
 /**
  * Create a form to edit a Fact object.
  *
  * @param GedcomRecord $record
  * @param Fact $fact
  *
  * @return string
  */
 public static function createEditForm(GedcomRecord $record, Fact $fact)
 {
     global $tags, $WT_TREE;
     $pid = $record->getXref();
     $tags = array();
     $gedlines = explode("\n", $fact->getGedcom());
     $linenum = 0;
     $fields = explode(' ', $gedlines[$linenum]);
     $glevel = $fields[0];
     $level = $glevel;
     $type = $fact->getTag();
     $parent = $fact->getParent();
     $level0type = $parent::RECORD_TYPE;
     $level1type = $type;
     $i = $linenum;
     $inSource = false;
     $levelSource = 0;
     $add_date = true;
     // List of tags we would expect at the next level
     // NB add_missing_subtags() already takes care of the simple cases
     // where a level 1 tag is missing a level 2 tag. Here we only need to
     // handle the more complicated cases.
     $expected_subtags = array('SOUR' => array('PAGE', 'DATA'), 'DATA' => array('TEXT'), 'PLAC' => array('MAP'), 'MAP' => array('LATI', 'LONG'));
     if ($record->getTree()->getPreference('FULL_SOURCES')) {
         $expected_subtags['SOUR'][] = 'QUAY';
         $expected_subtags['DATA'][] = 'DATE';
     }
     if (preg_match_all('/(' . WT_REGEX_TAG . ')/', $record->getTree()->getPreference('ADVANCED_PLAC_FACTS'), $match)) {
         $expected_subtags['PLAC'] = array_merge($match[1], $expected_subtags['PLAC']);
     }
     $stack = array(0 => $level0type);
     // Loop on existing tags :
     while (true) {
         // Keep track of our hierarchy, e.g. 1=>BIRT, 2=>PLAC, 3=>FONE
         $stack[(int) $level] = $type;
         // Merge them together, e.g. BIRT:PLAC:FONE
         $label = implode(':', array_slice($stack, 1, $level));
         $text = '';
         for ($j = 2; $j < count($fields); $j++) {
             if ($j > 2) {
                 $text .= ' ';
             }
             $text .= $fields[$j];
         }
         $text = rtrim($text);
         while ($i + 1 < count($gedlines) && preg_match("/" . ($level + 1) . ' CONT ?(.*)/', $gedlines[$i + 1], $cmatch) > 0) {
             $text .= "\n" . $cmatch[1];
             $i++;
         }
         if ($type === 'SOUR') {
             $inSource = true;
             $levelSource = $level;
         } elseif ($levelSource >= $level) {
             $inSource = false;
         }
         if ($type !== 'DATA' && $type !== 'CONT') {
             $tags[] = $type;
             $person = Individual::getInstance($pid, $WT_TREE);
             $subrecord = $level . ' ' . $type . ' ' . $text;
             if ($inSource && $type === 'DATE') {
                 self::addSimpleTag($subrecord, '', GedcomTag::getLabel($label, $person));
             } elseif (!$inSource && $type === 'DATE') {
                 self::addSimpleTag($subrecord, $level1type, GedcomTag::getLabel($label, $person));
                 if ($level === '2') {
                     // We already have a date - no need to add one.
                     $add_date = false;
                 }
             } elseif ($type === 'STAT') {
                 self::addSimpleTag($subrecord, $level1type, GedcomTag::getLabel($label, $person));
             } elseif ($level0type === 'REPO') {
                 $repo = Repository::getInstance($pid, $WT_TREE);
                 self::addSimpleTag($subrecord, $level0type, GedcomTag::getLabel($label, $repo));
             } else {
                 self::addSimpleTag($subrecord, $level0type, GedcomTag::getLabel($label, $person));
             }
         }
         // Get a list of tags present at the next level
         $subtags = array();
         for ($ii = $i + 1; isset($gedlines[$ii]) && preg_match('/^\\s*(\\d+)\\s+(\\S+)/', $gedlines[$ii], $mm) && $mm[1] > $level; ++$ii) {
             if ($mm[1] == $level + 1) {
                 $subtags[] = $mm[2];
             }
         }
         // Insert missing tags
         if (!empty($expected_subtags[$type])) {
             foreach ($expected_subtags[$type] as $subtag) {
                 if (!in_array($subtag, $subtags)) {
                     if (!$inSource || $subtag !== 'DATA') {
                         self::addSimpleTag($level + 1 . ' ' . $subtag, '', GedcomTag::getLabel($label . ':' . $subtag));
                     }
                     if (!empty($expected_subtags[$subtag])) {
                         foreach ($expected_subtags[$subtag] as $subsubtag) {
                             self::addSimpleTag($level + 2 . ' ' . $subsubtag, '', GedcomTag::getLabel($label . ':' . $subtag . ':' . $subsubtag));
                         }
                     }
                 }
             }
         }
         // Awkward special cases
         if ($level == 2 && $type === 'DATE' && in_array($level1type, Config::dateAndTime()) && !in_array('TIME', $subtags)) {
             self::addSimpleTag('3 TIME');
             // TIME is NOT a valid 5.5.1 tag
         }
         if ($level == 2 && $type === 'STAT' && GedcomCodeTemp::isTagLDS($level1type) && !in_array('DATE', $subtags)) {
             self::addSimpleTag('3 DATE', '', GedcomTag::getLabel('STAT:DATE'));
         }
         $i++;
         if (isset($gedlines[$i])) {
             $fields = explode(' ', $gedlines[$i]);
             $level = $fields[0];
             if (isset($fields[1])) {
                 $type = trim($fields[1]);
             } else {
                 $level = 0;
             }
         } else {
             $level = 0;
         }
         if ($level <= $glevel) {
             break;
         }
     }
     if ($level1type !== '_PRIM') {
         self::insertMissingSubtags($level1type, $add_date);
     }
     return $level1type;
 }
Ejemplo n.º 15
0
/**
 * Format an anniversary display.
 *
 * @param Fact $fact
 * @param bool $show_places
 *
 * @return string
 */
function calendar_fact_text(Fact $fact, $show_places)
{
    $text = $fact->getLabel() . ' — ' . $fact->getDate()->display(true, null, false);
    if ($fact->anniv) {
        $text .= ' (' . I18N::translate('%s year anniversary', $fact->anniv) . ')';
    }
    if ($show_places && $fact->getAttribute('PLAC')) {
        $text .= ' — ' . $fact->getAttribute('PLAC');
    }
    return $text;
}
Ejemplo n.º 16
0
 /**
  * Print a row for the media tab on the individual page.
  *
  * @param Fact $fact
  * @param int $level
  */
 public static function printMainMedia(Fact $fact, $level)
 {
     $factrec = $fact->getGedcom();
     $parent = $fact->getParent();
     if ($fact->isPendingAddition()) {
         $styleadd = 'new';
         $can_edit = $level == 1 && $fact->canEdit();
     } elseif ($fact->isPendingDeletion()) {
         $styleadd = 'old';
         $can_edit = false;
     } else {
         $styleadd = '';
         $can_edit = $level == 1 && $fact->canEdit();
     }
     // -- find source for each fact
     preg_match_all('/(?:^|\\n)' . $level . ' OBJE @(.*)@/', $factrec, $matches);
     foreach ($matches[1] as $xref) {
         $media = Media::getInstance($xref, $fact->getParent()->getTree());
         // Allow access to "1 OBJE @non_existent_source@", so it can be corrected/deleted
         if (!$media || $media->canShow()) {
             if ($level > 1) {
                 echo '<tr class="row_obje2">';
             } else {
                 echo '<tr>';
             }
             echo '<td class="descriptionbox';
             if ($level > 1) {
                 echo ' rela';
             }
             echo ' ', $styleadd, ' width20">';
             preg_match("/^\\d (\\w*)/", $factrec, $factname);
             $factlines = explode("\n", $factrec);
             // 1 BIRT Y\n2 SOUR ...
             $factwords = explode(" ", $factlines[0]);
             // 1 BIRT Y
             $factname = $factwords[1];
             // BIRT
             if ($factname == 'EVEN' || $factname == 'FACT') {
                 // Add ' EVEN' to provide sensible output for an event with an empty TYPE record
                 $ct = preg_match("/2 TYPE (.*)/", $factrec, $ematch);
                 if ($ct > 0) {
                     $factname = $ematch[1];
                     echo $factname;
                 } else {
                     echo GedcomTag::getLabel($factname, $parent);
                 }
             } elseif ($can_edit) {
                 echo '<a onclick="window.open(\'addmedia.php?action=editmedia&amp;pid=', $media->getXref(), '\', \'_blank\', edit_window_specs); return false;" href="#" title="', I18N::translate('Edit'), '">';
                 echo GedcomTag::getLabel($factname, $parent), '</a>';
                 echo '<div class="editfacts">';
                 echo '<div class="editlink"><a class="editicon" onclick="window.open(\'addmedia.php?action=editmedia&amp;pid=', $media->getXref(), '\', \'_blank\', edit_window_specs); return false;" href="#" title="', I18N::translate('Edit'), '"><span class="link_text">', I18N::translate('Edit'), '</span></a></div>';
                 echo '<div class="copylink"><a class="copyicon" href="#" onclick="jQuery.post(\'action.php\',{action:\'copy-fact\', type:\'\', factgedcom:\'' . rawurlencode($factrec) . '\'},function(){location.reload();})" title="' . I18N::translate('Copy') . '"><span class="link_text">' . I18N::translate('Copy') . '</span></a></div>';
                 echo '<div class="deletelink"><a class="deleteicon" onclick="return delete_fact(\'', I18N::translate('Are you sure you want to delete this fact?'), '\', \'', $parent->getXref(), '\', \'', $fact->getFactId(), '\');" href="#" title="', I18N::translate('Delete'), '"><span class="link_text">', I18N::translate('Delete'), '</span></a></div>';
                 echo '</div>';
             } else {
                 echo GedcomTag::getLabel($factname, $parent);
             }
             echo '</td>';
             echo '<td class="optionbox ', $styleadd, ' wrap">';
             if ($media) {
                 echo '<span class="field">';
                 echo $media->displayImage();
                 echo '<a href="' . $media->getHtmlUrl() . '">';
                 echo '<em>';
                 foreach ($media->getAllNames() as $name) {
                     if ($name['type'] != 'TITL') {
                         echo '<br>';
                     }
                     echo $name['full'];
                 }
                 echo '</em>';
                 echo '</a>';
                 echo '</span>';
                 echo GedcomTag::getLabelValue('FORM', $media->mimeType());
                 $imgsize = $media->getImageAttributes('main');
                 if (!empty($imgsize['WxH'])) {
                     echo GedcomTag::getLabelValue('__IMAGE_SIZE__', $imgsize['WxH']);
                 }
                 if ($media->getFilesizeraw() > 0) {
                     echo GedcomTag::getLabelValue('__FILE_SIZE__', $media->getFilesize());
                 }
                 $mediatype = $media->getMediaType();
                 if ($mediatype) {
                     echo GedcomTag::getLabelValue('TYPE', GedcomTag::getFileFormTypeValue($mediatype));
                 }
                 switch ($media->isPrimary()) {
                     case 'Y':
                         echo GedcomTag::getLabelValue('_PRIM', I18N::translate('yes'));
                         break;
                     case 'N':
                         echo GedcomTag::getLabelValue('_PRIM', I18N::translate('no'));
                         break;
                 }
                 echo FunctionsPrint::printFactNotes($media->getGedcom(), 1);
                 echo self::printFactSources($media->getGedcom(), 1);
             } else {
                 echo $xref;
             }
             echo '</td></tr>';
         }
     }
 }
Ejemplo n.º 17
0
 /**
  * print information for a sex record
  *
  * @param Fact $event the Event object
  */
 public function printSexRecord(Fact $event)
 {
     $sex = $event->getValue();
     if (empty($sex)) {
         $sex = 'U';
     }
     echo '<span id="sex" class="';
     if ($event->isPendingDeletion()) {
         echo 'old ';
     }
     if ($event->isPendingAddition()) {
         echo 'new ';
     }
     switch ($sex) {
         case 'M':
             echo 'male_gender"';
             if ($event->canEdit()) {
                 echo ' title="', I18N::translate('Male'), ' - ', I18N::translate('Edit'), '"';
                 echo ' onclick="edit_record(\'' . $this->record->getXref() . '\', \'' . $event->getFactId() . '\'); return false;">';
             } else {
                 echo ' title="', I18N::translate('Male'), '">';
             }
             break;
         case 'F':
             echo 'female_gender"';
             if ($event->canEdit()) {
                 echo ' title="', I18N::translate('Female'), ' - ', I18N::translate('Edit'), '"';
                 echo ' onclick="edit_record(\'' . $this->record->getXref() . '\', \'' . $event->getFactId() . '\'); return false;">';
             } else {
                 echo ' title="', I18N::translate('Female'), '">';
             }
             break;
         default:
             echo 'unknown_gender"';
             if ($event->canEdit()) {
                 echo ' title="', I18N::translateContext('unknown gender', 'Unknown'), ' - ', I18N::translate('Edit'), '"';
                 echo ' onclick="edit_record(\'' . $this->record->getXref() . '\', \'' . $event->getFactId() . '\'); return false;">';
             } else {
                 echo ' title="', I18N::translateContext('unknown gender', 'Unknown'), '">';
             }
             break;
     }
     echo '</span>';
 }
Ejemplo n.º 18
0
 public static function CompareDate(FactPlace $a, FactPlace $b)
 {
     return Fact::CompareDate($a->fact, $b->fact);
 }