This is the API documentation for concrete5 version 5.6 and earlier. View Current API Documentation
 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 
<?php
defined('C5_EXECUTE') or die("Access Denied.");

class Concrete5_Controller_Dashboard_Reports_Statistics extends DashboardBaseController {

    protected $labels = array();
    protected $dates = array();
    
    protected function setLatestPageViews() {
        Loader::model('page_statistics');
        $viewsArray = array();
        $u = new User();
        foreach($this->dates as $i => $date) { 
            $total = PageStatistics::getTotalPageViewsForOthers($u, $date);
            $viewsArray[$this->labels[$i]] = $total;
        }
        $this->set('pageViews', $viewsArray);
    }

    protected function setLatestPagesCreated() {
        $viewsArray = array();
        $u = new User();
        foreach($this->dates as $i => $date) { 
            $total = PageStatistics::getTotalPagesCreated($date);
            $newPages[$this->labels[$i]] = $total;
        }
        $this->set('newPages', $newPages);
    }

    protected function setLatestRegistrations() {
        $registrationsArray = array();
        foreach($this->dates as $i => $date) { 
            $total = UserStatistics::getTotalRegistrationsForDay($date);
            $registrationsArray[$this->labels[$i]] = $total;
        }
        $this->set('userRegistrations', $registrationsArray);
    }

    public function on_start() {
        $dh = Loader::helper('date');
        for ($i = -4; $i < 1; $i++) {
            $date = date('Y-m-d', strtotime($i . ' days'));
            if ($i == 0) {
                $label = t('Today');
            } else { 
                $label = $dh->date('D', strtotime($i . ' days'));
            }
            $this->labels[] = $label;
            $this->dates[] = $date;
        }
    }
    
    protected function setDownloadStatistics() {
        $downloads = File::getDownloadStatistics(5);
        $this->set('downloads', $downloads);
    }
    
    public function view() {
        $this->addHeaderItem(Loader::helper('html')->javascript('jquery.visualize.js'));
        $this->addHeaderItem(Loader::helper('html')->css('jquery.visualize.css'));
        $this->setLatestPageViews();
        $this->setLatestPagesCreated();
        $this->setLatestRegistrations();
        $this->setDownloadStatistics();
        
        $this->set('totalVersions', PageStatistics::getTotalPageVersions());
        $this->set('totalEditMode', PageStatistics::getTotalPagesCheckedOut());

    }
}