From d19ad9c2d051a88797021911af48c0925a192d42 Mon Sep 17 00:00:00 2001 From: ovclas Date: Wed, 26 Dec 2012 08:39:15 +0000 Subject: [PATCH] issue 2740 add last week statistics git-svn-id: http://xe-core.googlecode.com/svn/branches/maserati@12470 201d5d3c-b55e-5fd7-737f-ddc643e51545 --- modules/counter/counter.model.php | 46 ++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/modules/counter/counter.model.php b/modules/counter/counter.model.php index bfb6ec3e8..d1386fdfb 100644 --- a/modules/counter/counter.model.php +++ b/modules/counter/counter.model.php @@ -287,32 +287,58 @@ class counterModel extends counter public function getWeeklyUniqueVisitor() { - $date = date('Ymd'); - $output = $this->getHourlyStatus('week', $date); + //for last week + $date1 = date('Ymd', strtotime('-1 week')); + $output1 = $this->getHourlyStatus('week', $date1); $tmp = array(); - foreach($output->list AS $key=>$value) + foreach($output1->list AS $key=>$value) { $tmp["'".$key."'"] = $value; } - $output->list = $tmp; + $output1->list = $tmp; - $this->add('data', $output); + //for this week + $date2 = date('Ymd'); + $output2 = $this->getHourlyStatus('week', $date2); + + $tmp = array(); + foreach($output2->list AS $key=>$value) + { + $tmp["'".$key."'"] = $value; + } + $output2->list = $tmp; + + $this->add('last_week', $output1); + $this->add('this_week', $output2); } public function getWeeklyPageView() { - $date = date('Ymd'); - $output = $this->getHourlyStatus('week', $date, 0, true); + //for last week + $date1 = date('Ymd', strtotime('-1 week')); + $output1 = $this->getHourlyStatus('week', $date1, 0, true); $tmp = array(); - foreach($output->list AS $key=>$value) + foreach($output1->list AS $key=>$value) { $tmp["'".$key."'"] = $value; } - $output->list = $tmp; + $output1->list = $tmp; - $this->add('data', $output); + //for this week + $date2 = date('Ymd'); + $output2 = $this->getHourlyStatus('week', $date2, 0, true); + + $tmp = array(); + foreach($output2->list AS $key=>$value) + { + $tmp["'".$key."'"] = $value; + } + $output2->list = $tmp; + + $this->add('last_week', $output1); + $this->add('this_week', $output2); } } /* End of file counter.model.php */