public function index($setting) { // Load dependencies $this->load->library('cackle/comment'); // Init variables $chan = $_SERVER['REQUEST_URI']; // Init cackle $cackle = new CackleComment($this->db, $this->config->get('cackle_comment_site_id'), $this->config->get('cackle_comment_account_api_key'), $this->config->get('cackle_comment_site_api_key')); // Update comments #$time_updated = (int) $this->cache->get('cackle.comments.time_updated.' . md5($chan)); // If timeout has been expired #if ($time_updated < time() - 432000) { // todo // Add new comments $cackle->addComments($cackle->receiveComments($chan, $cackle->getLastCommentId($chan), false)); // Update old comments $cackle->updateComments($cackle->receiveComments($chan, false, $cackle->getLastCommentModified($chan))); // Update time updated #$this->cache->set('cackle.comments.time_updated.' . md5($chan), time()); #} // Prepare view variables $this->data = $this->load->language('module/cackle_comment'); $this->data['site_id'] = $this->config->get('cackle_comment_site_id'); $this->data['comments'] = array(); foreach ($cackle->getComments($chan) as $comment) { $this->data['comments'][] = array('creator' => $comment['user_name'] ? $comment['user_name'] : $comment['name'], 'comment_text' => $comment['msg'], 'comment_time' => date('Y-m-d', $comment['created'] / 1000)); } // Render template if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/cackle_comment.tpl')) { $this->template = $this->config->get('config_template') . '/template/module/cackle_comment.tpl'; } else { $this->template = 'default/template/module/cackle_comment.tpl'; } $this->render(); }