/**
  * (non-PHPdoc)
  * @see src/lib/Faett/Piwik/Decoder/Interfaces/Faett_Piwik_Decoder_Interfaces_Decoder#decode($params)
  */
 public function decode(array $params)
 {
     // check of the piwik API can be invoked and read the data
     $toDecode = @file_get_contents($piwikUrl = $this->_service->build($params));
     // check if the data can be loaded successfully
     if ($toDecode === false) {
         throw new Exception('Invalid piwik URL ' . $piwikUrl . ' specified');
     }
     // load, decode and return the data
     return Zend_Json::decode($toDecode, Zend_Json::TYPE_ARRAY);
 }
 /**
  * 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();
 }