/** * get instance * * * @return Cms_Model_GAMapper */ public static function getInstance() { if (self::$_instance === null) { self::$_instance = new self(); } return self::$_instance; }
public function widgetAction() { if ($this->getRequest()->isXmlHttpRequest()) { $this->getHelper('layout')->disableLayout(); } $gaSettings = $this->_application->get_settings('ga'); //check ga settings if (!isset($gaSettings) || !isset($gaSettings['email']) || $gaSettings['email'] == '' || !isset($gaSettings['password']) || $gaSettings['password'] == '' || !isset($gaSettings['account_id']) || $gaSettings['account_id'] == '') { return; } $today = Zend_Date::now(); $toDate = clone $today->subDay(1); $fromDate = clone $today->subDay(6); $this->_statistics = Cms_Model_GAMapper::getInstance()->fetchByDate($gaSettings['email'], $gaSettings['password'], $gaSettings['account_id'], $fromDate->get("yyyy-MM-dd"), $toDate->get("yyyy-MM-dd")); //sparklines data $this->_repackMetricsData(); $this->view->statistics = $this->_statistics; $this->view->metricsValues = $this->_metricsValues; $this->view->metricsDesc = $this->_metricsDesc; $this->view->fromDate = $fromDate; $this->view->toDate = $toDate; }