/** * Show the control panel * * @access public * @return void */ public function index() { if (CMS_VERSION !== $this->settings->version) { $this->data->messages['notice'] = sprintf(lang('cp_upgrade_message'), CMS_VERSION, $this->settings->version, site_url('upgrade')); } else { if (is_dir('./installer')) { $this->data->messages['notice'] = lang('cp_delete_installer_message'); } } $this->load->model('comments/comments_m'); $this->load->model('pages/pages_m'); $this->load->model('users/users_m'); $this->lang->load('comments/comments'); $this->data->recent_users = $this->users_m->get_recent(5); $recent_comments = $this->comments_m->get_recent(5); $this->data->recent_comments = process_comment_items($recent_comments); // Dashboard RSS feed (using SimplePie) $this->load->library('simplepie'); $this->simplepie->set_cache_location(APPPATH . 'cache/simplepie/'); $this->simplepie->set_feed_url($this->settings->dashboard_rss); $this->simplepie->init(); $this->simplepie->handle_content_type(); // Store the feed items $this->data->rss_items = $this->simplepie->get_items(0, $this->settings->dashboard_rss_count); $this->template->set_partial('sidebar', 'admin/partials/sidebar', FALSE); $this->template->title(lang('cp_admin_home_title'))->build('admin/dashboard', $this->data); }
/** * Show the control panel * * @access public * @return void */ public function index() { if (is_dir('./installer')) { $data->messages['notice'] = lang('cp_delete_installer_message'); } if ($this->settings->ga_email and $this->settings->ga_password and $this->settings->ga_profile) { // Not FALSE? Return it if ($cached_response = $this->cache->get('analytics')) { $data->analytic_visits = $cached_response['analytic_visits']; $data->analytic_views = $cached_response['analytic_views']; } else { try { $this->load->library('analytics', array('username' => $this->settings->ga_email, 'password' => $this->settings->ga_password)); // Set by GA Profile ID if provided, else try and use the current domain $this->analytics->setProfileById('ga:' . $this->settings->ga_profile); $end_date = date('Y-m-d'); $start_date = date('Y-m-d', strtotime('-30 days')); $this->analytics->setDateRange($start_date, $end_date); $visits = $this->analytics->getVisitors(); $views = $this->analytics->getPageviews(); /* build tables */ if (count($visits)) { foreach ($visits as $day => $visit) { $utc = mktime(date('h') + 1, NULL, NULL, date('m'), $day) * 1000; $flot_datas_visits[] = '[' . $utc . ',' . $visit . ']'; $flot_datas_views[] = '[' . $utc . ',' . $views[$day] . ']'; } $flot_data_visits = '[' . implode(',', $flot_datas_visits) . ']'; $flot_data_views = '[' . implode(',', $flot_datas_views) . ']'; } $data->analytic_visits = $flot_data_visits; $data->analytic_views = $flot_data_views; // Call the model or library with the method provided and the same arguments $this->cache->write(array('analytic_visits' => $flot_data_visits, 'analytic_views' => $flot_data_views), 'analytics', 60 * 60 * 6); // 6 hours } catch (Exception $e) { $data->messages['notice'] = 'Could not connect to Google Analytics. Check in ' . anchor('admin/settings', 'Settings') . '.'; } } } elseif (empty($data->messages['notice'])) { $data->messages['notice'] = 'Google Analytics settings are missing. Add them into ' . anchor('admin/settings', 'Settings') . ' or contact your administrator.'; } $this->load->model('comments/comments_m'); $this->load->model('pages/pages_m'); $this->load->model('users/users_m'); $this->lang->load('comments/comments'); $data->recent_users = $this->users_m->get_recent(5); $recent_comments = $this->comments_m->get_recent(5); $data->recent_comments = process_comment_items($recent_comments); // Dashboard RSS feed (using SimplePie) $this->load->library('simplepie'); $this->simplepie->set_cache_location(APPPATH . 'cache/simplepie/'); $this->simplepie->set_feed_url($this->settings->dashboard_rss); $this->simplepie->init(); $this->simplepie->handle_content_type(); $this->template->append_metadata(js('jquery/jquery.flot.js')); // Store the feed items $data->rss_items = $this->simplepie->get_items(0, $this->settings->dashboard_rss_count); $this->template->title(lang('cp_admin_home_title'))->build('admin/dashboard', $data); }
/** * Show the control panel * * @access public * @return void */ public function index() { if (CMS_VERSION !== $this->settings->version) { $this->data->messages['notice'] = sprintf(lang('cp_upgrade_message'), CMS_VERSION, $this->settings->version, site_url('upgrade')); } else { if (is_dir('./installer')) { $this->data->messages['notice'] = lang('cp_delete_installer_message'); } } $this->load->model('comments/comments_m'); $this->load->model('pages/pages_m'); $this->load->model('users/users_m'); $this->lang->load('comments/comments'); $this->data->recent_users = $this->users_m->get_recent(5); $recent_comments = $this->comments_m->get_recent(5); $this->data->recent_comments = process_comment_items($recent_comments); // Dashboard RSS feed (using SimplePie) $this->load->library('simplepie'); $this->simplepie->set_cache_location(APPPATH . 'cache/simplepie/'); $this->simplepie->set_feed_url($this->settings->dashboard_rss); $this->simplepie->init(); $this->simplepie->handle_content_type(); // Dashboard Analytics //$this->load->library('analytics'); // Just use dummy data for now - we need more settings to make this work... // Note: Data will need to be in javascript timestamps (multiply unix timestamp by 1000) $times = array(time() - 7 * 24 * 60 * 60 * 5 * 1000, time() - 7 * 24 * 60 * 60 * 4 * 1000, time() - 7 * 24 * 60 * 60 * 3 * 1000, time() - 7 * 24 * 60 * 60 * 2 * 1000, time() - 7 * 24 * 60 * 60 * 1000); $this->data->ga_visits = '[[' . $times[0] . ', 300], [' . $times[1] . ', 800], [' . $times[2] . ', 500], [' . $times[3] . ', 800], [' . $times[4] . ', 1300]]'; $this->template->append_metadata(js('jquery/jquery.flot.js')); // Store the feed items $this->data->rss_items = $this->simplepie->get_items(0, $this->settings->dashboard_rss_count); $this->template->set_partial('sidebar', 'admin/partials/sidebar', FALSE); $this->template->title(lang('cp_admin_home_title'))->build('admin/dashboard', $this->data); }
/** * Displays active comments * @access public * @return void */ public function approved() { // Create pagination links $total_rows = $this->comments_m->count_by('is_active', 1); $pagination = create_pagination('admin/comments/approved', $total_rows); // get all comments $comments = $this->comments_m->limit($pagination['limit'])->order_by('comments.created_on', 'desc')->get_many_by('comments.is_active', 1); $this->template->title($this->module_details['name'])->set('comments', process_comment_items($comments))->set('pagination', $pagination)->build('admin/index'); }
/** * Index * * @return void */ public function index() { // Only show is_active = 0 if we are moderating comments $base_where = array('comments.is_active' => (int) (!Settings::get('moderate_comments'))); //capture active $base_where['comments.is_active'] = is_int($this->session->flashdata('is_active')) ? $this->session->flashdata('is_active') : $base_where['comments.is_active']; $base_where['comments.is_active'] = $this->input->post('f_active') ? (int) $this->input->post('f_active') : $base_where['comments.is_active']; //capture module slug $base_where = $this->input->post('module_slug') ? $base_where + array('module' => $this->input->post('module_slug')) : $base_where; // Create pagination links $total_rows = $this->comments_m->count_by($base_where); $pagination = create_pagination('admin/comments/index', $total_rows); $comments = $this->comments_m->limit($pagination['limit'])->order_by('comments.created_on', 'desc')->get_many_by($base_where); $content_title = $base_where['comments.is_active'] ? lang('comments.active_title') : lang('comments.inactive_title'); $this->input->is_ajax_request() && $this->template->set_layout(FALSE); $module_list = $this->comments_m->get_slugs(); $this->template->title($this->module_details['name'])->append_js('admin/filter.js')->set('module_list', $module_list)->set('content_title', $content_title)->set('comments', process_comment_items($comments))->set('comments_active', $base_where['comments.is_active'])->set('pagination', $pagination); $this->input->is_ajax_request() ? $this->template->build('admin/tables/comments') : $this->template->build('admin/index'); }
public function get_recent_comments() { $this->load->model('comments/comments_m'); $this->load->model('users/user_m'); $this->lang->load('comments/comments'); $recent_comments = $this->comments_m->get_recent(5); $data['recent_comments'] = process_comment_items($recent_comments); $this->template->set($data); }
/** * Activates an unapproved comment * @access public * @return void */ public function active() { $this->load->helper('text'); // Create pagination links $total_rows = $this->comments_m->count_by('is_active', 1); $this->data->pagination = create_pagination('admin/comments/active', $total_rows); // get all comments $comments = $this->comments_m->limit($this->data->pagination['limit'])->order_by('comments.created_on', 'desc')->get_many_by('comments.is_active', 1); $this->data->comments = process_comment_items($comments); $this->template->build('admin/index', $this->data); }
/** * Show the control panel * * @access public * @return void */ public function index() { $data = array(); if (is_dir('./installer')) { $data['notice'] = lang('cp_delete_installer_message'); } if ($this->settings->ga_email AND $this->settings->ga_password AND $this->settings->ga_profile) { // Not FALSE? Return it if ($cached_response = $this->pyrocache->get('analytics')) { $data['analytic_visits'] = $cached_response['analytic_visits']; $data['analytic_views'] = $cached_response['analytic_views']; } else { try { $this->load->library('analytics', array( 'username' => $this->settings->ga_email, 'password' => $this->settings->ga_password )); // Set by GA Profile ID if provided, else try and use the current domain $this->analytics->setProfileById('ga:'.$this->settings->ga_profile); $end_date = date('Y-m-d'); $start_date = date('Y-m-d', strtotime('-1 month')); $this->analytics->setDateRange($start_date, $end_date); $visits = $this->analytics->getVisitors(); $views = $this->analytics->getPageviews(); /* build tables */ if (count($visits)) { foreach ($visits as $date => $visit) { $year = substr($date, 0, 4); $month = substr($date, 4, 2); $day = substr($date, 6, 2); $utc = mktime(date('h') + 1, NULL, NULL, $month, $day, $year) * 1000; $flot_datas_visits[] = '[' . $utc . ',' . $visit . ']'; $flot_datas_views[] = '[' . $utc . ',' . $views[$date] . ']'; } $flot_data_visits = '[' . implode(',', $flot_datas_visits) . ']'; $flot_data_views = '[' . implode(',', $flot_datas_views) . ']'; } $data['analytic_visits'] = $flot_data_visits; $data['analytic_views'] = $flot_data_views; // Call the model or library with the method provided and the same arguments $this->pyrocache->write(array('analytic_visits' => $flot_data_visits, 'analytic_views' => $flot_data_views), 'analytics', 60 * 60 * 6); // 6 hours } catch (Exception $e) { $data['messages']['notice'] = sprintf(lang('cp_google_analytics_no_connect'), anchor('admin/settings', lang('cp_nav_settings'))); } } } // Only mention this notice if no other notices are set elseif (empty($data['messages']['notice'])) { $data['messages']['notice'] = sprintf(lang('cp_google_analytics_missing'), anchor('admin/settings', lang('cp_nav_settings'))); } $this->load->model('comments/comments_m'); $this->load->model('pages/pages_m'); $this->load->model('users/users_m'); $this->lang->load('comments/comments'); $data['recent_users'] = $this->users_m->get_recent(5); $recent_comments = $this->comments_m->get_recent(5); $data['recent_comments'] = process_comment_items($recent_comments); // Dashboard RSS feed (using SimplePie) $this->load->library('simplepie'); $this->simplepie->set_cache_location($this->config->item('simplepie_cache_dir')); $this->simplepie->set_feed_url($this->settings->dashboard_rss); $this->simplepie->init(); $this->simplepie->handle_content_type(); $this->template->append_metadata(js('jquery/jquery.flot.js')); // Store the feed items $data['rss_items'] = $this->simplepie->get_items(0, $this->settings->dashboard_rss_count); $this->template ->title(lang('cp_admin_home_title')) ->build('admin/dashboard', $data); }