diff options
| author | Greg Roach <fisharebest@gmail.com> | 2015-01-31 22:56:04 +0000 |
|---|---|---|
| committer | Greg Roach <fisharebest@gmail.com> | 2015-01-31 22:56:04 +0000 |
| commit | 416a30c73a53db5fb0e64d2ab62d5bd18774fdf3 (patch) | |
| tree | a269c3a735a4c3ec5c36822529e9dad514d349f6 /library | |
| parent | d479bd75482b9a2e89c9fcd1eb23e3c236426c79 (diff) | |
| download | webtrees-416a30c73a53db5fb0e64d2ab62d5bd18774fdf3.tar.gz webtrees-416a30c73a53db5fb0e64d2ab62d5bd18774fdf3.tar.bz2 webtrees-416a30c73a53db5fb0e64d2ab62d5bd18774fdf3.zip | |
#1416744 - Family tree titles on RTL/LTR pages
Diffstat (limited to 'library')
| -rw-r--r-- | library/WT/Controller/Search.php | 36 | ||||
| -rw-r--r-- | library/WT/Log.php | 2 | ||||
| -rw-r--r-- | library/WT/Module.php | 2 | ||||
| -rw-r--r-- | library/WT/Stats.php | 216 | ||||
| -rw-r--r-- | library/WT/Theme/BaseTheme.php | 16 | ||||
| -rw-r--r-- | library/WT/Tree.php | 162 | ||||
| -rw-r--r-- | library/WT/User.php | 2 |
7 files changed, 241 insertions, 195 deletions
diff --git a/library/WT/Controller/Search.php b/library/WT/Controller/Search.php index b96c93be8c..60786338a9 100644 --- a/library/WT/Controller/Search.php +++ b/library/WT/Controller/Search.php @@ -133,9 +133,9 @@ class WT_Controller_Search extends WT_Controller_Page { // Retrieve the gedcoms to search in if (count(WT_Tree::getAll()) > 1 && WT_Site::getPreference('ALLOW_CHANGE_GEDCOM')) { foreach (WT_Tree::getAll() as $search_tree) { - $str = str_replace(array(".", "-", " "), array("_", "_", "_"), $search_tree->tree_name); + $str = str_replace(array(".", "-", " "), array("_", "_", "_"), $search_tree->name); if (isset ($_REQUEST["$str"]) || $topsearch) { - $this->search_trees[$search_tree->tree_id] = $search_tree; + $this->search_trees[$search_tree->id()] = $search_tree; $_REQUEST["$str"] = 'yes'; } } @@ -607,15 +607,15 @@ class WT_Controller_Search extends WT_Controller_Page { foreach ($this->search_trees as $search_tree) { $datalist = array(); foreach ($this->myindilist as $individual) { - if ($individual->getGedcomId() === $search_tree->tree_id) { + if ($individual->getGedcomId() === $search_tree->id()) { $datalist[] = $individual; } } if ($datalist) { usort($datalist, array('WT_GedcomRecord', 'compare')); - $GEDCOM = $search_tree->tree_name; - load_gedcom_settings($search_tree->tree_id); - echo '<h3 class="indi-acc-header"><a href="#"><span class="search_item" dir="auto">', $this->myquery, '</span> @ <span>', $search_tree->tree_title_html, '</span></a></h3> + $GEDCOM = $search_tree->name; + load_gedcom_settings($search_tree->id()); + echo '<h3 class="indi-acc-header"><a href="#"><span class="search_item" dir="auto">', $this->myquery, '</span> @ <span>', $search_tree->titleHtml(), '</span></a></h3> <div class="indi-acc_content">', format_indi_table($datalist); echo '</div>'; //indi-acc_content @@ -630,15 +630,15 @@ class WT_Controller_Search extends WT_Controller_Page { foreach ($this->search_trees as $search_tree) { $datalist = array(); foreach ($this->myfamlist as $family) { - if ($family->getGedcomId() === $search_tree->tree_id) { + if ($family->getGedcomId() === $search_tree->id()) { $datalist[] = $family; } } if ($datalist) { usort($datalist, array('WT_GedcomRecord', 'compare')); - $GEDCOM = $search_tree->tree_name; - load_gedcom_settings($search_tree->tree_id); - echo '<h3 class="fam-acc-header"><a href="#"><span class="search_item" dir="auto">', $this->myquery, '</span> @ <span>', $search_tree->tree_title_html, '</span></a></h3> + $GEDCOM = $search_tree->name; + load_gedcom_settings($search_tree->id()); + echo '<h3 class="fam-acc-header"><a href="#"><span class="search_item" dir="auto">', $this->myquery, '</span> @ <span>', $search_tree->titleHtml(), '</span></a></h3> <div class="fam-acc_content">', format_fam_table($datalist); echo '</div>'; //fam-acc_content @@ -653,15 +653,15 @@ class WT_Controller_Search extends WT_Controller_Page { foreach ($this->search_trees as $search_tree) { $datalist = array(); foreach ($this->mysourcelist as $source) { - if ($source->getGedcomId() === $search_tree->tree_id) { + if ($source->getGedcomId() === $search_tree->id()) { $datalist[] = $source; } } if ($datalist) { usort($datalist, array('WT_GedcomRecord', 'compare')); - $GEDCOM = $search_tree->tree_name; - load_gedcom_settings($search_tree->tree_id); - echo '<h3 class="source-acc-header"><a href="#"><span class="search_item" dir="auto">', $this->myquery, '</span> @ <span>', $search_tree->tree_title_html, '</span></a></h3> + $GEDCOM = $search_tree->name; + load_gedcom_settings($search_tree->id()); + echo '<h3 class="source-acc-header"><a href="#"><span class="search_item" dir="auto">', $this->myquery, '</span> @ <span>', $search_tree->titleHtml(), '</span></a></h3> <div class="source-acc_content">', format_sour_table($datalist); echo '</div>'; //fam-acc_content @@ -676,15 +676,15 @@ class WT_Controller_Search extends WT_Controller_Page { foreach ($this->search_trees as $search_tree) { $datalist = array(); foreach ($this->mynotelist as $note) { - if ($note->getGedcomId() === $search_tree->tree_id) { + if ($note->getGedcomId() === $search_tree->id()) { $datalist[] = $note; } } if ($datalist) { usort($datalist, array('WT_GedcomRecord', 'compare')); - $GEDCOM = $search_tree->tree_name; - load_gedcom_settings($search_tree->tree_id); - echo '<h3 class="note-acc-header"><a href="#"><span class="search_item" dir="auto">', $this->myquery, '</span> @ <span>', $search_tree->tree_title_html, '</span></a></h3> + $GEDCOM = $search_tree->name; + load_gedcom_settings($search_tree->id()); + echo '<h3 class="note-acc-header"><a href="#"><span class="search_item" dir="auto">', $this->myquery, '</span> @ <span>', $search_tree->titleHtml(), '</span></a></h3> <div class="note-acc_content">', format_note_table($datalist); echo '</div>'; //note-acc_content diff --git a/library/WT/Log.php b/library/WT/Log.php index aa9a4fd085..38dee21e4a 100644 --- a/library/WT/Log.php +++ b/library/WT/Log.php @@ -55,7 +55,7 @@ class Log { $message, $WT_REQUEST->getClientIp(), Auth::id(), - $tree ? $tree->tree_id : null + $tree ? $tree->id() : null )); } diff --git a/library/WT/Module.php b/library/WT/Module.php index 721b9bf212..cfc4a7a03c 100644 --- a/library/WT/Module.php +++ b/library/WT/Module.php @@ -171,7 +171,7 @@ abstract class WT_Module { $access_level = WT_DB::prepare( "SELECT access_level FROM `##module_privacy` WHERE gedcom_id = :gedcom_id AND module_name = :module_name AND component = :component" )->execute(array( - 'gedcom_id' => $tree->tree_id, + 'gedcom_id' => $tree->id(), 'module_name' => $this->getName(), 'component' => $component, ))->fetchOne(); diff --git a/library/WT/Stats.php b/library/WT/Stats.php index 3d6736caae..99817c9e34 100644 --- a/library/WT/Stats.php +++ b/library/WT/Stats.php @@ -181,21 +181,21 @@ class WT_Stats { * @return string */ public function gedcomFilename() { - return $this->tree->tree_name; + return $this->tree->name(); } /** * @return string */ public function gedcomID() { - return $this->tree->tree_id; + return $this->tree->id(); } /** * @return string */ public function gedcomTitle() { - return $this->tree->tree_title_html; + return $this->tree->titleHtml(); } /** @@ -266,7 +266,7 @@ class WT_Stats { public function gedcomUpdated() { $row = WT_DB::prepare( "SELECT SQL_CACHE d_year, d_month, d_day FROM `##dates` WHERE d_julianday1 = (SELECT MAX(d_julianday1) FROM `##dates` WHERE d_file =? AND d_fact='CHAN') LIMIT 1" - )->execute(array($this->tree->tree_id))->fetchOneRow(); + )->execute(array($this->tree->id()))->fetchOneRow(); if ($row) { $date = new WT_Date("{$row->d_day} {$row->d_month} {$row->d_year}"); @@ -328,7 +328,7 @@ class WT_Stats { private function totalIndividualsQuery() { return (int) WT_DB::prepare("SELECT SQL_CACHE COUNT(*) FROM `##individuals` WHERE i_file = ?") - ->execute(array($this->tree->tree_id)) + ->execute(array($this->tree->id())) ->fetchOne(); } @@ -343,7 +343,7 @@ class WT_Stats { * @return integer */ private function totalIndisWithSourcesQuery() { - $rows = $this->runSql("SELECT SQL_CACHE COUNT(DISTINCT i_id) AS tot FROM `##link`, `##individuals` WHERE i_id=l_from AND i_file=l_file AND l_file=" . $this->tree->tree_id . " AND l_type='SOUR'"); + $rows = $this->runSql("SELECT SQL_CACHE COUNT(DISTINCT i_id) AS tot FROM `##link`, `##individuals` WHERE i_id=l_from AND i_file=l_file AND l_file=" . $this->tree->id() . " AND l_type='SOUR'"); return (int) $rows[0]['tot']; } @@ -408,7 +408,7 @@ class WT_Stats { private function totalFamiliesQuery() { return (int) WT_DB::prepare("SELECT SQL_CACHE COUNT(*) FROM `##families` WHERE f_file=?") - ->execute(array($this->tree->tree_id)) + ->execute(array($this->tree->id())) ->fetchOne(); } @@ -423,7 +423,7 @@ class WT_Stats { * @return integer */ private function totalFamsWithSourcesQuery() { - $rows = $this->runSql("SELECT SQL_CACHE COUNT(DISTINCT f_id) AS tot FROM `##link`, `##families` WHERE f_id=l_from AND f_file=l_file AND l_file=" . $this->tree->tree_id . " AND l_type='SOUR'"); + $rows = $this->runSql("SELECT SQL_CACHE COUNT(DISTINCT f_id) AS tot FROM `##link`, `##families` WHERE f_id=l_from AND f_file=l_file AND l_file=" . $this->tree->id() . " AND l_type='SOUR'"); return (int) $rows[0]['tot']; } @@ -489,7 +489,7 @@ class WT_Stats { private function totalSourcesQuery() { return (int) WT_DB::prepare("SELECT SQL_CACHE COUNT(*) FROM `##sources` WHERE s_file=?") - ->execute(array($this->tree->tree_id)) + ->execute(array($this->tree->id())) ->fetchOne(); } @@ -513,7 +513,7 @@ class WT_Stats { private function totalNotesQuery() { return (int) WT_DB::prepare("SELECT SQL_CACHE COUNT(*) FROM `##other` WHERE o_type='NOTE' AND o_file=?") - ->execute(array($this->tree->tree_id)) + ->execute(array($this->tree->id())) ->fetchOne(); } @@ -537,7 +537,7 @@ class WT_Stats { private function totalRepositoriesQuery() { return (Int) WT_DB::prepare("SELECT SQL_CACHE COUNT(*) FROM `##other` WHERE o_type='REPO' AND o_file=?") - ->execute(array($this->tree->tree_id)) + ->execute(array($this->tree->id())) ->fetchOne(); } @@ -571,7 +571,7 @@ class WT_Stats { $vars = ''; $distinct = 'DISTINCT'; } - $vars[] = $this->tree->tree_id; + $vars[] = $this->tree->id(); $total = WT_DB::prepare( "SELECT SQL_CACHE COUNT({$distinct} n_surn COLLATE '" . WT_I18N::$collation . "')" . @@ -594,7 +594,7 @@ class WT_Stats { public function totalGivennames($params = array()) { if ($params) { $qs = implode(',', array_fill(0, count($params), '?')); - $params[] = $this->tree->tree_id; + $params[] = $this->tree->id(); $total = WT_DB::prepare("SELECT SQL_CACHE COUNT( n_givn) FROM `##name` WHERE n_givn IN ({$qs}) AND n_file=?") ->execute($params) @@ -602,7 +602,7 @@ class WT_Stats { } else { $total = WT_DB::prepare("SELECT SQL_CACHE COUNT(DISTINCT n_givn) FROM `##name` WHERE n_givn IS NOT NULL AND n_file=?") - ->execute(array($this->tree->tree_id)) + ->execute(array($this->tree->id())) ->fetchOne(); } @@ -616,7 +616,7 @@ class WT_Stats { */ public function totalEvents($params = array()) { $sql = "SELECT SQL_CACHE COUNT(*) AS tot FROM `##dates` WHERE d_file=?"; - $vars = array($this->tree->tree_id); + $vars = array($this->tree->id()); $no_types = array('HEAD', 'CHAN'); if ($params) { @@ -715,7 +715,7 @@ class WT_Stats { private function totalSexMalesQuery() { return (int) WT_DB::prepare("SELECT SQL_CACHE COUNT(*) FROM `##individuals` WHERE i_file=? AND i_sex=?") - ->execute(array($this->tree->tree_id, 'M')) + ->execute(array($this->tree->id(), 'M')) ->fetchOne(); } @@ -739,7 +739,7 @@ class WT_Stats { private function totalSexFemalesQuery() { return (int) WT_DB::prepare("SELECT SQL_CACHE COUNT(*) FROM `##individuals` WHERE i_file=? AND i_sex=?") - ->execute(array($this->tree->tree_id, 'F')) + ->execute(array($this->tree->id(), 'F')) ->fetchOne(); } @@ -763,7 +763,7 @@ class WT_Stats { private function totalSexUnknownQuery() { return (int) WT_DB::prepare("SELECT SQL_CACHE COUNT(*) FROM `##individuals` WHERE i_file=? AND i_sex=?") - ->execute(array($this->tree->tree_id, 'U')) + ->execute(array($this->tree->id(), 'U')) ->fetchOne(); } @@ -856,7 +856,7 @@ class WT_Stats { private function totalLivingQuery() { return (int) WT_DB::prepare("SELECT SQL_CACHE COUNT(*) FROM `##individuals` WHERE i_file=? AND i_gedcom NOT REGEXP '\\n1 (" . WT_EVENTS_DEAT . ")'") - ->execute(array($this->tree->tree_id)) + ->execute(array($this->tree->id())) ->fetchOne(); } @@ -880,7 +880,7 @@ class WT_Stats { private function totalDeceasedQuery() { return (int) WT_DB::prepare("SELECT SQL_CACHE COUNT(*) FROM `##individuals` WHERE i_file=? AND i_gedcom REGEXP '\\n1 (" . WT_EVENTS_DEAT . ")'") - ->execute(array($this->tree->tree_id)) + ->execute(array($this->tree->id())) ->fetchOne(); } @@ -983,7 +983,7 @@ class WT_Stats { return 0; } $sql = "SELECT SQL_CACHE COUNT(*) AS tot FROM `##media` WHERE m_file=?"; - $vars = array($this->tree->tree_id); + $vars = array($this->tree->id()); if ($type != 'all') { if ($type == 'unknown') { @@ -1252,10 +1252,10 @@ class WT_Stats { $rows = $this->runSql( "SELECT SQL_CACHE d_year, d_type, d_fact, d_gid" . " FROM `##dates`" . - " WHERE d_file={$this->tree->tree_id} AND d_fact IN ({$query_field}) AND d_julianday1=(" . + " WHERE d_file={$this->tree->id()} AND d_fact IN ({$query_field}) AND d_julianday1=(" . " SELECT {$dmod}( d_julianday1 )" . " FROM `##dates`" . - " WHERE d_file={$this->tree->tree_id} AND d_fact IN ({$query_field}) AND d_julianday1<>0 )" . + " WHERE d_file={$this->tree->id()} AND d_fact IN ({$query_field}) AND d_julianday1<>0 )" . " LIMIT 1" ); if (!isset($rows[0])) { @@ -1305,12 +1305,12 @@ class WT_Stats { if ($what == 'INDI') { $rows = WT_DB::prepare("SELECT i_gedcom AS ged FROM `##individuals` WHERE i_file=?") - ->execute(array($this->tree->tree_id)) + ->execute(array($this->tree->id())) ->fetchAll(); } elseif ($what == 'FAM') { $rows = WT_DB::prepare("SELECT f_gedcom AS ged FROM `##families` WHERE f_file=?") - ->execute(array($this->tree->tree_id)) + ->execute(array($this->tree->id())) ->fetchAll(); } $placelist = array(); @@ -1350,7 +1350,7 @@ class WT_Stats { $join . " WHERE" . " p_id={$parent} AND" . - " p_file={$this->tree->tree_id}" . + " p_file={$this->tree->id()}" . " GROUP BY place" ); @@ -1372,7 +1372,7 @@ class WT_Stats { " JOIN `##placelinks` ON pl_file=p_file AND p_id=pl_p_id" . $join . " WHERE" . - " p_file={$this->tree->tree_id}" . + " p_file={$this->tree->id()}" . " AND p_parent_id='0'" . " GROUP BY country ORDER BY tot DESC, country ASC" ); @@ -1387,7 +1387,7 @@ class WT_Stats { private function totalPlacesQuery() { return (int) WT_DB::prepare("SELECT SQL_CACHE COUNT(*) FROM `##places` WHERE p_file=?") - ->execute(array($this->tree->tree_id)) + ->execute(array($this->tree->id())) ->fetchOne(); } @@ -1588,7 +1588,7 @@ class WT_Stats { foreach ($all_db_countries as $country_code => $country) { $top10[] = '<li>'; foreach ($country as $country_name => $tot) { - $tmp = new WT_Place($country_name, $this->tree->tree_id); + $tmp = new WT_Place($country_name, $this->tree->id()); $place = '<a href="' . $tmp->getURL() . '" class="list_item">' . $all_countries[$country_code] . '</a>'; $top10[] .= $place . ' - ' . WT_I18N::number($tot); } @@ -1610,7 +1610,7 @@ class WT_Stats { $i = 1; arsort($places); foreach ($places as $place => $count) { - $tmp = new WT_Place($place, $this->tree->tree_id); + $tmp = new WT_Place($place, $this->tree->id()); $place = '<a href="' . $tmp->getURL() . '" class="list_item">' . $tmp->getFullName() . '</a>'; $top10[] = '<li>' . $place . ' - ' . WT_I18N::number($count) . '</li>'; if ($i++ == 10) { @@ -1631,7 +1631,7 @@ class WT_Stats { $i = 1; arsort($places); foreach ($places as $place => $count) { - $tmp = new WT_Place($place, $this->tree->tree_id); + $tmp = new WT_Place($place, $this->tree->id()); $place = '<a href="' . $tmp->getURL() . '" class="list_item">' . $tmp->getFullName() . '</a>'; $top10[] = '<li>' . $place . ' - ' . WT_I18N::number($count) . '</li>'; if ($i++ == 10) { @@ -1652,7 +1652,7 @@ class WT_Stats { $i = 1; arsort($places); foreach ($places as $place => $count) { - $tmp = new WT_Place($place, $this->tree->tree_id); + $tmp = new WT_Place($place, $this->tree->id()); $place = '<a href="' . $tmp->getURL() . '" class="list_item">' . $tmp->getFullName() . '</a>'; $top10[] = '<li>' . $place . ' - ' . WT_I18N::number($count) . '</li>'; if ($i++ == 10) { @@ -1684,7 +1684,7 @@ class WT_Stats { $sql = "SELECT SQL_CACHE FLOOR(d_year/100+1) AS century, COUNT(*) AS total FROM `##dates` " . "WHERE " . - "d_file={$this->tree->tree_id} AND " . + "d_file={$this->tree->id()} AND " . "d_year<>0 AND " . "d_fact='BIRT' AND " . "d_type IN ('@#DGREGORIAN@', '@#DJULIAN@')"; @@ -1693,14 +1693,14 @@ class WT_Stats { "SELECT SQL_CACHE d_month, i_sex, COUNT(*) AS total FROM `##dates` " . "JOIN `##individuals` ON d_file = i_file AND d_gid = i_id " . "WHERE " . - "d_file={$this->tree->tree_id} AND " . + "d_file={$this->tree->id()} AND " . "d_fact='BIRT' AND " . "d_type IN ('@#DGREGORIAN@', '@#DJULIAN@')"; } else { $sql = "SELECT SQL_CACHE d_month, COUNT(*) AS total FROM `##dates` " . "WHERE " . - "d_file={$this->tree->tree_id} AND " . + "d_file={$this->tree->id()} AND " . "d_fact='BIRT' AND " . "d_type IN ('@#DGREGORIAN@', '@#DJULIAN@')"; } @@ -1775,7 +1775,7 @@ class WT_Stats { $sql = "SELECT SQL_CACHE FLOOR(d_year/100+1) AS century, COUNT(*) AS total FROM `##dates` " . "WHERE " . - "d_file={$this->tree->tree_id} AND " . + "d_file={$this->tree->id()} AND " . 'd_year<>0 AND ' . "d_fact='DEAT' AND " . "d_type IN ('@#DGREGORIAN@', '@#DJULIAN@')"; @@ -1784,14 +1784,14 @@ class WT_Stats { "SELECT SQL_CACHE d_month, i_sex, COUNT(*) AS total FROM `##dates` " . "JOIN `##individuals` ON d_file = i_file AND d_gid = i_id " . "WHERE " . - "d_file={$this->tree->tree_id} AND " . + "d_file={$this->tree->id()} AND " . "d_fact='DEAT' AND " . "d_type IN ('@#DGREGORIAN@', '@#DJULIAN@')"; } else { $sql = "SELECT SQL_CACHE d_month, COUNT(*) AS total FROM `##dates` " . "WHERE " . - "d_file={$this->tree->tree_id} AND " . + "d_file={$this->tree->id()} AND " . "d_fact='DEAT' AND " . "d_type IN ('@#DGREGORIAN@', '@#DJULIAN@')"; } @@ -2003,7 +2003,7 @@ class WT_Stats { " WHERE" . " indi.i_id=birth.d_gid AND" . " birth.d_gid=death.d_gid AND" . - " death.d_file={$this->tree->tree_id} AND" . + " death.d_file={$this->tree->id()} AND" . " birth.d_file=death.d_file AND" . " birth.d_file=indi.i_file AND" . " birth.d_fact='BIRT' AND" . @@ -2071,7 +2071,7 @@ class WT_Stats { "WHERE " . " indi.i_id=birth.d_gid AND " . " birth.d_gid=death.d_gid AND " . - " death.d_file={$this->tree->tree_id} AND " . + " death.d_file={$this->tree->id()} AND " . " birth.d_file=death.d_file AND " . " birth.d_file=indi.i_file AND " . " birth.d_fact='BIRT' AND " . @@ -2155,7 +2155,7 @@ class WT_Stats { " WHERE" . " indi.i_id=birth.d_gid AND" . " indi.i_gedcom NOT REGEXP '\\n1 (" . WT_EVENTS_DEAT . ")' AND" . - " birth.d_file={$this->tree->tree_id} AND" . + " birth.d_file={$this->tree->id()} AND" . " birth.d_fact='BIRT' AND" . " birth.d_file=indi.i_file AND" . " birth.d_julianday1<>0" . @@ -2220,7 +2220,7 @@ class WT_Stats { "WHERE " . " indi.i_id=birth.d_gid AND " . " birth.d_gid=death.d_gid AND " . - " death.d_file=" . $this->tree->tree_id . " AND " . + " death.d_file=" . $this->tree->id() . " AND " . " birth.d_file=death.d_file AND " . " birth.d_file=indi.i_file AND " . " birth.d_fact='BIRT' AND " . @@ -2278,7 +2278,7 @@ class WT_Stats { " WHERE" . " indi.i_id=birth.d_gid AND" . " birth.d_gid=death.d_gid AND" . - " death.d_file={$this->tree->tree_id} AND" . + " death.d_file={$this->tree->id()} AND" . " birth.d_file=death.d_file AND" . " birth.d_file=indi.i_file AND" . " birth.d_fact='BIRT' AND" . @@ -2374,7 +2374,7 @@ class WT_Stats { " WHERE" . " indi.i_id=birth.d_gid AND" . " birth.d_gid=death.d_gid AND" . - " death.d_file={$this->tree->tree_id} AND" . + " death.d_file={$this->tree->id()} AND" . " birth.d_file=death.d_file AND" . " birth.d_file=indi.i_file AND" . " birth.d_fact='BIRT' AND" . @@ -2631,7 +2631,7 @@ class WT_Stats { . ' FROM' . " `##dates`" . ' WHERE' - . " d_file={$this->tree->tree_id} AND" + . " d_file={$this->tree->id()} AND" . " d_gid<>'HEAD' AND" . " d_fact {$fact_query} AND" . ' d_julianday1<>0' @@ -2770,14 +2770,14 @@ class WT_Stats { $rows = $this->runSql( " SELECT SQL_CACHE fam.f_id AS famid, fam.{$sex_field}, married.d_julianday2-birth.d_julianday1 AS age, indi.i_id AS i_id" . " FROM `##families` AS fam" . - " LEFT JOIN `##dates` AS birth ON birth.d_file = {$this->tree->tree_id}" . - " LEFT JOIN `##dates` AS married ON married.d_file = {$this->tree->tree_id}" . - " LEFT JOIN `##individuals` AS indi ON indi.i_file = {$this->tree->tree_id}" . + " LEFT JOIN `##dates` AS birth ON birth.d_file = {$this->tree->id()}" . + " LEFT JOIN `##dates` AS married ON married.d_file = {$this->tree->id()}" . + " LEFT JOIN `##individuals` AS indi ON indi.i_file = {$this->tree->id()}" . " WHERE" . " birth.d_gid = indi.i_id AND" . " married.d_gid = fam.f_id AND" . " indi.i_id = fam.{$sex_field} AND" . - " fam.f_file = {$this->tree->tree_id} AND" . + " fam.f_file = {$this->tree->id()} AND" . " birth.d_fact = 'BIRT' AND" . " married.d_fact = 'MARR' AND" . " birth.d_julianday1 <> 0 AND" . @@ -2848,10 +2848,10 @@ class WT_Stats { $hrows = $this->runSql( " SELECT SQL_CACHE DISTINCT fam.f_id AS family, MIN(husbdeath.d_julianday2-married.d_julianday1) AS age" . " FROM `##families` AS fam" . - " LEFT JOIN `##dates` AS married ON married.d_file = {$this->tree->tree_id}" . - " LEFT JOIN `##dates` AS husbdeath ON husbdeath.d_file = {$this->tree->tree_id}" . + " LEFT JOIN `##dates` AS married ON married.d_file = {$this->tree->id()}" . + " LEFT JOIN `##dates` AS husbdeath ON husbdeath.d_file = {$this->tree->id()}" . " WHERE" . - " fam.f_file = {$this->tree->tree_id} AND" . + " fam.f_file = {$this->tree->id()} AND" . " husbdeath.d_gid = fam.f_husb AND" . " husbdeath.d_fact = 'DEAT' AND" . " married.d_gid = fam.f_id AND" . @@ -2863,10 +2863,10 @@ class WT_Stats { $wrows = $this->runSql( " SELECT SQL_CACHE DISTINCT fam.f_id AS family, MIN(wifedeath.d_julianday2-married.d_julianday1) AS age" . " FROM `##families` AS fam" . - " LEFT JOIN `##dates` AS married ON married.d_file = {$this->tree->tree_id}" . - " LEFT JOIN `##dates` AS wifedeath ON wifedeath.d_file = {$this->tree->tree_id}" . + " LEFT JOIN `##dates` AS married ON married.d_file = {$this->tree->id()}" . + " LEFT JOIN `##dates` AS wifedeath ON wifedeath.d_file = {$this->tree->id()}" . " WHERE" . - " fam.f_file = {$this->tree->tree_id} AND" . + " fam.f_file = {$this->tree->id()} AND" . " wifedeath.d_gid = fam.f_wife AND" . " wifedeath.d_fact = 'DEAT' AND" . " married.d_gid = fam.f_id AND" . @@ -2878,10 +2878,10 @@ class WT_Stats { $drows = $this->runSql( " SELECT SQL_CACHE DISTINCT fam.f_id AS family, MIN(divorced.d_julianday2-married.d_julianday1) AS age" . " FROM `##families` AS fam" . - " LEFT JOIN `##dates` AS married ON married.d_file = {$this->tree->tree_id}" . - " LEFT JOIN `##dates` AS divorced ON divorced.d_file = {$this->tree->tree_id}" . + " LEFT JOIN `##dates` AS married ON married.d_file = {$this->tree->id()}" . + " LEFT JOIN `##dates` AS divorced ON divorced.d_file = {$this->tree->id()}" . " WHERE" . - " fam.f_file = {$this->tree->tree_id} AND" . + " fam.f_file = {$this->tree->id()} AND" . " married.d_gid = fam.f_id AND" . " married.d_fact = 'MARR' AND" . " divorced.d_gid = fam.f_id AND" . @@ -2986,10 +2986,10 @@ class WT_Stats { $rows = $this->runSql( " SELECT SQL_CACHE fam.f_id AS family," . $query1 . " FROM `##families` AS fam" . - " LEFT JOIN `##dates` AS wifebirth ON wifebirth.d_file = {$this->tree->tree_id}" . - " LEFT JOIN `##dates` AS husbbirth ON husbbirth.d_file = {$this->tree->tree_id}" . + " LEFT JOIN `##dates` AS wifebirth ON wifebirth.d_file = {$this->tree->id()}" . + " LEFT JOIN `##dates` AS husbbirth ON husbbirth.d_file = {$this->tree->id()}" . " WHERE" . - " fam.f_file = {$this->tree->tree_id} AND" . + " fam.f_file = {$this->tree->id()} AND" . " husbbirth.d_gid = fam.f_husb AND" . " husbbirth.d_fact = 'BIRT' AND" . " wifebirth.d_gid = fam.f_wife AND" . @@ -3060,16 +3060,16 @@ class WT_Stats { " parentfamily.l_to AS id," . " childbirth.d_julianday2-birth.d_julianday1 AS age" . " FROM `##link` AS parentfamily" . - " JOIN `##link` AS childfamily ON childfamily.l_file = {$this->tree->tree_id}" . - " JOIN `##dates` AS birth ON birth.d_file = {$this->tree->tree_id}" . - " JOIN `##dates` AS childbirth ON childbirth.d_file = {$this->tree->tree_id}" . + " JOIN `##link` AS childfamily ON childfamily.l_file = {$this->tree->id()}" . + " JOIN `##dates` AS birth ON birth.d_file = {$this->tree->id()}" . + " JOIN `##dates` AS childbirth ON childbirth.d_file = {$this->tree->id()}" . " WHERE" . " birth.d_gid = parentfamily.l_to AND" . " childfamily.l_to = childbirth.d_gid AND" . " childfamily.l_type = 'CHIL' AND" . " parentfamily.l_type = '{$sex_field}' AND" . " childfamily.l_from = parentfamily.l_from AND" . - " parentfamily.l_file = {$this->tree->tree_id} AND" . + " parentfamily.l_file = {$this->tree->id()} AND" . " birth.d_fact = 'BIRT' AND" . " childbirth.d_fact = 'BIRT' AND" . " birth.d_julianday1 <> 0 AND" . @@ -3134,7 +3134,7 @@ class WT_Stats { $sql = "SELECT SQL_CACHE FLOOR(d_year/100+1) AS century, COUNT(*) AS total" . " FROM `##dates`" . - " WHERE d_file={$this->tree->tree_id} AND d_year<>0 AND d_fact='MARR' AND d_type IN ('@#DGREGORIAN@', '@#DJULIAN@')"; + " WHERE d_file={$this->tree->id()} AND d_year<>0 AND d_fact='MARR' AND d_type IN ('@#DGREGORIAN@', '@#DJULIAN@')"; if ($year1 >= 0 && $year2 >= 0) { $sql .= " AND d_year BETWEEN '{$year1}' AND '{$year2}'"; } @@ -3147,11 +3147,11 @@ class WT_Stats { $sql = " SELECT SQL_CACHE fam.f_id AS fams, fam.f_husb, fam.f_wife, married.d_julianday2 AS age, married.d_month AS month, indi.i_id AS indi" . " FROM `##families` AS fam" . - " LEFT JOIN `##dates` AS married ON married.d_file = {$this->tree->tree_id}" . - " LEFT JOIN `##individuals` AS indi ON indi.i_file = {$this->tree->tree_id}" . + " LEFT JOIN `##dates` AS married ON married.d_file = {$this->tree->id()}" . + " LEFT JOIN `##individuals` AS indi ON indi.i_file = {$this->tree->id()}" . " WHERE" . " married.d_gid = fam.f_id AND" . - " fam.f_file = {$this->tree->tree_id} AND" . + " fam.f_file = {$this->tree->id()} AND" . " married.d_fact = 'MARR' AND" . " married.d_julianday2 <> 0 AND" . $years . @@ -3161,7 +3161,7 @@ class WT_Stats { $sql = "SELECT SQL_CACHE d_month, COUNT(*) AS total" . " FROM `##dates`" . - " WHERE d_file={$this->tree->tree_id} AND d_fact='MARR'"; + " WHERE d_file={$this->tree->id()} AND d_fact='MARR'"; if ($year1 >= 0 && $year2 >= 0) { $sql .= " AND d_year BETWEEN '{$year1}' AND '{$year2}'"; } @@ -3229,7 +3229,7 @@ class WT_Stats { $sql = "SELECT SQL_CACHE FLOOR(d_year/100+1) AS century, COUNT(*) AS total" . " FROM `##dates`" . - " WHERE d_file={$this->tree->tree_id} AND d_year<>0 AND d_fact = 'DIV' AND d_type IN ('@#DGREGORIAN@', '@#DJULIAN@')"; + " WHERE d_file={$this->tree->id()} AND d_year<>0 AND d_fact = 'DIV' AND d_type IN ('@#DGREGORIAN@', '@#DJULIAN@')"; if ($year1 >= 0 && $year2 >= 0) { $sql .= " AND d_year BETWEEN '{$year1}' AND '{$year2}'"; } @@ -3242,11 +3242,11 @@ class WT_Stats { $sql = " SELECT SQL_CACHE fam.f_id AS fams, fam.f_husb, fam.f_wife, divorced.d_julianday2 AS age, divorced.d_month AS month, indi.i_id AS indi" . " FROM `##families` AS fam" . - " LEFT JOIN `##dates` AS divorced ON divorced.d_file = {$this->tree->tree_id}" . - " LEFT JOIN `##individuals` AS indi ON indi.i_file = {$this->tree->tree_id}" . + " LEFT JOIN `##dates` AS divorced ON divorced.d_file = {$this->tree->id()}" . + " LEFT JOIN `##individuals` AS indi ON indi.i_file = {$this->tree->id()}" . " WHERE" . " divorced.d_gid = fam.f_id AND" . - " fam.f_file = {$this->tree->tree_id} AND" . + " fam.f_file = {$this->tree->id()} AND" . " divorced.d_fact = 'DIV' AND" . " divorced.d_julianday2 <> 0 AND" . $years . @@ -3255,7 +3255,7 @@ class WT_Stats { } else { $sql = "SELECT SQL_CACHE d_month, COUNT(*) AS total FROM `##dates` " . - "WHERE d_file={$this->tree->tree_id} AND d_fact = 'DIV'"; + "WHERE d_file={$this->tree->id()} AND d_fact = 'DIV'"; if ($year1 >= 0 && $year2 >= 0) { $sql .= " AND d_year BETWEEN '{$year1}' AND '{$year2}'"; } @@ -3460,7 +3460,7 @@ class WT_Stats { "JOIN `##dates` AS birth ON (birth.d_gid=fam.f_husb AND birth.d_file=fam.f_file) " . "WHERE " . " '{$sex}' IN ('M', 'BOTH') AND " . - " married.d_file={$this->tree->tree_id} AND married.d_type IN ('@#DGREGORIAN@', '@#DJULIAN@') AND married.d_fact='MARR' AND " . + " married.d_file={$this->tree->id()} AND married.d_type IN ('@#DGREGORIAN@', '@#DJULIAN@') AND married.d_fact='MARR' AND " . " birth.d_type IN ('@#DGREGORIAN@', '@#DJULIAN@') AND birth.d_fact='BIRT' AND " . " married.d_julianday1>birth.d_julianday1 AND birth.d_julianday1<>0 " . "GROUP BY century, sex " . @@ -3474,7 +3474,7 @@ class WT_Stats { "JOIN `##dates` AS birth ON (birth.d_gid=fam.f_wife AND birth.d_file=fam.f_file) " . "WHERE " . " '{$sex}' IN ('F', 'BOTH') AND " . - " married.d_file={$this->tree->tree_id} AND married.d_type IN ('@#DGREGORIAN@', '@#DJULIAN@') AND married.d_fact='MARR' AND " . + " married.d_file={$this->tree->id()} AND married.d_type IN ('@#DGREGORIAN@', '@#DJULIAN@') AND married.d_fact='MARR' AND " . " birth.d_type IN ('@#DGREGORIAN@', '@#DJULIAN@') AND birth.d_fact='BIRT' AND " . " married.d_julianday1>birth.d_julianday1 AND birth.d_julianday1<>0 " . " GROUP BY century, sex ORDER BY century" @@ -3580,7 +3580,7 @@ class WT_Stats { "JOIN `##dates` AS birth ON (birth.d_gid=fam.f_husb AND birth.d_file=fam.f_file) " . "WHERE " . " '{$sex}' IN ('M', 'BOTH') AND {$years} " . - " married.d_file={$this->tree->tree_id} AND married.d_type IN ('@#DGREGORIAN@', '@#DJULIAN@') AND married.d_fact='MARR' AND " . + " married.d_file={$this->tree->id()} AND married.d_type IN ('@#DGREGORIAN@', '@#DJULIAN@') AND married.d_fact='MARR' AND " . " birth.d_type IN ('@#DGREGORIAN@', '@#DJULIAN@') AND birth.d_fact='BIRT' AND " . " married.d_julianday1>birth.d_julianday1 AND birth.d_julianday1<>0 " . "UNION ALL " . @@ -3593,7 +3593,7 @@ class WT_Stats { "JOIN `##dates` AS birth ON (birth.d_gid=fam.f_wife AND birth.d_file=fam.f_file) " . "WHERE " . " '{$sex}' IN ('F', 'BOTH') AND {$years} " . - " married.d_file={$this->tree->tree_id} AND married.d_type IN ('@#DGREGORIAN@', '@#DJULIAN@') AND married.d_fact='MARR' AND " . + " married.d_file={$this->tree->id()} AND married.d_type IN ('@#DGREGORIAN@', '@#DJULIAN@') AND married.d_fact='MARR' AND " . " birth.d_type IN ('@#DGREGORIAN@', '@#DJULIAN@') AND birth.d_fact='BIRT' AND " . " married.d_julianday1>birth.d_julianday1 AND birth.d_julianday1<>0 " ); @@ -3899,7 +3899,7 @@ class WT_Stats { */ public function totalMarriedMales() { $n = WT_DB::prepare("SELECT SQL_CACHE COUNT(DISTINCT f_husb) FROM `##families` WHERE f_file=? AND f_gedcom LIKE '%\\n1 MARR%'") - ->execute(array($this->tree->tree_id)) + ->execute(array($this->tree->id())) ->fetchOne(); return WT_I18N::number($n); } @@ -3909,7 +3909,7 @@ class WT_Stats { */ public function totalMarriedFemales() { $n = WT_DB::prepare("SELECT SQL_CACHE COUNT(DISTINCT f_wife) FROM `##families` WHERE f_file=? AND f_gedcom LIKE '%\\n1 MARR%'") - ->execute(array($this->tree->tree_id)) + ->execute(array($this->tree->id())) ->fetchOne(); return WT_I18N::number($n); } @@ -3924,11 +3924,11 @@ class WT_Stats { " SELECT SQL_CACHE f_numchil AS tot, f_id AS id" . " FROM `##families`" . " WHERE" . - " f_file={$this->tree->tree_id}" . + " f_file={$this->tree->id()}" . " AND f_numchil = (" . " SELECT max( f_numchil )" . " FROM `##families`" . - " WHERE f_file ={$this->tree->tree_id}" . + " WHERE f_file ={$this->tree->id()}" . " )" . " LIMIT 1" ); @@ -3974,7 +3974,7 @@ class WT_Stats { "SELECT SQL_CACHE f_numchil AS tot, f_id AS id" . " FROM `##families`" . " WHERE" . - " f_file={$this->tree->tree_id}" . + " f_file={$this->tree->id()}" . " ORDER BY tot DESC" . " LIMIT " . $total ); @@ -4039,11 +4039,11 @@ class WT_Stats { " link2.l_to AS ch2," . " child1.d_julianday2-child2.d_julianday2 AS age" . " FROM `##link` AS link1" . - " LEFT JOIN `##dates` AS child1 ON child1.d_file = {$this->tree->tree_id}" . - " LEFT JOIN `##dates` AS child2 ON child2.d_file = {$this->tree->tree_id}" . - " LEFT JOIN `##link` AS link2 ON link2.l_file = {$this->tree->tree_id}" . + " LEFT JOIN `##dates` AS child1 ON child1.d_file = {$this->tree->id()}" . + " LEFT JOIN `##dates` AS child2 ON child2.d_file = {$this->tree->id()}" . + " LEFT JOIN `##link` AS link2 ON link2.l_file = {$this->tree->id()}" . " WHERE" . - " link1.l_file = {$this->tree->tree_id} AND" . + " link1.l_file = {$this->tree->id()} AND" . " link1.l_from = link2.l_from AND" . " link1.l_type = 'CHIL' AND" . " child1.d_gid = link1.l_to AND" . @@ -4176,10 +4176,10 @@ class WT_Stats { " child1.d_month as d_month" . $sql_sex1 . " FROM `##link` AS link1" . - " LEFT JOIN `##dates` AS child1 ON child1.d_file = {$this->tree->tree_id}" . + " LEFT JOIN `##dates` AS child1 ON child1.d_file = {$this->tree->id()}" . $sql_sex2 . " WHERE" . - " link1.l_file = {$this->tree->tree_id} AND" . + " link1.l_file = {$this->tree->id()} AND" . " link1.l_type = 'CHIL' AND" . " child1.d_gid = link1.l_to AND" . " child1.d_fact = 'BIRT' AND" . @@ -4347,7 +4347,7 @@ class WT_Stats { $rows = $this->runSql( " SELECT SQL_CACHE f_numchil AS tot, f_id AS id" . " FROM `##families`" . - " WHERE f_file={$this->tree->tree_id}" . + " WHERE f_file={$this->tree->id()}" . " ORDER BY tot DESC" . " LIMIT " . $total ); @@ -4381,7 +4381,7 @@ class WT_Stats { * @return string */ public function totalChildren() { - $rows = $this->runSql("SELECT SQL_CACHE SUM(f_numchil) AS tot FROM `##families` WHERE f_file={$this->tree->tree_id}"); + $rows = $this->runSql("SELECT SQL_CACHE SUM(f_numchil) AS tot FROM `##families` WHERE f_file={$this->tree->id()}"); return WT_I18N::number($rows[0]['tot']); } @@ -4390,7 +4390,7 @@ class WT_Stats { * @return string */ public function averageChildren() { - $rows = $this->runSql("SELECT SQL_CACHE AVG(f_numchil) AS tot FROM `##families` WHERE f_file={$this->tree->tree_id}"); + $rows = $this->runSql("SELECT SQL_CACHE AVG(f_numchil) AS tot FROM `##families` WHERE f_file={$this->tree->id()}"); return WT_I18N::number($rows[0]['tot'], 2); } @@ -4417,7 +4417,7 @@ class WT_Stats { " SELECT SQL_CACHE ROUND(AVG(f_numchil),2) AS num, FLOOR(d_year/100+1) AS century" . " FROM `##families`" . " JOIN `##dates` ON (d_file = f_file AND d_gid=f_id)" . - " WHERE f_file = {$this->tree->tree_id}" . + " WHERE f_file = {$this->tree->id()}" . " AND d_julianday1<>0" . " AND d_fact = 'MARR'" . " AND d_type IN ('@#DGREGORIAN@', '@#DJULIAN@')" . @@ -4464,7 +4464,7 @@ class WT_Stats { "(SELECT count(i_sex) AS num FROM `##link` " . "LEFT OUTER JOIN `##individuals` " . "ON l_from=i_id AND l_file=i_file AND i_sex='M' AND l_type='FAMC' " . - "JOIN `##families` ON f_file=l_file AND f_id=l_to WHERE f_file={$this->tree->tree_id} GROUP BY l_to" . + "JOIN `##families` ON f_file=l_file AND f_id=l_to WHERE f_file={$this->tree->id()} GROUP BY l_to" . ") boys" . " GROUP BY num" . " ORDER BY num"; @@ -4474,7 +4474,7 @@ class WT_Stats { "(SELECT count(i_sex) AS num FROM `##link` " . "LEFT OUTER JOIN `##individuals` " . "ON l_from=i_id AND l_file=i_file AND i_sex='F' AND l_type='FAMC' " . - "JOIN `##families` ON f_file=l_file AND f_id=l_to WHERE f_file={$this->tree->tree_id} GROUP BY l_to" . + "JOIN `##families` ON f_file=l_file AND f_id=l_to WHERE f_file={$this->tree->id()} GROUP BY l_to" . ") girls" . " GROUP BY num" . " ORDER BY num"; @@ -4482,14 +4482,14 @@ class WT_Stats { $sql = "SELECT SQL_CACHE f_numchil, COUNT(*) AS total FROM `##families` "; if ($year1 >= 0 && $year2 >= 0) { $sql .= - "AS fam LEFT JOIN `##dates` AS married ON married.d_file = {$this->tree->tree_id}" + "AS fam LEFT JOIN `##dates` AS married ON married.d_file = {$this->tree->id()}" . " WHERE" . " married.d_gid = fam.f_id AND" - . " fam.f_file = {$this->tree->tree_id} AND" + . " fam.f_file = {$this->tree->id()} AND" . " married.d_fact = 'MARR' AND" . " married.d_year BETWEEN '{$year1}' AND '{$year2}'"; } else { - $sql .= "WHERE f_file={$this->tree->tree_id}"; + $sql .= "WHERE f_file={$this->tree->id()}"; } $sql .= " GROUP BY f_numchil"; } @@ -4551,7 +4551,7 @@ class WT_Stats { $rows = $this->runSql( " SELECT SQL_CACHE COUNT(*) AS tot" . " FROM `##families`" . - " WHERE f_numchil = 0 AND f_file = {$this->tree->tree_id}"); + " WHERE f_numchil = 0 AND f_file = {$this->tree->id()}"); return $rows[0]['tot']; } @@ -4579,7 +4579,7 @@ class WT_Stats { $rows = $this->runSql( " SELECT SQL_CACHE f_id AS family" . " FROM `##families` AS fam" . - " WHERE f_numchil = 0 AND fam.f_file = {$this->tree->tree_id}"); + " WHERE f_numchil = 0 AND fam.f_file = {$this->tree->id()}"); if (!isset($rows[0])) { return ''; } @@ -4648,7 +4648,7 @@ class WT_Stats { " `##dates` AS married ON (married.d_file = fam.f_file AND married.d_gid = fam.f_id)" . " WHERE" . " f_numchil = 0 AND" . - " fam.f_file = {$this->tree->tree_id} AND" . + " fam.f_file = {$this->tree->id()} AND" . $years . " married.d_fact = 'MARR' AND" . " married.d_type IN ('@#DGREGORIAN@', '@#DJULIAN@')" . @@ -4721,11 +4721,11 @@ class WT_Stats { $rows = $this->runSql( "SELECT SQL_CACHE COUNT(*) AS tot, f_id AS id" . " FROM `##families`" . - " JOIN `##link` AS children ON children.l_file = {$this->tree->tree_id}" . - " JOIN `##link` AS mchildren ON mchildren.l_file = {$this->tree->tree_id}" . - " JOIN `##link` AS gchildren ON gchildren.l_file = {$this->tree->tree_id}" . + " JOIN `##link` AS children ON children.l_file = {$this->tree->id()}" . + " JOIN `##link` AS mchildren ON mchildren.l_file = {$this->tree->id()}" . + " JOIN `##link` AS gchildren ON gchildren.l_file = {$this->tree->id()}" . " WHERE" . - " f_file={$this->tree->tree_id} AND" . + " f_file={$this->tree->id()} AND" . " children.l_from=f_id AND" . " children.l_type='CHIL' AND" . " children.l_to=mchildren.l_from AND" . @@ -4843,7 +4843,7 @@ class WT_Stats { * @return string */ public function getCommonSurname() { - $surnames = array_keys(get_top_surnames($this->tree->tree_id, 1, 1)); + $surnames = array_keys(get_top_surnames($this->tree->id(), 1, 1)); return array_shift($surnames); } @@ -5991,7 +5991,7 @@ class WT_Stats { public function totalGedcomNews() { try { $number = (int) WT_DB::prepare("SELECT COUNT(*) FROM `##news` WHERE gedcom_id = ?") - ->execute(array($this->tree->tree_id)) + ->execute(array($this->tree->id())) ->fetchOne(); } catch (PDOException $ex) { // The module may not be installed, so the table may not exist. diff --git a/library/WT/Theme/BaseTheme.php b/library/WT/Theme/BaseTheme.php index 5d066ca8b0..d9a12413d9 100644 --- a/library/WT/Theme/BaseTheme.php +++ b/library/WT/Theme/BaseTheme.php @@ -433,7 +433,7 @@ abstract class BaseTheme { return '<form action="search.php" class="header-search" method="post" role="search">' . '<input type="hidden" name="action" value="general">' . - '<input type="hidden" name="ged" value="' . $this->tree->tree_name_html . '">' . + '<input type="hidden" name="ged" value="' . $this->tree->nameHtml() . '">' . '<input type="hidden" name="topsearch" value="yes">' . $this->formQuickSearchFields() . '</form>'; @@ -460,7 +460,7 @@ abstract class BaseTheme { */ protected function formatTreeTitle() { if ($this->tree) { - return '<h1 class="header-title">' . $this->tree->tree_title_html . '</h1>'; + return '<h1 class="header-title">' . $this->tree->titleHtml() . '</h1>'; } else { return ''; } @@ -535,7 +535,7 @@ abstract class BaseTheme { $this->metaCanonicalUrl($controller->getCanonicalUrl()); if ($this->tree) { - $html .= $this->metaDescription($this->tree->getPreference('META_DESCRIPTION', html_entity_decode(strip_tags($this->tree->tree_title_html), ENT_QUOTES))); + $html .= $this->metaDescription($this->tree->getPreference('META_DESCRIPTION')); } // CSS files @@ -961,7 +961,7 @@ abstract class BaseTheme { */ final public function init(Zend_Session_Namespace $session, $search_engine, WT_Tree $tree = null) { $this->tree = $tree; - $this->tree_url = $tree ? 'ged=' . WT_Filter::escapeUrl($tree->tree_name) : null; + $this->tree_url = $tree ? 'ged=' . $tree->nameUrl() : ''; $this->session = $session; $this->search_engine = $search_engine; @@ -1300,11 +1300,11 @@ abstract class BaseTheme { $ALLOW_CHANGE_GEDCOM = WT_Site::getPreference('ALLOW_CHANGE_GEDCOM') && count(WT_Tree::getAll()) > 1; foreach (WT_Tree::getAll() as $tree) { - if ($tree->tree_id === WT_GED_ID || $ALLOW_CHANGE_GEDCOM) { + if ($tree->id() === WT_GED_ID || $ALLOW_CHANGE_GEDCOM) { $submenu = new WT_Menu( - $tree->tree_title_html, - 'index.php?ctype=gedcom&ged=' . $tree->tree_name_url, - 'menu-tree-' . $tree->tree_id // Cannot use name - it must be a CSS identifier + $tree->titleHtml(), + 'index.php?ctype=gedcom&ged=' . $tree->nameUrl(), + 'menu-tree-' . $tree->id() // Cannot use name - it must be a CSS identifier ); $submenus[] = $submenu; } diff --git a/library/WT/Tree.php b/library/WT/Tree.php index 77a6974e1d..7907bbc9cf 100644 --- a/library/WT/Tree.php +++ b/library/WT/Tree.php @@ -25,13 +25,9 @@ use WT\User; */ class WT_Tree { // Tree attributes - public $tree_id; // The "gedcom ID" number - public $tree_name; // The "gedcom name" text - public $tree_name_url; - public $tree_name_html; - public $tree_title; // The "gedcom title" text - public $tree_title_html; - public $imported; + private $id; // The tree/gedcom ID number + private $name; // The tree/gedcom name + private $title; // The tree's title /** @var WT_Tree[] All trees that we have permission to see. */ private static $trees; @@ -46,18 +42,68 @@ class WT_Tree { * Create a tree object. This is a private constructor - it can only * be called from WT_Tree::getAll() to ensure proper initialisation. * - * @param $tree_id - * @param $tree_name - * @param $tree_title - * @param $imported + * @param string $id + * @param string $tree_name + * @param string $tree_title + */ + private function __construct($id, $tree_name, $tree_title) { + $this->id = $id; + $this->name = $tree_name; + $this->title = $tree_title; + } + + /** + * The ID of this tree + * + * @return string + */ + public function id() { + return $this->id; + } + + /** + * The name of this tree + * + * @return string + */ + public function name() { + return $this->name; + } + + /** + * The name of this tree + * + * @return string + */ + public function nameHtml() { + return WT_Filter::escapeHtml($this->name); + } + + /** + * The name of this tree + * + * @return string + */ + public function nameUrl() { + return WT_Filter::escapeUrl($this->name); + } + + /** + * The title of this tree + * + * @return string + */ + public function title() { + return $this->title; + } + + /** + * The title of this tree, with HTML markup + * + * @return string */ - private function __construct($tree_id, $tree_name, $tree_title) { - $this->tree_id = $tree_id; - $this->tree_name = $tree_name; - $this->tree_name_url = rawurlencode($tree_name); - $this->tree_name_html = WT_Filter::escapeHtml($tree_name); - $this->tree_title = $tree_title; - $this->tree_title_html = '<span dir="auto">' . WT_Filter::escapeHtml($tree_title) . '</span>'; + public function titleHtml() { + return WT_Filter::escapeHtml($this->title); } /** @@ -72,7 +118,7 @@ class WT_Tree { if ($this->preferences === null) { $this->preferences = WT_DB::prepare( "SELECT SQL_CACHE setting_name, setting_value FROM `##gedcom_setting` WHERE gedcom_id = ?" - )->execute(array($this->tree_id))->fetchAssoc(); + )->execute(array($this->id))->fetchAssoc(); } if (array_key_exists($setting_name, $this->preferences)) { @@ -97,7 +143,7 @@ class WT_Tree { WT_DB::prepare( "DELETE FROM `##gedcom_setting` WHERE gedcom_id = :tree_id AND setting_name = :setting_name" )->execute(array( - 'tree_id' => $this->tree_id, + 'tree_id' => $this->id, 'setting_name' => $setting_name, )); } else { @@ -105,7 +151,7 @@ class WT_Tree { "REPLACE INTO `##gedcom_setting` (gedcom_id, setting_name, setting_value)" . " VALUES (:tree_id, :setting_name, LEFT(:setting_value, 255))" )->execute(array( - 'tree_id' => $this->tree_id, + 'tree_id' => $this->id, 'setting_name' => $setting_name, 'setting_value' => $setting_value, )); @@ -134,7 +180,7 @@ class WT_Tree { if (!array_key_exists($user->getUserId(), $this->user_preferences)) { $this->user_preferences[$user->getUserId()] = WT_DB::prepare( "SELECT SQL_CACHE setting_name, setting_value FROM `##user_gedcom_setting` WHERE user_id = ? AND gedcom_id = ?" - )->execute(array($user->getUserId(), $this->tree_id))->fetchAssoc(); + )->execute(array($user->getUserId(), $this->id))->fetchAssoc(); } if (array_key_exists($setting_name, $this->user_preferences[$user->getUserId()])) { @@ -160,7 +206,7 @@ class WT_Tree { WT_DB::prepare( "DELETE FROM `##user_gedcom_setting` WHERE gedcom_id = :tree_id AND user_id = :user_id AND setting_name = :setting_name" )->execute(array( - 'tree_id' => $this->tree_id, + 'tree_id' => $this->id, 'user_id' => $user->getUserId(), 'setting_name' => $setting_name, )); @@ -169,7 +215,7 @@ class WT_Tree { "REPLACE INTO `##user_gedcom_setting` (user_id, gedcom_id, setting_name, setting_value) VALUES (:user_id, :tree_id, :setting_name, LEFT(:setting_value, 255))" )->execute(array( 'user_id' => $user->getUserId(), - 'tree_id' => $this->tree_id, + 'tree_id' => $this->id, 'setting_name' => $setting_name, 'setting_value' => $setting_value )); @@ -250,7 +296,7 @@ class WT_Tree { public static function getIdList() { $list = array(); foreach (self::getAll() as $tree) { - $list[$tree->tree_id] = $tree->tree_title; + $list[$tree->id] = $tree->title; } return $list; @@ -265,7 +311,7 @@ class WT_Tree { public static function getNameList() { $list = array(); foreach (self::getAll() as $tree) { - $list[$tree->tree_name] = $tree->tree_title; + $list[$tree->name] = $tree->title; } return $list; @@ -280,7 +326,7 @@ class WT_Tree { */ public static function getIdFromName($tree_name) { foreach (self::getAll() as $tree_id => $tree) { - if ($tree->tree_name == $tree_name) { + if ($tree->name == $tree_name) { return $tree_id; } } @@ -295,7 +341,7 @@ class WT_Tree { * @return string */ public static function getNameFromId($tree_id) { - return self::get($tree_id)->tree_name; + return self::get($tree_id)->name; } /** @@ -468,7 +514,7 @@ class WT_Tree { )->execute(array($tree_id)); // Update our cache - self::$trees[$tree->tree_id] = $tree; + self::$trees[$tree->id] = $tree; return $tree; } @@ -482,22 +528,22 @@ class WT_Tree { * @param bool $keep_media */ public function deleteGenealogyData($keep_media) { - WT_DB::prepare("DELETE FROM `##gedcom_chunk` WHERE gedcom_id = ?")->execute(array($this->tree_id)); - WT_DB::prepare("DELETE FROM `##individuals` WHERE i_file = ?")->execute(array($this->tree_id)); - WT_DB::prepare("DELETE FROM `##families` WHERE f_file = ?")->execute(array($this->tree_id)); - WT_DB::prepare("DELETE FROM `##sources` WHERE s_file = ?")->execute(array($this->tree_id)); - WT_DB::prepare("DELETE FROM `##other` WHERE o_file = ?")->execute(array($this->tree_id)); - WT_DB::prepare("DELETE FROM `##places` WHERE p_file = ?")->execute(array($this->tree_id)); - WT_DB::prepare("DELETE FROM `##placelinks` WHERE pl_file = ?")->execute(array($this->tree_id)); - WT_DB::prepare("DELETE FROM `##name` WHERE n_file = ?")->execute(array($this->tree_id)); - WT_DB::prepare("DELETE FROM `##dates` WHERE d_file = ?")->execute(array($this->tree_id)); - WT_DB::prepare("DELETE FROM `##change` WHERE gedcom_id = ?")->execute(array($this->tree_id)); + WT_DB::prepare("DELETE FROM `##gedcom_chunk` WHERE gedcom_id = ?")->execute(array($this->id)); + WT_DB::prepare("DELETE FROM `##individuals` WHERE i_file = ?")->execute(array($this->id)); + WT_DB::prepare("DELETE FROM `##families` WHERE f_file = ?")->execute(array($this->id)); + WT_DB::prepare("DELETE FROM `##sources` WHERE s_file = ?")->execute(array($this->id)); + WT_DB::prepare("DELETE FROM `##other` WHERE o_file = ?")->execute(array($this->id)); + WT_DB::prepare("DELETE FROM `##places` WHERE p_file = ?")->execute(array($this->id)); + WT_DB::prepare("DELETE FROM `##placelinks` WHERE pl_file = ?")->execute(array($this->id)); + WT_DB::prepare("DELETE FROM `##name` WHERE n_file = ?")->execute(array($this->id)); + WT_DB::prepare("DELETE FROM `##dates` WHERE d_file = ?")->execute(array($this->id)); + WT_DB::prepare("DELETE FROM `##change` WHERE gedcom_id = ?")->execute(array($this->id)); if ($keep_media) { - WT_DB::prepare("DELETE FROM `##link` WHERE l_file =? AND l_type<>'OBJE'")->execute(array($this->tree_id)); + WT_DB::prepare("DELETE FROM `##link` WHERE l_file =? AND l_type<>'OBJE'")->execute(array($this->id)); } else { - WT_DB::prepare("DELETE FROM `##link` WHERE l_file =?")->execute(array($this->tree_id)); - WT_DB::prepare("DELETE FROM `##media` WHERE m_file =?")->execute(array($this->tree_id)); + WT_DB::prepare("DELETE FROM `##link` WHERE l_file =?")->execute(array($this->id)); + WT_DB::prepare("DELETE FROM `##media` WHERE m_file =?")->execute(array($this->id)); } } @@ -506,23 +552,23 @@ class WT_Tree { */ public function delete() { // If this is the default tree, then unset it - if (WT_Site::getPreference('DEFAULT_GEDCOM') === self::getNameFromId($this->tree_id)) { + if (WT_Site::getPreference('DEFAULT_GEDCOM') === self::getNameFromId($this->id)) { WT_Site::setPreference('DEFAULT_GEDCOM', ''); } $this->deleteGenealogyData(false); - WT_DB::prepare("DELETE `##block_setting` FROM `##block_setting` JOIN `##block` USING (block_id) WHERE gedcom_id=?")->execute(array($this->tree_id)); - WT_DB::prepare("DELETE FROM `##block` WHERE gedcom_id = ?")->execute(array($this->tree_id)); - WT_DB::prepare("DELETE FROM `##user_gedcom_setting` WHERE gedcom_id = ?")->execute(array($this->tree_id)); - WT_DB::prepare("DELETE FROM `##gedcom_setting` WHERE gedcom_id = ?")->execute(array($this->tree_id)); - WT_DB::prepare("DELETE FROM `##module_privacy` WHERE gedcom_id = ?")->execute(array($this->tree_id)); - WT_DB::prepare("DELETE FROM `##next_id` WHERE gedcom_id = ?")->execute(array($this->tree_id)); - WT_DB::prepare("DELETE FROM `##hit_counter` WHERE gedcom_id = ?")->execute(array($this->tree_id)); - WT_DB::prepare("DELETE FROM `##default_resn` WHERE gedcom_id = ?")->execute(array($this->tree_id)); - WT_DB::prepare("DELETE FROM `##gedcom_chunk` WHERE gedcom_id = ?")->execute(array($this->tree_id)); - WT_DB::prepare("DELETE FROM `##log` WHERE gedcom_id = ?")->execute(array($this->tree_id)); - WT_DB::prepare("DELETE FROM `##gedcom` WHERE gedcom_id = ?")->execute(array($this->tree_id)); + WT_DB::prepare("DELETE `##block_setting` FROM `##block_setting` JOIN `##block` USING (block_id) WHERE gedcom_id=?")->execute(array($this->id)); + WT_DB::prepare("DELETE FROM `##block` WHERE gedcom_id = ?")->execute(array($this->id)); + WT_DB::prepare("DELETE FROM `##user_gedcom_setting` WHERE gedcom_id = ?")->execute(array($this->id)); + WT_DB::prepare("DELETE FROM `##gedcom_setting` WHERE gedcom_id = ?")->execute(array($this->id)); + WT_DB::prepare("DELETE FROM `##module_privacy` WHERE gedcom_id = ?")->execute(array($this->id)); + WT_DB::prepare("DELETE FROM `##next_id` WHERE gedcom_id = ?")->execute(array($this->id)); + WT_DB::prepare("DELETE FROM `##hit_counter` WHERE gedcom_id = ?")->execute(array($this->id)); + WT_DB::prepare("DELETE FROM `##default_resn` WHERE gedcom_id = ?")->execute(array($this->id)); + WT_DB::prepare("DELETE FROM `##gedcom_chunk` WHERE gedcom_id = ?")->execute(array($this->id)); + WT_DB::prepare("DELETE FROM `##log` WHERE gedcom_id = ?")->execute(array($this->id)); + WT_DB::prepare("DELETE FROM `##gedcom` WHERE gedcom_id = ?")->execute(array($this->id)); // After updating the database, we need to fetch a new (sorted) copy self::$trees = null; @@ -546,7 +592,7 @@ class WT_Tree { return false; } - $buffer = reformat_record_export(gedcom_header($this->tree_name)); + $buffer = reformat_record_export(gedcom_header($this->name)); $stmt = WT_DB::prepare( "SELECT i_gedcom AS gedcom FROM `##individuals` WHERE i_file = ?" . @@ -558,7 +604,7 @@ class WT_Tree { "SELECT o_gedcom AS gedcom FROM `##other` WHERE o_file = ? AND o_type NOT IN ('HEAD', 'TRLR')" . " UNION ALL " . "SELECT m_gedcom AS gedcom FROM `##media` WHERE m_file = ?" - )->execute(array($this->tree_id, $this->tree_id, $this->tree_id, $this->tree_id, $this->tree_id)); + )->execute(array($this->id, $this->id, $this->id, $this->id, $this->id)); while ($row = $stmt->fetch()) { $buffer .= reformat_record_export($row->gedcom); @@ -612,13 +658,13 @@ class WT_Tree { if ($pos) { WT_DB::prepare( "INSERT INTO `##gedcom_chunk` (gedcom_id, chunk_data) VALUES (?, ?)" - )->execute(array($this->tree_id, substr($file_data, 0, $pos))); + )->execute(array($this->id, substr($file_data, 0, $pos))); $file_data = substr($file_data, $pos); } } WT_DB::prepare( "INSERT INTO `##gedcom_chunk` (gedcom_id, chunk_data) VALUES (?, ?)" - )->execute(array($this->tree_id, $file_data)); + )->execute(array($this->id, $file_data)); WT_DB::commit(); fclose($fp); diff --git a/library/WT/User.php b/library/WT/User.php index 18fafd8ba6..782f24aa31 100644 --- a/library/WT/User.php +++ b/library/WT/User.php @@ -91,7 +91,7 @@ class User { "SELECT SQL_CACHE user_id" . " FROM `##user_gedcom_setting`" . " WHERE gedcom_id = ? AND setting_name = 'gedcomid' AND setting_value = ?" - )->execute(array($tree->tree_id, $individual->getXref()))->fetchOne(); + )->execute(array($tree->id(), $individual->getXref()))->fetchOne(); return self::find($user_id); } |
