protected function updateMonthly()
{
if (!$this->monthly_data) {
$this->monthly_data = $this->getData($this->monthly_file);
}
$month_year = date(self::MONTHLY_FORMAT);
// get the monthly access count
if (array_key_exists($month_year, $this->monthly_data)) {
$this->monthly_data[$month_year] = intval($this->monthly_data[$month_year]) + 1;
} else {
$this->monthly_data[$month_year] = 1;
}
// keep correct number as set by history
$count = intval($this->config->get('plugins.admin.popularity.history.monthly', 12));
$total = count($this->monthly_data);
$this->monthly_data = array_slice($this->monthly_data, $total - $count, $count);
file_put_contents($this->monthly_file, json_encode($this->monthly_data));
}