diff options
author | plegall <plg@piwigo.org> | 2007-01-17 23:06:24 +0000 |
---|---|---|
committer | plegall <plg@piwigo.org> | 2007-01-17 23:06:24 +0000 |
commit | 8e43a0fec128ad379bcdf432ddb034db66097c7e (patch) | |
tree | e0204bca4bc45a0cc9a981a2b39f506fc9e35f9a /admin/stats.php | |
parent | 94755e7bd764e2e4ccfa6cbc146b324ac27dc116 (diff) |
Modification: the history summary graph does not use a true image anymore,
CSS divs are faster and don't require GD library.
git-svn-id: http://piwigo.org/svn/trunk@1729 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r-- | admin/stats.php | 118 |
1 files changed, 73 insertions, 45 deletions
diff --git a/admin/stats.php b/admin/stats.php index 228860b9c..1030c5f45 100644 --- a/admin/stats.php +++ b/admin/stats.php @@ -317,23 +317,6 @@ if (isset($page['month'])) } } -$url_img = PHPWG_ROOT_PATH.'admin/images/stats.img.php'; - -if (isset($page['year'])) -{ - $url_img.= '?year='.$page['year']; -} - -if (isset($page['month'])) -{ - $url_img.= '&month='.$page['month']; -} - -if (isset($page['day'])) -{ - $url_img.= '&day='.$page['day']; -} - $summary_lines = get_summary( @$page['year'], @$page['month'], @@ -405,7 +388,6 @@ $template->set_filenames(array('stats'=>'admin/stats.tpl')); $template->assign_vars( array( 'L_STAT_TITLE' => implode($conf['level_separator'], $title_parts), - 'SRC_REPORT' => $url_img, 'PERIOD_LABEL' => $period_label, ) ); @@ -414,46 +396,90 @@ $template->assign_vars( // | Display statistic rows | // +-----------------------------------------------------------------------+ -$i = 1; +$max_width = 400; + +$datas = array(); +if (isset($page['day'])) +{ + $key = 'hour'; + $min_x = 0; + $max_x = 23; +} +elseif (isset($page['month'])) +{ + $key = 'day'; + $min_x = 1; + $max_x = date( + 't', + mktime(12, 0, 0, $page['month'], 1, $page['year']) + ); +} +elseif (isset($page['year'])) +{ + $key = 'month'; + $min_x = 1; + $max_x = 12; +} +else +{ + $key = 'year'; +} + +$max_pages = 1; foreach ($summary_lines as $line) { - // echo '<pre>'; print_r($line); echo '</pre>'; + if ($line['nb_pages'] > $max_pages) + { + $max_pages = $line['nb_pages']; + } - $value = ''; - - if (isset($line['hour'])) + $datas[ $line[$key] ] = $line['nb_pages']; +} + +if (!isset($min_x) and !isset($max_x)) +{ + $min_x = min(array_keys($datas)); + $max_x = max(array_keys($datas)); +} + +for ($i = $min_x; $i <= $max_x; $i++) +{ + if (!isset($datas[$i])) + { + $datas[$i] = 0; + } + + $url = null; + + if (isset($page['day'])) { - $value.= $line['hour'].' '.l10n('hour'); + $value = $i.' '.l10n('hour'); } - else if (isset($line['day'])) + else if (isset($page['month'])) { $url = PHPWG_ROOT_PATH.'admin.php' .'?page=stats' - .'&year='.$line['year'] - .'&month='.$line['month'] - .'&day='.$line['day'] + .'&year='.$page['year'] + .'&month='.$page['month'] + .'&day='.$i ; - $time = mktime(12, 0, 0, $line['month'], $line['day'], $line['year']); + $time = mktime(12, 0, 0, $page['month'], $i, $page['year']); - $value = '<a href="'.$url.'">'; - $value.= $line['day'].' ('.$lang['day'][date('w', $time)].')'; - $value.= "</a>"; + $value = $i.' ('.$lang['day'][date('w', $time)].')'; } - else if (isset($line['month'])) + else if (isset($page['year'])) { $url = PHPWG_ROOT_PATH.'admin.php' .'?page=stats' - .'&year='.$line['year'] - .'&month='.$line['month'] + .'&year='.$page['year'] + .'&month='.$i ; - $value = '<a href="'.$url.'">'; - $value.= $lang['month'][$line['month']]; - $value.= "</a>"; + $value = $lang['month'][$i]; } else { @@ -461,21 +487,23 @@ foreach ($summary_lines as $line) $url = PHPWG_ROOT_PATH.'admin.php' .'?page=stats' - .'&year='.$line['year'] + .'&year='.$i ; - $value = '<a href="'.$url.'">'; - $value.= $line['year']; - $value.= "</a>"; + $value = $i; + } + + if ($datas[$i] != 0 and isset($url)) + { + $value = '<a href="'.$url.'">'.$value.'</a>'; } $template->assign_block_vars( 'statrow', array( 'VALUE' => $value, - 'PAGES' => $line['nb_pages'], - - 'T_CLASS' => ($i++ % 2) ? 'row1' : 'row2' + 'PAGES' => $datas[$i], + 'WIDTH' => ceil(($datas[$i] * $max_width) / $max_pages ), ) ); } |