Пример #1
0
	protected function postDataTableLoadedFromAPI()
	{
		parent::postDataTableLoadedFromAPI();
		Piwik_Controller::setPeriodVariablesView($this);
		$columnUniqueVisitors = false;
		if($this->period == 'day')
		{
			$columnUniqueVisitors = 'nb_uniq_visitors';
		}
		
		// only display conversion rate for the plugins that do not provide "per goal" metrics
		// otherwise, conversion rate is meaningless as a whole (since we don't process 'cross goals' conversions)
		$columnConversionRate = false;
		if(empty($this->viewProperties['show_goals']))
		{
			$columnConversionRate = 'conversion_rate';
		}
		$this->setColumnsToDisplay(array('label', 
										'nb_visits', 
										$columnUniqueVisitors, 
										'nb_actions_per_visit', 
										'avg_time_on_site', 
										'bounce_rate',
										$columnConversionRate
										));
		$this->dataTable->filter('ColumnCallbackReplace', array('avg_time_on_site', create_function('$averageTimeOnSite', 'return Piwik::getPrettyTimeFromSeconds($averageTimeOnSite);')));
	}
Пример #2
0
 function redirectToCoreHomeIndex()
 {
     // redirect to Login only for anonymous user
     if ((bool) Zend_Registry::get('config')->General->default_module_login == true && Piwik::getCurrentUserLogin() == 'anonymous') {
         return Piwik_FrontController::dispatch('Login', false);
     }
     parent::redirectToIndex('CoreHome', 'index');
 }
Пример #3
0
 public function __construct()
 {
     parent::__construct();
     $this->period = Piwik_Common::getRequestVar("period");
     if (isset($this->date)) {
         $this->range = Piwik_Period_Range::factory($this->period, $this->date);
     }
 }
Пример #4
0
 /**
  * Set the minimal variables in the view object
  * Extended by some admin view specific variables
  * 
  * @param Piwik_View  $view
  */
 protected function setBasicVariablesView($view)
 {
     parent::setBasicVariablesView($view);
     $view->currentAdminMenuName = Piwik_GetCurrentAdminMenuName();
     $view->enableFrames = Piwik_Config::getInstance()->General['enable_framed_settings'];
     if (!$view->enableFrames) {
         $view->setXFrameOptions('sameorigin');
     }
 }
Пример #5
0
 /**
  * Used by Admin screens
  * 
  * @param Piwik_View $view
  */
 protected function setBasicVariablesView($view)
 {
     parent::setBasicVariablesView($view);
     $view->currentAdminMenuName = Piwik_GetCurrentAdminMenuName();
     $view->enableFrames = Zend_Registry::get('config')->General->enable_framed_settings;
     if (!$view->enableFrames) {
         $view->setXFrameOptions('sameorigin');
     }
 }
Пример #6
0
 protected function postDataTableLoadedFromAPI()
 {
     parent::postDataTableLoadedFromAPI();
     Piwik_Controller::setPeriodVariablesView($this);
     $columnUniqueVisitors = false;
     if ($this->period == 'day') {
         $columnUniqueVisitors = 'nb_uniq_visitors';
     }
     $this->setColumnsToDisplay(array('label', 'nb_visits', $columnUniqueVisitors, 'nb_actions_per_visit', 'avg_time_on_site', 'bounce_rate', 'conversion_rate'));
     $this->dataTable->filter('ColumnCallbackReplace', array('avg_time_on_site', create_function('$averageTimeOnSite', 'return Piwik::getPrettyTimeFromSeconds($averageTimeOnSite);')));
 }
Пример #7
0
 public function __construct()
 {
     parent::__construct();
     $this->idSite = Piwik_Common::getRequestVar('idSite', null, 'int');
     $this->goals = Piwik_Goals_API::getInstance()->getGoals($this->idSite);
     foreach ($this->goals as &$goal) {
         $goal['name'] = Piwik_Common::sanitizeInputValue($goal['name']);
         if (isset($goal['pattern'])) {
             $goal['pattern'] = Piwik_Common::sanitizeInputValue($goal['pattern']);
         }
     }
 }
Пример #8
0
 function redirectToCoreHomeIndex()
 {
     $defaultReport = Piwik_UsersManager_API::getInstance()->getUserPreference(Piwik::getCurrentUserLogin(), Piwik_UsersManager_API::PREFERENCE_DEFAULT_REPORT);
     $module = 'CoreHome';
     $action = 'index';
     // User preference: default report to load is the All Websites dashboard
     if ($defaultReport == 'MultiSites' && Piwik_PluginsManager::getInstance()->isPluginActivated('MultiSites')) {
         $module = 'MultiSites';
     }
     if ($defaultReport == Piwik::getLoginPluginName()) {
         $module = Piwik::getLoginPluginName();
     }
     $idSite = Piwik_Common::getRequestVar('idSite', false, 'int');
     parent::redirectToIndex($module, $action, !empty($idSite) ? $idSite : null);
 }
Пример #9
0
 /**
  * @param Piwik_Event_Notification $notification  notification object
  * @return mixed
  */
 public function getReportMetadata($notification)
 {
     $info = $notification->getNotificationInfo();
     $reports =& $notification->getNotificationObject();
     $idSites = $info['idSites'];
     // If only one website is selected, we add the Graph URL
     if (count($idSites) != 1) {
         return;
     }
     $idSite = reset($idSites);
     // in case API.getReportMetadata was not called with date/period we use sane defaults
     if (empty($info['period'])) {
         $info['period'] = 'day';
     }
     if (empty($info['date'])) {
         $info['date'] = 'today';
     }
     // need two sets of period & date, one for single period graphs, one for multiple periods graphs
     if (Piwik_Archive::isMultiplePeriod($info['date'], $info['period'])) {
         $periodForMultiplePeriodGraph = $info['period'];
         $dateForMultiplePeriodGraph = $info['date'];
         $periodForSinglePeriodGraph = 'range';
         $dateForSinglePeriodGraph = $info['date'];
     } else {
         $periodForSinglePeriodGraph = $info['period'];
         $dateForSinglePeriodGraph = $info['date'];
         $piwikSite = new Piwik_Site($idSite);
         if ($periodForSinglePeriodGraph == 'range') {
             $periodForMultiplePeriodGraph = Piwik_Config::getInstance()->General['graphs_default_period_to_plot_when_period_range'];
             $dateForMultiplePeriodGraph = $dateForSinglePeriodGraph;
         } else {
             $periodForMultiplePeriodGraph = $periodForSinglePeriodGraph;
             $dateForMultiplePeriodGraph = Piwik_Controller::getDateRangeRelativeToEndDate($periodForSinglePeriodGraph, 'last' . self::GRAPH_EVOLUTION_LAST_PERIODS, $dateForSinglePeriodGraph, $piwikSite);
         }
     }
     $token_auth = Piwik_Common::getRequestVar('token_auth', false);
     $urlPrefix = "index.php?";
     foreach ($reports as &$report) {
         $reportModule = $report['module'];
         $reportAction = $report['action'];
         $reportUniqueId = $reportModule . '_' . $reportAction;
         $parameters = array();
         $parameters['module'] = 'API';
         $parameters['method'] = 'ImageGraph.get';
         $parameters['idSite'] = $idSite;
         $parameters['apiModule'] = $reportModule;
         $parameters['apiAction'] = $reportAction;
         if (!empty($token_auth)) {
             $parameters['token_auth'] = $token_auth;
         }
         // Forward custom Report parameters to the graph URL
         if (!empty($report['parameters'])) {
             $parameters = array_merge($parameters, $report['parameters']);
         }
         if (empty($report['dimension'])) {
             $parameters['period'] = $periodForMultiplePeriodGraph;
             $parameters['date'] = $dateForMultiplePeriodGraph;
         } else {
             $parameters['period'] = $periodForSinglePeriodGraph;
             $parameters['date'] = $dateForSinglePeriodGraph;
         }
         // add the idSubtable if it exists
         $idSubtable = Piwik_Common::getRequestVar('idSubtable', false);
         if ($idSubtable !== false) {
             $parameters['idSubtable'] = $idSubtable;
         }
         $report['imageGraphUrl'] = $urlPrefix . Piwik_Url::getQueryStringFromParameters($parameters);
         // thanks to API.getRowEvolution, reports with dimensions can now be plotted using an evolution graph
         // however, most reports with a fixed set of dimension values are excluded
         // this is done so Piwik Mobile and Scheduled Reports do not display them
         if (empty($report['constantRowsCount']) || in_array($reportUniqueId, self::$CONSTANT_ROW_COUNT_REPORT_EXCEPTIONS)) {
             $parameters['period'] = $periodForMultiplePeriodGraph;
             $parameters['date'] = $dateForMultiplePeriodGraph;
             $report['imageGraphEvolutionUrl'] = $urlPrefix . Piwik_Url::getQueryStringFromParameters($parameters);
         }
     }
 }
Пример #10
0
 function __construct()
 {
     parent::__construct();
     $this->idSite = Piwik_Common::getRequestVar('idSite');
     $this->minIdVisit = Piwik_Common::getRequestVar('minIdVisit', 0, 'int');
 }
Пример #11
0
 public function getReportMetadata($notification)
 {
     $info = $notification->getNotificationInfo();
     $reports =& $notification->getNotificationObject();
     $idSites = $info['idSites'];
     // If only one website is selected, we add the Graph URL
     if (count($idSites) != 1) {
         return;
     }
     $idSite = reset($idSites);
     // in case API.getReportMetadata was not called with date/period we use sane defaults
     if (empty($info['period'])) {
         $info['period'] = 'day';
     }
     if (empty($info['date'])) {
         $info['date'] = 'today';
     }
     // need two sets of period & date, one for single period graphs, one for multiple periods graphs
     if (Piwik_Archive::isMultiplePeriod($info['date'], $info['period'])) {
         $periodForMultiplePeriodGraph = $info['period'];
         $dateForMultiplePeriodGraph = $info['date'];
         $periodForSinglePeriodGraph = 'range';
         $dateForSinglePeriodGraph = $info['date'];
     } else {
         $periodForSinglePeriodGraph = $info['period'];
         $dateForSinglePeriodGraph = $info['date'];
         $piwikSite = new Piwik_Site($idSite);
         if ($periodForSinglePeriodGraph == 'range') {
             $periodForMultiplePeriodGraph = Zend_Registry::get('config')->General->graphs_default_period_to_plot_when_period_range;
             $dateForMultiplePeriodGraph = $dateForSinglePeriodGraph;
         } else {
             $periodForMultiplePeriodGraph = $periodForSinglePeriodGraph;
             $dateForMultiplePeriodGraph = Piwik_Controller::getDateRangeRelativeToEndDate($periodForSinglePeriodGraph, 'last' . self::GRAPH_EVOLUTION_LAST_PERIODS, $dateForSinglePeriodGraph, $piwikSite);
         }
     }
     $token_auth = Piwik_Common::getRequestVar('token_auth', false);
     $urlPrefix = "index.php?";
     foreach ($reports as &$report) {
         $parameters = array();
         $parameters['module'] = 'API';
         $parameters['method'] = 'ImageGraph.get';
         $parameters['idSite'] = $idSite;
         $parameters['apiModule'] = $report['module'];
         $parameters['apiAction'] = $report['action'];
         if (!empty($token_auth)) {
             $parameters['token_auth'] = $token_auth;
         }
         // Forward custom Report parameters to the graph URL
         if (!empty($report['parameters'])) {
             $parameters = array_merge($parameters, $report['parameters']);
         }
         if (empty($report['dimension'])) {
             $parameters['period'] = $periodForMultiplePeriodGraph;
             $parameters['date'] = $dateForMultiplePeriodGraph;
         } else {
             $parameters['period'] = $periodForSinglePeriodGraph;
             $parameters['date'] = $dateForSinglePeriodGraph;
         }
         $report['imageGraphUrl'] = $urlPrefix . Piwik_Url::getQueryStringFromParameters($parameters);
     }
 }
Пример #12
0
 public function __construct()
 {
     parent::__construct();
     $this->osRelatedReports = array('UserSettings.getOSFamily' => Piwik_Translate('UserSettings_OperatingSystemFamily'), 'UserSettings.getOS' => Piwik_Translate('UserSettings_OperatingSystems'));
 }
Пример #13
0
 protected function setGeneralVariablesView($view)
 {
     parent::setGeneralVariablesView($view);
     $view->menu = Piwik_GetMenu();
 }
Пример #14
0
 /**
  * Set the minimal variables in the view object
  * Extended by some admin view specific variables
  *
  * @param Piwik_View $view
  */
 protected function setBasicVariablesView($view)
 {
     parent::setBasicVariablesView($view);
     self::setBasicVariablesAdminView($view);
 }
Пример #15
0
 function __construct()
 {
     parent::__construct();
     $this->limit = Piwik_Config::getInstance()->General['all_websites_website_per_page'];
 }
Пример #16
0
 function __construct()
 {
     parent::__construct();
     $this->idSite = Piwik_Common::getRequestVar('idSite');
     $this->goals = Piwik_Goals_API::getInstance()->getGoals($this->idSite);
 }
Пример #17
0
 function __construct()
 {
     parent::__construct();
     $this->limit = Zend_Registry::get('config')->General->all_websites_website_per_page;
 }
Пример #18
0
 /**
  * Returns the entire date range and lastN value for the current request, based on
  * a period type and end date.
  *
  * @param string $period The period type, 'day', 'week', 'month' or 'year'
  * @param string $endDate The end date.
  * @param int|null $defaultLastN The default lastN to use. If null, the result of
  *                               getDefaultLastN is used.
  * @return array An array w/ two elements. The first is a whole date range and the second
  *               is the lastN number used, ie, array('2010-01-01,2012-01-02', 2).
  */
 public static function getDateRangeAndLastN($period, $endDate, $defaultLastN = null)
 {
     if ($defaultLastN === null) {
         $defaultLastN = self::getDefaultLastN($period);
     }
     $lastNParamName = self::getLastNParamName($period);
     $lastN = Piwik_Common::getRequestVar($lastNParamName, $defaultLastN, 'int');
     $site = new Piwik_Site(Piwik_Common::getRequestVar('idSite'));
     $dateRange = Piwik_Controller::getDateRangeRelativeToEndDate($period, 'last' . $lastN, $endDate, $site);
     return array($dateRange, $lastN);
 }
Пример #19
0
 function __construct()
 {
     parent::__construct();
     $this->idSite = Piwik_Common::getRequestVar('idSite');
     $this->experiments = Piwik_ABTests_API::getInstance()->getExperiments($this->idSite);
 }