/** * Initializes the collection with the data * necessary for rendering the chart. * * @return void */ protected function _initCollection() { // initialize the array with the params $params = array('period' => 'day', 'date' => 'last30'); // check the selected period switch ($period = $this->getParam('period')) { case '7d': break; case '1m': $params['period'] = 'day'; $params['date'] = 'last30'; break; case '1y': $params['period'] = 'month'; $params['date'] = 'last12'; break; case '2y': $params['period'] = 'month'; $params['date'] = 'last24'; break; default: throw new Exception('Invalid period ' . $period); } // initialize the Piwik service $service = Faett_Piwik_Service::create(); // load the live user data $this->_collection = $service->call('VisitsSummary.get', $params); }
/** * Loads the necessary live user data * from the specified Piwik instance. * * @return Faett_Piwik_Block_Adminhtml_Dashboard_Tab_Live_User The instance */ protected function _prepareCollection() { // initialize the Piwik service $service = Faett_Piwik_Service::create(); // load the live user data $collection = $service->call('Live.getLastVisits'); // set the data $this->setCollection($collection); // call the method of the parent class return parent::_prepareCollection(); }