diff options
| author | Rico Sonntag <mail@ricosonntag.de> | 2018-09-23 00:32:55 +0200 |
|---|---|---|
| committer | Greg Roach <fisharebest@gmail.com> | 2018-09-22 23:32:55 +0100 |
| commit | b2ce94c6833c25934b40a7e6bc15985d50b5f42a (patch) | |
| tree | 62b41467db3d26698ff21ed862461402d2febd1d /app/Stats.php | |
| parent | a0cead57f9defbc64fdc8dfbbfb2cf01c516be57 (diff) | |
| download | webtrees-b2ce94c6833c25934b40a7e6bc15985d50b5f42a.tar.gz webtrees-b2ce94c6833c25934b40a7e6bc15985d50b5f42a.tar.bz2 webtrees-b2ce94c6833c25934b40a7e6bc15985d50b5f42a.zip | |
Reduced if/else complexity, removed not require else conditions (#1866)
* Reduced if/else complexity, removed not require else conditions
* Fix indentation
* Fix indentation
* Use null-coalesce to simplify logic
* Use null-coalesce to simplify logic
* Use null-coalesce to simplify logic
* Use null-coalesce to simplify logic
* Use null-coalesce to simplify logic
* Use null-coalesce to simplify logic
* Admin theme no longer exists
* Code style
* Use null-coalesce operator to simplify logic
Diffstat (limited to 'app/Stats.php')
| -rw-r--r-- | app/Stats.php | 418 |
1 files changed, 213 insertions, 205 deletions
diff --git a/app/Stats.php b/app/Stats.php index 12f36d102d..9d26d2f341 100644 --- a/app/Stats.php +++ b/app/Stats.php @@ -328,9 +328,9 @@ class Stats $date = new Date("{$row->d_day} {$row->d_month} {$row->d_year}"); return $date->display(); - } else { - return $this->gedcomDate(); } + + return $this->gedcomDate(); } /** @@ -468,18 +468,18 @@ class Stats $tot_indi = $this->totalIndividualsQuery(); if ($tot_indi == 0) { return ''; - } else { - $tot_sindi_per = round($this->totalIndisWithSourcesQuery() / $tot_indi, 3); - $chd = $this->arrayToExtendedEncoding([ - 100 - 100 * $tot_sindi_per, - 100 * $tot_sindi_per, - ]); - $chl = I18N::translate('Without sources') . ' - ' . I18N::percentage(1 - $tot_sindi_per, 1) . '|' . - I18N::translate('With sources') . ' - ' . I18N::percentage($tot_sindi_per, 1); - $chart_title = I18N::translate('Individuals with sources'); - - return '<img src="https://chart.googleapis.com/chart?cht=p3&chd=e:' . $chd . '&chs=' . $size . '&chco=' . $color_from . ',' . $color_to . '&chf=bg,s,ffffff00&chl=' . rawurlencode($chl) . '" width="' . $sizes[0] . '" height="' . $sizes[1] . '" alt="' . $chart_title . '" title="' . $chart_title . '">'; } + + $tot_sindi_per = round($this->totalIndisWithSourcesQuery() / $tot_indi, 3); + $chd = $this->arrayToExtendedEncoding([ + 100 - 100 * $tot_sindi_per, + 100 * $tot_sindi_per, + ]); + $chl = I18N::translate('Without sources') . ' - ' . I18N::percentage(1 - $tot_sindi_per, 1) . '|' . + I18N::translate('With sources') . ' - ' . I18N::percentage($tot_sindi_per, 1); + $chart_title = I18N::translate('Individuals with sources'); + + return '<img src="https://chart.googleapis.com/chart?cht=p3&chd=e:' . $chd . '&chs=' . $size . '&chco=' . $color_from . ',' . $color_to . '&chf=bg,s,ffffff00&chl=' . rawurlencode($chl) . '" width="' . $sizes[0] . '" height="' . $sizes[1] . '" alt="' . $chart_title . '" title="' . $chart_title . '">'; } /** @@ -575,18 +575,18 @@ class Stats $tot_fam = $this->totalFamiliesQuery(); if ($tot_fam == 0) { return ''; - } else { - $tot_sfam_per = round($this->totalFamsWithSourcesQuery() / $tot_fam, 3); - $chd = $this->arrayToExtendedEncoding([ - 100 - 100 * $tot_sfam_per, - 100 * $tot_sfam_per, - ]); - $chl = I18N::translate('Without sources') . ' - ' . I18N::percentage(1 - $tot_sfam_per, 1) . '|' . - I18N::translate('With sources') . ' - ' . I18N::percentage($tot_sfam_per, 1); - $chart_title = I18N::translate('Families with sources'); - - return "<img src=\"https://chart.googleapis.com/chart?cht=p3&chd=e:{$chd}&chs={$size}&chco={$color_from},{$color_to}&chf=bg,s,ffffff00&chl={$chl}\" width=\"{$sizes[0]}\" height=\"{$sizes[1]}\" alt=\"" . $chart_title . '" title="' . $chart_title . '" />'; } + + $tot_sfam_per = round($this->totalFamsWithSourcesQuery() / $tot_fam, 3); + $chd = $this->arrayToExtendedEncoding([ + 100 - 100 * $tot_sfam_per, + 100 * $tot_sfam_per, + ]); + $chl = I18N::translate('Without sources') . ' - ' . I18N::percentage(1 - $tot_sfam_per, 1) . '|' . + I18N::translate('With sources') . ' - ' . I18N::percentage($tot_sfam_per, 1); + $chart_title = I18N::translate('Families with sources'); + + return "<img src=\"https://chart.googleapis.com/chart?cht=p3&chd=e:{$chd}&chs={$size}&chco={$color_from},{$color_to}&chf=bg,s,ffffff00&chl={$chl}\" width=\"{$sizes[0]}\" height=\"{$sizes[1]}\" alt=\"" . $chart_title . '" title="' . $chart_title . '" />'; } /** @@ -1040,7 +1040,9 @@ class Stats $per_u = $this->totalSexUnknownPercentage(); if ($tot == 0) { return ''; - } elseif ($tot_u > 0) { + } + + if ($tot_u > 0) { $chd = $this->arrayToExtendedEncoding([ 4095 * $tot_u / $tot, 4095 * $tot_f / $tot, @@ -1056,19 +1058,19 @@ class Stats I18N::translateContext('unknown people', 'Unknown') . ' - ' . $per_u; return "<img src=\"https://chart.googleapis.com/chart?cht=p3&chd=e:{$chd}&chs={$size}&chco={$color_unknown},{$color_female},{$color_male}&chf=bg,s,ffffff00&chl={$chl}\" width=\"{$sizes[0]}\" height=\"{$sizes[1]}\" alt=\"" . $chart_title . '" title="' . $chart_title . '" />'; - } else { - $chd = $this->arrayToExtendedEncoding([ - 4095 * $tot_f / $tot, - 4095 * $tot_m / $tot, - ]); - $chl = - I18N::translate('Females') . ' - ' . $per_f . '|' . - I18N::translate('Males') . ' - ' . $per_m; - $chart_title = I18N::translate('Males') . ' - ' . $per_m . I18N::$list_separator . - I18N::translate('Females') . ' - ' . $per_f; - - return "<img src=\"https://chart.googleapis.com/chart?cht=p3&chd=e:{$chd}&chs={$size}&chco={$color_female},{$color_male}&chf=bg,s,ffffff00&chl={$chl}\" width=\"{$sizes[0]}\" height=\"{$sizes[1]}\" alt=\"" . $chart_title . '" title="' . $chart_title . '" />'; } + + $chd = $this->arrayToExtendedEncoding([ + 4095 * $tot_f / $tot, + 4095 * $tot_m / $tot, + ]); + $chl = + I18N::translate('Females') . ' - ' . $per_f . '|' . + I18N::translate('Males') . ' - ' . $per_m; + $chart_title = I18N::translate('Males') . ' - ' . $per_m . I18N::$list_separator . + I18N::translate('Females') . ' - ' . $per_f; + + return "<img src=\"https://chart.googleapis.com/chart?cht=p3&chd=e:{$chd}&chs={$size}&chco={$color_female},{$color_male}&chf=bg,s,ffffff00&chl={$chl}\" width=\"{$sizes[0]}\" height=\"{$sizes[1]}\" alt=\"" . $chart_title . '" title="' . $chart_title . '" />'; } /** @@ -1181,19 +1183,19 @@ class Stats $per_d = $this->totalDeceasedPercentage(); if ($tot == 0) { return ''; - } else { - $chd = $this->arrayToExtendedEncoding([ - 4095 * $tot_l / $tot, - 4095 * $tot_d / $tot, - ]); - $chl = - I18N::translate('Living') . ' - ' . $per_l . '|' . - I18N::translate('Dead') . ' - ' . $per_d . '|'; - $chart_title = I18N::translate('Living') . ' - ' . $per_l . I18N::$list_separator . - I18N::translate('Dead') . ' - ' . $per_d; - - return "<img src=\"https://chart.googleapis.com/chart?cht=p3&chd=e:{$chd}&chs={$size}&chco={$color_living},{$color_dead}&chf=bg,s,ffffff00&chl={$chl}\" width=\"{$sizes[0]}\" height=\"{$sizes[1]}\" alt=\"" . $chart_title . '" title="' . $chart_title . '" />'; } + + $chd = $this->arrayToExtendedEncoding([ + 4095 * $tot_l / $tot, + 4095 * $tot_d / $tot, + ]); + $chl = + I18N::translate('Living') . ' - ' . $per_l . '|' . + I18N::translate('Dead') . ' - ' . $per_d . '|'; + $chart_title = I18N::translate('Living') . ' - ' . $per_l . I18N::$list_separator . + I18N::translate('Dead') . ' - ' . $per_d; + + return "<img src=\"https://chart.googleapis.com/chart?cht=p3&chd=e:{$chd}&chs={$size}&chco={$color_living},{$color_dead}&chf=bg,s,ffffff00&chl={$chl}\" width=\"{$sizes[0]}\" height=\"{$sizes[1]}\" alt=\"" . $chart_title . '" title="' . $chart_title . '" />'; } /** @@ -1667,7 +1669,9 @@ class Stats } return $placelist; - } elseif ($parent > 0) { + } + + if ($parent > 0) { // used by placehierarchy googlemap module if ($what == 'INDI') { $join = " JOIN `##individuals` ON pl_file = i_file AND pl_gid = i_id"; @@ -1691,30 +1695,30 @@ class Stats ); return $rows; - } else { - if ($what == 'INDI') { - $join = " JOIN `##individuals` ON pl_file = i_file AND pl_gid = i_id"; - } elseif ($what == 'FAM') { - $join = " JOIN `##families` ON pl_file = f_file AND pl_gid = f_id"; - } else { - $join = ""; - } - $rows = $this->runSql( - " SELECT" . - " p_place AS country," . - " COUNT(*) AS tot" . - " FROM" . - " `##places`" . - " JOIN `##placelinks` ON pl_file=p_file AND p_id=pl_p_id" . - $join . - " WHERE" . - " p_file={$this->tree->getTreeId()}" . - " AND p_parent_id='0'" . - " GROUP BY country ORDER BY tot DESC, country ASC" - ); + } - return $rows; + if ($what == 'INDI') { + $join = " JOIN `##individuals` ON pl_file = i_file AND pl_gid = i_id"; + } elseif ($what == 'FAM') { + $join = " JOIN `##families` ON pl_file = f_file AND pl_gid = f_id"; + } else { + $join = ""; } + $rows = $this->runSql( + " SELECT" . + " p_place AS country," . + " COUNT(*) AS tot" . + " FROM" . + " `##places`" . + " JOIN `##placelinks` ON pl_file=p_file AND p_id=pl_p_id" . + $join . + " WHERE" . + " p_file={$this->tree->getTreeId()}" . + " AND p_parent_id='0'" . + " GROUP BY country ORDER BY tot DESC, country ASC" + ); + + return $rows; } /** @@ -2123,9 +2127,9 @@ class Stats $chl = rawurlencode(substr($centuries, 0, -1)); return "<img src=\"https://chart.googleapis.com/chart?cht=p3&chd=e:{$chd}&chs={$size}&chco={$color_from},{$color_to}&chf=bg,s,ffffff00&chl={$chl}\" width=\"{$sizes[0]}\" height=\"{$sizes[1]}\" alt=\"" . I18N::translate('Births by century') . '" title="' . I18N::translate('Births by century') . '" />'; - } else { - return $rows; } + + return $rows; } /** @@ -2704,9 +2708,9 @@ class Stats } return FunctionsDate::getAgeAtEvent($age); - } else { - return I18N::number($age / 365.25); } + + return I18N::number($age / 365.25); } /** @@ -2815,47 +2819,47 @@ class Stats } return '<img src="' . "https://chart.googleapis.com/chart?cht=bvg&chs={$sizes[0]}x{$sizes[1]}&chm=D,FF0000,2,0,3,1|N*f1*,000000,0,-1,11,1|N*f1*,000000,1,-1,11,1&chf=bg,s,ffffff00|c,s,ffffff00&chtt=" . rawurlencode($chtt) . "&chd={$chd}&chco=0000FF,FFA0CB,FF0000&chbh=20,3&chxt=x,x,y,y&chxl=" . rawurlencode($chxl) . '&chdl=' . rawurlencode(I18N::translate('Males') . '|' . I18N::translate('Females') . '|' . I18N::translate('Average age at death')) . "\" width=\"{$sizes[0]}\" height=\"{$sizes[1]}\" alt=\"" . I18N::translate('Average age related to death century') . '" title="' . I18N::translate('Average age related to death century') . '" />'; - } else { - $sex_search = ''; - $years = ''; - if ($sex == 'F') { - $sex_search = " AND i_sex='F'"; - } elseif ($sex == 'M') { - $sex_search = " AND i_sex='M'"; - } - if ($year1 >= 0 && $year2 >= 0) { - if ($related == 'BIRT') { - $years = " AND birth.d_year BETWEEN '{$year1}' AND '{$year2}'"; - } elseif ($related == 'DEAT') { - $years = " AND death.d_year BETWEEN '{$year1}' AND '{$year2}'"; - } - } - $rows = $this->runSql( - "SELECT" . - " death.d_julianday2-birth.d_julianday1 AS age" . - " FROM" . - " `##dates` AS death," . - " `##dates` AS birth," . - " `##individuals` AS indi" . - " WHERE" . - " indi.i_id=birth.d_gid AND" . - " birth.d_gid=death.d_gid AND" . - " death.d_file={$this->tree->getTreeId()} AND" . - " birth.d_file=death.d_file AND" . - " birth.d_file=indi.i_file AND" . - " birth.d_fact='BIRT' AND" . - " death.d_fact='DEAT' AND" . - " birth.d_julianday1 <> 0 AND" . - " birth.d_type IN ('@#DGREGORIAN@', '@#DJULIAN@') AND" . - " death.d_type IN ('@#DGREGORIAN@', '@#DJULIAN@') AND" . - " death.d_julianday1>birth.d_julianday2" . - $years . - $sex_search . - " ORDER BY age DESC" - ); + } - return $rows; + $sex_search = ''; + $years = ''; + if ($sex == 'F') { + $sex_search = " AND i_sex='F'"; + } elseif ($sex == 'M') { + $sex_search = " AND i_sex='M'"; } + if ($year1 >= 0 && $year2 >= 0) { + if ($related == 'BIRT') { + $years = " AND birth.d_year BETWEEN '{$year1}' AND '{$year2}'"; + } elseif ($related == 'DEAT') { + $years = " AND death.d_year BETWEEN '{$year1}' AND '{$year2}'"; + } + } + $rows = $this->runSql( + "SELECT" . + " death.d_julianday2-birth.d_julianday1 AS age" . + " FROM" . + " `##dates` AS death," . + " `##dates` AS birth," . + " `##individuals` AS indi" . + " WHERE" . + " indi.i_id=birth.d_gid AND" . + " birth.d_gid=death.d_gid AND" . + " death.d_file={$this->tree->getTreeId()} AND" . + " birth.d_file=death.d_file AND" . + " birth.d_file=indi.i_file AND" . + " birth.d_fact='BIRT' AND" . + " death.d_fact='DEAT' AND" . + " birth.d_julianday1 <> 0 AND" . + " birth.d_type IN ('@#DGREGORIAN@', '@#DJULIAN@') AND" . + " death.d_type IN ('@#DGREGORIAN@', '@#DJULIAN@') AND" . + " death.d_julianday1>birth.d_julianday2" . + $years . + $sex_search . + " ORDER BY age DESC" + ); + + return $rows; } /** @@ -4228,42 +4232,42 @@ class Stats } return '<img src="' . "https://chart.googleapis.com/chart?cht=bvg&chs={$sizes[0]}x{$sizes[1]}&chm=D,FF0000,2,0,3,1|{$chmm}{$chmf}&chf=bg,s,ffffff00|c,s,ffffff00&chtt=" . rawurlencode($chtt) . "&chd={$chd}&chco=0000FF,FFA0CB,FF0000&chbh=20,3&chxt=x,x,y,y&chxl=" . rawurlencode($chxl) . '&chdl=' . rawurlencode(I18N::translate('Males') . '|' . I18N::translate('Females') . '|' . I18N::translate('Average age')) . "\" width=\"{$sizes[0]}\" height=\"{$sizes[1]}\" alt=\"" . I18N::translate('Average age in century of marriage') . '" title="' . I18N::translate('Average age in century of marriage') . '" />'; - } else { - if ($year1 >= 0 && $year2 >= 0) { - $years = " married.d_year BETWEEN {$year1} AND {$year2} AND "; - } else { - $years = ''; - } - $rows = $this->runSql( - "SELECT " . - " fam.f_id, " . - " birth.d_gid, " . - " married.d_julianday2-birth.d_julianday1 AS age " . - "FROM `##dates` AS married " . - "JOIN `##families` AS fam ON (married.d_gid=fam.f_id AND married.d_file=fam.f_file) " . - "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->getTreeId()} 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 " . - "SELECT " . - " fam.f_id, " . - " birth.d_gid, " . - " married.d_julianday2-birth.d_julianday1 AS age " . - "FROM `##dates` AS married " . - "JOIN `##families` AS fam ON (married.d_gid=fam.f_id AND married.d_file=fam.f_file) " . - "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->getTreeId()} 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 " - ); + } - return $rows; + if ($year1 >= 0 && $year2 >= 0) { + $years = " married.d_year BETWEEN {$year1} AND {$year2} AND "; + } else { + $years = ''; } + $rows = $this->runSql( + "SELECT " . + " fam.f_id, " . + " birth.d_gid, " . + " married.d_julianday2-birth.d_julianday1 AS age " . + "FROM `##dates` AS married " . + "JOIN `##families` AS fam ON (married.d_gid=fam.f_id AND married.d_file=fam.f_file) " . + "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->getTreeId()} 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 " . + "SELECT " . + " fam.f_id, " . + " birth.d_gid, " . + " married.d_julianday2-birth.d_julianday1 AS age " . + "FROM `##dates` AS married " . + "JOIN `##families` AS fam ON (married.d_gid=fam.f_id AND married.d_file=fam.f_file) " . + "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->getTreeId()} 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 " + ); + + return $rows; } /** @@ -4924,9 +4928,9 @@ class Stats $return .= '<br><a href="' . e($family->url()) . '">[' . I18N::translate('View this family') . ']</a>'; return $return; - } else { - return I18N::translate('This information is private and cannot be shown.'); } + + return I18N::translate('This information is private and cannot be shown.'); } } if ($type === 'list') { @@ -5314,46 +5318,46 @@ class Stats } return "<img src=\"https://chart.googleapis.com/chart?cht=bvg&chs={$sizes[0]}x{$sizes[1]}&chf=bg,s,ffffff00|c,s,ffffff00&chm=D,FF0000,0,0,3,1|{$chm}&chd=e:{$chd}&chco=0000FF&chbh=30,3&chxt=x,x,y,y&chxl=" . rawurlencode($chxl) . "\" width=\"{$sizes[0]}\" height=\"{$sizes[1]}\" alt=\"" . I18N::translate('Average number of children per family') . '" title="' . I18N::translate('Average number of children per family') . '" />'; + } + + if ($sex == 'M') { + $sql = + "SELECT num, COUNT(*) AS total FROM " . + "(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->getTreeId()} GROUP BY l_to" . + ") boys" . + " GROUP BY num" . + " ORDER BY num"; + } elseif ($sex == 'F') { + $sql = + "SELECT num, COUNT(*) AS total FROM " . + "(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->getTreeId()} GROUP BY l_to" . + ") girls" . + " GROUP BY num" . + " ORDER BY num"; } else { - if ($sex == 'M') { - $sql = - "SELECT num, COUNT(*) AS total FROM " . - "(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->getTreeId()} GROUP BY l_to" . - ") boys" . - " GROUP BY num" . - " ORDER BY num"; - } elseif ($sex == 'F') { - $sql = - "SELECT num, COUNT(*) AS total FROM " . - "(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->getTreeId()} GROUP BY l_to" . - ") girls" . - " GROUP BY num" . - " ORDER BY num"; + $sql = "SELECT 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->getTreeId()}" + . " WHERE" + . " married.d_gid = fam.f_id AND" + . " fam.f_file = {$this->tree->getTreeId()} AND" + . " married.d_fact = 'MARR' AND" + . " married.d_year BETWEEN '{$year1}' AND '{$year2}'"; } else { - $sql = "SELECT 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->getTreeId()}" - . " WHERE" - . " married.d_gid = fam.f_id AND" - . " fam.f_file = {$this->tree->getTreeId()} AND" - . " married.d_fact = 'MARR' AND" - . " married.d_year BETWEEN '{$year1}' AND '{$year2}'"; - } else { - $sql .= "WHERE f_file={$this->tree->getTreeId()}"; - } - $sql .= ' GROUP BY f_numchil'; + $sql .= "WHERE f_file={$this->tree->getTreeId()}"; } - $rows = $this->runSql($sql); - - return $rows; + $sql .= ' GROUP BY f_numchil'; } + $rows = $this->runSql($sql); + + return $rows; } /** @@ -6422,11 +6426,13 @@ class Stats } if ($type == 'anon') { return $anon; - } elseif ($type == 'visible') { + } + + if ($type == 'visible') { return $visible; - } else { - return $visible + $anon; } + + return $visible + $anon; } /** @@ -6500,12 +6506,14 @@ class Stats { if (Auth::check()) { return e(Auth::user()->getUserName()); - } elseif (isset($params[0]) && $params[0] != '') { + } + + if (isset($params[0]) && $params[0] != '') { // if #username:visitor# was specified, then "visitor" will be returned when the user is not logged in return e($params[0]); - } else { - return ''; } + + return ''; } /** @@ -6653,9 +6661,9 @@ class Stats $user = User::find($user_id); if ($user) { return Theme::theme()->contactLink($user); - } else { - return $user_id; } + + return $user_id; } /** @@ -6669,9 +6677,9 @@ class Stats $user = User::find($user_id); if ($user) { return Theme::theme()->contactLink($user); - } else { - return $user_id; } + + return $user_id; } /** @@ -6939,9 +6947,9 @@ class Stats $block = new FamilyTreeFavoritesModule(WT_MODULES_DIR . 'gedcom_favorites'); return $block->getBlock($this->tree, 0, false); - } else { - return ''; } + + return ''; } /** @@ -6955,9 +6963,9 @@ class Stats $block = new UserFavoritesModule(WT_MODULES_DIR . 'gedcom_favorites'); return $block->getBlock($this->tree, 0, false); - } else { - return ''; } + + return ''; } /** @@ -6972,9 +6980,9 @@ class Stats if ($module !== null) { return count($module->getFavorites($this->tree)); - } else { - return 0; } + + return 0; } /** @@ -6989,9 +6997,9 @@ class Stats if ($module !== null) { return count($module->getFavorites($this->tree, Auth::user())); - } else { - return 0; } + + return 0; } /** |
