NOISSUE code rearrange on counter.model.php

This commit is contained in:
ngleader 2013-11-23 19:58:42 +09:00
parent 5f253adbfc
commit f16c2aced0

View file

@ -48,7 +48,7 @@ class counterModel extends counter
$result = $output->data->count ? TRUE : FALSE; $result = $output->data->count ? TRUE : FALSE;
if($result && $oCacheHandler->isSupport()) if($result && $oCacheHandler->isSupport())
{ {
$oCacheHandler->put($cache_key, $result); $oCacheHandler->put($cache_key, TRUE);
} }
return $result; return $result;
@ -88,7 +88,7 @@ class counterModel extends counter
$result = $output->data->count ? TRUE : FALSE; $result = $output->data->count ? TRUE : FALSE;
if($result && $oCacheHandler->isSupport()) if($result && $oCacheHandler->isSupport())
{ {
$oCacheHandler->put($cache_key, $result); $oCacheHandler->put($cache_key, TRUE);
$_old_date = date('Ymd', strtotime('-1 day')); $_old_date = date('Ymd', strtotime('-1 day'));
$oCacheHandler->delete('object:insertedTodayStatus:' . $site_srl . '_' . $_old_date); $oCacheHandler->delete('object:insertedTodayStatus:' . $site_srl . '_' . $_old_date);
} }
@ -106,22 +106,8 @@ class counterModel extends counter
function getStatus($selected_date, $site_srl = 0) function getStatus($selected_date, $site_srl = 0)
{ {
// If more than one date logs are selected // If more than one date logs are selected
if(is_array($selected_date)) $args = new stdClass();
{ $args->regdate = is_array($selected_date) ? join(',', $selected_date) : $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;
}
if($site_srl) if($site_srl)
{ {
$args->site_srl = $site_srl; $args->site_srl = $site_srl;
@ -131,7 +117,6 @@ class counterModel extends counter
{ {
$output = executeQuery('counter.getCounterStatusDays', $args); $output = executeQuery('counter.getCounterStatusDays', $args);
} }
$status = $output->data; $status = $output->data;
if(!is_array($selected_date)) if(!is_array($selected_date))
@ -139,14 +124,9 @@ class counterModel extends counter
return $status; return $status;
} }
if(!is_array($status)) if(!is_array($status)) $status = array($status);
{ $output = array();
$status = array($status); foreach($status as $val)
}
unset($output);
foreach($status as $key => $val)
{ {
$output[substr($val->regdate, 0, 8)] = $val; $output[substr($val->regdate, 0, 8)] = $val;
} }
@ -182,14 +162,12 @@ class counterModel extends counter
$output = executeQuery('counter.getStartLogDate'); $output = executeQuery('counter.getStartLogDate');
} }
$start_year = substr($output->data->regdate, 0, 4); if(!($start_year = substr($output->data->regdate, 0, 4)))
if(!$start_year)
{ {
$start_year = date("Y"); $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 = new stdClass();
$args->start_date = sprintf('%04d0000', $i); $args->start_date = sprintf('%04d0000', $i);
@ -205,21 +183,10 @@ class counterModel extends counter
$output = executeQuery('counter.getCounterStatus', $args); $output = executeQuery('counter.getCounterStatus', $args);
} }
if(!$isPageView) $count = (int)($isPageView ? $output->data->pageview : $output->data->unique_visitor);
{
$count = (int) $output->data->unique_visitor;
}
else
{
$count = (int) $output->data->pageview;
}
$status->list[$i] = $count; $status->list[$i] = $count;
if($count > $max) if($count > $max) $max = $count;
{
$max = $count;
}
$sum += $count; $sum += $count;
} }
@ -262,21 +229,10 @@ class counterModel extends counter
$output = executeQuery('counter.getCounterStatus', $args); $output = executeQuery('counter.getCounterStatus', $args);
} }
if(!$isPageView) $count = (int)($isPageView ? $output->data->pageview : $output->data->unique_visitor);
{ $status->list[$day] = $count;
$count = (int) $output->data->unique_visitor;
}
else
{
$count = (int) $output->data->pageview;
}
$status->list[$day] = (int) $count; if($count > $max) $max = $count;
if($count > $max)
{
$max = $count;
}
$sum += $count; $sum += $count;
} }
@ -300,21 +256,10 @@ class counterModel extends counter
$output = executeQuery('counter.getCounterStatus', $args); $output = executeQuery('counter.getCounterStatus', $args);
} }
if(!$isPageView) $count = (int)($isPageView ? $output->data->pageview : $output->data->unique_visitor);
{ $status->list[$i] = $count;
$count = (int) $output->data->unique_visitor;
}
else
{
$count = (int) $output->data->pageview;
}
$status->list[$i] = (int) $count; if($count > $max) $max = $count;
if($count > $max)
{
$max = $count;
}
$sum += $count; $sum += $count;
} }
@ -341,10 +286,7 @@ class counterModel extends counter
$count = (int) $output->data->count; $count = (int) $output->data->count;
$status->list[$i] = $count; $status->list[$i] = $count;
if($count > $max) if($count > $max) $max = $count;
{
$max = $count;
}
$sum += $count; $sum += $count;
} }
@ -371,21 +313,10 @@ class counterModel extends counter
$output = executeQuery('counter.getCounterStatus', $args); $output = executeQuery('counter.getCounterStatus', $args);
} }
if(!$isPageView) $count = (int)($isPageView ? $output->data->pageview : $output->data->unique_visitor);
{
$count = (int) $output->data->unique_visitor;
}
else
{
$count = (int) $output->data->pageview;
}
$status->list[$i] = $count; $status->list[$i] = $count;
if($count > $max) if($count > $max) $max = $count;
{
$max = $count;
}
$sum += $count; $sum += $count;
} }
@ -405,7 +336,7 @@ class counterModel extends counter
$output1 = $this->getHourlyStatus('week', $date1); $output1 = $this->getHourlyStatus('week', $date1);
$tmp = array(); $tmp = array();
foreach($output1->list AS $key => $value) foreach($output1->list as $key => $value)
{ {
$tmp["'" . $key . "'"] = $value; $tmp["'" . $key . "'"] = $value;
} }
@ -416,7 +347,7 @@ class counterModel extends counter
$output2 = $this->getHourlyStatus('week', $date2); $output2 = $this->getHourlyStatus('week', $date2);
$tmp = array(); $tmp = array();
foreach($output2->list AS $key => $value) foreach($output2->list as $key => $value)
{ {
$tmp["'" . $key . "'"] = $value; $tmp["'" . $key . "'"] = $value;
} }
@ -433,7 +364,7 @@ class counterModel extends counter
$output1 = $this->getHourlyStatus('week', $date1, 0, TRUE); $output1 = $this->getHourlyStatus('week', $date1, 0, TRUE);
$tmp = array(); $tmp = array();
foreach($output1->list AS $key => $value) foreach($output1->list as $key => $value)
{ {
$tmp["'" . $key . "'"] = $value; $tmp["'" . $key . "'"] = $value;
} }
@ -444,7 +375,7 @@ class counterModel extends counter
$output2 = $this->getHourlyStatus('week', $date2, 0, TRUE); $output2 = $this->getHourlyStatus('week', $date2, 0, TRUE);
$tmp = array(); $tmp = array();
foreach($output2->list AS $key => $value) foreach($output2->list as $key => $value)
{ {
$tmp["'" . $key . "'"] = $value; $tmp["'" . $key . "'"] = $value;
} }