/** * Loads the data from the Piwik instance and * ass assembles a collection with the summary * of the visits for a given time. * * @param array $params * Array with additional params for requesting the Piwik API * @return Varien_Data_Collection The collection with the live users */ public function get(array $params) { try { // load the data and decode it $phpNative = $this->decode($params); // initialize the collection foreach ($phpNative as $date => $values) { // pass the data if (is_array($values)) { // check if a value for the unique visitors exists if (array_key_exists('nb_uniq_visitors', $values)) { // if yes, initialize an empty object $obj = new Varien_Object(); $obj->addData($values); $obj->setUsers($values['nb_uniq_visitors']); $obj->setRange($date); // add the object to the collection $this->_collection->addItem($obj); } } } } catch (Exception $e) { // log the exception Mage::logException($e); // add an error to the session Mage::getSingleton('adminhtml/session')->addError(Mage::helper('piwik')->__('900.error.invalid.piwik-configuration')); } // return the collection return $this->_collection; }
/** * Loads the data from the Piwik instance and * ass assembles a collection with the summary * of the visits for a given time. * * @param array $params * Array with additional params for requesting the Piwik API * @return Varien_Data_Collection The collection with the live users */ public function get(array $params) { // load the data and decode it $phpNative = $this->decode($params); // initialize the collection foreach ($phpNative as $date => $values) { // pass the data if (is_array($values)) { // check if a value for the unique visitors exists if (array_key_exists('nb_uniq_visitors', $values)) { // if yes, initialize an empty object $obj = new Varien_Object(); $obj->addData($values); $obj->setUsers($values['nb_uniq_visitors']); $obj->setRange($date); // add the object to the collection $this->_collection->addItem($obj); } } } // return the collection return $this->_collection; }
/** * Initializes the filter params Varien_Object, and saves it to the session * * @param $registryNode * @return Varien_Object */ public function initDateFilterParams($registryNode) { $request = Mage::app()->getRequest(); if (!$request->getParam('form_filter')) { $input = null; //Mage::getSingleton('adminhtml/session')->getData($registryNode); if (!$input) { if ($input = Mage::getSingleton('adminhtml/session')->getData($registryNode)) { // do nothing... } else { $input = new Varien_Object(); $input->setStandard($this->_getDefaultRange()); } } } else { $input = new Varien_Object(get_object_vars(json_decode($request->getParam('form_filter')))); } if ($input->getStandard()) { switch ($input->getStandard()) { case "next": $range = $this->_getNextRange($registryNode); break; case "previous": $range = $this->_getPreviousRange($registryNode); break; default: $range = $this->getRange($input->getStandard()); } $input->setStandard($range->getIdentifier()); } else { $range = $this->_generateCustomRange($input->getStart(), $input->getEnd()); } $input->setRange($range); $this->_dateRange = $input; Mage::getSingleton('adminhtml/session')->setData($registryNode, $input); return $input; }