本文整理汇总了PHP中Fisharebest\Webtrees\Date::isOK方法的典型用法代码示例。如果您正苦于以下问题:PHP Date::isOK方法的具体用法?PHP Date::isOK怎么用?PHP Date::isOK使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fisharebest\Webtrees\Date
的用法示例。
在下文中一共展示了Date::isOK方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: formatParentsAges
/**
* Format age of parents in HTML
*
* @param Individual $person child
* @param Date $birth_date
*
* @return string HTML
*/
public static function formatParentsAges(Individual $person, Date $birth_date)
{
$html = '';
$families = $person->getChildFamilies();
// Multiple sets of parents (e.g. adoption) cause complications, so ignore.
if ($birth_date->isOK() && count($families) == 1) {
$family = current($families);
foreach ($family->getSpouses() as $parent) {
if ($parent->getBirthDate()->isOK()) {
$sex = $parent->getSexImage();
$age = Date::getAge($parent->getBirthDate(), $birth_date, 2);
$deatdate = $parent->getDeathDate();
switch ($parent->getSex()) {
case 'F':
// Highlight mothers who die in childbirth or shortly afterwards
if ($deatdate->isOK() && $deatdate->maximumJulianDay() < $birth_date->minimumJulianDay() + 90) {
$html .= ' <span title="' . GedcomTag::getLabel('_DEAT_PARE', $parent) . '" class="parentdeath">' . $sex . $age . '</span>';
} else {
$html .= ' <span title="' . I18N::translate('Mother’s age') . '">' . $sex . $age . '</span>';
}
break;
case 'M':
// Highlight fathers who die before the birth
if ($deatdate->isOK() && $deatdate->maximumJulianDay() < $birth_date->minimumJulianDay()) {
$html .= ' <span title="' . GedcomTag::getLabel('_DEAT_PARE', $parent) . '" class="parentdeath">' . $sex . $age . '</span>';
} else {
$html .= ' <span title="' . I18N::translate('Father’s age') . '">' . $sex . $age . '</span>';
}
break;
default:
$html .= ' <span title="' . I18N::translate('Parent’s age') . '">' . $sex . $age . '</span>';
break;
}
}
}
if ($html) {
$html = '<span class="age">' . $html . '</span>';
}
}
return $html;
}
示例2: advancedSearch
//.........这里部分代码省略.........
break;
case 'SDX':
// SDX uses DM by default.
// SDX uses DM by default.
case 'SDX_DM':
$sdx = Soundex::daitchMokotoff($value);
if ($sdx !== null) {
$sdx = explode(':', $sdx);
foreach ($sdx as $k => $v) {
$sdx[$k] = "i_n.n_soundex_surn_dm LIKE CONCAT('%', ?, '%')";
$bind[] = $v;
}
$sql .= " AND (" . implode(' OR ', $sdx) . ")";
break;
} else {
// No phonetic content? Use a substring match
$sql .= " AND i_n.n_surn LIKE CONCAT('%', ?, '%')";
$bind[] = $value;
}
}
break;
case 'NICK':
case '_MARNM':
case '_HEB':
case '_AKA':
$sql .= " AND i_n.n_type=? AND i_n.n_full LIKE CONCAT('%', ?, '%')";
$bind[] = $parts[1];
$bind[] = $value;
break;
}
} elseif ($parts[1] == 'DATE') {
// *:DATE
$date = new Date($value);
if ($date->isOK()) {
$jd1 = $date->minimumJulianDay();
$jd2 = $date->maximumJulianDay();
if (!empty($this->plusminus[$i])) {
$adjd = $this->plusminus[$i] * 365;
$jd1 -= $adjd;
$jd2 += $adjd;
}
$sql .= " AND i_d.d_fact=? AND i_d.d_julianday1>=? AND i_d.d_julianday2<=?";
$bind[] = $parts[0];
$bind[] = $jd1;
$bind[] = $jd2;
}
} elseif ($parts[0] == 'FAMS' && $parts[2] == 'DATE') {
// FAMS:*:DATE
$date = new Date($value);
if ($date->isOK()) {
$jd1 = $date->minimumJulianDay();
$jd2 = $date->maximumJulianDay();
if (!empty($this->plusminus[$i])) {
$adjd = $this->plusminus[$i] * 365;
$jd1 -= $adjd;
$jd2 += $adjd;
}
$sql .= " AND f_d.d_fact=? AND f_d.d_julianday1>=? AND f_d.d_julianday2<=?";
$bind[] = $parts[1];
$bind[] = $jd1;
$bind[] = $jd2;
}
} elseif ($parts[1] == 'PLAC') {
// *:PLAC
// SQL can only link a place to a person/family, not to an event.
$sql .= " AND i_p.place LIKE CONCAT('%', ?, '%')";
示例3: isDead
/**
* Calculate whether this individual is living or dead.
* If not known to be dead, then assume living.
*
* @return bool
*/
public function isDead()
{
$MAX_ALIVE_AGE = $this->tree->getPreference('MAX_ALIVE_AGE');
// "1 DEAT Y" or "1 DEAT/2 DATE" or "1 DEAT/2 PLAC"
if (preg_match('/\\n1 (?:' . WT_EVENTS_DEAT . ')(?: Y|(?:\\n[2-9].+)*\\n2 (DATE|PLAC) )/', $this->gedcom)) {
return true;
}
// If any event occured more than $MAX_ALIVE_AGE years ago, then assume the individual is dead
if (preg_match_all('/\\n2 DATE (.+)/', $this->gedcom, $date_matches)) {
foreach ($date_matches[1] as $date_match) {
$date = new Date($date_match);
if ($date->isOK() && $date->maximumJulianDay() <= WT_CLIENT_JD - 365 * $MAX_ALIVE_AGE) {
return true;
}
}
// The individual has one or more dated events. All are less than $MAX_ALIVE_AGE years ago.
// If one of these is a birth, the individual must be alive.
if (preg_match('/\\n1 BIRT(?:\\n[2-9].+)*\\n2 DATE /', $this->gedcom)) {
return false;
}
}
// If we found no conclusive dates then check the dates of close relatives.
// Check parents (birth and adopted)
foreach ($this->getChildFamilies(Auth::PRIV_HIDE) as $family) {
foreach ($family->getSpouses(Auth::PRIV_HIDE) as $parent) {
// Assume parents are no more than 45 years older than their children
preg_match_all('/\\n2 DATE (.+)/', $parent->gedcom, $date_matches);
foreach ($date_matches[1] as $date_match) {
$date = new Date($date_match);
if ($date->isOK() && $date->maximumJulianDay() <= WT_CLIENT_JD - 365 * ($MAX_ALIVE_AGE + 45)) {
return true;
}
}
}
}
// Check spouses
foreach ($this->getSpouseFamilies(Auth::PRIV_HIDE) as $family) {
preg_match_all('/\\n2 DATE (.+)/', $family->gedcom, $date_matches);
foreach ($date_matches[1] as $date_match) {
$date = new Date($date_match);
// Assume marriage occurs after age of 10
if ($date->isOK() && $date->maximumJulianDay() <= WT_CLIENT_JD - 365 * ($MAX_ALIVE_AGE - 10)) {
return true;
}
}
// Check spouse dates
$spouse = $family->getSpouse($this);
if ($spouse) {
preg_match_all('/\\n2 DATE (.+)/', $spouse->gedcom, $date_matches);
foreach ($date_matches[1] as $date_match) {
$date = new Date($date_match);
// Assume max age difference between spouses of 40 years
if ($date->isOK() && $date->maximumJulianDay() <= WT_CLIENT_JD - 365 * ($MAX_ALIVE_AGE + 40)) {
return true;
}
}
}
// Check child dates
foreach ($family->getChildren(Auth::PRIV_HIDE) as $child) {
preg_match_all('/\\n2 DATE (.+)/', $child->gedcom, $date_matches);
// Assume children born after age of 15
foreach ($date_matches[1] as $date_match) {
$date = new Date($date_match);
if ($date->isOK() && $date->maximumJulianDay() <= WT_CLIENT_JD - 365 * ($MAX_ALIVE_AGE - 15)) {
return true;
}
}
// Check grandchildren
foreach ($child->getSpouseFamilies(Auth::PRIV_HIDE) as $child_family) {
foreach ($child_family->getChildren(Auth::PRIV_HIDE) as $grandchild) {
preg_match_all('/\\n2 DATE (.+)/', $grandchild->gedcom, $date_matches);
// Assume grandchildren born after age of 30
foreach ($date_matches[1] as $date_match) {
$date = new Date($date_match);
if ($date->isOK() && $date->maximumJulianDay() <= WT_CLIENT_JD - 365 * ($MAX_ALIVE_AGE - 30)) {
return true;
}
}
}
}
}
}
return false;
}
示例4: printFamily
//.........这里部分代码省略.........
', 'WIFE');"><?php
echo I18N::translate('Add a wife to this family');
?>
</a></td>
</tr>
<?php
}
///// MARR /////
$found = false;
$prev = new Date('');
foreach ($family->getFacts(WT_EVENTS_MARR . '|' . WT_EVENTS_DIV, true) as $fact) {
$found |= !$fact->isPendingDeletion();
if ($fact->isPendingAddition()) {
$class = ' new';
} elseif ($fact->isPendingDeletion()) {
$class = ' old';
} else {
$class = '';
}
?>
<tr>
<td class="facts_label">
</td>
<td class="facts_value<?php
echo $class;
?>
">
<?php
echo GedcomTag::getLabelValue($fact->getTag(), $fact->getDate()->display() . ' — ' . $fact->getPlace()->getFullName());
?>
</td>
</tr>
<?php
if (!$prev->isOK() && $fact->getDate()->isOK()) {
$prev = $fact->getDate();
}
}
if (!$found && $family->canShow() && $family->canEdit()) {
// Add a new marriage
?>
<tr>
<td class="facts_label">
</td>
<td class="facts_value">
<a href="#" onclick="return add_new_record('<?php
echo $family->getXref();
?>
', 'MARR');">
<?php
echo I18N::translate('Add marriage details');
?>
</a>
</td>
</tr>
<?php
}
///// CHIL /////
$child_number = 0;
foreach ($family->getFacts('CHIL', false, $access_level) as $fact) {
$person = $fact->getTarget();
if ($person instanceof Individual) {
if ($fact->isPendingAddition()) {
$child_number++;
$class = 'facts_label new';
} elseif ($fact->isPendingDeletion()) {
$class = 'facts_label old';