Skip to content

Commit

Permalink
moved some more dimensions to plugins, fixed some issues, removed som…
Browse files Browse the repository at this point in the history
…e more duplicated code etc. Tests will not be green as there fixes to country detection
  • Loading branch information
tsteur committed Jun 16, 2014
1 parent fccdcc0 commit 336cd45
Show file tree
Hide file tree
Showing 119 changed files with 1,515 additions and 825 deletions.
9 changes: 0 additions & 9 deletions core/Db/Schema/Mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,6 @@ public function getTablesCreateSql()
idvisit INTEGER(10) UNSIGNED NOT NULL AUTO_INCREMENT,
idsite INTEGER(10) UNSIGNED NOT NULL,
idvisitor BINARY(8) NOT NULL,
visitor_returning TINYINT(1) NOT NULL,
visit_total_time SMALLINT(5) UNSIGNED NOT NULL,
visit_goal_converted TINYINT(1) NOT NULL,
visit_goal_buyer TINYINT(1) NOT NULL,
visit_last_action_time DATETIME NOT NULL,
config_id BINARY(8) NOT NULL,
config_pdf TINYINT(1) NOT NULL,
Expand All @@ -165,11 +161,6 @@ public function getTablesCreateSql()
config_silverlight TINYINT(1) NOT NULL,
config_cookie TINYINT(1) NOT NULL,
location_ip VARBINARY(16) NOT NULL,
location_country CHAR(3) NOT NULL,
location_region char(2) DEFAULT NULL,
location_city varchar(255) DEFAULT NULL,
location_latitude float(10, 6) DEFAULT NULL,
location_longitude float(10, 6) DEFAULT NULL,
PRIMARY KEY(idvisit),
INDEX index_idsite_config_datetime (idsite, config_id, visit_last_action_time),
INDEX index_idsite_datetime (idsite, visit_last_action_time),
Expand Down
1 change: 1 addition & 0 deletions core/Plugin/ActionDimension.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

/**
* @api
* @since 2.4.0
*/
abstract class ActionDimension
{
Expand Down
1 change: 1 addition & 0 deletions core/Plugin/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* For an example, see the {@link https://github.com/piwik/piwik/blob/master/plugins/ExampleUI/Menu.php} plugin.
*
* @api
* @since 2.4.0
*/
class Menu
{
Expand Down
40 changes: 34 additions & 6 deletions core/Plugin/Report.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
use Piwik\WidgetsList;
use Piwik\ViewDataTable\Factory as ViewDataTableFactory;

/**
* @api
* @since 2.4.0
*/
class Report
{
protected $module;
Expand All @@ -28,6 +32,7 @@ class Report
protected $widgetParams = array();
protected $menuTitle;
protected $processedMetrics = array();
protected $hasGoalMetrics = false;
protected $metrics = array();
protected $constantRowsCount = null;
protected $isSubtableReport = null;
Expand Down Expand Up @@ -85,7 +90,7 @@ public function render()

$apiAction = $apiProxy->buildApiActionName($this->module, $this->action);

$view = ViewDataTableFactory::build(null, $apiAction, 'CoreHome.renderWidget');
$view = ViewDataTableFactory::build(null, $apiAction, 'CoreHome.renderMenuReport');
$rendered = $view->render();

return $rendered;
Expand Down Expand Up @@ -115,7 +120,7 @@ public function configureReportingMenu(MenuReporting $menu)
}
}

protected function getMetrics()
public function getMetrics()
{
// TODO cache this
$translations = Metrics::getDefaultMetricTranslations();
Expand Down Expand Up @@ -147,13 +152,18 @@ protected function getMetricsDocumentation()
return $documentation;
}

public function hasGoalMetrics()
{
return $this->hasGoalMetrics;
}

public function toArray()
{
$report = array(
'category' => Piwik::translate($this->category),
'name' => $this->name,
'module' => $this->module,
'action' => $this->action
'category' => $this->getCategory(),
'name' => $this->getName(),
'module' => $this->getModule(),
'action' => $this->getAction()
);

if (!empty($this->dimension)) {
Expand Down Expand Up @@ -185,6 +195,14 @@ public function toArray()
return $report;
}

/**
* @return Report[]
*/
public function getRelatedReports()
{
return array();
}

public function getName()
{
return $this->name;
Expand All @@ -195,6 +213,16 @@ public function getAction()
return $this->action;
}

public function getCategory()
{
return Piwik::translate($this->category);
}

public function getModule()
{
return $this->module;
}

public static function factory($module, $action = '')
{
foreach (self::getAllReports() as $report) {
Expand Down
3 changes: 2 additions & 1 deletion core/Plugin/Segment.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

/**
* @api
* @since 2.4.0
*/
class Segment
{
Expand Down Expand Up @@ -39,7 +40,7 @@ protected function init()
/**
* @param string $acceptValues
*/
public function setAcceptValues($acceptValues)
public function setAcceptedValues($acceptValues)
{
$this->acceptValues = $acceptValues;
}
Expand Down
16 changes: 16 additions & 0 deletions core/Plugin/ViewDataTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,22 @@ public function __construct($controllerAction, $apiMethodToRequestDataTable, $ov
$report = Report::factory($this->requestConfig->getApiModuleToRequest(), $this->requestConfig->getApiMethodToRequest());

if (!empty($report)) {
$this->config->subtable_controller_action = 'renderWidget';
$relatedReports = $report->getRelatedReports();
if (!empty($relatedReports)) {
foreach ($relatedReports as $relatedReport) {
$params = array('reportModule' => $relatedReport->getModule(), 'reportAction' => $relatedReport->getAction());
$this->config->addRelatedReport('CoreHome.renderWidget',
$relatedReport->getName(),
$params);
}
}

$metrics = $report->getMetrics();
if (!empty($metrics)) {
$this->config->addTranslations($metrics);
}

$report->configureView($this);
}

Expand Down
1 change: 1 addition & 0 deletions core/Plugin/VisitDimension.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

/**
* @api
* @since 2.4.0
*/
abstract class VisitDimension
{
Expand Down
1 change: 1 addition & 0 deletions core/Settings/SystemSetting.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class SystemSetting extends Setting
* readable by everyone.
*
* @var bool
* @since 2.4.0
*/
public $readableByCurrentUser = false;

Expand Down
30 changes: 5 additions & 25 deletions core/Tracker/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,11 @@ public function getParam($name)
return $value;
}

public function getParams()
{
return $this->params;
}

public function getCurrentTimestamp()
{
return $this->timestamp;
Expand Down Expand Up @@ -518,31 +523,6 @@ public function getForcedVisitorId()
return $this->forcedVisitorId;
}

public function overrideLocation(&$visitorInfo)
{
if (!$this->isAuthenticated()) {
return;
}

// check for location override query parameters (ie, lat, long, country, region, city)
static $locationOverrideParams = array(
'country' => array('string', 'location_country'),
'region' => array('string', 'location_region'),
'city' => array('string', 'location_city'),
'lat' => array('float', 'location_latitude'),
'long' => array('float', 'location_longitude'),
);
foreach ($locationOverrideParams as $queryParamName => $info) {
list($type, $visitorInfoKey) = $info;

$value = Common::getRequestVar($queryParamName, false, $type, $this->params);
if (!empty($value)) {
$visitorInfo[$visitorInfoKey] = $value;
}
}
return;
}

public function getPlugins()
{
static $pluginsInOrder = array('fla', 'java', 'dir', 'qt', 'realp', 'pdf', 'wma', 'gears', 'ag', 'cookie');
Expand Down
Loading

0 comments on commit 336cd45

Please sign in to comment.