summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--admin_site_upgrade.php13
-rw-r--r--includes/functions/functions_charts.php9
-rw-r--r--library/WT/Fact.php217
-rw-r--r--modules_v3/batch_update/plugins/search_replace.php4
4 files changed, 152 insertions, 91 deletions
diff --git a/admin_site_upgrade.php b/admin_site_upgrade.php
index aafe1fcd94..62fea56db2 100644
--- a/admin_site_upgrade.php
+++ b/admin_site_upgrade.php
@@ -281,6 +281,7 @@ echo '</li>'; flush();
echo '<li>', /* I18N: The system is about to [...] */ WT_I18N::translate('Export all family trees to GEDCOM files…');
foreach (WT_Tree::getAll() as $tree) {
+ reset_timeout();
$filename = WT_DATA_DIR . $tree->tree_name . date('-Y-m-d') . '.ged';
if ($tree->exportGedcom($filename)) {
echo '<br>', WT_I18N::translate('Family tree exported to %s.', '<span dir="ltr">' . $filename . '</span>'), $icon_success;
@@ -301,6 +302,7 @@ echo '<li>', /* I18N: The system is about to [...]; %s is a URL. */ WT_I18N::tra
$zip_file = WT_DATA_DIR . basename($download_url);
$zip_dir = WT_DATA_DIR . basename($download_url, '.zip');
$zip_stream = fopen($zip_file, 'w');
+reset_timeout();
$start_time = microtime(true);
WT_File::fetchUrl($download_url, $zip_stream);
$end_time = microtime(true);
@@ -341,6 +343,7 @@ if (!is_array($res) || $res['status'] != 'ok') {
$num_files = $res['nb'];
+reset_timeout();
$start_time = microtime(true);
$res = $archive->extract(
PCLZIP_OPT_PATH, $zip_dir,
@@ -376,6 +379,7 @@ echo '</li>'; flush();
echo '<li>', WT_I18N::translate('Check file permissions…');
+reset_timeout();
$iterator = new RecursiveDirectoryIterator($zip_dir);
//$iterator->setFlags(RecursiveDirectoryIterator::SKIP_DOTS);
foreach (new RecursiveIteratorIterator($iterator) as $file) {
@@ -421,6 +425,7 @@ echo '<li>', /* I18N: The system is about to [...] */ WT_I18N::translate('Copy f
@copy('library/WT/Gedcom/Code/Rela.php', 'library/WT/Gedcom/Code/Rela' . date('-Y-m-d') . '.php');
@copy('library/WT/Gedcom/Tag.php', 'library/WT/Gedcom/Tag' . date('-Y-m-d') . '.php');
+reset_timeout();
$start_time = microtime(true);
$res = $archive->extract(
PCLZIP_OPT_PATH, WT_ROOT,
@@ -465,6 +470,7 @@ echo '</li>'; flush();
echo '<li>', /* I18N: The system is about to [...] */ WT_I18N::translate('Delete temporary files…');
+reset_timeout();
if (WT_File::delete($zip_dir)) {
echo '<br>', WT_I18N::translate('The folder %s was deleted.', '<span dir="auto">' . $zip_dir . '</span>'), $icon_success;
} else {
@@ -481,3 +487,10 @@ echo '</li>';
echo '</ul>';
echo '<p>', WT_I18N::translate('The upgrade is complete.'), '</p>';
+
+// Reset the time limit, as timeouts in this script could leave the upgrade incomplete.
+function reset_timeout() {
+ if (!ini_get('safe_mode') && strpos(ini_get('disable_functions'), 'set_time_limit')===false) {
+ set_time_limit(ini_get('max_execution_time'));
+ }
+}
diff --git a/includes/functions/functions_charts.php b/includes/functions/functions_charts.php
index 19558a1e86..a97b4701c2 100644
--- a/includes/functions/functions_charts.php
+++ b/includes/functions/functions_charts.php
@@ -119,8 +119,7 @@ function print_family_parents(WT_Family $family, $sosa=0, $label='', $parid='',
echo "</td>";
// husband’s parents
$hfam = $husb->getPrimaryChildFamily();
-
- if ($hfam || $sosa) {
+ if ($hfam) { // remove the|| test for $sosa
echo "<td rowspan=\"2\"><img src=\"".$WT_IMAGES["hline"]."\" alt=\"\"></td><td rowspan=\"2\"><img src=\"".$WT_IMAGES["vline"]."\" width=\"3\" height=\"" . ($pbheight+9) . "\" alt=\"\"></td>";
echo "<td><img class=\"line5\" src=\"".$WT_IMAGES["hline"]."\" alt=\"\"></td><td>";
// husband’s father
@@ -144,7 +143,7 @@ function print_family_parents(WT_Family $family, $sosa=0, $label='', $parid='',
print_url_arrow($hfam->getXref(), ($sosa==0 ? '?famid='.$hfam->getXref().'&amp;ged='.WT_GEDURL : '#'.$hfam->getXref()), $hfam->getXref(), 1);
echo '</td>';
}
- if ($hfam || $sosa) {
+ if ($hfam) { // remove the|| test for $sosa
// husband’s mother
echo "</tr><tr><td><img src=\"".$WT_IMAGES["hline"]."\" alt=\"\"></td><td>";
if ($hfam && $hfam->getWife()) {
@@ -200,7 +199,7 @@ function print_family_parents(WT_Family $family, $sosa=0, $label='', $parid='',
// wife’s parents
$hfam = $wife->getPrimaryChildFamily();
- if ($hfam || $sosa) {
+ if ($hfam) { // remove the|| test for $sosa
echo "<td rowspan=\"2\"><img src=\"".$WT_IMAGES["hline"]."\" alt=\"\"></td><td rowspan=\"2\"><img src=\"".$WT_IMAGES["vline"]."\" width=\"3\" height=\"" . ($pbheight+9) . "\" alt=\"\"></td>";
echo "<td><img class=\"line5\" src=\"".$WT_IMAGES["hline"]."\" alt=\"\"></td><td>";
// wife’s father
@@ -224,7 +223,7 @@ function print_family_parents(WT_Family $family, $sosa=0, $label='', $parid='',
print_url_arrow($hfam->getXref(), ($sosa==0 ? '?famid='.$hfam->getXref().'&amp;ged='.WT_GEDURL : '#'.$hfam->getXref()), $hfam->getXref(), 1);
echo '</td>';
}
- if ($hfam || $sosa) {
+ if ($hfam) { // remove the|| test for $sosa
// wife’s mother
echo "</tr><tr><td><img src=\"".$WT_IMAGES["hline"]."\" alt=\"\"></td><td>";
if ($hfam && $hfam->getWife()) {
diff --git a/library/WT/Fact.php b/library/WT/Fact.php
index f1e23256e8..de3b261420 100644
--- a/library/WT/Fact.php
+++ b/library/WT/Fact.php
@@ -307,94 +307,118 @@ class WT_Fact {
}
}
- // Static Helper functions to sort events
- static function CompareDate($a, $b) {
+ /**
+ * Static Helper functions to sort events
+ *
+ * @param WT_Fact $a Fact one
+ * @param WT_Fact $b Fact two
+ *
+ * @return integer
+ */
+ public static function CompareDate(WT_Fact $a, WT_Fact $b)
+ {
if ($a->getDate()->isOK() && $b->getDate()->isOK()) {
// If both events have dates, compare by date
- $ret=WT_Date::Compare($a->getDate(), $b->getDate());
- if ($ret==0) {
+ $ret = WT_Date::Compare($a->getDate(), $b->getDate());
+
+ if ($ret == 0) {
// If dates are the same, compare by fact type
- $ret=self::CompareType($a, $b);
+ $ret = self::CompareType($a, $b);
+
// If the fact type is also the same, retain the initial order
- if ($ret==0) {
- $ret=$a->sortOrder - $b->sortOrder;
+ if ($ret == 0) {
+ $ret = $a->sortOrder - $b->sortOrder;
}
}
+
return $ret;
} else {
- // One or both events have no date - retain the initial orde
+ // One or both events have no date - retain the initial order
return $a->sortOrder - $b->sortOrder;
}
}
- // Static method to Compare two events by their type
- static function CompareType($a, $b) {
+ /**
+ * Static method to compare two events by their type.
+ *
+ * @param WT_Fact $a Fact one
+ * @param WT_Fact $b Fact two
+ *
+ * @return integer
+ */
+ public static function CompareType(WT_Fact $a, WT_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_', // other events of close relatives
- 'CENS',
- 'OCCU',
- 'RESI',
- 'PROP',
- 'CHRA',
- 'RETI',
- 'FACT', 'EVEN',
- '_NMR', '_NMAR', 'NMR',
- 'NCHI',
- 'WILL',
- '_HOL',
- '_????_',
- 'DEAT',
- '_FNRL', 'BURI', 'CREM', '_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', // For media objects
- 'AFN', 'REFN', '_PRMN', 'REF', 'RIN', '_UID',
- 'OBJE', 'NOTE', 'SOUR',
- 'CHAN', '_TODO',
- ));
+ 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_', // other events of close relatives
+ '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', // For media objects
+ '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 WT_Family && $b->parent instanceof WT_Family && $a->parent !== $b->parent) {
+ if (($a->parent instanceof WT_Family)
+ && ($b->parent instanceof WT_Family)
+ && ($a->parent !== $b->parent)
+ ) {
return $a->sortOrder - $b->sortOrder;
}
@@ -404,31 +428,56 @@ class WT_Fact {
// 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];
+ $atag = $match[1];
} else {
- $atag="_????_";
+ $atag = "_????_";
}
}
+
if (!array_key_exists($btag, $factsort)) {
if (preg_match('/^(_(BIRT|MARR|DEAT|BURI)_)/', $btag, $match)) {
- $btag=$match[1];
+ $btag = $match[1];
} else {
- $btag="_????_";
+ $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
+ // - 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;
}
diff --git a/modules_v3/batch_update/plugins/search_replace.php b/modules_v3/batch_update/plugins/search_replace.php
index 8314b10241..ce5bf59a1e 100644
--- a/modules_v3/batch_update/plugins/search_replace.php
+++ b/modules_v3/batch_update/plugins/search_replace.php
@@ -45,13 +45,13 @@ class search_replace_bu_plugin extends base_plugin {
}
function doesRecordNeedUpdate($xref, $gedrec) {
- return !$this->error && preg_match('/(?:'.$this->regex.')/m'.$this->case, $gedrec);
+ return !$this->error && preg_match('/(?:'.$this->regex.')/mu'.$this->case, $gedrec);
}
function updateRecord($xref, $gedrec) {
// Allow "\n" to indicate a line-feed in replacement text.
// Back-references such as $1, $2 are handled automatically.
- return preg_replace('/'.$this->regex.'/'.$this->case, str_replace('\n', "\n", $this->replace), $gedrec);
+ return preg_replace('/'.$this->regex.'/mu'.$this->case, str_replace('\n', "\n", $this->replace), $gedrec);
}
function getOptions() {