diff options
author | matt <matt@59fd770c-687e-43c8-a1e3-f5a4ff64c105> | 2008-02-01 07:17:22 +0300 |
---|---|---|
committer | matt <matt@59fd770c-687e-43c8-a1e3-f5a4ff64c105> | 2008-02-01 07:17:22 +0300 |
commit | 22d8115234e152b91620f5eaec88573e0801d633 (patch) | |
tree | 9fd69eb676110fdce58b1a794170d4e3a5a2126e | |
parent | b04add2fea31214640fa3e95af5de4eaf909af00 (diff) |
finished splitting HomeController in all the plugins controller
27 files changed, 964 insertions, 868 deletions
diff --git a/modules/Controller.php b/modules/Controller.php index fe3a76b852..058f12eab0 100644 --- a/modules/Controller.php +++ b/modules/Controller.php @@ -17,7 +17,8 @@ abstract class Piwik_Controller { function __construct() { - + $aPluginName = explode('_', get_class($this)); + $this->pluginName = $aPluginName[1]; $this->strDate = Piwik_Common::getRequestVar('date', 'yesterday','string'); // the date looks like YYYY-MM-DD we can build it diff --git a/plugins/Actions/Actions.php b/plugins/Actions/Actions.php index 98325c1001..d6c0f5f272 100644 --- a/plugins/Actions/Actions.php +++ b/plugins/Actions/Actions.php @@ -293,3 +293,12 @@ class Piwik_Actions extends Piwik_Plugin } } + +Piwik_AddWidget( 'Actions', 'getDownloads', 'Downloads'); +Piwik_AddWidget( 'Actions', 'getOutlinks', 'Outlinks'); +Piwik_AddWidget( 'Actions', 'getActions', 'Pages'); + +Piwik_AddMenu('Actions', 'Pages', array('module' => 'Actions', 'action' => 'getActions')); +Piwik_AddMenu('Actions', 'Outlinks', array('module' => 'Actions', 'action' => 'getOutlinks')); +Piwik_AddMenu('Actions', 'Downloads', array('module' => 'Actions', 'action' => 'getDownloads')); + diff --git a/plugins/Actions/Controller.php b/plugins/Actions/Controller.php new file mode 100644 index 0000000000..5046da8060 --- /dev/null +++ b/plugins/Actions/Controller.php @@ -0,0 +1,172 @@ +<?php + +require_once "ViewDataTable.php"; +class Piwik_Actions_Controller extends Piwik_Controller +{ + function index() + { + $view = new Piwik_View('Actions/index.tpl'); + + /* Actions / Downloads / Outlinks */ + $view->dataTableActions = $this->getActions( true ); + $view->dataTableDownloads = $this->getDownloads( true ); + $view->dataTableOutlinks = $this->getOutlinks( true ); + + echo $view->render(); + } + + /* + * + +List of the public methods for the class Piwik_Actions_API +- getActions : [idSite, period, date, expanded = , idSubtable = ] +- getDownloads : [idSite, period, date, expanded = , idSubtable = ] +- getOutlinks : [idSite, period, date, expanded = , idSubtable = ] + + */ + protected function getActionsView($currentControllerName, + $currentMethod, + $methodToCall = 'Actions.getActions', + $subMethod = 'getActionsSubDataTable') + { + $view = Piwik_ViewDataTable::factory(); + $view->init( $currentControllerName, + $currentMethod, + $methodToCall, + $subMethod ); + $view->setTemplate('Home/templates/datatable_actions.tpl'); + + if(Piwik_Common::getRequestVar('idSubtable', -1) != -1) + { + $view->setTemplate('Home/templates/datatable_actions_subdatable.tpl'); + } + $view->setSearchRecursive(); + + $currentlySearching = $view->setRecursiveLoadDataTableIfSearchingForPattern(); + if($currentlySearching) + { + $view->setTemplate('Home/templates/datatable_actions_recursive.tpl'); + } + $view->disableSort(); + + $view->setSortedColumn( 'nb_hits', 'desc' ); + + $view->disableOffsetInformation(); + + $view->setColumnsToDisplay( array(0,1,2) ); + $view->setLimit( 100 ); + + // computing minimum value to exclude + + $visitsInfo = Piwik_VisitsSummary_Controller::getVisitsSummary(); + $nbActions = $visitsInfo->getColumn('nb_actions'); + $nbActionsLowPopulationThreshold = floor(0.02 * $nbActions); // 2 percent of the total number of actions + $view->setExcludeLowPopulation( $nbActionsLowPopulationThreshold, 'nb_hits' ); + + $view->main(); + + // we need to rewrite the phpArray so it contains all the recursive arrays + if($currentlySearching) + { + $phpArrayRecursive = $this->getArrayFromRecursiveDataTable($view->dataTable); +// var_dump($phpArrayRecursive);exit; + $view->view->arrayDataTable = $phpArrayRecursive; + } +// var_dump( $view->view->arrayDataTable);exit; + return $view; + } + + protected function getArrayFromRecursiveDataTable( $dataTable, $depth = 0 ) + { + $table = array(); + foreach($dataTable->getRows() as $row) + { + $phpArray = array(); + if(($idSubtable = $row->getIdSubDataTable()) !== null) + { + $subTable = Piwik_DataTable_Manager::getInstance()->getTable( $idSubtable ); + + if($subTable->getRowsCount() > 0) + { +// $filter = new Piwik_DataTable_Filter_ReplaceColumnNames( +// $subTable, +// Piwik_Actions::getColumnsMap() +// ); + $phpArray = $this->getArrayFromRecursiveDataTable( $subTable, $depth + 1 ); + } + } + + $label = $row->getColumn('label'); + $newRow = array( + 'level' => $depth, + 'columns' => $row->getColumns(), + 'details' => $row->getDetails(), + 'idsubdatatable' => $row->getIdSubDataTable() + ); + $table[] = $newRow; + if(count($phpArray) > 0) + { + $table = array_merge( $table, $phpArray); + } + } + return $table; + } + + + function getDownloads($fetch = false) + { + $view = $this->getActionsView( $this->pluginName, + __FUNCTION__, + 'Actions.getDownloads', + 'getDownloadsSubDataTable' ); + + return $this->renderView($view, $fetch); + } + function getDownloadsSubDataTable($fetch = false) + { + $view = $this->getActionsView( $this->pluginName, + __FUNCTION__, + 'Actions.getDownloads', + 'getDownloadsSubDataTable' ); + + return $this->renderView($view, $fetch); + } + function getActions($fetch = false) + { + $view = $this->getActionsView( $this->pluginName, + __FUNCTION__, + 'Actions.getActions', + 'getActionsSubDataTable' ); + + return $this->renderView($view, $fetch); + } + function getActionsSubDataTable($fetch = false) + { + $view = $this->getActionsView( $this->pluginName, + __FUNCTION__, + 'Actions.getActions', + 'getActionsSubDataTable' ); + + return $this->renderView($view, $fetch); + } + function getOutlinks($fetch = false) + { + $view = $this->getActionsView( $this->pluginName, + __FUNCTION__, + 'Actions.getOutlinks', + 'getOutlinksSubDataTable' ); + + return $this->renderView($view, $fetch); + } + function getOutlinksSubDataTable($fetch = false) + { + $view = $this->getActionsView( $this->pluginName, + __FUNCTION__, + 'Actions.getOutlinks', + 'getOutlinksSubDataTable' ); + + return $this->renderView($view, $fetch); + } + + +} diff --git a/plugins/Dashboard/Controller.php b/plugins/Dashboard/Controller.php index 84882f4d35..52c239194d 100644 --- a/plugins/Dashboard/Controller.php +++ b/plugins/Dashboard/Controller.php @@ -23,7 +23,6 @@ class Piwik_Dashboard_Controller extends Piwik_Controller function __construct() { parent::__construct(); - $this->currentControllerName = 'Dashboard'; //FIXME: copy paste of Home controller => should be refactored //in a 'master' controller for statistics (tracs #91) diff --git a/plugins/Home/Controller.php b/plugins/Home/Controller.php index f5926938c9..193704bf8d 100644 --- a/plugins/Home/Controller.php +++ b/plugins/Home/Controller.php @@ -20,12 +20,6 @@ require_once "ViewDataTable.php"; */ class Piwik_Home_Controller extends Piwik_Controller { - function __construct() - { - parent::__construct(); - $this->currentControllerName = 'Home'; - - } function getDefaultAction() { return 'redirectToIndex'; @@ -87,747 +81,11 @@ class Piwik_Home_Controller extends Piwik_Controller $view->minDateMonth = $minDate->toString('m'); $view->minDateDay = $minDate->toString('d'); - /* Actions / Downloads / Outlinks */ - $view->dataTableActions = $this->getActions( true ); - $view->dataTableDownloads = $this->getDownloads( true ); - $view->dataTableOutlinks = $this->getOutlinks( true ); - - - - - /* User settings */ - $view->dataTablePlugin = $this->getPlugin( true ); - $view->dataTableResolution = $this->getResolution( true ); - $view->dataTableConfiguration = $this->getConfiguration( true ); - $view->dataTableOS = $this->getOS( true ); - $view->dataTableBrowser = $this->getBrowser( true ); - $view->dataTableBrowserType = $this->getBrowserType ( true ); - $view->dataTableWideScreen = $this->getWideScreen( true ); - - /* VisitorTime */ - $view->dataTableVisitInformationPerLocalTime = $this->getVisitInformationPerLocalTime(true); - $view->dataTableVisitInformationPerServerTime = $this->getVisitInformationPerServerTime(true); - - /* VisitFrequency */ - //$view->graphEvolutionVisitFrequency = $this->getLastVisitsReturningGraph( true ); - - $view->urlSparklineNbVisitsReturning = $this->getUrlSparkline( 'getLastVisitsReturningGraph'); - $view->urlSparklineNbActionsReturning = $this->getUrlSparkline( 'getLastActionsReturningGraph'); - $view->urlSparklineSumVisitLengthReturning = $this->getUrlSparkline( 'getLastSumVisitsLengthReturningGraph'); - $view->urlSparklineMaxActionsReturning = $this->getUrlSparkline( 'getLastMaxActionsReturningGraph'); - $view->urlSparklineBounceCountReturning = $this->getUrlSparkline( 'getLastBounceCountReturningGraph'); - - $dataTableFrequency = $this->getSummary(true); - - $view->nbVisitsReturning = $dataTableFrequency->getColumn('nb_visits_returning'); - $view->nbActionsReturning = $dataTableFrequency->getColumn('nb_actions_returning'); - $view->maxActionsReturning = $dataTableFrequency->getColumn('max_actions_returning'); - $view->sumVisitLengthReturning = $dataTableFrequency->getColumn('sum_visit_length_returning'); - $view->bounceCountReturning = $dataTableFrequency->getColumn('bounce_count_returning'); - - /* Visitor Interest */ - $view->dataTableNumberOfVisitsPerVisitDuration = $this->getNumberOfVisitsPerVisitDuration(true); - $view->dataTableNumberOfVisitsPerPage = $this->getNumberOfVisitsPerPage(true); - - /* Referers */ - //$view->graphEvolutionReferers = $this->getLastDistinctKeywordsGraph(true); - - $view->dataTableKeywords = $this->getKeywords(true); - $view->dataTableSearchEngines = $this->getSearchEngines(true); - $view->dataTableWebsites = $this->getWebsites(true); - $view->dataTablePartners = $this->getPartners(true); - $view->dataTableCampaigns = $this->getCampaigns(true); - - $view->numberDistinctSearchEngines = $this->getNumberOfDistinctSearchEngines(true); - $view->numberDistinctKeywords = $this->getNumberOfDistinctKeywords(true); - $view->numberDistinctWebsites = $this->getNumberOfDistinctWebsites(true); - $view->numberDistinctWebsitesUrls = $this->getNumberOfDistinctWebsitesUrls(true); - $view->numberDistinctPartners = $this->getNumberOfDistinctPartners(true); - $view->numberDistinctPartnersUrls = $this->getNumberOfDistinctPartnersUrls(true); - $view->numberDistinctCampaigns = $this->getNumberOfDistinctCampaigns(true); - - // building the referers summary report - $view->dataTableRefererType = $this->getRefererType(true); - - - $nameValues = $this->getReferersVisitorsByType(); - foreach($nameValues as $name => $value) - { - $view->$name = $value; - } - // sparkline for the historical data of the above values - $view->urlSparklineSearchEngines = $this->getUrlSparkline('getLastSearchEnginesGraph'); - $view->urlSparklineDirectEntry = $this->getUrlSparkline('getLastDirectEntryGraph'); - $view->urlSparklineWebsites = $this->getUrlSparkline('getLastWebsitesGraph'); - $view->urlSparklineCampaigns = $this->getUrlSparkline('getLastCampaignsGraph'); - $view->urlSparklineNewsletters = $this->getUrlSparkline('getLastNewslettersGraph'); - $view->urlSparklinePartners = $this->getUrlSparkline('getLastPartnersGraph'); - - // sparklines for the evolution of the distinct keywords count/websites count/ etc - $view->urlSparklineDistinctSearchEngines = $this->getUrlSparkline('getLastDistinctSearchEnginesGraph'); - $view->urlSparklineDistinctKeywords = $this->getUrlSparkline('getLastDistinctKeywordsGraph'); - $view->urlSparklineDistinctWebsites = $this->getUrlSparkline('getLastDistinctWebsitesGraph'); - $view->urlSparklineDistinctPartners = $this->getUrlSparkline('getLastDistinctPartnersGraph'); - $view->urlSparklineDistinctCampaigns = $this->getUrlSparkline('getLastDistinctCampaignsGraph'); - - echo $view->render(); - } - - - /* - * - -List of the public methods for the class Piwik_Actions_API -- getActions : [idSite, period, date, expanded = , idSubtable = ] -- getDownloads : [idSite, period, date, expanded = , idSubtable = ] -- getOutlinks : [idSite, period, date, expanded = , idSubtable = ] - - */ - protected function getActionsView($currentControllerName, - $currentMethod, - $methodToCall = 'Actions.getActions', - $subMethod = 'getActionsSubDataTable') - { - $view = Piwik_ViewDataTable::factory(); - $view->init( $currentControllerName, - $currentMethod, - $methodToCall, - $subMethod ); - $view->setTemplate('Home/templates/datatable_actions.tpl'); - - if(Piwik_Common::getRequestVar('idSubtable', -1) != -1) - { - $view->setTemplate('Home/templates/datatable_actions_subdatable.tpl'); - } - $view->setSearchRecursive(); - - $currentlySearching = $view->setRecursiveLoadDataTableIfSearchingForPattern(); - if($currentlySearching) - { - $view->setTemplate('Home/templates/datatable_actions_recursive.tpl'); - } - $view->disableSort(); - - $view->setSortedColumn( 'nb_hits', 'desc' ); - - $view->disableOffsetInformation(); - - $view->setColumnsToDisplay( array(0,1,2) ); - $view->setLimit( 100 ); -
- // computing minimum value to exclude -
- $visitsInfo = Piwik_VisitsSummary_Controller::getVisitsSummary();
- $nbActions = $visitsInfo->getColumn('nb_actions');
- $nbActionsLowPopulationThreshold = floor(0.02 * $nbActions); // 2 percent of the total number of actions
- $view->setExcludeLowPopulation( $nbActionsLowPopulationThreshold, 'nb_hits' );
- - $view->main(); - - // we need to rewrite the phpArray so it contains all the recursive arrays - if($currentlySearching) - { - $phpArrayRecursive = $this->getArrayFromRecursiveDataTable($view->dataTable); -// var_dump($phpArrayRecursive);exit; - $view->view->arrayDataTable = $phpArrayRecursive; - } -// var_dump( $view->view->arrayDataTable);exit; - return $view; - } - - protected function getArrayFromRecursiveDataTable( $dataTable, $depth = 0 ) - { - $table = array(); - foreach($dataTable->getRows() as $row) - { - $phpArray = array(); - if(($idSubtable = $row->getIdSubDataTable()) !== null) - { - $subTable = Piwik_DataTable_Manager::getInstance()->getTable( $idSubtable ); - - if($subTable->getRowsCount() > 0) - { -// $filter = new Piwik_DataTable_Filter_ReplaceColumnNames( -// $subTable, -// Piwik_Actions::getColumnsMap() -// ); - $phpArray = $this->getArrayFromRecursiveDataTable( $subTable, $depth + 1 ); - } - } - - $label = $row->getColumn('label'); - $newRow = array( - 'level' => $depth, - 'columns' => $row->getColumns(), - 'details' => $row->getDetails(), - 'idsubdatatable' => $row->getIdSubDataTable() - ); - $table[] = $newRow; - if(count($phpArray) > 0) - { - $table = array_merge( $table, $phpArray); - } - } - return $table; - } - - - function getDownloads($fetch = false) - { - $view = $this->getActionsView( $this->currentControllerName, - __FUNCTION__, - 'Actions.getDownloads', - 'getDownloadsSubDataTable' ); - - return $this->renderView($view, $fetch); - } - function getDownloadsSubDataTable($fetch = false) - { - $view = $this->getActionsView( $this->currentControllerName, - __FUNCTION__, - 'Actions.getDownloads', - 'getDownloadsSubDataTable' ); - - return $this->renderView($view, $fetch); - } - function getActions($fetch = false) - { - $view = $this->getActionsView( $this->currentControllerName, - __FUNCTION__, - 'Actions.getActions', - 'getActionsSubDataTable' ); - - return $this->renderView($view, $fetch); - } - function getActionsSubDataTable($fetch = false) - { - $view = $this->getActionsView( $this->currentControllerName, - __FUNCTION__, - 'Actions.getActions', - 'getActionsSubDataTable' ); - - return $this->renderView($view, $fetch); - } - function getOutlinks($fetch = false) - {
- $view = $this->getActionsView( $this->currentControllerName, - __FUNCTION__, - 'Actions.getOutlinks', - 'getOutlinksSubDataTable' );
- - return $this->renderView($view, $fetch); - } - function getOutlinksSubDataTable($fetch = false) - { - $view = $this->getActionsView( $this->currentControllerName, - __FUNCTION__, - 'Actions.getOutlinks', - 'getOutlinksSubDataTable' ); - - return $this->renderView($view, $fetch); - } - - /** - * VisitFrequency - */ - function getSummary( ) - { - $requestString = 'method='."VisitFrequency.getSummary".'&format=original'; - $request = new Piwik_API_Request($requestString); - return $request->process(); - } - - function getLastVisitsReturningGraph( $fetch = false ) - { - $view = $this->getLastUnitGraph(__FUNCTION__, "VisitFrequency.getVisitsReturning"); - return $this->renderView($view, $fetch); - } - - function getLastActionsReturningGraph( $fetch = false ) - { - $view = $this->getLastUnitGraph(__FUNCTION__, "VisitFrequency.getActionsReturning"); - return $this->renderView($view, $fetch); - } - - function getLastSumVisitsLengthReturningGraph( $fetch = false ) - { - $view = $this->getLastUnitGraph(__FUNCTION__, "VisitFrequency.getSumVisitsLengthReturning"); - return $this->renderView($view, $fetch); - } - - function getLastMaxActionsReturningGraph( $fetch = false ) - { - $view = $this->getLastUnitGraph(__FUNCTION__, "VisitFrequency.getMaxActionsReturning"); - return $this->renderView($view, $fetch); - } - - function getLastBounceCountReturningGraph( $fetch = false ) - { - $view = $this->getLastUnitGraph(__FUNCTION__, "VisitFrequency.getBounceCountReturning"); - return $this->renderView($view, $fetch); - } - - - /** - * VisitTime - */ - function getVisitInformationPerServerTime( $fetch = false) - { - $view = Piwik_ViewDataTable::factory(null, 'graphVerticalBar'); - $view->init( $this->currentControllerName, __FUNCTION__, - "VisitTime.getVisitInformationPerServerTime" ); - - $view->setColumnsToDisplay( array(0,2) ); - $view->setSortedColumn( 0, 'asc' ); - $view->setLimit( 24 ); - $view->disableSearchBox(); - $view->disableExcludeLowPopulation(); - $view->disableOffsetInformation(); - - return $this->renderView($view, $fetch); - } - - function getVisitInformationPerLocalTime( $fetch = false) - { - $view = Piwik_ViewDataTable::factory(null, 'graphVerticalBar'); - $view->init( $this->currentControllerName, __FUNCTION__, - "VisitTime.getVisitInformationPerLocalTime" ); - - $view->setColumnsToDisplay( array(0,2) ); - $view->setSortedColumn( 0, 'asc' );
- $view->setLimit( 24 );
- $view->setGraphLimit( 24 ); - $view->disableSearchBox(); - $view->disableExcludeLowPopulation(); - $view->disableOffsetInformation(); - - return $this->renderView($view, $fetch); - } - /** - * VisitorInterest - */ - function getNumberOfVisitsPerVisitDuration( $fetch = false) - { - $view = Piwik_ViewDataTable::factory( null, 'cloud' ); - $view->init( $this->currentControllerName, __FUNCTION__, - "VisitorInterest.getNumberOfVisitsPerVisitDuration" ); - - $view->setColumnsToDisplay( array(0,1) ); - $view->disableSort(); - $view->disableExcludeLowPopulation(); - $view->disableOffsetInformation(); - $view->disableSearchBox(); - - return $this->renderView($view, $fetch); - } - - function getNumberOfVisitsPerPage( $fetch = false) - { - $view = Piwik_ViewDataTable::factory(); - $view->init( $this->currentControllerName, __FUNCTION__, - "VisitorInterest.getNumberOfVisitsPerPage" ); - - $view->setColumnsToDisplay( array(0,1) ); - $view->setSortedColumn( 'nb_visits' ); - $view->disableExcludeLowPopulation(); - $view->disableOffsetInformation(); - $view->disableSearchBox(); - $view->disableSort(); - $view->main();
- - return $this->renderView($view, $fetch); - } - - /** - * User settings - */ - function getStandardDataTableUserSettings( $currentControllerAction, - $APItoCall ) - { - $view = Piwik_ViewDataTable::factory(); - $view->init( $this->currentControllerName, $currentControllerAction, $APItoCall ); - $view->disableSearchBox(); - $view->disableExcludeLowPopulation(); - - $view->setColumnsToDisplay( array(0,2) ); - $view->setSortedColumn( 1 ); - $view->setLimit( 5 ); - $view->setGraphLimit(5); - return $view; - } - - function getResolution( $fetch = false) - { - $view = $this->getStandardDataTableUserSettings( - __FUNCTION__, - 'UserSettings.getResolution' - ); - return $this->renderView($view, $fetch); - } - - function getConfiguration( $fetch = false) - { - $view = $this->getStandardDataTableUserSettings( - __FUNCTION__, - 'UserSettings.getConfiguration' - ); - $view->setLimit( 3 ); - return $this->renderView($view, $fetch); - } - - function getOS( $fetch = false) - { - $view = $this->getStandardDataTableUserSettings( - __FUNCTION__, - 'UserSettings.getOS' - ); - return $this->renderView($view, $fetch); - } - - function getBrowser( $fetch = false) - { - $view = $this->getStandardDataTableUserSettings( - __FUNCTION__, - 'UserSettings.getBrowser' - );
- $view->setGraphLimit(7); - return $this->renderView($view, $fetch); - } - - function getBrowserType ( $fetch = false) - { - $view = $this->getStandardDataTableUserSettings( - __FUNCTION__, - 'UserSettings.getBrowserType' - ); - $view->disableOffsetInformation(); - return $this->renderView($view, $fetch); - } - - function getWideScreen( $fetch = false) - { - $view = $this->getStandardDataTableUserSettings( - __FUNCTION__, - 'UserSettings.getWideScreen' - ); - $view->disableOffsetInformation(); - return $this->renderView($view, $fetch); - } - - function getPlugin( $fetch = false) - { - $view = Piwik_ViewDataTable::factory(); - $view->init( $this->currentControllerName, __FUNCTION__, 'UserSettings.getPlugin' ); - $view->disableSearchBox(); - $view->disableExcludeLowPopulation(); - $view->disableSort(); - $view->disableOffsetInformation(); - - $view->setColumnsToDisplay( array(0,1) ); - $view->setSortedColumn( 2 ); - $view->setLimit( 10 ); - - return $this->renderView($view, $fetch); - } - - - - /** - * Referers - */ - function getRefererType( $fetch = false) - { - $view = Piwik_ViewDataTable::factory(null, 'cloud'); - $view->init( $this->currentControllerName, - 'getRefererType', - 'Referers.getRefererType' - ); - $view->disableSearchBox(); - $view->disableOffsetInformation(); - $view->disableExcludeLowPopulation(); - $view->doNotShowFooter(); - - $view->setColumnsToDisplay( array(0,1,2) ); - - return $this->renderView($view, $fetch); - } - function getKeywords( $fetch = false) - { - $view = Piwik_ViewDataTable::factory(); - - $view->init( $this->currentControllerName, 'getKeywords', - 'Referers.getKeywords', - 'getSearchEnginesFromKeywordId' - ); - $view->disableExcludeLowPopulation(); - $view->setColumnsToDisplay( array(0,2)); - - return $this->renderView($view, $fetch); - } - - function getSearchEnginesFromKeywordId( $fetch = false ) - { - $view = Piwik_ViewDataTable::factory(); - $view->init( $this->currentControllerName, 'getSearchEnginesFromKeywordId', - 'Referers.getSearchEnginesFromKeywordId' - ); - $view->disableSearchBox(); - $view->disableExcludeLowPopulation(); - $view->setColumnsToDisplay( array(0,2)); - - return $this->renderView($view, $fetch); - } - - function getSearchEngines( $fetch = false) - { - $view = Piwik_ViewDataTable::factory(); - $view->init( $this->currentControllerName, 'getSearchEngines', - 'Referers.getSearchEngines', - 'getKeywordsFromSearchEngineId' - ); - $view->disableSearchBox(); - $view->disableExcludeLowPopulation(); - - $view->setColumnsToDisplay( array(0,2) ); - - return $this->renderView($view, $fetch); - } - - - function getKeywordsFromSearchEngineId( $fetch = false ) - { - $view = Piwik_ViewDataTable::factory(); - $view->init( $this->currentControllerName, 'getKeywordsFromSearchEngineId', - 'Referers.getKeywordsFromSearchEngineId' - ); - $view->disableSearchBox(); - $view->disableExcludeLowPopulation(); - $view->setColumnsToDisplay( array(0,2)); - - return $this->renderView($view, $fetch); - } - - function getWebsites( $fetch = false) - { - $view = Piwik_ViewDataTable::factory(); - $view->init( $this->currentControllerName, 'getWebsites', - 'Referers.getWebsites', - 'getUrlsFromWebsiteId' - ); - $view->disableExcludeLowPopulation(); - - $view->setColumnsToDisplay( array(0,2) );
-
- $view->setLimit(5);
- $view->setGraphLimit(12); - - return $this->renderView($view, $fetch); - } - - function getCampaigns( $fetch = false) - { - $view = Piwik_ViewDataTable::factory(); - $view->init( $this->currentControllerName, 'getCampaigns', - 'Referers.getCampaigns', - 'getKeywordsFromCampaignId' - ); - - $view->disableSearchBox(); - $view->disableExcludeLowPopulation(); - $view->setLimit( 5 ); - - $view->setColumnsToDisplay( array(0,2) ); - - return $this->renderView($view, $fetch); - } - - function getKeywordsFromCampaignId( $fetch = false) - { - $view = Piwik_ViewDataTable::factory(); - $view->init( $this->currentControllerName, 'getKeywordsFromCampaignId', - 'Referers.getKeywordsFromCampaignId' - ); - - $view->disableSearchBox(); - $view->disableExcludeLowPopulation(); - $view->setColumnsToDisplay( array(0,2)); - - return $this->renderView($view, $fetch); - } - - function getUrlsFromWebsiteId( $fetch = false) - { - $view = Piwik_ViewDataTable::factory(); - $view->init( $this->currentControllerName, 'getUrlsFromWebsiteId', - 'Referers.getUrlsFromWebsiteId' - ); - $view->disableSearchBox(); - $view->disableExcludeLowPopulation(); - $view->setColumnsToDisplay( array(0,2)); - - return $this->renderView($view, $fetch); - } - - function getPartners( $fetch = false) - { - $view = Piwik_ViewDataTable::factory(); - $view->init( $this->currentControllerName, 'getPartners', - 'Referers.getPartners', - 'getUrlsFromPartnerId' - ); - $view->disableSearchBox(); - $view->disableExcludeLowPopulation(); - $view->setLimit( 5 ); - - $view->setColumnsToDisplay( array(0,2) ); - - return $this->renderView($view, $fetch); + echo $view->render(); } - - function getUrlsFromPartnerId( $fetch = false) - { - $view = Piwik_ViewDataTable::factory(); - $view->init( $this->currentControllerName, 'getUrlsFromPartnerId', - 'Referers.getUrlsFromPartnerId' - ); - $view->disableSearchBox(); - $view->disableExcludeLowPopulation(); - $view->setColumnsToDisplay( array(0,2)); - return $this->renderView($view, $fetch); - } - - - function getReferersType() - { - // we disable the queued filters because here we want to get the visits coming from search engines - // if the filters were applied we would have to look up for a label looking like "Search Engines" - // which is not good when we have translations - $requestString = 'method='."Referers.getRefererType".'&format=original'.'&disable_queued_filters=1'; - $request = new Piwik_API_Request($requestString); - return $request->process(); - } - - protected function getReferersVisitorsByType() - { - // this is raw data (no filters applied, on purpose) so we select the data using the magic integers ID - $dataTableReferersType = $this->getReferersType(true); - - $nameToColumnId = array( - 'visitorsFromSearchEngines' => Piwik_Common::REFERER_TYPE_SEARCH_ENGINE, - 'visitorsFromDirectEntry' => Piwik_Common::REFERER_TYPE_DIRECT_ENTRY, - 'visitorsFromWebsites' => Piwik_Common::REFERER_TYPE_WEBSITE, - 'visitorsFromCampaigns' => Piwik_Common::REFERER_TYPE_CAMPAIGN, - 'visitorsFromNewsletters' => Piwik_Common::REFERER_TYPE_NEWSLETTER, - 'visitorsFromPartners' => Piwik_Common::REFERER_TYPE_PARTNER, - ); - $return = array(); - foreach($nameToColumnId as $nameVar => $columnId) - { - $value = 0; - $row = $dataTableReferersType->getRowFromLabel($columnId); - if($row !== false) - { - $value = $row->getColumn(Piwik_Archive::INDEX_NB_UNIQ_VISITORS); - } - $return[$nameVar] = $value; - } - - return $return; - } - function getLastSearchEnginesGraph( $fetch = false ) - { - $view = $this->getLastUnitGraph(__FUNCTION__, 'Referers.getRefererType'); - $view->setSearchPattern(Piwik_Common::REFERER_TYPE_SEARCH_ENGINE, 'label'); - return $this->renderView($view, $fetch); - } - function getLastDirectEntryGraph( $fetch = false ) - { - $view = $this->getLastUnitGraph(__FUNCTION__, 'Referers.getRefererType'); - $view->setSearchPattern(Piwik_Common::REFERER_TYPE_DIRECT_ENTRY, 'label'); - return $this->renderView($view, $fetch); - } - function getLastWebsitesGraph( $fetch = false ) - { - $view = $this->getLastUnitGraph(__FUNCTION__, 'Referers.getRefererType'); - $view->setSearchPattern(Piwik_Common::REFERER_TYPE_WEBSITE, 'label'); - return $this->renderView($view, $fetch); - } - function getLastCampaignsGraph( $fetch = false ) - { - $view = $this->getLastUnitGraph(__FUNCTION__, 'Referers.getRefererType'); - $view->setSearchPattern(Piwik_Common::REFERER_TYPE_CAMPAIGN, 'label'); - return $this->renderView($view, $fetch); - } - function getLastNewslettersGraph( $fetch = false ) - { - $view = $this->getLastUnitGraph(__FUNCTION__, 'Referers.getRefererType'); - $view->setSearchPattern(Piwik_Common::REFERER_TYPE_NEWSLETTER, 'label'); - return $this->renderView($view, $fetch); - } - function getLastPartnersGraph( $fetch = false ) - { - $view = $this->getLastUnitGraph(__FUNCTION__, 'Referers.getRefererType'); - $view->setSearchPattern(Piwik_Common::REFERER_TYPE_PARTNER, 'label'); - return $this->renderView($view, $fetch); - } - function getLastDistinctSearchEnginesGraph( $fetch = false ) - { - $view = $this->getLastUnitGraph(__FUNCTION__, "Referers.getNumberOfDistinctSearchEngines"); - return $this->renderView($view, $fetch); - } - function getLastDistinctKeywordsGraph( $fetch = false ) - { - $view = $this->getLastUnitGraph(__FUNCTION__, "Referers.getNumberOfDistinctKeywords"); - return $this->renderView($view, $fetch); - } - function getLastDistinctWebsitesGraph( $fetch = false ) - { - $view = $this->getLastUnitGraph(__FUNCTION__, "Referers.getNumberOfDistinctWebsites"); - return $this->renderView($view, $fetch); - } - function getLastDistinctPartnersGraph( $fetch = false ) - { - $view = $this->getLastUnitGraph(__FUNCTION__, "Referers.getNumberOfDistinctPartners"); - return $this->renderView($view, $fetch); - } - function getLastDistinctCampaignsGraph( $fetch = false ) - { - $view = $this->getLastUnitGraph(__FUNCTION__, "Referers.getNumberOfDistinctCampaigns"); - return $this->renderView($view, $fetch); - } - function getNumberOfDistinctSearchEngines( $fetch = false) - { - return $this->getNumericValue('Referers.' . __FUNCTION__); - } - - function getNumberOfDistinctKeywords( $fetch = false) - { - return $this->getNumericValue('Referers.' . __FUNCTION__); - } - function getNumberOfDistinctCampaigns( $fetch = false) - { - return $this->getNumericValue('Referers.' . __FUNCTION__); - } - function getNumberOfDistinctWebsites( $fetch = false) - { - return $this->getNumericValue('Referers.' . __FUNCTION__); - } - function getNumberOfDistinctWebsitesUrls( $fetch = false) - { - return $this->getNumericValue('Referers.' . __FUNCTION__); - } - function getNumberOfDistinctPartners( $fetch = false) - { - return $this->getNumericValue('Referers.' . __FUNCTION__); - } - function getNumberOfDistinctPartnersUrls ( $fetch = false) - { - return $this->getNumericValue('Referers.' . __FUNCTION__); - } - }
\ No newline at end of file diff --git a/plugins/Home/templates/index.tpl b/plugins/Home/templates/index.tpl index b202e1107f..459ebda280 100644 --- a/plugins/Home/templates/index.tpl +++ b/plugins/Home/templates/index.tpl @@ -270,127 +270,16 @@ Site <select name="idSite" onchange='javascript:this.form.submit()'> <span id="loadingPiwik"><img src="themes/default/images/loading-blue.gif"> Loading data...</span> -{include file="Home/templates/menu.tpl"}
+{include file="Home/templates/period_select.tpl"}
<br><br>
+{include file="Home/templates/menu.tpl"}
+
<div style='clear:both'></div>
-{include file="Home/templates/period_select.tpl"}
<div id='content'>
</div> -{php}exit;{/php} {* useful when working on the UI, the page generation is faster to skip other reports...
-{php}exit;{/php}*}
- -<div class="section" id="Referers"> - - <a name="evolutionGraph" graphId="getLastDistinctKeywordsGraph"></a> - <h3>Evolution over the period</h3> - {$graphEvolutionReferers} - - <h3>Referer Type</h3> - <table> - <tr><td> - <p><img class="sparkline" src="{$urlSparklineDirectEntry}" /> <span><strong>{$visitorsFromDirectEntry} </strong> direct entries</span></p> - <p><img class="sparkline" src="{$urlSparklineSearchEngines}" /> <span><strong>{$visitorsFromSearchEngines} </strong> from search engines</span></p> - <p><img class="sparkline" src="{$urlSparklinePartners}" /> <span><strong>{$visitorsFromPartners} </strong> from partners</span></p> - </td><td> - <p><img class="sparkline" src="{$urlSparklineWebsites}" /> <span><strong>{$visitorsFromWebsites} </strong> from websites</span></p> - <p><img class="sparkline" src="{$urlSparklineNewsletters}" /> <span><strong>{$visitorsFromNewsletters} </strong> from newsletters</span></p> - <p><img class="sparkline" src="{$urlSparklineCampaigns}" /> <span><strong>{$visitorsFromCampaigns} </strong> from campaigns</span></p> - </td></tr> - </table> - - <h3>Search Engines</h3> - {$dataTableSearchEngines} - - <h3>Keywords</h3> - {$dataTableKeywords} - - <h3>Websites</h3> - {$dataTableWebsites} - - <h3>Partners</h3> - {$dataTablePartners} - - <h3>Campaigns</h3> - {$dataTableCampaigns} - - - <h3>Other</h3> - <table> - <tr><td> - <p><img class="sparkline" src="{$urlSparklineDistinctSearchEngines}" /> <span><strong>{$numberDistinctSearchEngines} </strong> distinct search engines</span></p> - <p><img class="sparkline" src="{$urlSparklineDistinctKeywords}" /> <span><strong>{$numberDistinctKeywords} </strong> distinct keywords</span></p> - </td><td> - <p><img class="sparkline" src="{$urlSparklineDistinctWebsites}" /> <span><strong>{$numberDistinctWebsites} </strong> distinct websites (using <strong>{$numberDistinctWebsitesUrls}</strong> distinct urls)</span></p> - <p><img class="sparkline" src="{$urlSparklineDistinctPartners}" /> <span><strong>{$numberDistinctPartners} </strong> distinct partners (using <strong>{$numberDistinctPartnersUrls}</strong> distinct urls)</span></p> - <p><img class="sparkline" src="{$urlSparklineDistinctCampaigns}" /> <span><strong>{$numberDistinctCampaigns} </strong> distinct campaigns</span></p> - </td></tr> - </table> - - <p>Tag cloud output</p> - {$dataTableRefererType} -</div> -<div class="section" id="Actions"> - <h3>Actions</h3> - {$dataTableActions} - <h3>Downloads</h3> - {$dataTableDownloads} - <h3>Outlinks</h3> - {$dataTableOutlinks} -</div> - -<div class="section" id="User_Settings"> - <h3>Configurations</h3> - {$dataTableConfiguration} - - <h3>Resolutions</h3> - {$dataTableResolution} - - <h3>Operating systems</h3> - {$dataTableOS} - - <h3>Browsers</h3> - {$dataTableBrowser} - - <h3>Browser families</h3> - {$dataTableBrowserType} - - <h3>Wide Screen</h3> - {$dataTableWideScreen} - - <h3>Plugins</h3> - {$dataTablePlugin} -</div> - - -<div class="section" id="Frequency">
-
- <a name="evolutionGraph" graphId="getLastVisitsReturningGraph"></a>
- <h3>Evolution over the period</h3>
- {$graphEvolutionVisitFrequency}
- - <p><img class="sparkline" src="{$urlSparklineNbVisitsReturning}" /> <span><strong>{$nbVisitsReturning} </strong> returning visits</span></p> - <p><img class="sparkline" src="{$urlSparklineNbActionsReturning}" /> <span><strong>{$nbActionsReturning} </strong> actions by the returning visits</span></p> - <p><img class="sparkline" src="{$urlSparklineMaxActionsReturning}" /> <span><strong>{$maxActionsReturning} </strong> maximum actions by a returning visit</span></p> - <p><img class="sparkline" src="{$urlSparklineSumVisitLengthReturning}" /> <span><strong>{$sumVisitLengthReturning|sumtime} </strong> total time spent by returning visits</span></p> - <p><img class="sparkline" src="{$urlSparklineBounceCountReturning}" /> <span><strong>{$bounceCountReturning} </strong> times that a returning visit has bounced (left the site after one page) </span></p> -</div> - -<div class="section" id="Visit_Time"> - <h3>Visit per local time</h3> - {$dataTableVisitInformationPerLocalTime} - <h3>Visit per server time</h3> - {$dataTableVisitInformationPerServerTime} -</div> - -<div class="section" id="Visitor_Interest"> - <h3>Visits per visit duration</h3> - {$dataTableNumberOfVisitsPerVisitDuration} - <h3>Visits per number of pages</h3> - {$dataTableNumberOfVisitsPerPage} -</div> - +{php}exit;{/php}*} diff --git a/plugins/Home/templates/links_misc_modules.tpl b/plugins/Home/templates/links_misc_modules.tpl index f9d29b7856..0a9520dfc4 100644 --- a/plugins/Home/templates/links_misc_modules.tpl +++ b/plugins/Home/templates/links_misc_modules.tpl @@ -5,6 +5,7 @@ <a href='?module=API&action=listAllAPI'>API examples</a></li>
<li>View examples of how to embed graphs/tables as widgets
<br><a href='?module=Widgetize'>Widgetize!</a></li>
+ <li><a href='?module=PluginsAdmin'>Admin plugins</a></li>
<li><a href='?module=SitesManager'>Admin websites</a></li>
<li><a href='?module=UsersManager'>Admin users</a></li>
<li><a href='?module=SitesManager&action=displayJavascriptCode&idsite={$idSite}'>Show the javascript code to insert</a></li>
diff --git a/plugins/Home/templates/menu.tpl b/plugins/Home/templates/menu.tpl index 6dd379315a..4cfebc795f 100644 --- a/plugins/Home/templates/menu.tpl +++ b/plugins/Home/templates/menu.tpl @@ -2,7 +2,7 @@ <ul class="nav">
{foreach from=$menu key=level1 item=level2}
<li>
- <a href=''>{$level1} ↓</a>
+ <a href='#'>{$level1} ↓</a>
<ul>
{foreach from=$level2 key=name item=urlParameters}
<li><a href='{$urlParameters|@urlRewriteWithParameters}'>{$name}</a></li>
diff --git a/plugins/Provider/Provider.php b/plugins/Provider/Provider.php index 80647aa501..66d16f0bf0 100644 --- a/plugins/Provider/Provider.php +++ b/plugins/Provider/Provider.php @@ -219,4 +219,4 @@ class Piwik_Provider_Controller extends Piwik_Controller Piwik_AddWidget( 'Provider', 'getProvider', 'Providers'); -Piwik_AddMenu('User Country', 'Provider', array('module' => 'Provider', 'action'=> 'getProvider')); +Piwik_AddMenu('Visitors', 'Provider', array('module' => 'Provider', 'action'=> 'getProvider')); diff --git a/plugins/Referers/Controller.php b/plugins/Referers/Controller.php new file mode 100644 index 0000000000..fdefad6913 --- /dev/null +++ b/plugins/Referers/Controller.php @@ -0,0 +1,352 @@ +<?php +require_once "ViewDataTable.php"; + +class Piwik_Referers_Controller extends Piwik_Controller +{ + function index() + { + $view = new Piwik_View('Referers/index.tpl'); + + $view->graphEvolutionReferers = $this->getLastDistinctKeywordsGraph(true); + + $view->numberDistinctSearchEngines = $this->getNumberOfDistinctSearchEngines(true); + $view->numberDistinctKeywords = $this->getNumberOfDistinctKeywords(true); + $view->numberDistinctWebsites = $this->getNumberOfDistinctWebsites(true); + $view->numberDistinctWebsitesUrls = $this->getNumberOfDistinctWebsitesUrls(true); + $view->numberDistinctPartners = $this->getNumberOfDistinctPartners(true); + $view->numberDistinctPartnersUrls = $this->getNumberOfDistinctPartnersUrls(true); + $view->numberDistinctCampaigns = $this->getNumberOfDistinctCampaigns(true); + + // building the referers summary report + $view->dataTableRefererType = $this->getRefererType(true); + + + $nameValues = $this->getReferersVisitorsByType(); + foreach($nameValues as $name => $value) + { + $view->$name = $value; + } + // sparkline for the historical data of the above values + $view->urlSparklineSearchEngines = $this->getUrlSparkline('getLastSearchEnginesGraph'); + $view->urlSparklineDirectEntry = $this->getUrlSparkline('getLastDirectEntryGraph'); + $view->urlSparklineWebsites = $this->getUrlSparkline('getLastWebsitesGraph'); + $view->urlSparklineCampaigns = $this->getUrlSparkline('getLastCampaignsGraph'); + $view->urlSparklineNewsletters = $this->getUrlSparkline('getLastNewslettersGraph'); + $view->urlSparklinePartners = $this->getUrlSparkline('getLastPartnersGraph'); + + // sparklines for the evolution of the distinct keywords count/websites count/ etc + $view->urlSparklineDistinctSearchEngines = $this->getUrlSparkline('getLastDistinctSearchEnginesGraph'); + $view->urlSparklineDistinctKeywords = $this->getUrlSparkline('getLastDistinctKeywordsGraph'); + $view->urlSparklineDistinctWebsites = $this->getUrlSparkline('getLastDistinctWebsitesGraph'); + $view->urlSparklineDistinctPartners = $this->getUrlSparkline('getLastDistinctPartnersGraph'); + $view->urlSparklineDistinctCampaigns = $this->getUrlSparkline('getLastDistinctCampaignsGraph'); + + echo $view->render(); + } + + function getSearchEnginesAndKeywords() + { + $view = new Piwik_View('Referers/searchEngines_Keywords.tpl'); + $view->searchEngines = $this->getSearchEngines(true) ; + $view->keywords = $this->getKeywords(true); + echo $view->render(); + } + /** + * Referers + */ + function getRefererType( $fetch = false) + { + $view = Piwik_ViewDataTable::factory(null, 'cloud'); + $view->init( $this->pluginName, + 'getRefererType', + 'Referers.getRefererType' + ); + $view->disableSearchBox(); + $view->disableOffsetInformation(); + $view->disableExcludeLowPopulation(); + $view->doNotShowFooter(); + + $view->setColumnsToDisplay( array(0,1,2) ); + + return $this->renderView($view, $fetch); + } + + function getKeywords( $fetch = false) + { + $view = Piwik_ViewDataTable::factory(); + + $view->init( $this->pluginName, 'getKeywords', + 'Referers.getKeywords', + 'getSearchEnginesFromKeywordId' + ); + $view->disableExcludeLowPopulation(); + $view->setColumnsToDisplay( array(0,2)); + + return $this->renderView($view, $fetch); + } + + function getSearchEnginesFromKeywordId( $fetch = false ) + { + $view = Piwik_ViewDataTable::factory(); + $view->init( $this->pluginName, 'getSearchEnginesFromKeywordId', + 'Referers.getSearchEnginesFromKeywordId' + ); + $view->disableSearchBox(); + $view->disableExcludeLowPopulation(); + $view->setColumnsToDisplay( array(0,2)); + + return $this->renderView($view, $fetch); + } + + + function getSearchEngines( $fetch = false) + { + $view = Piwik_ViewDataTable::factory(); + $view->init( $this->pluginName, 'getSearchEngines', + 'Referers.getSearchEngines', + 'getKeywordsFromSearchEngineId' + ); + $view->disableSearchBox(); + $view->disableExcludeLowPopulation(); + + $view->setColumnsToDisplay( array(0,2) ); + + return $this->renderView($view, $fetch); + } + + + function getKeywordsFromSearchEngineId( $fetch = false ) + { + $view = Piwik_ViewDataTable::factory(); + $view->init( $this->pluginName, 'getKeywordsFromSearchEngineId', + 'Referers.getKeywordsFromSearchEngineId' + ); + $view->disableSearchBox(); + $view->disableExcludeLowPopulation(); + $view->setColumnsToDisplay( array(0,2)); + + return $this->renderView($view, $fetch); + } + + function getWebsites( $fetch = false) + { + $view = Piwik_ViewDataTable::factory(); + $view->init( $this->pluginName, 'getWebsites', + 'Referers.getWebsites', + 'getUrlsFromWebsiteId' + ); + $view->disableExcludeLowPopulation(); + + $view->setColumnsToDisplay( array(0,2) ); + + $view->setLimit(5); + $view->setGraphLimit(12); + + return $this->renderView($view, $fetch); + } + + function getCampaigns( $fetch = false) + { + $view = Piwik_ViewDataTable::factory(); + $view->init( $this->pluginName, 'getCampaigns', + 'Referers.getCampaigns', + 'getKeywordsFromCampaignId' + ); + + $view->disableSearchBox(); + $view->disableExcludeLowPopulation(); + $view->setLimit( 5 ); + + $view->setColumnsToDisplay( array(0,2) ); + + return $this->renderView($view, $fetch); + } + + function getKeywordsFromCampaignId( $fetch = false) + { + $view = Piwik_ViewDataTable::factory(); + $view->init( $this->pluginName, 'getKeywordsFromCampaignId', + 'Referers.getKeywordsFromCampaignId' + ); + + $view->disableSearchBox(); + $view->disableExcludeLowPopulation(); + $view->setColumnsToDisplay( array(0,2)); + + return $this->renderView($view, $fetch); + } + + function getUrlsFromWebsiteId( $fetch = false) + { + $view = Piwik_ViewDataTable::factory(); + $view->init( $this->pluginName, 'getUrlsFromWebsiteId', + 'Referers.getUrlsFromWebsiteId' + ); + $view->disableSearchBox(); + $view->disableExcludeLowPopulation(); + $view->setColumnsToDisplay( array(0,2)); + + return $this->renderView($view, $fetch); + } + + function getPartners( $fetch = false) + { + $view = Piwik_ViewDataTable::factory(); + $view->init( $this->pluginName, 'getPartners', + 'Referers.getPartners', + 'getUrlsFromPartnerId' + ); + $view->disableSearchBox(); + $view->disableExcludeLowPopulation(); + $view->setLimit( 5 ); + + $view->setColumnsToDisplay( array(0,2) ); + + return $this->renderView($view, $fetch); + } + + function getUrlsFromPartnerId( $fetch = false) + { + $view = Piwik_ViewDataTable::factory(); + $view->init( $this->pluginName, 'getUrlsFromPartnerId', + 'Referers.getUrlsFromPartnerId' + ); + $view->disableSearchBox(); + $view->disableExcludeLowPopulation(); + $view->setColumnsToDisplay( array(0,2)); + + return $this->renderView($view, $fetch); + } + + + function getReferersType() + { + // we disable the queued filters because here we want to get the visits coming from search engines + // if the filters were applied we would have to look up for a label looking like "Search Engines" + // which is not good when we have translations + $requestString = 'method='."Referers.getRefererType".'&format=original'.'&disable_queued_filters=1'; + $request = new Piwik_API_Request($requestString); + return $request->process(); + } + + protected function getReferersVisitorsByType() + { + // this is raw data (no filters applied, on purpose) so we select the data using the magic integers ID + $dataTableReferersType = $this->getReferersType(true); + + $nameToColumnId = array( + 'visitorsFromSearchEngines' => Piwik_Common::REFERER_TYPE_SEARCH_ENGINE, + 'visitorsFromDirectEntry' => Piwik_Common::REFERER_TYPE_DIRECT_ENTRY, + 'visitorsFromWebsites' => Piwik_Common::REFERER_TYPE_WEBSITE, + 'visitorsFromCampaigns' => Piwik_Common::REFERER_TYPE_CAMPAIGN, + 'visitorsFromNewsletters' => Piwik_Common::REFERER_TYPE_NEWSLETTER, + 'visitorsFromPartners' => Piwik_Common::REFERER_TYPE_PARTNER, + ); + $return = array(); + foreach($nameToColumnId as $nameVar => $columnId) + { + $value = 0; + $row = $dataTableReferersType->getRowFromLabel($columnId); + if($row !== false) + { + $value = $row->getColumn(Piwik_Archive::INDEX_NB_UNIQ_VISITORS); + } + $return[$nameVar] = $value; + } + + return $return; + } + function getLastSearchEnginesGraph( $fetch = false ) + { + $view = $this->getLastUnitGraph($this->pluginName,__FUNCTION__, 'Referers.getRefererType'); + $view->setSearchPattern(Piwik_Common::REFERER_TYPE_SEARCH_ENGINE, 'label'); + return $this->renderView($view, $fetch); + } + function getLastDirectEntryGraph( $fetch = false ) + { + $view = $this->getLastUnitGraph($this->pluginName,__FUNCTION__, 'Referers.getRefererType'); + $view->setSearchPattern(Piwik_Common::REFERER_TYPE_DIRECT_ENTRY, 'label'); + return $this->renderView($view, $fetch); + } + function getLastWebsitesGraph( $fetch = false ) + { + $view = $this->getLastUnitGraph($this->pluginName,__FUNCTION__, 'Referers.getRefererType'); + $view->setSearchPattern(Piwik_Common::REFERER_TYPE_WEBSITE, 'label'); + return $this->renderView($view, $fetch); + } + function getLastCampaignsGraph( $fetch = false ) + { + $view = $this->getLastUnitGraph($this->pluginName,__FUNCTION__, 'Referers.getRefererType'); + $view->setSearchPattern(Piwik_Common::REFERER_TYPE_CAMPAIGN, 'label'); + return $this->renderView($view, $fetch); + } + function getLastNewslettersGraph( $fetch = false ) + { + $view = $this->getLastUnitGraph($this->pluginName,__FUNCTION__, 'Referers.getRefererType'); + $view->setSearchPattern(Piwik_Common::REFERER_TYPE_NEWSLETTER, 'label'); + return $this->renderView($view, $fetch); + } + function getLastPartnersGraph( $fetch = false ) + { + $view = $this->getLastUnitGraph($this->pluginName,__FUNCTION__, 'Referers.getRefererType'); + $view->setSearchPattern(Piwik_Common::REFERER_TYPE_PARTNER, 'label'); + return $this->renderView($view, $fetch); + } + + function getLastDistinctSearchEnginesGraph( $fetch = false ) + { + $view = $this->getLastUnitGraph($this->pluginName,__FUNCTION__, "Referers.getNumberOfDistinctSearchEngines"); + return $this->renderView($view, $fetch); + } + function getLastDistinctKeywordsGraph( $fetch = false ) + { + $view = $this->getLastUnitGraph($this->pluginName,__FUNCTION__, "Referers.getNumberOfDistinctKeywords"); + return $this->renderView($view, $fetch); + } + function getLastDistinctWebsitesGraph( $fetch = false ) + { + $view = $this->getLastUnitGraph($this->pluginName,__FUNCTION__, "Referers.getNumberOfDistinctWebsites"); + return $this->renderView($view, $fetch); + } + function getLastDistinctPartnersGraph( $fetch = false ) + { + $view = $this->getLastUnitGraph($this->pluginName,__FUNCTION__, "Referers.getNumberOfDistinctPartners"); + return $this->renderView($view, $fetch); + } + function getLastDistinctCampaignsGraph( $fetch = false ) + { + $view = $this->getLastUnitGraph($this->pluginName,__FUNCTION__, "Referers.getNumberOfDistinctCampaigns"); + return $this->renderView($view, $fetch); + } + + function getNumberOfDistinctSearchEngines( $fetch = false) + { + return $this->getNumericValue('Referers.' . __FUNCTION__); + } + + function getNumberOfDistinctKeywords( $fetch = false) + { + return $this->getNumericValue('Referers.' . __FUNCTION__); + } + function getNumberOfDistinctCampaigns( $fetch = false) + { + return $this->getNumericValue('Referers.' . __FUNCTION__); + } + function getNumberOfDistinctWebsites( $fetch = false) + { + return $this->getNumericValue('Referers.' . __FUNCTION__); + } + function getNumberOfDistinctWebsitesUrls( $fetch = false) + { + return $this->getNumericValue('Referers.' . __FUNCTION__); + } + function getNumberOfDistinctPartners( $fetch = false) + { + return $this->getNumericValue('Referers.' . __FUNCTION__); + } + function getNumberOfDistinctPartnersUrls ( $fetch = false) + { + return $this->getNumericValue('Referers.' . __FUNCTION__); + } + +}
\ No newline at end of file diff --git a/plugins/Referers/Referers.php b/plugins/Referers/Referers.php index 43301863e7..ca1f58b5f8 100644 --- a/plugins/Referers/Referers.php +++ b/plugins/Referers/Referers.php @@ -313,4 +313,16 @@ class Piwik_Referers extends Piwik_Plugin // Piwik::printMemoryUsage("End of ".get_class($this)." "); // echo "after serialization = ". $timer; } -}
\ No newline at end of file +} + + + +Piwik_AddWidget( 'Referers', 'getKeywords', 'Keywords'); +Piwik_AddWidget( 'Referers', 'getLastDistinctWebsitesGraph', 'Distinct websites graph'); + +Piwik_AddMenu('Referers', 'Evolution', array('module' => 'Referers')); +Piwik_AddMenu('Referers', 'Search engines & keywords', array('module' => 'Referers', 'action' => 'getSearchEnginesAndKeywords')); +Piwik_AddMenu('Referers', 'Websites', array('module' => 'Referers', 'action' => 'getWebsites')); +Piwik_AddMenu('Referers', 'Campaigns', array('module' => 'Referers', 'action' => 'getCampaigns')); +Piwik_AddMenu('Referers', 'Partners', array('module' => 'Referers', 'action' => 'getPartners')); + diff --git a/plugins/Referers/index.tpl b/plugins/Referers/index.tpl new file mode 100644 index 0000000000..e1662f751f --- /dev/null +++ b/plugins/Referers/index.tpl @@ -0,0 +1,33 @@ +<script type="text/javascript" src="plugins/Home/templates/sparkline.js"></script> + + <a name="evolutionGraph" graphId="getLastDistinctKeywordsGraph"></a> + <h3>Evolution over the period</h3> + {$graphEvolutionReferers} + + <h3>Referer Type</h3> + <table> + <tr><td> + <p><img class="sparkline" src="{$urlSparklineDirectEntry}" /> <span><strong>{$visitorsFromDirectEntry} </strong> direct entries</span></p> + <p><img class="sparkline" src="{$urlSparklineSearchEngines}" /> <span><strong>{$visitorsFromSearchEngines} </strong> from search engines</span></p> + <p><img class="sparkline" src="{$urlSparklinePartners}" /> <span><strong>{$visitorsFromPartners} </strong> from partners</span></p> + </td><td> + <p><img class="sparkline" src="{$urlSparklineWebsites}" /> <span><strong>{$visitorsFromWebsites} </strong> from websites</span></p> + <p><img class="sparkline" src="{$urlSparklineNewsletters}" /> <span><strong>{$visitorsFromNewsletters} </strong> from newsletters</span></p> + <p><img class="sparkline" src="{$urlSparklineCampaigns}" /> <span><strong>{$visitorsFromCampaigns} </strong> from campaigns</span></p> + </td></tr> + </table> + + <h3>Other</h3> + <table> + <tr><td> + <p><img class="sparkline" src="{$urlSparklineDistinctSearchEngines}" /> <span><strong>{$numberDistinctSearchEngines} </strong> distinct search engines</span></p> + <p><img class="sparkline" src="{$urlSparklineDistinctKeywords}" /> <span><strong>{$numberDistinctKeywords} </strong> distinct keywords</span></p> + </td><td> + <p><img class="sparkline" src="{$urlSparklineDistinctWebsites}" /> <span><strong>{$numberDistinctWebsites} </strong> distinct websites (using <strong>{$numberDistinctWebsitesUrls}</strong> distinct urls)</span></p> + <p><img class="sparkline" src="{$urlSparklineDistinctPartners}" /> <span><strong>{$numberDistinctPartners} </strong> distinct partners (using <strong>{$numberDistinctPartnersUrls}</strong> distinct urls)</span></p> + <p><img class="sparkline" src="{$urlSparklineDistinctCampaigns}" /> <span><strong>{$numberDistinctCampaigns} </strong> distinct campaigns</span></p> + </td></tr> + </table> + + <p>Tag cloud output</p> + {$dataTableRefererType}
\ No newline at end of file diff --git a/plugins/Referers/searchEngines_Keywords.tpl b/plugins/Referers/searchEngines_Keywords.tpl new file mode 100644 index 0000000000..58c5789dfc --- /dev/null +++ b/plugins/Referers/searchEngines_Keywords.tpl @@ -0,0 +1,6 @@ + +<h3>Search engines</h3> +{$searchEngines} + +<h3>Keywords</h3> +{$keywords} diff --git a/plugins/UserCountry/UserCountry.php b/plugins/UserCountry/UserCountry.php index 18ed0e05b6..c538ec76e3 100644 --- a/plugins/UserCountry/UserCountry.php +++ b/plugins/UserCountry/UserCountry.php @@ -158,5 +158,5 @@ class Piwik_UserCountry_Controller extends Piwik_Controller Piwik_AddWidget( 'UserCountry', 'getContinent', 'Visitor continents'); Piwik_AddWidget( 'UserCountry', 'getCountry', 'Visitor countries'); -Piwik_AddMenu('User Country', 'Overview', array('module' => 'UserCountry')); +Piwik_AddMenu('Visitors', 'Locations', array('module' => 'UserCountry')); diff --git a/plugins/UserSettings/Controller.php b/plugins/UserSettings/Controller.php new file mode 100644 index 0000000000..6dc128439f --- /dev/null +++ b/plugins/UserSettings/Controller.php @@ -0,0 +1,114 @@ +<?php +require_once "ViewDataTable.php"; + +class Piwik_UserSettings_Controller extends Piwik_Controller +{ + function index() + { + $view = new Piwik_View('UserSettings/index.tpl'); + + /* User settings */ + $view->dataTablePlugin = $this->getPlugin( true ); + $view->dataTableResolution = $this->getResolution( true ); + $view->dataTableConfiguration = $this->getConfiguration( true ); + $view->dataTableOS = $this->getOS( true ); + $view->dataTableBrowser = $this->getBrowser( true ); + $view->dataTableBrowserType = $this->getBrowserType ( true ); + $view->dataTableWideScreen = $this->getWideScreen( true ); + + echo $view->render(); + } + + + /** + * User settings + */ + function getStandardDataTableUserSettings( $currentControllerAction, + $APItoCall ) + { + $view = Piwik_ViewDataTable::factory(); + $view->init( $this->pluginName, $currentControllerAction, $APItoCall ); + $view->disableSearchBox(); + $view->disableExcludeLowPopulation(); + + $view->setColumnsToDisplay( array(0,2) ); + $view->setSortedColumn( 1 ); + $view->setLimit( 5 ); + $view->setGraphLimit(5); + return $view; + } + + function getResolution( $fetch = false) + { + $view = $this->getStandardDataTableUserSettings( + __FUNCTION__, + 'UserSettings.getResolution' + ); + return $this->renderView($view, $fetch); + } + + function getConfiguration( $fetch = false) + { + $view = $this->getStandardDataTableUserSettings( + __FUNCTION__, + 'UserSettings.getConfiguration' + ); + $view->setLimit( 3 ); + return $this->renderView($view, $fetch); + } + + function getOS( $fetch = false) + { + $view = $this->getStandardDataTableUserSettings( + __FUNCTION__, + 'UserSettings.getOS' + ); + return $this->renderView($view, $fetch); + } + + function getBrowser( $fetch = false) + { + $view = $this->getStandardDataTableUserSettings( + __FUNCTION__, + 'UserSettings.getBrowser' + ); + $view->setGraphLimit(7); + return $this->renderView($view, $fetch); + } + + function getBrowserType ( $fetch = false) + { + $view = $this->getStandardDataTableUserSettings( + __FUNCTION__, + 'UserSettings.getBrowserType' + ); + $view->disableOffsetInformation(); + return $this->renderView($view, $fetch); + } + + function getWideScreen( $fetch = false) + { + $view = $this->getStandardDataTableUserSettings( + __FUNCTION__, + 'UserSettings.getWideScreen' + ); + $view->disableOffsetInformation(); + return $this->renderView($view, $fetch); + } + + function getPlugin( $fetch = false) + { + $view = Piwik_ViewDataTable::factory(); + $view->init( $this->pluginName, __FUNCTION__, 'UserSettings.getPlugin' ); + $view->disableSearchBox(); + $view->disableExcludeLowPopulation(); + $view->disableSort(); + $view->disableOffsetInformation(); + + $view->setColumnsToDisplay( array(0,1) ); + $view->setSortedColumn( 2 ); + $view->setLimit( 10 ); + + return $this->renderView($view, $fetch); + } +}
\ No newline at end of file diff --git a/plugins/UserSettings/UserSettings.php b/plugins/UserSettings/UserSettings.php index 32964e2454..71b71cb19c 100644 --- a/plugins/UserSettings/UserSettings.php +++ b/plugins/UserSettings/UserSettings.php @@ -218,3 +218,7 @@ function Piwik_UserSettings_keepStrlenGreater($value) } +Piwik_AddWidget( 'UserSettings', 'getResolution', 'Screen resolutions'); +Piwik_AddWidget( 'UserSettings', 'getBrowser', 'Visitor browsers'); + +Piwik_AddMenu('Visitors', 'Settings', array('module' => 'UserSettings')); diff --git a/plugins/UserSettings/index.tpl b/plugins/UserSettings/index.tpl new file mode 100644 index 0000000000..6f7c8d8545 --- /dev/null +++ b/plugins/UserSettings/index.tpl @@ -0,0 +1,21 @@ + + <h3>Configurations</h3> + {$dataTableConfiguration} + + <h3>Resolutions</h3> + {$dataTableResolution} + + <h3>Operating systems</h3> + {$dataTableOS} + + <h3>Browsers</h3> + {$dataTableBrowser} + + <h3>Browser families</h3> + {$dataTableBrowserType} + + <h3>Wide Screen</h3> + {$dataTableWideScreen} + + <h3>Plugins</h3> + {$dataTablePlugin}
\ No newline at end of file diff --git a/plugins/VisitFrequency/Controller.php b/plugins/VisitFrequency/Controller.php new file mode 100644 index 0000000000..1ac4373cc8 --- /dev/null +++ b/plugins/VisitFrequency/Controller.php @@ -0,0 +1,70 @@ +<?php + +require_once "ViewDataTable.php"; +class Piwik_VisitFrequency_Controller extends Piwik_Controller +{ + function index() + { + $view = new Piwik_View('VisitFrequency/index.tpl'); + /* VisitFrequency */ + $view->graphEvolutionVisitFrequency = $this->getLastVisitsReturningGraph( true ); + + $view->urlSparklineNbVisitsReturning = $this->getUrlSparkline( 'getLastVisitsReturningGraph'); + $view->urlSparklineNbActionsReturning = $this->getUrlSparkline( 'getLastActionsReturningGraph'); + $view->urlSparklineSumVisitLengthReturning = $this->getUrlSparkline( 'getLastSumVisitsLengthReturningGraph'); + $view->urlSparklineMaxActionsReturning = $this->getUrlSparkline( 'getLastMaxActionsReturningGraph'); + $view->urlSparklineBounceCountReturning = $this->getUrlSparkline( 'getLastBounceCountReturningGraph'); + + $dataTableFrequency = $this->getSummary(true); + + $view->nbVisitsReturning = $dataTableFrequency->getColumn('nb_visits_returning'); + $view->nbActionsReturning = $dataTableFrequency->getColumn('nb_actions_returning'); + $view->maxActionsReturning = $dataTableFrequency->getColumn('max_actions_returning'); + $view->sumVisitLengthReturning = $dataTableFrequency->getColumn('sum_visit_length_returning'); + $view->bounceCountReturning = $dataTableFrequency->getColumn('bounce_count_returning'); + + echo $view->render(); + } + + + /** + * VisitFrequency + */ + function getSummary( ) + { + $requestString = 'method='."VisitFrequency.getSummary".'&format=original'; + $request = new Piwik_API_Request($requestString); + return $request->process(); + } + + function getLastVisitsReturningGraph( $fetch = false ) + { + $view = $this->getLastUnitGraph($this->pluginName, __FUNCTION__, "VisitFrequency.getVisitsReturning"); + return $this->renderView($view, $fetch); + } + + function getLastActionsReturningGraph( $fetch = false ) + { + $view = $this->getLastUnitGraph($this->pluginName, __FUNCTION__, "VisitFrequency.getActionsReturning"); + return $this->renderView($view, $fetch); + } + + function getLastSumVisitsLengthReturningGraph( $fetch = false ) + { + $view = $this->getLastUnitGraph($this->pluginName, __FUNCTION__, "VisitFrequency.getSumVisitsLengthReturning"); + return $this->renderView($view, $fetch); + } + + function getLastMaxActionsReturningGraph( $fetch = false ) + { + $view = $this->getLastUnitGraph($this->pluginName, __FUNCTION__, "VisitFrequency.getMaxActionsReturning"); + return $this->renderView($view, $fetch); + } + + function getLastBounceCountReturningGraph( $fetch = false ) + { + $view = $this->getLastUnitGraph($this->pluginName, __FUNCTION__, "VisitFrequency.getBounceCountReturning"); + return $this->renderView($view, $fetch); + } + +} diff --git a/plugins/VisitFrequency/VisitFrequency.php b/plugins/VisitFrequency/VisitFrequency.php index faa841eece..87ea1f11f3 100644 --- a/plugins/VisitFrequency/VisitFrequency.php +++ b/plugins/VisitFrequency/VisitFrequency.php @@ -99,4 +99,17 @@ class Piwik_VisitFrequency extends Piwik_Plugin } } -}
\ No newline at end of file +} + + +Piwik_AddWidget( 'VisitFrequency', 'getSummary', 'Visitor frequency'); +Piwik_AddWidget( 'VisitFrequency', 'getLastVisitsReturningGraph', 'Graph returning visits'); +Piwik_AddWidget( 'VisitFrequency', 'getLastActionsReturningGraph', 'Graph returning actions'); +Piwik_AddWidget( 'VisitFrequency', 'getLastSumVisitsLengthReturningGraph', 'Graph duration returning visits'); +Piwik_AddWidget( 'VisitFrequency', 'getLastMaxActionsReturningGraph', 'Graph max actions for returning visits'); +Piwik_AddWidget( 'VisitFrequency', 'getLastBounceCountReturningGraph', 'Graph boucing returning visits'); + +Piwik_AddMenu('General', 'Frequency', array('module' => 'VisitFrequency')); + + + diff --git a/plugins/VisitFrequency/index.tpl b/plugins/VisitFrequency/index.tpl new file mode 100644 index 0000000000..4f7954097e --- /dev/null +++ b/plugins/VisitFrequency/index.tpl @@ -0,0 +1,11 @@ +<script type="text/javascript" src="plugins/Home/templates/sparkline.js"></script> + + <a name="evolutionGraph" graphId="getLastVisitsReturningGraph"></a> + <h3>Evolution over the period</h3> + {$graphEvolutionVisitFrequency} + + <p><img class="sparkline" src="{$urlSparklineNbVisitsReturning}" /> <span><strong>{$nbVisitsReturning} </strong> returning visits</span></p> + <p><img class="sparkline" src="{$urlSparklineNbActionsReturning}" /> <span><strong>{$nbActionsReturning} </strong> actions by the returning visits</span></p> + <p><img class="sparkline" src="{$urlSparklineMaxActionsReturning}" /> <span><strong>{$maxActionsReturning} </strong> maximum actions by a returning visit</span></p> + <p><img class="sparkline" src="{$urlSparklineSumVisitLengthReturning}" /> <span><strong>{$sumVisitLengthReturning|sumtime} </strong> total time spent by returning visits</span></p> + <p><img class="sparkline" src="{$urlSparklineBounceCountReturning}" /> <span><strong>{$bounceCountReturning} </strong> times that a returning visit has bounced (left the site after one page) </span></p> diff --git a/plugins/VisitTime/Controller.php b/plugins/VisitTime/Controller.php new file mode 100644 index 0000000000..1f0a782818 --- /dev/null +++ b/plugins/VisitTime/Controller.php @@ -0,0 +1,52 @@ +<?php + +require_once "ViewDataTable.php"; +class Piwik_VisitTime_Controller extends Piwik_Controller +{ + function index() + { + $view = new Piwik_View('VisitTime/index.tpl'); + + /* VisitorTime */ + $view->dataTableVisitInformationPerLocalTime = $this->getVisitInformationPerLocalTime(true); + $view->dataTableVisitInformationPerServerTime = $this->getVisitInformationPerServerTime(true); + + echo $view->render(); + } + + /** + * VisitTime + */ + function getVisitInformationPerServerTime( $fetch = false) + { + $view = Piwik_ViewDataTable::factory(null, 'graphVerticalBar'); + $view->init( $this->pluginName, __FUNCTION__, + "VisitTime.getVisitInformationPerServerTime" ); + + $view->setColumnsToDisplay( array(0,2) ); + $view->setSortedColumn( 0, 'asc' ); + $view->setLimit( 24 ); + $view->disableSearchBox(); + $view->disableExcludeLowPopulation(); + $view->disableOffsetInformation(); + + return $this->renderView($view, $fetch); + } + + function getVisitInformationPerLocalTime( $fetch = false) + { + $view = Piwik_ViewDataTable::factory(null, 'graphVerticalBar'); + $view->init( $this->pluginName, __FUNCTION__, + "VisitTime.getVisitInformationPerLocalTime" ); + + $view->setColumnsToDisplay( array(0,2) ); + $view->setSortedColumn( 0, 'asc' ); + $view->setLimit( 24 ); + $view->setGraphLimit( 24 ); + $view->disableSearchBox(); + $view->disableExcludeLowPopulation(); + $view->disableOffsetInformation(); + + return $this->renderView($view, $fetch); + } +} diff --git a/plugins/VisitTime/VisitTime.php b/plugins/VisitTime/VisitTime.php index d1f1a5e3e9..29da566a60 100644 --- a/plugins/VisitTime/VisitTime.php +++ b/plugins/VisitTime/VisitTime.php @@ -95,4 +95,11 @@ class Piwik_VisitTime extends Piwik_Plugin }
}
} -}
\ No newline at end of file +} + + +Piwik_AddWidget( 'VisitTime', 'getVisitInformationPerLocalTime', 'Visits by local time'); +Piwik_AddWidget( 'VisitTime', 'getVisitInformationPerServerTime', 'Visits by server time'); + +Piwik_AddMenu('General', 'Time', array('module' => 'VisitTime')); + diff --git a/plugins/VisitTime/index.tpl b/plugins/VisitTime/index.tpl new file mode 100644 index 0000000000..3987e8ca4f --- /dev/null +++ b/plugins/VisitTime/index.tpl @@ -0,0 +1,5 @@ + + <h3>Visit per local time</h3> + {$dataTableVisitInformationPerLocalTime} + <h3>Visit per server time</h3> + {$dataTableVisitInformationPerServerTime}
\ No newline at end of file diff --git a/plugins/VisitorInterest/Controller.php b/plugins/VisitorInterest/Controller.php new file mode 100644 index 0000000000..80f9a03c60 --- /dev/null +++ b/plugins/VisitorInterest/Controller.php @@ -0,0 +1,53 @@ +<?php + +require_once "ViewDataTable.php"; +class Piwik_VisitorInterest_Controller extends Piwik_Controller +{ + function index() + { + $view = new Piwik_View('VisitorInterest/index.tpl'); + + /* Visitor Interest */ + $view->dataTableNumberOfVisitsPerVisitDuration = $this->getNumberOfVisitsPerVisitDuration(true); + $view->dataTableNumberOfVisitsPerPage = $this->getNumberOfVisitsPerPage(true); + + echo $view->render(); + } + + /** + * VisitorInterest + */ + function getNumberOfVisitsPerVisitDuration( $fetch = false) + { + $view = Piwik_ViewDataTable::factory( null, 'cloud' ); + $view->init( $this->pluginName, __FUNCTION__, + "VisitorInterest.getNumberOfVisitsPerVisitDuration" ); + + $view->setColumnsToDisplay( array(0,1) ); + $view->disableSort(); + $view->disableExcludeLowPopulation(); + $view->disableOffsetInformation(); + $view->disableSearchBox(); + + return $this->renderView($view, $fetch); + } + + function getNumberOfVisitsPerPage( $fetch = false) + { + $view = Piwik_ViewDataTable::factory(); + $view->init( $this->pluginName, __FUNCTION__, + "VisitorInterest.getNumberOfVisitsPerPage" ); + + $view->setColumnsToDisplay( array(0,1) ); + $view->setSortedColumn( 'nb_visits' ); + $view->disableExcludeLowPopulation(); + $view->disableOffsetInformation(); + $view->disableSearchBox(); + $view->disableSort(); + $view->main(); + + return $this->renderView($view, $fetch); + } + + +} diff --git a/plugins/VisitorInterest/VisitorInterest.php b/plugins/VisitorInterest/VisitorInterest.php index 545113a3d6..ac54f2c8a1 100644 --- a/plugins/VisitorInterest/VisitorInterest.php +++ b/plugins/VisitorInterest/VisitorInterest.php @@ -159,4 +159,13 @@ class Piwik_VisitorInterest extends Piwik_Plugin // echo $table;
return $table; } -}
\ No newline at end of file +} + + + +Piwik_AddWidget( 'VisitorInterest', 'getNumberOfVisitsPerVisitDuration', 'Visits lengths'); +Piwik_AddWidget( 'VisitorInterest', 'getNumberOfVisitsPerPage', 'Pages per visit'); + +Piwik_AddMenu('General', 'Loyalty', array('module' => 'VisitorInterest')); + + diff --git a/plugins/VisitorInterest/index.tpl b/plugins/VisitorInterest/index.tpl new file mode 100644 index 0000000000..0b429fa0d8 --- /dev/null +++ b/plugins/VisitorInterest/index.tpl @@ -0,0 +1,5 @@ + + <h3>Visits per visit duration</h3> + {$dataTableNumberOfVisitsPerVisitDuration} + <h3>Visits per number of pages</h3> + {$dataTableNumberOfVisitsPerPage}
\ No newline at end of file diff --git a/plugins/VisitsSummary/VisitsSummary.php b/plugins/VisitsSummary/VisitsSummary.php index cefb46986b..88b0fe94b3 100644 --- a/plugins/VisitsSummary/VisitsSummary.php +++ b/plugins/VisitsSummary/VisitsSummary.php @@ -122,4 +122,4 @@ class Piwik_VisitsSummary_Controller extends Piwik_Controller Piwik_AddWidget( 'VisitsSummary', 'getLastVisitsGraph', 'Last visits graph'); Piwik_AddWidget( 'VisitsSummary', 'getLastUniqueVisitorsGraph', 'Last unique visitors graph'); -Piwik_AddMenu('Visits Summary', 'Overview', array('module' => 'VisitsSummary'));
\ No newline at end of file +Piwik_AddMenu('General', 'Overview', array('module' => 'VisitsSummary'));
\ No newline at end of file |