From f16c2aced03e743a8a84fa5b2f492c6df6d337f3 Mon Sep 17 00:00:00 2001 From: ngleader Date: Sat, 23 Nov 2013 19:58:42 +0900 Subject: [PATCH] NOISSUE code rearrange on counter.model.php --- modules/counter/counter.model.php | 117 ++++++------------------------ 1 file changed, 24 insertions(+), 93 deletions(-) diff --git a/modules/counter/counter.model.php b/modules/counter/counter.model.php index d961ae44c..f60aea505 100644 --- a/modules/counter/counter.model.php +++ b/modules/counter/counter.model.php @@ -48,7 +48,7 @@ class counterModel extends counter $result = $output->data->count ? TRUE : FALSE; if($result && $oCacheHandler->isSupport()) { - $oCacheHandler->put($cache_key, $result); + $oCacheHandler->put($cache_key, TRUE); } return $result; @@ -88,7 +88,7 @@ class counterModel extends counter $result = $output->data->count ? TRUE : FALSE; if($result && $oCacheHandler->isSupport()) { - $oCacheHandler->put($cache_key, $result); + $oCacheHandler->put($cache_key, TRUE); $_old_date = date('Ymd', strtotime('-1 day')); $oCacheHandler->delete('object:insertedTodayStatus:' . $site_srl . '_' . $_old_date); } @@ -106,22 +106,8 @@ class counterModel extends counter function getStatus($selected_date, $site_srl = 0) { // If more than one date logs are selected - if(is_array($selected_date)) - { - $date_count = count($selected_date); - $args = new stdClass(); - $args->regdate = implode(',', $selected_date); - // If a single date log is selected - } - else - { - if(strlen($selected_date) == 8) - { - $selected_date = $selected_date; - } - $args->regdate = $selected_date; - } - + $args = new stdClass(); + $args->regdate = is_array($selected_date) ? join(',', $selected_date) : $selected_date; if($site_srl) { $args->site_srl = $site_srl; @@ -131,7 +117,6 @@ class counterModel extends counter { $output = executeQuery('counter.getCounterStatusDays', $args); } - $status = $output->data; if(!is_array($selected_date)) @@ -139,14 +124,9 @@ class counterModel extends counter return $status; } - if(!is_array($status)) - { - $status = array($status); - } - - unset($output); - - foreach($status as $key => $val) + if(!is_array($status)) $status = array($status); + $output = array(); + foreach($status as $val) { $output[substr($val->regdate, 0, 8)] = $val; } @@ -182,14 +162,12 @@ class counterModel extends counter $output = executeQuery('counter.getStartLogDate'); } - $start_year = substr($output->data->regdate, 0, 4); - - if(!$start_year) + if(!($start_year = substr($output->data->regdate, 0, 4))) { $start_year = date("Y"); } - for($i = $start_year; $i <= date("Y"); $i++) + for($i = $start_year, $y = date("Y"); $i <= $y; $i++) { $args = new stdClass(); $args->start_date = sprintf('%04d0000', $i); @@ -205,21 +183,10 @@ class counterModel extends counter $output = executeQuery('counter.getCounterStatus', $args); } - if(!$isPageView) - { - $count = (int) $output->data->unique_visitor; - } - else - { - $count = (int) $output->data->pageview; - } - + $count = (int)($isPageView ? $output->data->pageview : $output->data->unique_visitor); $status->list[$i] = $count; - if($count > $max) - { - $max = $count; - } + if($count > $max) $max = $count; $sum += $count; } @@ -262,21 +229,10 @@ class counterModel extends counter $output = executeQuery('counter.getCounterStatus', $args); } - if(!$isPageView) - { - $count = (int) $output->data->unique_visitor; - } - else - { - $count = (int) $output->data->pageview; - } + $count = (int)($isPageView ? $output->data->pageview : $output->data->unique_visitor); + $status->list[$day] = $count; - $status->list[$day] = (int) $count; - - if($count > $max) - { - $max = $count; - } + if($count > $max) $max = $count; $sum += $count; } @@ -300,21 +256,10 @@ class counterModel extends counter $output = executeQuery('counter.getCounterStatus', $args); } - if(!$isPageView) - { - $count = (int) $output->data->unique_visitor; - } - else - { - $count = (int) $output->data->pageview; - } + $count = (int)($isPageView ? $output->data->pageview : $output->data->unique_visitor); + $status->list[$i] = $count; - $status->list[$i] = (int) $count; - - if($count > $max) - { - $max = $count; - } + if($count > $max) $max = $count; $sum += $count; } @@ -341,10 +286,7 @@ class counterModel extends counter $count = (int) $output->data->count; $status->list[$i] = $count; - if($count > $max) - { - $max = $count; - } + if($count > $max) $max = $count; $sum += $count; } @@ -371,21 +313,10 @@ class counterModel extends counter $output = executeQuery('counter.getCounterStatus', $args); } - if(!$isPageView) - { - $count = (int) $output->data->unique_visitor; - } - else - { - $count = (int) $output->data->pageview; - } - + $count = (int)($isPageView ? $output->data->pageview : $output->data->unique_visitor); $status->list[$i] = $count; - if($count > $max) - { - $max = $count; - } + if($count > $max) $max = $count; $sum += $count; } @@ -405,7 +336,7 @@ class counterModel extends counter $output1 = $this->getHourlyStatus('week', $date1); $tmp = array(); - foreach($output1->list AS $key => $value) + foreach($output1->list as $key => $value) { $tmp["'" . $key . "'"] = $value; } @@ -416,7 +347,7 @@ class counterModel extends counter $output2 = $this->getHourlyStatus('week', $date2); $tmp = array(); - foreach($output2->list AS $key => $value) + foreach($output2->list as $key => $value) { $tmp["'" . $key . "'"] = $value; } @@ -433,7 +364,7 @@ class counterModel extends counter $output1 = $this->getHourlyStatus('week', $date1, 0, TRUE); $tmp = array(); - foreach($output1->list AS $key => $value) + foreach($output1->list as $key => $value) { $tmp["'" . $key . "'"] = $value; } @@ -444,7 +375,7 @@ class counterModel extends counter $output2 = $this->getHourlyStatus('week', $date2, 0, TRUE); $tmp = array(); - foreach($output2->list AS $key => $value) + foreach($output2->list as $key => $value) { $tmp["'" . $key . "'"] = $value; }