diff options
| author | Greg Roach <fisharebest@gmail.com> | 2015-02-12 22:49:33 +0000 |
|---|---|---|
| committer | Greg Roach <fisharebest@gmail.com> | 2015-02-12 22:49:33 +0000 |
| commit | afec310947e83154c3e9749928329731907ce2c1 (patch) | |
| tree | 6b16b8526855326e2f522e2099ea4d72e142409c | |
| parent | 394663b1492f8feb349a23eb0849f0a78a7f7691 (diff) | |
| download | webtrees-afec310947e83154c3e9749928329731907ce2c1.tar.gz webtrees-afec310947e83154c3e9749928329731907ce2c1.tar.bz2 webtrees-afec310947e83154c3e9749928329731907ce2c1.zip | |
Unused code and tidy statistics charts
| -rw-r--r-- | statistics.php | 64 | ||||
| -rw-r--r-- | statisticsplot.php | 130 |
2 files changed, 40 insertions, 154 deletions
diff --git a/statistics.php b/statistics.php index b41ce168f1..d89ca20247 100644 --- a/statistics.php +++ b/statistics.php @@ -473,9 +473,9 @@ if (!$ajax) { document.getElementById('surname_opt').style.display = 'none'; } } - function statsModalDialog(url, title) { + function statsModalDialog() { var form = jQuery('#own-stats-form'); - jQuery.post(form.attr('action'), form.serialize(), function (response) { + jQuery.get(form.attr('action'), form.serialize(), function (response) { jQuery(response).dialog({ modal: true, width: 964, @@ -492,99 +492,52 @@ if (!$ajax) { } </script> <?php - echo '<div id="own-stats"><form method="post" id="own-stats-form" name="form" action="statisticsplot.php" onsubmit="statsModalDialog(\'statisticsplot.php?action=newform\', \'', I18N::translate('Statistics plot'), '\'); return false;">'; + echo '<div id="own-stats"><form method="post" id="own-stats-form" name="form" action="statisticsplot.php" onsubmit="return statsModalDialog();">'; echo '<input type="hidden" name="action" value="update">'; echo '<table width="100%">'; - if (!isset($plottype)) { - $plottype = 11; - } - if (!isset($charttype)) { - $charttype = 1; - } - if (!isset($plotshow)) { - $plotshow = 302; - } - if (!isset($plotnp)) { - $plotnp = 201; - } - if (isset($WT_SESSION->statTicks[$WT_TREE->getTreeId()])) { - $x_axis_boundary_ages = $WT_SESSION->statTicks[$WT_TREE->getTreeId()]['x_axis_boundary_ages']; - $x_axis_boundary_months = $WT_SESSION->statTicks[$WT_TREE->getTreeId()]['x_axis_boundary_months']; - $x_axis_boundary_numbers = $WT_SESSION->statTicks[$WT_TREE->getTreeId()]['x_axis_boundary_numbers']; - $x_axis_boundary_periods = $WT_SESSION->statTicks[$WT_TREE->getTreeId()]['z_axis_boundary_periods']; - } else { - $x_axis_boundary_ages = '1,5,10,20,30,40,50,60,70,80,90,100'; - $x_axis_boundary_months = '-24,-12,0,8,12,18,24,48'; - $x_axis_boundary_numbers = '1,2,3,4,5,6,7,8,9,10'; - $x_axis_boundary_periods = '1700,1750,1800,1850,1900,1950,2000'; - } - if (isset($WT_SESSION->statTicks1[$WT_TREE->getTreeId()])) { - $chart_shows = $WT_SESSION->statTicks1[$WT_TREE->getTreeId()]['chart_shows']; - $chart_type = $WT_SESSION->statTicks1[$WT_TREE->getTreeId()]['chart_type']; - $surname = $WT_SESSION->statTicks1[$WT_TREE->getTreeId()]['surname']; - } else { - $chart_shows = 'world'; - $chart_type = 'indi_distribution_chart'; - $surname = $stats->getCommonSurname(); - } - echo '<tr> <td class="descriptionbox width25 wrap">', I18N::translate('Select chart type:'), '</td> <td class="optionbox"> - <input type="radio" id="stat_11" name="x-as" value="11" '; - echo $plottype == '11' ? 'checked' : ''; + <input type="radio" id="stat_11" name="x-as" value="11" checked'; echo " onclick=\"{statusEnable('z_sex'); statusHide('x_years'); statusHide('x_months'); statusHide('x_numbers'); statusHide('map_opt');}"; echo '"><label for="stat_11">', I18N::translate('Month of birth'), '</label><br>'; echo '<input type="radio" id="stat_12" name="x-as" value="12" '; - echo $plottype == '12' ? 'checked' : ''; echo " onclick=\"{statusEnable('z_sex'); statusHide('x_years'); statusHide('x_months'); statusHide('x_numbers'); statusHide('map_opt');}"; echo '"><label for="stat_12">', I18N::translate('Month of death'), '</label><br>'; echo '<input type="radio" id="stat_13" name="x-as" value="13" '; - echo $plottype == '13' ? 'checked' : ''; echo " onclick=\"{statusChecked('z_none'); statusDisable('z_sex'); statusHide('x_years'); statusHide('x_months'); statusHide('x_numbers'); statusHide('map_opt');}"; echo '"><label for="stat_13">', I18N::translate('Month of marriage'), '</label><br>'; echo '<input type="radio" id="stat_15" name="x-as" value="15" '; - echo $plottype == '15' ? 'checked' : ''; echo " onclick=\"{statusChecked('z_none'); statusDisable('z_sex'); statusHide('x_years'); statusHide('x_months'); statusHide('x_numbers'); statusHide('map_opt');}"; echo '"><label for="stat_15">', I18N::translate('Month of first marriage'), '</label><br>'; echo '<input type="radio" id="stat_14" name="x-as" value="14" '; - echo $plottype == '14' ? 'checked' : ''; echo " onclick=\"{statusEnable('z_sex'); statusHide('x_years'); statusHide('x_months'); statusHide('x_numbers'); statusHide('map_opt');}"; echo '"><label for="stat_14">', I18N::translate('Month of birth of first child in a relation'), '</label><br>'; echo '<input type="radio" id="stat_17" name="x-as" value="17" '; - echo $plottype == '17' ? 'checked' : ''; echo " onclick=\"{statusEnable('z_sex'); statusShow('x_years'); statusHide('x_months'); statusHide('x_numbers'); statusHide('map_opt');}"; echo '"><label for="stat_17">', I18N::translate('Age related to birth year'), '</label><br>'; echo '<input type="radio" id="stat_18" name="x-as" value="18" '; - echo $plottype == '18' ? 'checked' : ''; echo " onclick=\"{statusEnable('z_sex'); statusShow('x_years'); statusHide('x_months'); statusHide('x_numbers'); statusHide('map_opt');}"; echo '"><label for="stat_18">', I18N::translate('Age related to death year'), '</label><br>'; echo '<input type="radio" id="stat_19" name="x-as" value="19" '; - echo $plottype == '19' ? 'checked' : ''; echo " onclick=\"{statusEnable('z_sex'); statusHide('x_years'); statusShow('x_years_m'); statusHide('x_months'); statusHide('x_numbers'); statusHide('map_opt');}"; echo '"><label for="stat_19">', I18N::translate('Age in year of marriage'), '</label><br>'; echo '<input type="radio" id="stat_20" name="x-as" value="20" '; - echo $plottype == "20" ? 'checked' : ''; echo " onclick=\"{statusEnable('z_sex'); statusHide('x_years'); statusShow('x_years_m'); statusHide('x_months'); statusHide('x_numbers'); statusHide('map_opt');}"; echo '"><label for="stat_20">', I18N::translate('Age in year of first marriage'), '</label><br>'; echo '<input type="radio" id="stat_21" name="x-as" value="21" '; - echo $plottype == '21' ? 'checked' : ''; echo " onclick=\"{statusEnable('z_sex'); statusHide('x_years'); statusHide('x_months'); statusShow('x_numbers'); statusHide('map_opt');}"; echo '"><label for="stat_21">', I18N::translate('Number of children'), '</label><br>'; echo '<input type="radio" id="stat_1" name="x-as" value="1" '; - echo $plottype == '1' ? 'checked' : ''; echo " onclick=\"{statusHide('x_years'); statusHide('x_months'); statusHide('x_numbers'); statusShow('map_opt'); statusShow('chart_type'); statusHide('axes');}"; echo '"><label for="stat_1">', I18N::translate('Individual distribution'), '</label><br>'; echo '<input type="radio" id="stat_2" name="x-as" value="2" '; - echo $plottype == '2' ? 'checked' : ''; echo " onclick=\"{statusHide('x_years'); statusHide('x_months'); statusHide('x_numbers'); statusShow('map_opt'); statusHide('chart_type'); statusHide('surname_opt');}"; echo '"><label for="stat_2">', I18N::translate('Birth by country'), '</label><br>'; echo '<input type="radio" id="stat_4" name="x-as" value="4" '; - echo $plottype == '4' ? 'checked' : ''; echo " onclick=\"{statusHide('x_years'); statusHide('x_months'); statusHide('x_numbers'); statusShow('map_opt'); statusHide('chart_type'); statusHide('surname_opt');}"; echo '"><label for="stat_4">', I18N::translate('Marriage by country'), '</label><br>'; echo '<input type="radio" id="stat_3" name="x-as" value="3" '; - echo $plottype == '3' ? 'checked' : ''; echo " onclick=\"{statusHide('x_years'); statusHide('x_months'); statusHide('x_numbers'); statusShow('map_opt'); statusHide('chart_type'); statusHide('surname_opt');}"; echo '"><label for="stat_3">', I18N::translate('Death by country'), '</label><br>'; echo '<br><div id="x_years" style="display:none;">'; @@ -651,15 +604,12 @@ if (!$ajax) { <td class="descriptionbox width20 wrap" id="axes">', I18N::translate('Categories:'), '</td> <td class="optionbox width30" id="zyaxes"> <input type="radio" id="z_none" name="z-as" value="300" '; - echo $plotshow == '300' ? 'checked' : ''; echo " onclick=\"statusDisable('z-axis-boundaries-periods');"; echo '"><label for="z_none">', I18N::translate('overall'), '</label><br>'; echo '<input type="radio" id="z_sex" name="z-as" value="301" '; - echo $plotshow == '301' ? 'checked' : ''; echo " onclick=\"statusDisable('z-axis-boundaries-periods');"; echo '"><label for="z_sex">', I18N::translate('gender'), '</label><br>'; - echo '<input type="radio" id="z_time" name="z-as" value="302" '; - echo $plotshow == '302' ? 'checked' : ''; + echo '<input type="radio" id="z_time" name="z-as" value="302" checked'; echo " onclick=\"statusEnable('z-axis-boundaries-periods');"; echo '"><label for="z_time">', I18N::translate('date periods'), '</label><br><br>'; echo I18N::translate('Date range'), '<br>'; @@ -680,11 +630,9 @@ if (!$ajax) { </select> <br><br>'; echo I18N::translate('results:'), '<br>'; - echo '<input type="radio" id="y_num" name="y-as" value="201" '; - echo $plotnp == '201' ? 'checked' : ''; + echo '<input type="radio" id="y_num" name="y-as" value="201" checked'; echo '><label for="y_num">', I18N::translate('numbers'), '</label><br>'; echo '<input type="radio" id="y_perc" name="y-as" value="202" '; - echo $plotnp == '202' ? 'checked' : ''; echo '><label for="y_perc">', I18N::translate('percentage'), '</label><br>'; echo '</td> </tr> diff --git a/statisticsplot.php b/statisticsplot.php index f82aa36ea1..bed56e812c 100644 --- a/statisticsplot.php +++ b/statisticsplot.php @@ -16,21 +16,16 @@ namespace Fisharebest\Webtrees; * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -use Zend_Session; - /** * Defined in session.php * - * @global Zend_Session $WT_SESSION - * @global Tree $WT_TREE + * @global Tree $WT_TREE */ -global $WT_SESSION, $WT_TREE; +global $WT_TREE; define('WT_SCRIPT_NAME', 'statisticsplot.php'); require './includes/session.php'; -$controller = new AjaxController; - $stats = new Stats($WT_TREE); /** @@ -788,6 +783,8 @@ function set_parameters($current, $indfam, $xg, $zg, $titstr, $xt, $gx, $gz, $my global $legend, $xdata, $ydata, $xmax, $zmax, $z_boundaries, $xgiven, $zgiven, $percentage, $male_female; global $stats; + $myfunc = __NAMESPACE__ . '\\' . $myfunc; + if (!function_exists($myfunc)) { throw new \DomainException(I18N::translate('%s not implemented', $myfunc)); } @@ -810,36 +807,36 @@ function set_parameters($current, $indfam, $xg, $zg, $titstr, $xt, $gx, $gz, $my $ytitle = I18N::translate('numbers'); $boundaries_x_axis = $gx; $boundaries_z_axis = $gz; - if ($xg == true) { + if ($xg) { $xdata = $monthdata; $xmax = 12; } else { calculate_axis($boundaries_x_axis); } - if ($z_axis != 300 && $z_axis != 301) { + if ($z_axis !== 300 && $z_axis !== 301) { calculate_legend($boundaries_z_axis); } $percentage = false; - if ($y_axis == 201) { + if ($y_axis === 201) { $percentage = false; - if ($current == 13 || $current == 15 || $current == 16 || $current == 21) { + if ($current === 13 || $current === 15 || $current === 16 || $current === 21) { $ytitle = I18N::translate('Families'); - } elseif ($current == 14) { + } elseif ($current === 14) { $ytitle = I18N::translate('Children'); } else { $ytitle = I18N::translate('Individuals'); } - } elseif ($y_axis == 202) { + } elseif ($y_axis === 202) { $percentage = true; $ytitle = I18N::translate('percentage'); } $male_female = false; - if ($z_axis == 300) { + if ($z_axis === 300) { $zgiven = false; $legend[0] = 'all'; $zmax = 1; $z_boundaries[0] = 100000; - } elseif ($z_axis == 301) { + } elseif ($z_axis === 301) { $male_female = true; $zgiven = true; $legend[0] = I18N::translate('Male'); @@ -867,80 +864,33 @@ function set_parameters($current, $indfam, $xg, $zg, $titstr, $xt, $gx, $gz, $my } } -//-- ========= start of main program ========= -$action = Filter::post('action'); - -if ($action === 'update') { - $x_axis = $_POST['x-as']; - $y_axis = $_POST['y-as']; - if (isset($_POST['z-as'])) { - $z_axis = $_POST['z-as']; - } else { - $z_axis = 300; - } - $xgl = $_POST['x-axis-boundaries-ages']; - $xglm = $_POST['x-axis-boundaries-ages_m']; - $xgm = $_POST['x-axis-boundaries-months']; - $xga = $_POST['x-axis-boundaries-numbers']; - if (isset($_POST['z-axis-boundaries-periods'])) { - $zgp = $_POST['z-axis-boundaries-periods']; - } else { - $zgp = 0; - } - $chart_shows = $_POST['chart_shows']; - $chart_type = $_POST['chart_type']; - $surname = $_POST['SURN']; - - $WT_SESSION->statTicks[$WT_TREE->getTreeId()]['x_axis_boundary_ages'] = $xgl; - $WT_SESSION->statTicks[$WT_TREE->getTreeId()]['x_axis_boundary_ages_marriage'] = $xglm; - $WT_SESSION->statTicks[$WT_TREE->getTreeId()]['x_axis_boundary_months'] = $xgm; - $WT_SESSION->statTicks[$WT_TREE->getTreeId()]['x_axis_boundary_numbers'] = $xga; - $WT_SESSION->statTicks[$WT_TREE->getTreeId()]['z_axis_boundary_periods'] = $zgp; - $WT_SESSION->statTicks[$WT_TREE->getTreeId()]['chart_shows'] = $chart_shows; - $WT_SESSION->statTicks[$WT_TREE->getTreeId()]['chart_type'] = $chart_type; - $WT_SESSION->statTicks[$WT_TREE->getTreeId()]['SURN'] = $surname; - - // Save the input variables - $savedInput = array(); - $savedInput['x_axis'] = $x_axis; - $savedInput['y_axis'] = $y_axis; - $savedInput['z_axis'] = $z_axis; - $savedInput['xgl'] = $xgl; - $savedInput['xglm'] = $xglm; - $savedInput['xgm'] = $xgm; - $savedInput['xga'] = $xga; - $savedInput['zgp'] = $zgp; - $savedInput['chart_shows'] = $chart_shows; - $savedInput['chart_type'] = $chart_type; - $savedInput['SURN'] = $surname; - $WT_SESSION->statisticsplot[$WT_TREE->getTreeId()] = $savedInput; - unset($savedInput); -} else { - // Recover the saved input variables - $savedInput = $WT_SESSION->statisticsplot[$WT_TREE->getTreeId()]; - $x_axis = $savedInput['x_axis']; - $y_axis = $savedInput['y_axis']; - $z_axis = $savedInput['z_axis']; - $xgl = $savedInput['xgl']; - $xglm = $savedInput['xglm']; - $xgm = $savedInput['xgm']; - $xga = $savedInput['xga']; - $zgp = $savedInput['zgp']; - $chart_shows = $savedInput['chart_shows']; - $chart_type = $savedInput['chart_type']; - $surname = $savedInput['SURN']; - unset($savedInput); -} -Zend_Session::writeClose(); +$x_axis = Filter::getInteger('x-as', 1, 21, 11); +$y_axis = Filter::getInteger('y-as', 201, 202, 201); +$z_axis = Filter::getInteger('z-as', 300, 302, 302); +$xgl = Filter::get('x-axis-boundaries-ages'); +$xglm = Filter::get('x-axis-boundaries-ages_m'); +$xgm = Filter::get('x-axis-boundaries-months'); +$xga = Filter::get('x-axis-boundaries-numbers'); +$zgp = Filter::get('z-axis-boundaries-periods', null, '0'); +$chart_shows = Filter::get('chart_shows'); +$g_xas = '1,2,3,4,5,6,7,8,9,10,11,12'; echo '<div class="statistics_chart" title="', I18N::translate('Statistics plot'), '">'; -//-- Set params for request out of the information for plot -$g_xas = '1,2,3,4,5,6,7,8,9,10,11,12'; //should not be needed. but just for month - switch ($x_axis) { +case '1': + echo $stats->chartDistribution(array($chart_shows, Filter::get('chart_type'), Filter::get('SURN'))); + break; +case '2': + echo $stats->chartDistribution(array($chart_shows, 'birth_distribution_chart')); + break; +case '3': + echo $stats->chartDistribution(array($chart_shows, 'death_distribution_chart')); + break; +case '4': + echo $stats->chartDistribution(array($chart_shows, 'marriage_distribution_chart')); + break; case '11': - //--------- nr, type, xgiven, zgiven, title, xtitle, ytitle, boundaries_x, boundaries-z, function set_parameters(11, 'IND', true, false, I18N::translate('Month of birth'), I18N::translate('month'), $g_xas, $zgp, 'month_of_birth'); break; case '12': @@ -973,18 +923,6 @@ case '20': case '21': set_parameters(21, 'FAM', false, false, I18N::translate('Number of children'), I18N::translate('children'), $xga, $zgp, 'number_of_children'); break; -case '1': - echo $stats->chartDistribution(array($chart_shows, $chart_type, $surname)); - break; -case '2': - echo $stats->chartDistribution(array($chart_shows, 'birth_distribution_chart')); - break; -case '3': - echo $stats->chartDistribution(array($chart_shows, 'death_distribution_chart')); - break; -case '4': - echo $stats->chartDistribution(array($chart_shows, 'marriage_distribution_chart')); - break; default: echo '<i class="icon-loading-large"></i>'; break; |
