Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatt <matt@59fd770c-687e-43c8-a1e3-f5a4ff64c105>2008-12-17 20:26:15 +0300
committermatt <matt@59fd770c-687e-43c8-a1e3-f5a4ff64c105>2008-12-17 20:26:15 +0300
commit3966931ccc7f8b2a828ae704e3be1b9affcd1d81 (patch)
treee1b592d7358d3a01a1dc39cd8c3134d5ee551b2f /core/ViewDataTable.php
parent244fe1904bef08501f3c272d0214e4384019556f (diff)
- adding Goal Tracking related goodness in core, and plugins
- goal table icon below datatable that have goal segmentation - rss export icon below datatable - cleaning code, refactoring, renaming goodness - adding switch enable_detect_unique_visitor_using_settings that enables/disable heuristic based on config hash - refactoring how plugins handle archiving for more clarity
Diffstat (limited to 'core/ViewDataTable.php')
-rw-r--r--core/ViewDataTable.php142
1 files changed, 98 insertions, 44 deletions
diff --git a/core/ViewDataTable.php b/core/ViewDataTable.php
index c91a200e00..cc767a1337 100644
--- a/core/ViewDataTable.php
+++ b/core/ViewDataTable.php
@@ -93,13 +93,13 @@ abstract class Piwik_ViewDataTable
* @see init()
* @var string
*/
- protected $actionToLoadTheSubTable = null;
+ protected $controllerActionCalledWhenRequestSubTable = null;
/**
* @see init()
* @var string
*/
- protected $moduleNameAndMethod;
+ protected $apiMethodToRequestDataTable;
/**
* This view should be an implementation of the Interface Piwik_iView
@@ -197,6 +197,11 @@ abstract class Piwik_ViewDataTable
return new Piwik_ViewDataTable_HtmlTable_AllColumns();
break;
+ case 'tableGoals':
+ require_once "ViewDataTable/HtmlTable/Goals.php";
+ return new Piwik_ViewDataTable_HtmlTable_Goals();
+ break;
+
case 'table':
default:
require_once "ViewDataTable/HtmlTable.php";
@@ -208,42 +213,45 @@ abstract class Piwik_ViewDataTable
/**
* Inits the object given the $currentControllerName, $currentControllerAction of
* the calling controller action, eg. 'Referers' 'getLongListOfKeywords'.
- * The initialization also requires the $moduleNameAndMethod of the API method
+ * The initialization also requires the $apiMethodToRequestDataTable of the API method
* to call in order to get the DataTable, eg. 'Referers.getKeywords'.
- * The optional $actionToLoadTheSubTable defines the method name of the API to call when there is a idSubtable.
+ * The optional $controllerActionCalledWhenRequestSubTable defines the method name of the API to call when there is a idSubtable.
* This value would be used by the javascript code building the GET request to the API.
*
* Example:
* For the keywords listing, a click on the row loads the subTable of the Search Engines for this row.
- * In this case $actionToLoadTheSubTable = 'getSearchEnginesFromKeywordId'.
+ * In this case $controllerActionCalledWhenRequestSubTable = 'getSearchEnginesFromKeywordId'.
* The GET request will hit 'Referers.getSearchEnginesFromKeywordId'.
*
* @param string $currentControllerName eg. 'Referers'
* @param string $currentControllerAction eg. 'getKeywords'
- * @param string $moduleNameAndMethod eg. 'Referers.getKeywords'
- * @param string $actionToLoadTheSubTable eg. 'getSearchEnginesFromKeywordId'
+ * @param string $apiMethodToRequestDataTable eg. 'Referers.getKeywords'
+ * @param string $controllerActionCalledWhenRequestSubTable eg. 'getSearchEnginesFromKeywordId'
* @return void
*/
public function init( $currentControllerName,
$currentControllerAction,
- $moduleNameAndMethod,
- $actionToLoadTheSubTable = null)
+ $apiMethodToRequestDataTable,
+ $controllerActionCalledWhenRequestSubTable = null)
{
$this->currentControllerName = $currentControllerName;
$this->currentControllerAction = $currentControllerAction;
- $this->moduleNameAndMethod = $moduleNameAndMethod;
- $this->actionToLoadTheSubTable = $actionToLoadTheSubTable;
- $this->method = $moduleNameAndMethod;
+ $this->apiMethodToRequestDataTable = $apiMethodToRequestDataTable;
+ $this->controllerActionCalledWhenRequestSubTable = $controllerActionCalledWhenRequestSubTable;
$this->idSubtable = Piwik_Common::getRequestVar('idSubtable', false, 'int');
+ $this->viewProperties['show_goals'] = false;
$this->viewProperties['show_search'] = Piwik_Common::getRequestVar('show_search', true);
$this->viewProperties['show_table_all_columns'] = Piwik_Common::getRequestVar('show_table_all_columns', true);
$this->viewProperties['show_exclude_low_population'] = Piwik_Common::getRequestVar('show_exclude_low_population', true);
$this->viewProperties['show_offset_information'] = Piwik_Common::getRequestVar('show_offset_information', true);;
$this->viewProperties['show_footer'] = Piwik_Common::getRequestVar('show_footer', true);
$this->viewProperties['show_footer_icons'] = ($this->idSubtable == false);
+ $this->viewProperties['apiMethodToRequestDataTable'] = $this->apiMethodToRequestDataTable;
+ $this->viewProperties['uniqueId'] = $this->getUniqueIdViewDataTable();
}
+
/**
* Forces the View to use a given template.
* Usually the template to use is set in the specific ViewDataTable_*
@@ -274,6 +282,26 @@ abstract class Piwik_ViewDataTable
return $this->view;
}
+ public function getCurrentControllerAction()
+ {
+ return $this->currentControllerAction;
+ }
+
+ public function getCurrentControllerName()
+ {
+ return $this->currentControllerName;
+ }
+
+ public function getApiMethodToRequestDataTable()
+ {
+ return $this->apiMethodToRequestDataTable;
+ }
+
+ public function getControllerActionCalledWhenRequestSubTable()
+ {
+ return $this->controllerActionCalledWhenRequestSubTable;
+ }
+
/**
* Returns the DataTable loaded from the API
*
@@ -299,7 +327,7 @@ abstract class Piwik_ViewDataTable
protected function loadDataTableFromAPI()
{
// we build the request string (URL) to call the API
- $requestString = $this->getRequestString();
+ $requestString = $this->getRequestString();
// we make the request to the API
$request = new Piwik_API_Request($requestString);
@@ -319,7 +347,7 @@ abstract class Piwik_ViewDataTable
// we setup the method and format variable
// - we request the method to call to get this specific DataTable
// - the format = original specifies that we want to get the original DataTable structure itself, not rendered
- $requestString = 'method='.$this->moduleNameAndMethod;
+ $requestString = 'method='.$this->apiMethodToRequestDataTable;
$requestString .= '&format=original';
$toSetEventually = array(
@@ -384,7 +412,7 @@ abstract class Piwik_ViewDataTable
* @see datatable.js
* @return string
*/
- protected function getUniqIdTable()
+ protected function getUniqueIdViewDataTable()
{
// if we request a subDataTable the $this->currentControllerAction DIV ID is already there in the page
// we make the DIV ID really unique by appending the ID of the subtable requested
@@ -477,13 +505,25 @@ abstract class Piwik_ViewDataTable
$javascriptVariablesToSet[$name] = $value;
}
}
-
+
+ if($this->dataTable instanceof Piwik_DataTable)
+ {
+ // we override the filter_sort_column with the column used for sorting,
+ // which can be different from the one specified (eg. if the column doesn't exist)
+ $javascriptVariablesToSet['filter_sort_column'] = $this->dataTable->getSortedByColumnName();
+ // datatable can return "2" but we want to write "nb_visits" in the js
+ if(isset(Piwik_Archive::$mappingFromIdToName[$javascriptVariablesToSet['filter_sort_column']]))
+ {
+ $javascriptVariablesToSet['filter_sort_column'] = Piwik_Archive::$mappingFromIdToName[$javascriptVariablesToSet['filter_sort_column']];
+ }
+ }
+
$javascriptVariablesToSet['module'] = $this->currentControllerName;
$javascriptVariablesToSet['action'] = $this->currentControllerAction;
$javascriptVariablesToSet['viewDataTable'] = $this->getViewDataTableId();
- if(!is_null($this->actionToLoadTheSubTable))
+ if(!is_null($this->controllerActionCalledWhenRequestSubTable))
{
- $javascriptVariablesToSet['actionToLoadTheSubTable'] = $this->actionToLoadTheSubTable;
+ $javascriptVariablesToSet['controllerActionCalledWhenRequestSubTable'] = $this->controllerActionCalledWhenRequestSubTable;
}
if($this->dataTable)
@@ -496,16 +536,27 @@ abstract class Piwik_ViewDataTable
// are loaded with Piwik_Common::getRequestVar()
foreach($javascriptVariablesToSet as &$value)
{
- if(is_array($value))
- {
- $value = array_map('addslashes',$value);
- }
- else
- {
+ if(is_array($value))
+ {
+ $value = array_map('addslashes',$value);
+ }
+ else
+ {
$value = addslashes($value);
}
- }
+ }
+ $deleteFromJavascriptVariables = array(
+ 'filter_excludelowpop',
+ 'filter_excludelowpop_value',
+ );
+ foreach($deleteFromJavascriptVariables as $name)
+ {
+ if(isset($javascriptVariablesToSet[$name]))
+ {
+ unset($javascriptVariablesToSet[$name]);
+ }
+ }
return $javascriptVariablesToSet;
}
@@ -605,18 +656,27 @@ abstract class Piwik_ViewDataTable
$this->viewProperties['show_table_all_columns'] = false;
}
- /**
- * Sets the pattern to look for in the table (only rows with column equal to the pattern will be kept)
- *
- * @param array $pattern arrays of patterns to look for
- * @param string $column to compare the pattern to
- * @return void
- */
- public function setExactPattern($pattern, $column)
- {
- $this->variablesDefault['filter_exact_pattern'] = $pattern;
- $this->variablesDefault['filter_exact_column'] = $column;
- }
+ /**
+ * Whether or not to show the "goal" icon
+ * @return void
+ */
+ public function enableShowGoals()
+ {
+ $this->viewProperties['show_goals'] = true;
+ }
+
+ /**
+ * Sets the pattern to look for in the table (only rows with column equal to the pattern will be kept)
+ *
+ * @param array $pattern arrays of patterns to look for
+ * @param string $column to compare the pattern to
+ * @return void
+ */
+ public function setExactPattern($pattern, $column)
+ {
+ $this->variablesDefault['filter_exact_pattern'] = $pattern;
+ $this->variablesDefault['filter_exact_column'] = $column;
+ }
/**
* Sets the value to use for the Exclude low population filter.
@@ -625,18 +685,12 @@ abstract class Piwik_ViewDataTable
* @param string The name of the column for which we compare the value to $minValue
* @return void
*/
- public function setExcludeLowPopulation( $minValue = null, $columnName = null )
+ public function setExcludeLowPopulation( $columnName = null, $minValue = null )
{
- if( is_null( $minValue) )
- {
- throw new Exception("setExcludeLowPopulation() value shouldn't be null");
- }
-
if(is_null($columnName))
{
$columnName = Piwik_Archive::INDEX_NB_VISITS;
}
-
$this->variablesDefault['filter_excludelowpop'] = $columnName;
$this->variablesDefault['filter_excludelowpop_value'] = $minValue;
}