Skip to content

Commit

Permalink
Statistics charts improvements and HTML5 100% compatibility (opencach…
Browse files Browse the repository at this point in the history
  • Loading branch information
deg-pl committed Jul 24, 2017
1 parent 8c8b3c8 commit 6105c66
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 229 deletions.
3 changes: 2 additions & 1 deletion articles.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@
//set article inside the articles-directory
switch ($_REQUEST['page']) {
case 'stat':
require_once('./graphs/cachetypes-oc.php');
require_once('./graphs/stats-charts.php');
tpl_set_var('cachetype_chart_data', genChartDataCacheTypes());
tpl_set_var('cachesfound_chart_data', genChartDataCachesFound());
break;
default:
break;
Expand Down
38 changes: 0 additions & 38 deletions graphs/cachetypes-oc.php

This file was deleted.

172 changes: 0 additions & 172 deletions graphs/new-caches-oc.php

This file was deleted.

80 changes: 80 additions & 0 deletions graphs/stats-charts.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?php

use Utils\Database\XDb;

function genChartDataCacheTypes()
{
global $lang;
if (Xdb::xContainsColumn('cache_type', $lang))
$lang_db = XDb::xEscape($lang);
else
$lang_db = "en";

// Get data
$rsTypes = XDb::xSql(
"SELECT COUNT(`caches`.`type`) `count`, `cache_type`.`$lang_db` AS `type`
FROM `caches` INNER JOIN `cache_type` ON (`caches`.`type`=`cache_type`.`id`)
WHERE `status`=1
GROUP BY `caches`.`type`
ORDER BY `count` DESC");

$rows = array();
$table = array();
$table['cols'] = array (
array('label' => tr('cache_type'), 'type' => 'string'),
array('label' => tr('number_of_caches'), 'type' => 'number'),
);

while ($rTypes = XDb::xFetchArray($rsTypes)) {
$temp = array();
$temp[] = array('v' => (string) $rTypes['type']);
$temp[] = array('v' => (int) $rTypes['count']);
$rows[] = array('c' => $temp);
}

$table['rows'] = $rows;

return json_encode($table);
}

function genChartDataCachesFound()
{
global $lang;

// Get data
$rsStats = XDb::xSql(
"SELECT c.caches, l.founds, c.month, c.year FROM
(SELECT COUNT(*) `caches`, MONTH(`date_created`) `month`, YEAR(`date_created`) `year` FROM `caches`
WHERE caches.status=1
GROUP BY MONTH(`date_created`), YEAR(`date_created`)) c
LEFT JOIN
(SELECT COUNT(*) `founds`, MONTH(`date_created`) `month`, YEAR(`date_created`) `year` FROM `cache_logs`
WHERE (`type`=1 OR `type`=7) AND `deleted`=0
GROUP BY MONTH(`date_created`), YEAR(`date_created`)) l
USING(year, month)
ORDER BY year ASC, month ASC");

$caches = 0;
$finds = 0;
$rows = array();
$table = array();
$table['cols'] = array (
array('label' => tr('graph_statistics_04'), 'type' => 'date'),
array('label' => tr('graph_statistics_02'), 'type' => 'number'),
array('label' => tr('graph_statistics_03'), 'type' => 'number'),
);

while ($rStats = XDb::xFetchArray($rsStats)) {
$temp = array();
$caches += (int) $rStats['caches'];
$finds += (int) $rStats['founds'];
$temp[] = array('v' => 'Date(' . (string) $rStats['year'] . ', ' . (string) $rStats['month'] . ')');
$temp[] = array('v' => $caches);
$temp[] = array('v' => $finds);
$rows[] = array('c' => $temp);
}

$table['rows'] = $rows;

return json_encode($table);
}
22 changes: 11 additions & 11 deletions lib/languages/en.php
Original file line number Diff line number Diff line change
Expand Up @@ -558,21 +558,21 @@
'disable_fullscreen' => 'Turn off full screen',
'refresh_map'=> 'Refresh map',
'stats' => 'Statistics',
'rise_charts' => 'Our rising charts...',
'rise_charts' => 'Our charts',
'region_ranking' => 'Ranking per region',
'user_ranking' => 'Users ranking',
'cache_ranking' => 'Cache ranking',
'ranking_by_maintenace' => 'Maintenance of caches',
'ranking_by_number_of_created_caches' => 'User ranking by total number of caches hidden',
'ranking_by_number_of_created_active_caches' => 'User ranking by number of caches hidden and active',
'ranking_by_number_of_created_caches' => 'Total number of caches hidden',
'ranking_by_number_of_created_active_caches' => 'Number of caches hidden and active',
'ranking_by_number_of_finds_new' => 'Number of finds',
'ranking_by_number_of_finds' => 'User ranking by number of finds',
'ranking_by_number_of_recommnedations' => 'User ranking by number of received recommendations',
'cache_ranking_by_number_of_finds' => 'Cache ranking by number of finds',
'cache_ranking_by_calculated_indicator' => 'Cache ranking by formula',
'user_ranking_by_number_of_finds_of_their_caches' => 'User ranking by number of finds on caches they own',
'cache_ranking_by_finds_per_region' => 'Cache ranking by finds per region',
'cache_ranking_by_number_of_recommendations' => 'Cache ranking by number of recommendations',
'ranking_by_number_of_finds' => 'Cumulated number of finds',
'ranking_by_number_of_recommnedations' => 'Number of received recommendations',
'cache_ranking_by_number_of_finds' => 'Number of finds',
'cache_ranking_by_calculated_indicator' => 'Ranking by formula',
'user_ranking_by_number_of_finds_of_their_caches' => 'Number of finds on caches they own',
'cache_ranking_by_finds_per_region' => 'Finds per region',
'cache_ranking_by_number_of_recommendations' => 'Number of recommendations',
'oc_statistics' => 'OC statistics',
'only_active_caches' => 'Active caches only',
'users_who_created_caches' => 'Users who created caches',
Expand Down Expand Up @@ -2026,7 +2026,7 @@
'login_message_09' => 'To view this page, you need to log in.',
'graph_statistics_01' => 'Statistics for {site_name} :: Datum',
'graph_statistics_02' => 'Active caches',
'graph_statistics_03' => 'Finds',
'graph_statistics_03' => 'Finds (cumulated)',
'graph_statistics_04' => 'Date',
'graph_statistics_05' => 'Hidden caches:',
'graph_statistics_06' => 'Active caches:',
Expand Down
8 changes: 4 additions & 4 deletions lib/languages/pl.php
Original file line number Diff line number Diff line change
Expand Up @@ -2024,10 +2024,10 @@
'login_badCredentials' => 'Logowanie nie powiodło się.<br />Wprowadzona nazwa użytkownika lub hasło są nieprawidłowe.',
'login_cantSetCookie' => 'Twoja przeglądarka nie zapisała ciasteczek dla {site_name}.',
'login_message_09' => 'Strona, którą zamierzasz otworzyć, wymaga zalogowania.',
'graph_statistics_01' => 'Statystyka dla www.{site_name} :: Data',
'graph_statistics_01' => 'Statystyka dla {site_name} :: Data',
'graph_statistics_02' => 'Aktywne skrzynki',
'graph_statistics_03' => 'Znalezienia skrzynek',
'graph_statistics_04' => 'Dane na dzień',
'graph_statistics_03' => 'Znalezienia (skumulowane)',
'graph_statistics_04' => 'Data',
'graph_statistics_05' => 'Ukryte skrzynki:',
'graph_statistics_06' => 'W tym aktywnych:',
'graph_statistics_07' => 'Znalezienia skrzynek:',
Expand Down Expand Up @@ -2499,7 +2499,7 @@
'Stats_t4_01' => 'Ranking skrzynek według liczby znalezień',
'Stats_t4_02' => 'Ranking',
'Stats_t4_03' => 'Liczba znalezień',
'Stats_t4_04' => 'Nazwa skrzynki (Username)',
'Stats_t4_04' => 'Nazwa skrzynki (użytkownik)',
'Stats_t5_01' => 'Ranking użytkowników według liczby otrzymanych rekomendacji',
'Stats_t5_02' => 'gdzie',
'Stats_t5_03' => 'liczba skrzynek z rekomendacjami',
Expand Down
Loading

0 comments on commit 6105c66

Please sign in to comment.