/** * Print the lifespan of this person * * @param type $person * @param type $is_spouse * @return string */ private function printLifespan($person, $is_spouse = false) { $html = ''; $birthdate = $person->getBirthDate(); $deathdate = $person->getDeathdate(); $ageOfdeath = FunctionsDate::getAgeAtEvent(Date::GetAgeGedcom($birthdate, $deathdate), false); $birthdata = false; if ($birthdate->isOK() || $person->getBirthPlace() != '') { $birthdata = true; $bapm = $person->getFirstFact('BAPM'); $chr = $person->getFirstFact('CHR'); $birt = $person->getFirstFact('BIRT'); if ($birt) { $html .= $this->printBirthText($person, 'BIRT', $is_spouse); $html .= $this->printDate($birt); } else { if ($bapm || $chr) { $html .= $this->printBirthText($person, 'BAPM', $is_spouse); $html .= $bapm ? $this->printDate($bapm) : $this->printDate($chr); } } if ($person->getBirthPlace() != '') { $html .= $this->printPlace($person->getBirthPlace(), $person->getTree()); } } $deathdata = false; if ($deathdate->isOK() || $person->getDeathPlace() != '') { $deathdata = true; if ($birthdata) { $html .= ' ' . I18N::translate('and '); $person->getSex() == 'F' ? $html .= I18N::translateContext('FEMALE', 'died') : ($html .= I18N::translateContext('MALE', 'died')); } else { $person->getSex() == 'F' ? $html .= '. ' . I18N::translate('She died') : ($html .= '. ' . I18N::translate('He died')); } $deat = $person->getFirstFact('DEAT'); if ($deat) { $html .= $this->printDate($deat); } if ($person->getDeathPlace() != '') { $html .= $this->printPlace($person->getDeathPlace(), $person->getTree()); } if ($birthdate->isOK() && $deathdate->isOK() && $this->isDateDMY($birt) && $this->isDateDMY($deat)) { if (Date::getAge($birthdate, $deathdate, 0) < 2) { $html .= ' ' . I18N::translateContext('age in days/months', 'at the age of %s', $ageOfdeath); } else { $html .= ' ' . I18N::translateContext('age in years', 'at the age of %s', $ageOfdeath); } } } return $html; }
/** * 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>'; }
/** * Get the last-change timestamp for this record, either as a formatted string * (for display) or as a unix timestamp (for sorting) * * @param bool $sorting * * @return string */ public function lastChangeTimestamp($sorting = false) { $chan = $this->getFirstFact('CHAN'); if ($chan) { // The record does have a CHAN event $d = $chan->getDate()->minimumDate(); if (preg_match('/\\n3 TIME (\\d\\d):(\\d\\d):(\\d\\d)/', $chan->getGedcom(), $match)) { $t = mktime((int) $match[1], (int) $match[2], (int) $match[3], (int) $d->format('%n'), (int) $d->format('%j'), (int) $d->format('%Y')); } elseif (preg_match('/\\n3 TIME (\\d\\d):(\\d\\d)/', $chan->getGedcom(), $match)) { $t = mktime((int) $match[1], (int) $match[2], 0, (int) $d->format('%n'), (int) $d->format('%j'), (int) $d->format('%Y')); } else { $t = mktime(0, 0, 0, (int) $d->format('%n'), (int) $d->format('%j'), (int) $d->format('%Y')); } if ($sorting) { return $t; } else { return strip_tags(FunctionsDate::formatTimestamp($t)); } } else { // The record does not have a CHAN event if ($sorting) { return '0'; } else { return ' '; } } }
/** * Generate the HTML content of this block. * * @param int $block_id * @param bool $template * @param string[] $cfg * * @return string */ public function getBlock($block_id, $template = true, $cfg = array()) { global $ctype, $WT_TREE; $block = $this->getBlockSetting($block_id, 'block', '1'); foreach (array('block') as $name) { if (array_key_exists($name, $cfg)) { ${$name} = $cfg[$name]; } } $messages = Database::prepare("SELECT message_id, sender, subject, body, UNIX_TIMESTAMP(created) AS created FROM `##message` WHERE user_id=? ORDER BY message_id DESC")->execute(array(Auth::id()))->fetchAll(); $count = count($messages); $id = $this->getName() . $block_id; $class = $this->getName() . '_block'; $title = I18N::plural('%s message', '%s messages', $count, I18N::number($count)); $users = array_filter(User::all(), function (User $user) { return $user->getUserId() !== Auth::id() && $user->getPreference('verified_by_admin') && $user->getPreference('contactmethod') !== 'none'; }); $content = '<form id="messageform" name="messageform" method="post" action="module.php?mod=user_messages&mod_action=delete" onsubmit="return confirm(\'' . I18N::translate('Are you sure you want to delete this message? It cannot be retrieved later.') . '\');">'; $content .= '<input type="hidden" name="ged" value="' . $ctype . '">'; $content .= '<input type="hidden" name="ctype" value="' . $WT_TREE->getNameHtml() . '">'; if ($users) { $content .= '<label for="touser">' . I18N::translate('Send a message') . '</label>'; $content .= '<select id="touser" name="touser">'; $content .= '<option value="">' . I18N::translate('<select>') . '</option>'; foreach ($users as $user) { $content .= sprintf('<option value="%1$s">%2$s - %1$s</option>', Filter::escapeHtml($user->getUserName()), Filter::escapeHtml($user->getRealName())); } $content .= '</select>'; $content .= '<input type="button" value="' . I18N::translate('Send') . '" onclick="return message(document.messageform.touser.options[document.messageform.touser.selectedIndex].value, \'messaging2\', \'\');"><br><br>'; } if ($messages) { $content .= '<table class="list_table"><tr>'; $content .= '<th class="list_label">' . I18N::translate('Delete') . '<br><a href="#" onclick="jQuery(\'#' . $this->getName() . $block_id . ' :checkbox\').prop(\'checked\', true); return false;">' . I18N::translate('All') . '</a></th>'; $content .= '<th class="list_label">' . I18N::translate('Subject') . '</th>'; $content .= '<th class="list_label">' . I18N::translate('Date sent') . '</th>'; $content .= '<th class="list_label">' . I18N::translate('Email address') . '</th>'; $content .= '</tr>'; foreach ($messages as $message) { $content .= '<tr>'; $content .= '<td class="list_value_wrap"><input type="checkbox" name="message_id[]" value="' . $message->message_id . '" id="cb_message' . $message->message_id . '"></td>'; $content .= '<td class="list_value_wrap"><a href="#" onclick="return expand_layer(\'message' . $message->message_id . '\');"><i id="message' . $message->message_id . '_img" class="icon-plus"></i> <b dir="auto">' . Filter::escapeHtml($message->subject) . '</b></a></td>'; $content .= '<td class="list_value_wrap">' . FunctionsDate::formatTimestamp($message->created + WT_TIMESTAMP_OFFSET) . '</td>'; $content .= '<td class="list_value_wrap">'; $user = User::findByIdentifier($message->sender); if ($user) { $content .= $user->getRealNameHtml(); $content .= ' - <span dir="auto">' . $user->getEmail() . '</span>'; } else { $content .= '<a href="mailto:' . Filter::escapeHtml($message->sender) . '">' . Filter::escapeHtml($message->sender) . '</a>'; } $content .= '</td>'; $content .= '</tr>'; $content .= '<tr><td class="list_value_wrap" colspan="4"><div id="message' . $message->message_id . '" style="display:none;">'; $content .= '<div dir="auto" style="white-space: pre-wrap;">' . Filter::expandUrls($message->body) . '</div><br>'; if (strpos($message->subject, I18N::translate('RE: ')) !== 0) { $message->subject = I18N::translate('RE: ') . $message->subject; } if ($user) { $content .= '<button type="button" onclick="reply(\'' . Filter::escapeJs($message->sender) . '\', \'' . Filter::escapeJs($message->subject) . '\'); return false;">' . I18N::translate('Reply') . '</button> '; } $content .= '<button type="button" onclick="if (confirm(\'' . I18N::translate('Are you sure you want to delete this message? It cannot be retrieved later.') . '\')) {jQuery(\'#messageform :checkbox\').prop(\'checked\', false); jQuery(\'#cb_message' . $message->message_id . '\').prop(\'checked\', true); document.messageform.submit();}">' . I18N::translate('Delete') . '</button></div></td></tr>'; } $content .= '</table>'; $content .= '<p><button type="submit">' . I18N::translate('Delete selected messages') . '</button></p>'; } $content .= '</form>'; if ($template) { if ($block) { $class .= ' small_inner_block'; } return Theme::theme()->formatBlock($id, $title, $class, $content); } else { return $content; } }
/** * Print the age at death/bury * @param type $bfact * @param type $dfact * @return string */ private function printAgeOfDeath($bfact, $dfact) { $bdate = $bfact->getDate(); $ddate = $dfact->getDate(); $html = ''; if ($bdate->isOK() && $ddate->isOK() && $this->isDateDMY($bfact) && $this->isDateDMY($dfact)) { $ageOfdeath = FunctionsDate::getAgeAtEvent(Date::GetAgeGedcom($bdate, $ddate), false); if (Date::getAge($bdate, $ddate, 0) < 2) { $html .= ' ' . I18N::translateContext('age in days/months', 'at the age of %s', $ageOfdeath); } else { $html .= ' ' . I18N::translateContext('age in years', 'at the age of %s', $ageOfdeath); } } return $html; }
/** * Generate the HTML content of this block. * * @param int $block_id * @param bool $template * @param string[] $cfg * * @return string */ public function getBlock($block_id, $template = true, $cfg = array()) { global $ctype, $WT_TREE; $sendmail = $this->getBlockSetting($block_id, 'sendmail', '1'); $days = $this->getBlockSetting($block_id, 'days', '1'); $block = $this->getBlockSetting($block_id, 'block', '1'); foreach (array('days', 'sendmail', 'block') as $name) { if (array_key_exists($name, $cfg)) { ${$name} = $cfg[$name]; } } $changes = Database::prepare("SELECT 1" . " FROM `##change`" . " WHERE status='pending'" . " LIMIT 1")->fetchOne(); if ($changes === '1' && $sendmail === '1') { // There are pending changes - tell moderators/managers/administrators about them. if (WT_TIMESTAMP - Site::getPreference('LAST_CHANGE_EMAIL') > 60 * 60 * 24 * $days) { // Which users have pending changes? foreach (User::all() as $user) { if ($user->getPreference('contactmethod') !== 'none') { foreach (Tree::getAll() as $tree) { if ($tree->hasPendingEdit() && Auth::isManager($tree, $user)) { I18N::init($user->getPreference('language')); Mail::systemMessage($tree, $user, I18N::translate('Pending changes'), I18N::translate('There are pending changes for you to moderate.') . Mail::EOL . Mail::EOL . '<a href="' . WT_BASE_URL . 'index.php?ged=' . $WT_TREE->getNameUrl() . '">' . WT_BASE_URL . 'index.php?ged=' . $WT_TREE->getNameUrl() . '</a>'); I18N::init(WT_LOCALE); } } } } Site::setPreference('LAST_CHANGE_EMAIL', WT_TIMESTAMP); } } if (Auth::isEditor($WT_TREE) && $WT_TREE->hasPendingEdit()) { $id = $this->getName() . $block_id; $class = $this->getName() . '_block'; if ($ctype === 'user' || Auth::isManager($WT_TREE)) { $title = '<a class="icon-admin" title="' . I18N::translate('Configure') . '" href="block_edit.php?block_id=' . $block_id . '&ged=' . $WT_TREE->getNameHtml() . '&ctype=' . $ctype . '"></a>'; } else { $title = ''; } $title .= $this->getTitle(); $content = ''; if (Auth::isModerator($WT_TREE)) { $content .= "<a href=\"#\" onclick=\"window.open('edit_changes.php','_blank', chan_window_specs); return false;\">" . I18N::translate('There are pending changes for you to moderate.') . "</a><br>"; } if ($sendmail === '1') { $content .= I18N::translate('Last email reminder was sent ') . FunctionsDate::formatTimestamp(Site::getPreference('LAST_CHANGE_EMAIL')) . "<br>"; $content .= I18N::translate('Next email reminder will be sent after ') . FunctionsDate::formatTimestamp(Site::getPreference('LAST_CHANGE_EMAIL') + 60 * 60 * 24 * $days) . "<br><br>"; } $content .= '<ul>'; $changes = Database::prepare("SELECT xref" . " FROM `##change`" . " WHERE status='pending'" . " AND gedcom_id=?" . " GROUP BY xref")->execute(array($WT_TREE->getTreeId()))->fetchAll(); foreach ($changes as $change) { $record = GedcomRecord::getInstance($change->xref, $WT_TREE); if ($record->canShow()) { $content .= '<li><a href="' . $record->getHtmlUrl() . '">' . $record->getFullName() . '</a></li>'; } } $content .= '</ul>'; if ($template) { if ($block) { $class .= ' small_inner_block'; } return Theme::theme()->formatBlock($id, $title, $class, $content); } else { return $content; } } }
/** * XML <AgeAtDeath /> element handler */ private function ageAtDeathStartHandler() { // This duplicates functionality in FunctionsPrint::format_fact_date() global $factrec, $WT_TREE; $match = array(); if (preg_match("/0 @(.+)@/", $this->gedrec, $match)) { $person = Individual::getInstance($match[1], $WT_TREE); // Recorded age if (preg_match('/\\n2 AGE (.+)/', $factrec, $match)) { $fact_age = $match[1]; } else { $fact_age = ''; } if (preg_match('/\\n2 HUSB\\n3 AGE (.+)/', $factrec, $match)) { $husb_age = $match[1]; } else { $husb_age = ''; } if (preg_match('/\\n2 WIFE\\n3 AGE (.+)/', $factrec, $match)) { $wife_age = $match[1]; } else { $wife_age = ''; } // Calculated age $birth_date = $person->getBirthDate(); // Can't use getDeathDate(), as this also gives BURI/CREM events, which // wouldn't give the correct "days after death" result for people with // no DEAT. $death_event = $person->getFirstFact('DEAT'); if ($death_event) { $death_date = $death_event->getDate(); } else { $death_date = new Date(''); } $value = ''; if (Date::compare($birth_date, $death_date) <= 0 || !$person->isDead()) { $age = Date::getAgeGedcom($birth_date, $death_date); // Only show calculated age if it differs from recorded age if ($age != '' && $age != "0d") { if ($fact_age != '' && $fact_age != $age || $fact_age == '' && $husb_age == '' && $wife_age == '' || $husb_age != '' && $person->getSex() == 'M' && $husb_age != $age || $wife_age != '' && $person->getSex() == 'F' && $wife_age != $age) { $value = FunctionsDate::getAgeAtEvent($age); $abbrev = substr($value, 0, strpos($value, ' ') + 5); if ($value !== $abbrev) { $value = $abbrev . '.'; } } } } $this->current_element->addText($value); } }
/** * Print fact DATE/TIME * * @param Fact $event event containing the date/age * @param GedcomRecord $record the person (or couple) whose ages should be printed * @param bool $anchor option to print a link to calendar * @param bool $time option to print TIME value * * @return string */ public static function formatFactDate(Fact $event, GedcomRecord $record, $anchor, $time) { global $pid; $factrec = $event->getGedcom(); $html = ''; // Recorded age if (preg_match('/\\n2 AGE (.+)/', $factrec, $match)) { $fact_age = $match[1]; } else { $fact_age = ''; } if (preg_match('/\\n2 HUSB\\n3 AGE (.+)/', $factrec, $match)) { $husb_age = $match[1]; } else { $husb_age = ''; } if (preg_match('/\\n2 WIFE\\n3 AGE (.+)/', $factrec, $match)) { $wife_age = $match[1]; } else { $wife_age = ''; } // Calculated age if (preg_match('/\\n2 DATE (.+)/', $factrec, $match)) { $date = new Date($match[1]); $html .= ' ' . $date->display($anchor); // time if ($time && preg_match('/\\n3 TIME (.+)/', $factrec, $match)) { $html .= ' – <span class="date">' . $match[1] . '</span>'; } $fact = $event->getTag(); if ($record instanceof Individual) { if ($fact === 'BIRT' && $record->getTree()->getPreference('SHOW_PARENTS_AGE')) { // age of parents at child birth $html .= self::formatParentsAges($record, $date); } elseif ($fact !== 'CHAN' && $fact !== '_TODO') { // age at event $birth_date = $record->getBirthDate(); // Can't use getDeathDate(), as this also gives BURI/CREM events, which // wouldn't give the correct "days after death" result for people with // no DEAT. $death_event = $record->getFirstFact('DEAT'); if ($death_event) { $death_date = $death_event->getDate(); } else { $death_date = new Date(''); } $ageText = ''; if (Date::compare($date, $death_date) <= 0 || !$record->isDead() || $fact == 'DEAT') { // Before death, print age $age = Date::getAgeGedcom($birth_date, $date); // Only show calculated age if it differs from recorded age if ($age != '') { if ($fact_age != '' && $fact_age != $age || $fact_age == '' && $husb_age == '' && $wife_age == '' || $husb_age != '' && $record->getSex() == 'M' && $husb_age != $age || $wife_age != '' && $record->getSex() == 'F' && $wife_age != $age) { if ($age != "0d") { $ageText = '(' . I18N::translate('Age') . ' ' . FunctionsDate::getAgeAtEvent($age, false) . ')'; } } } } if ($fact != 'DEAT' && Date::compare($date, $death_date) >= 0) { // After death, print time since death $age = FunctionsDate::getAgeAtEvent(Date::getAgeGedcom($death_date, $date), true); if ($age != '') { if (Date::getAgeGedcom($death_date, $date) == "0d") { $ageText = '(' . I18N::translate('on the date of death') . ')'; } else { $ageText = '(' . $age . ' ' . I18N::translate('after death') . ')'; // Family events which occur after death are probably errors if ($event->getParent() instanceof Family) { $ageText .= '<i class="icon-warning"></i>'; } } } } if ($ageText) { $html .= ' <span class="age">' . $ageText . '</span>'; } } } elseif ($record instanceof Family) { $indi = Individual::getInstance($pid, $record->getTree()); if ($indi) { $birth_date = $indi->getBirthDate(); $death_date = $indi->getDeathDate(); $ageText = ''; if (Date::compare($date, $death_date) <= 0) { $age = Date::getAgeGedcom($birth_date, $date); // Only show calculated age if it differs from recorded age if ($age != '' && $age > 0) { if ($fact_age != '' && $fact_age != $age || $fact_age == '' && $husb_age == '' && $wife_age == '' || $husb_age != '' && $indi->getSex() == 'M' && $husb_age != $age || $wife_age != '' && $indi->getSex() == 'F' && $wife_age != $age) { $ageText = '(' . I18N::translate('Age') . ' ' . FunctionsDate::getAgeAtEvent($age, false) . ')'; } } } if ($ageText) { $html .= ' <span class="age">' . $ageText . '</span>'; } } } } else { // 1 DEAT Y with no DATE => print YES // 1 BIRT 2 SOUR @S1@ => 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. $factdetail = explode(' ', trim($factrec)); if (isset($factdetail) && (count($factdetail) == 3 && strtoupper($factdetail[2]) == 'Y') || count($factdetail) == 4 && $factdetail[2] == 'SOUR') { $html .= I18N::translate('yes'); } } // print gedcom ages foreach (array(GedcomTag::getLabel('AGE') => $fact_age, GedcomTag::getLabel('HUSB') => $husb_age, GedcomTag::getLabel('WIFE') => $wife_age) as $label => $age) { if ($age != '') { $html .= ' <span class="label">' . $label . ':</span> <span class="age">' . FunctionsDate::getAgeAtEvent($age, false) . '</span>'; } } return $html; }
use PclZip; define('WT_SCRIPT_NAME', 'admin_site_upgrade.php'); require './includes/session.php'; // Check for updates $latest_version_txt = Functions::fetchLatestVersion(); if (preg_match('/^[0-9.]+\\|[0-9.]+\\|/', $latest_version_txt)) { list($latest_version, $earliest_version, $download_url) = explode('|', $latest_version_txt); } else { // Cannot determine the latest version list($latest_version, $earliest_version, $download_url) = explode('|', '||'); } $latest_version_html = '<span dir="ltr">' . $latest_version . '</span>'; $download_url_html = '<b dir="auto"><a href="' . Filter::escapeHtml($download_url) . '">' . Filter::escapeHtml($download_url) . '</a></b>'; // Show a friendly message while the site is being upgraded $lock_file = __DIR__ . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'offline.txt'; $lock_file_text = I18N::translate('This website is being upgraded. Try again in a few minutes.') . PHP_EOL . FunctionsDate::formatTimestamp(WT_TIMESTAMP) . I18N::translate('UTC'); // Success/failure indicators $icon_success = '<i class="icon-yes"></i>'; $icon_failure = '<i class="icon-failure"></i>'; // Need confirmation for various actions $continue = Filter::post('continue', '1') && Filter::checkCsrf(); $modules_action = Filter::post('modules', 'ignore|disable'); $themes_action = Filter::post('themes', 'ignore|disable'); $controller = new PageController(); $controller->restrictAccess(Auth::isAdmin())->setPageTitle(I18N::translate('Upgrade wizard'))->pageHeader(); echo '<h1>', $controller->getPageTitle(), '</h1>'; if ($latest_version == '') { echo '<p>', I18N::translate('No upgrade information is available.'), '</p>'; return; } if (version_compare(WT_VERSION, $latest_version) >= 0) {
/** * Generate the HTML content of this block. * * @param int $block_id * @param bool $template * @param string[] $cfg * * @return string */ public function getBlock($block_id, $template = true, $cfg = array()) { global $ctype, $WT_TREE; switch (Filter::get('action')) { case 'deletenews': $news_id = Filter::get('news_id'); if ($news_id) { Database::prepare("DELETE FROM `##news` WHERE news_id = ?")->execute(array($news_id)); } break; } if (isset($_REQUEST['gedcom_news_archive'])) { $limit = 'nolimit'; $flag = '0'; } else { $flag = $this->getBlockSetting($block_id, 'flag', 0); if ($flag === '0') { $limit = 'nolimit'; } else { $limit = $this->getBlockSetting($block_id, 'limit', 'nolimit'); } } foreach (array('limit', 'flag') as $name) { if (array_key_exists($name, $cfg)) { ${$name} = $cfg[$name]; } } $usernews = Database::prepare("SELECT SQL_CACHE news_id, user_id, gedcom_id, UNIX_TIMESTAMP(updated) AS updated, subject, body FROM `##news` WHERE gedcom_id=? ORDER BY updated DESC")->execute(array($WT_TREE->getTreeId()))->fetchAll(); $id = $this->getName() . $block_id; $class = $this->getName() . '_block'; if ($ctype === 'gedcom' && Auth::isManager($WT_TREE) || $ctype === 'user' && Auth::check()) { $title = '<a class="icon-admin" title="' . I18N::translate('Configure') . '" href="block_edit.php?block_id=' . $block_id . '&ged=' . $WT_TREE->getNameHtml() . '&ctype=' . $ctype . '"></a>'; } else { $title = ''; } $title .= $this->getTitle(); $content = ''; if (count($usernews) == 0) { $content .= I18N::translate('No news articles have been submitted.') . '<br>'; } $c = 0; foreach ($usernews as $news) { if ($limit == 'count') { if ($c >= $flag) { break; } $c++; } if ($limit == 'date') { if ((int) ((WT_TIMESTAMP - $news->updated) / 86400) > $flag) { break; } } $content .= '<div class="news_box" id="article' . $news->news_id . '">'; $content .= '<div class="news_title">' . Filter::escapeHtml($news->subject) . '</div>'; $content .= '<div class="news_date">' . FunctionsDate::formatTimestamp($news->updated) . '</div>'; if ($news->body == strip_tags($news->body)) { $news->body = nl2br($news->body, false); } $content .= $news->body; // Print Admin options for this News item if (Auth::isManager($WT_TREE)) { $content .= '<hr>' . '<a href="#" onclick="window.open(\'editnews.php?news_id=\'+' . $news->news_id . ', \'_blank\', news_window_specs); return false;">' . I18N::translate('Edit') . '</a> | ' . '<a href="index.php?action=deletenews&news_id=' . $news->news_id . '&ctype=' . $ctype . '&ged=' . $WT_TREE->getNameHtml() . '" onclick="return confirm(\'' . I18N::translate('Are you sure you want to delete “%s”?', Filter::escapeHtml($news->subject)) . "');\">" . I18N::translate('Delete') . '</a><br>'; } $content .= '</div>'; } $printedAddLink = false; if (Auth::isManager($WT_TREE)) { $content .= "<a href=\"#\" onclick=\"window.open('editnews.php?gedcom_id=" . $WT_TREE->getTreeId() . "', '_blank', news_window_specs); return false;\">" . I18N::translate('Add a news article') . "</a>"; $printedAddLink = true; } if ($limit == 'date' || $limit == 'count') { if ($printedAddLink) { $content .= ' | '; } $content .= '<a href="index.php?gedcom_news_archive=yes&ctype=' . $ctype . '&ged=' . $WT_TREE->getNameHtml() . '">' . I18N::translate('View archive') . "</a>"; $content .= FunctionsPrint::helpLink('gedcom_news_archive') . '<br>'; } if ($template) { return Theme::theme()->formatBlock($id, $title, $class, $content); } else { return $content; } }
/** * Generate the HTML content of this block. * * @param int $block_id * @param bool $template * @param string[] $cfg * * @return string */ public function getBlock($block_id, $template = true, $cfg = array()) { global $ctype, $WT_TREE; switch (Filter::get('action')) { case 'deletenews': $news_id = Filter::get('news_id'); if ($news_id) { Database::prepare("DELETE FROM `##news` WHERE news_id = ?")->execute(array($news_id)); } break; } $more_news = Filter::getInteger('more_news'); $limit = 5 * (1 + $more_news); $articles = Database::prepare("SELECT SQL_CACHE news_id, user_id, gedcom_id, UNIX_TIMESTAMP(updated) + :offset AS updated, subject, body FROM `##news` WHERE gedcom_id = :tree_id ORDER BY updated DESC LIMIT :limit")->execute(array('offset' => WT_TIMESTAMP_OFFSET, 'tree_id' => $WT_TREE->getTreeId(), 'limit' => $limit))->fetchAll(); $count = Database::prepare("SELECT SQL_CACHE COUNT(*) FROM `##news` WHERE gedcom_id = :tree_id")->execute(array('tree_id' => $WT_TREE->getTreeId()))->fetchOne(); $id = $this->getName() . $block_id; $class = $this->getName() . '_block'; $title = $this->getTitle(); $content = ''; if (empty($articles)) { $content .= I18N::translate('No news articles have been submitted.'); } foreach ($articles as $article) { $content .= '<div class="news_box">'; $content .= '<div class="news_title">' . Filter::escapeHtml($article->subject) . '</div>'; $content .= '<div class="news_date">' . FunctionsDate::formatTimestamp($article->updated) . '</div>'; if ($article->body == strip_tags($article->body)) { $article->body = nl2br($article->body, false); } $content .= $article->body; if (Auth::isManager($WT_TREE)) { $content .= '<hr>'; $content .= '<a href="#" onclick="window.open(\'editnews.php?news_id=\'+' . $article->news_id . ', \'_blank\', news_window_specs); return false;">' . I18N::translate('Edit') . '</a>'; $content .= ' | '; $content .= '<a href="index.php?action=deletenews&news_id=' . $article->news_id . '&ctype=' . $ctype . '&ged=' . $WT_TREE->getNameHtml() . '" onclick="return confirm(\'' . I18N::translate('Are you sure you want to delete “%s”?', Filter::escapeHtml($article->subject)) . "');\">" . I18N::translate('Delete') . '</a><br>'; } $content .= '</div>'; } if (Auth::isManager($WT_TREE)) { $content .= '<a href="#" onclick="window.open(\'editnews.php?gedcom_id=' . $WT_TREE->getTreeId() . '\', \'_blank\', news_window_specs); return false;">' . I18N::translate('Add a news article') . '</a>'; } if ($count > $limit) { if (Auth::isManager($WT_TREE)) { $content .= ' | '; } $content .= '<a href="#" onclick="jQuery(\'#' . $id . '\').load(\'index.php?ctype=gedcom&ged=' . $WT_TREE->getNameUrl() . '&block_id=' . $block_id . '&action=ajax&more_news=' . ($more_news + 1) . '\'); return false;">' . I18N::translate('More news articles') . "</a>"; } if ($template) { return Theme::theme()->formatBlock($id, $title, $class, $content); } else { return $content; } }
<input type="hidden" name="action" value="addnoteaction_assisted"> <input type="hidden" name="noteid" value="newnote"> <input id="pid_array" type="hidden" name="pid_array" value="none"> <input id="xref" type="hidden" name="xref" value=<?php echo $xref; ?> > <?php echo Filter::getCsrf(); $summary = $person->formatFirstMajorFact(WT_EVENTS_BIRT, 2); if (!$person->isDead()) { // If alive display age $bdate = $person->getBirthDate(); $age = Date::getAgeGedcom($bdate); if ($age != "") { $summary .= "<span class=\"label\">" . I18N::translate('Age') . ":</span><span class=\"field\"> " . FunctionsDate::getAgeAtEvent($age, true) . "</span>"; } } $summary .= $person->formatFirstMajorFact(WT_EVENTS_DEAT, 2); global $summary, $censyear, $censdate; $censdate = new Date('31 MAR 1901'); $censyear = $censdate->minimumDate()->y; $ctry = 'UK'; // === Set $married to "Not married as we only want the Birth name here" === $married = -1; $nam = $person->getAllNames(); if ($person->getDeathYear() == 0) { $DeathYr = ''; } else { $DeathYr = $person->getDeathYear(); }
/** * Generate the HTML content of this block. * * @param int $block_id * @param bool $template * @param string[] $cfg * * @return string */ public function getBlock($block_id, $template = true, $cfg = array()) { global $ctype, $WT_TREE; switch (Filter::get('action')) { case 'deletenews': $news_id = Filter::getInteger('news_id'); if ($news_id) { Database::prepare("DELETE FROM `##news` WHERE news_id = ?")->execute(array($news_id)); } break; } $block = $this->getBlockSetting($block_id, 'block', '1'); foreach (array('block') as $name) { if (array_key_exists($name, $cfg)) { ${$name} = $cfg[$name]; } } $usernews = Database::prepare("SELECT SQL_CACHE news_id, user_id, gedcom_id, UNIX_TIMESTAMP(updated) AS updated, subject, body FROM `##news` WHERE user_id = ? ORDER BY updated DESC")->execute(array(Auth::id()))->fetchAll(); $id = $this->getName() . $block_id; $class = $this->getName() . '_block'; $title = ''; $title .= $this->getTitle(); $content = ''; if (!$usernews) { $content .= I18N::translate('You have not created any journal items.'); } foreach ($usernews as $news) { $content .= '<div class="journal_box">'; $content .= '<div class="news_title">' . $news->subject . '</div>'; $content .= '<div class="news_date">' . FunctionsDate::formatTimestamp($news->updated) . '</div>'; if ($news->body == strip_tags($news->body)) { // No HTML? $news->body = nl2br($news->body, false); } $content .= $news->body . '<br><br>'; $content .= '<a href="#" onclick="window.open(\'editnews.php?news_id=\'+' . $news->news_id . ', \'_blank\', indx_window_specs); return false;">' . I18N::translate('Edit') . '</a> | '; $content .= '<a href="index.php?action=deletenews&news_id=' . $news->news_id . '&ctype=' . $ctype . '&ged=' . $WT_TREE->getNameHtml() . '" onclick="return confirm(\'' . I18N::translate('Are you sure you want to delete “%s”?', Filter::escapeHtml($news->subject)) . "');\">" . I18N::translate('Delete') . '</a><br>'; $content .= "</div><br>"; } $content .= '<br><a href="#" onclick="window.open(\'editnews.php?user_id=' . Auth::id() . '\', \'_blank\', indx_window_specs); return false;">' . I18N::translate('Add a new journal entry') . '</a>'; if ($template) { if ($block) { $class .= ' small_inner_block'; } return Theme::theme()->formatBlock($id, $title, $class, $content); } else { return $content; } }
/** * What is the client's date. * * @return string */ public function browserDate() { return FunctionsDate::timestampToGedcomDate(WT_TIMESTAMP + WT_TIMESTAMP_OFFSET)->display(); }
if ($controller->record->canShow()) { // Highlight image or silhouette echo '<div id="indi_mainimage">', $controller->record->displayImage(), '</div>'; echo '<div id="header_accordion1">'; // contain accordions for names echo '<h3 class="name_one ', $controller->getPersonStyle($controller->record), '"><span>', $controller->record->getFullName(), '</span>'; // First name accordion header $bdate = $controller->record->getBirthDate(); $ddate = $controller->record->getDeathDate(); echo '<span class="header_age">'; if ($bdate->isOK() && !$controller->record->isDead()) { // If living display age echo GedcomTag::getLabelValue('AGE', FunctionsDate::getAgeAtEvent(Date::getAgeGedcom($bdate), true), $controller->record, 'span'); } elseif ($bdate->isOK() && $ddate->isOK()) { // If dead, show age at death echo GedcomTag::getLabelValue('AGE', FunctionsDate::getAgeAtEvent(Date::getAgeGedcom($bdate, $ddate), false), $controller->record, 'span'); } echo '</span>'; // Display summary birth/death info. echo '<span id="dates">', $controller->record->getLifeSpan(), '</span>'; // Display gender icon foreach ($controller->record->getFacts() as $fact) { if ($fact->getTag() == 'SEX') { $controller->printSexRecord($fact); } } echo '</h3>'; // close first name accordion header // Display name details foreach ($controller->record->getFacts() as $fact) { if ($fact->getTag() == 'NAME') {
<a href="?action=edit&user_id=<?php echo $user->getUserId(); ?> "> <?php echo Filter::escapeHtml($user->getUserName()); ?> — <?php echo $user->getRealNameHtml(); ?> </a> </td> <td> <?php echo I18N::translate('User’s account has been inactive too long: ') . FunctionsDate::timestampToGedcomDate($datelogin)->display(); ?> </td> <td> <input type="checkbox" name="del_<?php echo $user->getUserId(); ?> " value="1"> </td> </tr> <?php } } // Check unverified users foreach (User::all() as $user) { if (date('U') - (int) $user->getPreference('reg_timestamp') > 604800 && !$user->getPreference('verified')) {
/** * Generate the HTML content of this block. * * @param int $block_id * @param bool $template * @param string[] $cfg * * @return string */ public function getBlock($block_id, $template = true, $cfg = array()) { global $ctype, $WT_TREE; $title = $this->getBlockSetting($block_id, 'title'); $html = $this->getBlockSetting($block_id, 'html'); $gedcom = $this->getBlockSetting($block_id, 'gedcom'); $show_timestamp = $this->getBlockSetting($block_id, 'show_timestamp', '0'); $languages = $this->getBlockSetting($block_id, 'languages'); // Only show this block for certain languages if ($languages && !in_array(WT_LOCALE, explode(',', $languages))) { return ''; } /* * Select GEDCOM */ switch ($gedcom) { case '__current__': $stats = new Stats($WT_TREE); break; case '__default__': $tree = Tree::findByName(Site::getPreference('DEFAULT_GEDCOM')); if ($tree) { $stats = new Stats($tree); } else { $stats = new Stats($WT_TREE); } break; default: $tree = Tree::findByName($gedcom); if ($tree) { $stats = new Stats($tree); } else { $stats = new Stats($WT_TREE); } break; } /* * Retrieve text, process embedded variables */ if (strpos($title, '#') !== false || strpos($html, '#') !== false) { $title = $stats->embedTags($title); $html = $stats->embedTags($html); } /* * Start Of Output */ $id = $this->getName() . $block_id; $class = $this->getName() . '_block'; if ($ctype === 'gedcom' && Auth::isManager($WT_TREE) || $ctype === 'user' && Auth::check()) { $title = '<a class="icon-admin" title="' . I18N::translate('Configure') . '" href="block_edit.php?block_id=' . $block_id . '&ged=' . $WT_TREE->getNameHtml() . '&ctype=' . $ctype . '"></a>' . $title; } $content = $html; if ($show_timestamp) { $content .= '<br>' . FunctionsDate::formatTimestamp($this->getBlockSetting($block_id, 'timestamp', WT_TIMESTAMP) + WT_TIMESTAMP_OFFSET); } if ($template) { return Theme::theme()->formatBlock($id, $title, $class, $content); } else { return $content; } }
/** * Generate the HTML content of this block. * * @param int $block_id * @param bool $template * @param string[] $cfg * * @return string */ public function getBlock($block_id, $template = true, $cfg = array()) { global $ctype, $WT_TREE; switch (Filter::get('action')) { case 'deletenews': $news_id = Filter::getInteger('news_id'); if ($news_id) { Database::prepare("DELETE FROM `##news` WHERE news_id = ?")->execute(array($news_id)); } break; } $articles = Database::prepare("SELECT SQL_CACHE news_id, user_id, gedcom_id, UNIX_TIMESTAMP(updated) + :offset AS updated, subject, body FROM `##news` WHERE user_id = :user_id ORDER BY updated DESC")->execute(array('offset' => WT_TIMESTAMP_OFFSET, 'user_id' => Auth::id()))->fetchAll(); $id = $this->getName() . $block_id; $class = $this->getName() . '_block'; $title = $this->getTitle(); $content = ''; if (empty($articles)) { $content .= '<p>' . I18N::translate('You have not created any journal items.') . '</p>'; } foreach ($articles as $article) { $content .= '<div class="journal_box">'; $content .= '<div class="news_title">' . Filter::escapeHtml($article->subject) . '</div>'; $content .= '<div class="news_date">' . FunctionsDate::formatTimestamp($article->updated) . '</div>'; if ($article->body == strip_tags($article->body)) { $article->body = nl2br($article->body, false); } $content .= $article->body; $content .= '<a href="#" onclick="window.open(\'editnews.php?news_id=\'+' . $article->news_id . ', \'_blank\', indx_window_specs); return false;">' . I18N::translate('Edit') . '</a>'; $content .= ' | '; $content .= '<a href="index.php?action=deletenews&news_id=' . $article->news_id . '&ctype=' . $ctype . '&ged=' . $WT_TREE->getNameHtml() . '" onclick="return confirm(\'' . I18N::translate('Are you sure you want to delete “%s”?', Filter::escapeHtml($article->subject)) . "');\">" . I18N::translate('Delete') . '</a><br>'; $content .= '</div><br>'; } $content .= '<p><a href="#" onclick="window.open(\'editnews.php?user_id=' . Auth::id() . '\', \'_blank\', indx_window_specs); return false;">' . I18N::translate('Add a journal entry') . '</a></p>'; if ($template) { return Theme::theme()->formatBlock($id, $title, $class, $content); } else { return $content; } }
$output .= '<td class="list_value"><a href="edit_changes.php?action=accept&change_id=' . $change->change_id . '">' . I18N::translate('Accept') . '</a></td>'; $output .= '<td class="list_value">'; foreach ($record->getFacts() as $fact) { if ($fact->getTag() != 'CHAN') { if ($fact->isPendingAddition()) { $output .= '<div class="new" title="' . strip_tags($fact->summary()) . '">' . $fact->getLabel() . '</div>'; } elseif ($fact->isPendingDeletion()) { $output .= '<div class="old" title="' . strip_tags($fact->summary()) . '">' . $fact->getLabel() . '</div>'; } } } echo '</td>'; $output .= '<td class="list_value"><a href="#" onclick="return reply(\'' . $change->user_name . '\', \'' . I18N::translate('Moderate pending changes') . '\')" title="' . I18N::translate('Send a message') . '">'; $output .= Filter::escapeHtml($change->real_name); $output .= ' - ' . Filter::escapeHtml($change->user_name) . '</a></td>'; $output .= '<td class="list_value">' . FunctionsDate::formatTimestamp($change->change_timestamp) . '</td>'; $output .= '<td class="list_value">' . $change->gedcom_name . '</td>'; $output .= '<td class="list_value"><a href="edit_changes.php?action=undo&change_id=' . $change->change_id . '">' . I18N::translate('Reject') . '</a></td>'; $output .= '</tr>'; } $output .= '</table></td></tr></td></tr></table>'; //-- Now for the global Action bar: $output2 = '<br><table class="list_table">'; // Row 1 column 1: title "Accept all" $output2 .= '<tr><td class="list_label">' . I18N::translate('Accept all changes') . '</td>'; // Row 1 column 2: title "Undo all" $output2 .= '<td class="list_label">' . I18N::translate('Reject all changes') . '</td></tr>'; // Row 2 column 1: action "Accept all" $output2 .= '<tr><td class="list_value">'; $count = 0; foreach ($changed_gedcoms as $gedcom_name) {