update Piwik to version 2.16 (fixes #91)

This commit is contained in:
oliver 2016-04-10 18:55:57 +02:00
commit d885a4baa9
5833 changed files with 418860 additions and 226988 deletions

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -9,12 +9,14 @@
namespace Piwik\Plugins\CoreHome\DataTableRowAction;
use Exception;
use Piwik\API\DataTablePostProcessor;
use Piwik\API\Request;
use Piwik\API\ResponseBuilder;
use Piwik\Common;
use Piwik\DataTable;
use Piwik\Date;
use Piwik\Metrics;
use Piwik\NumberFormatter;
use Piwik\Period\Factory as PeriodFactory;
use Piwik\Piwik;
use Piwik\Plugins\CoreVisualizations\Visualizations\JqplotGraph\Evolution as EvolutionViz;
use Piwik\Url;
@ -80,18 +82,21 @@ class RowEvolution
* @param null|string $graphType
* @throws Exception
*/
public function __construct($idSite, $date, $graphType = null)
public function __construct($idSite, $date, $graphType = 'graphEvolution')
{
$this->apiMethod = Common::getRequestVar('apiMethod', '', 'string');
if (empty($this->apiMethod)) throw new Exception("Parameter apiMethod not set.");
$this->label = ResponseBuilder::getLabelFromRequest($_GET);
$this->label = $this->label[0];
$this->label = DataTablePostProcessor::getLabelFromRequest($_GET);
if (!is_array($this->label)) {
throw new Exception("Expected label to be an array, got instead: " . $this->label);
}
$this->label = Common::unsanitizeInputValue($this->label[0]);
if ($this->label === '') throw new Exception("Parameter label not set.");
$this->period = Common::getRequestVar('period', '', 'string');
if (empty($this->period)) throw new Exception("Parameter period not set.");
PeriodFactory::checkPeriodIsEnabled($this->period);
$this->idSite = $idSite;
$this->graphType = $graphType;
@ -140,6 +145,7 @@ class RowEvolution
{
list($apiModule, $apiAction) = explode('.', $this->apiMethod);
// getQueryStringFromParameters expects sanitised query parameter values
$parameters = array(
'method' => 'API.getRowEvolution',
'label' => $this->label,
@ -194,7 +200,9 @@ class RowEvolution
$view->config->columns_to_display = array_keys($metrics ? : $this->graphMetrics);
}
$view->requestConfig->request_parameters_to_modify['label'] = '';
$view->config->show_goals = false;
$view->config->show_search = false;
$view->config->show_all_views_icons = false;
$view->config->show_active_view_icon = false;
$view->config->show_related_reports = false;
@ -224,7 +232,10 @@ class RowEvolution
$change = isset($metricData['change']) ? $metricData['change'] : false;
list($first, $last) = $this->getFirstAndLastDataPointsForMetric($metric);
$details = Piwik::translate('RowEvolution_MetricBetweenText', array($first, $last));
$details = Piwik::translate('RowEvolution_MetricBetweenText', array(
NumberFormatter::getInstance()->format($first),
NumberFormatter::getInstance()->format($last)
));
if ($change !== false) {
$lowerIsBetter = Metrics::isLowerValueBetter($metric);
@ -251,7 +262,11 @@ class RowEvolution
$min = isset($metricData['min']) ? $metricData['min'] : 0;
$min .= $unit;
$max .= $unit;
$minmax = Piwik::translate('RowEvolution_MetricMinMax', array($metricData['name'], $min, $max));
$minmax = Piwik::translate('RowEvolution_MetricMinMax', array(
$metricData['name'],
NumberFormatter::getInstance()->formatNumber($min),
NumberFormatter::getInstance()->formatNumber($max)
));
$newMetric = array(
'label' => $metricData['name'],
@ -263,6 +278,15 @@ class RowEvolution
if (!empty($metricData['logo'])) {
$newMetric['logo'] = $metricData['logo'];
}
// TODO: this check should be determined by metric metadata, not hardcoded here
if ($metric == 'nb_users'
&& $first == 0
&& $last == 0
) {
$newMetric['hide'] = true;
}
$metrics[] = $newMetric;
$i++;
}
@ -334,7 +358,7 @@ class RowEvolution
$labelPretty = $dataTableMap->getColumn('label_html');
$labelPretty = array_filter($labelPretty, 'strlen');
$labelPretty = current($labelPretty);
if(!empty($labelPretty)) {
if (!empty($labelPretty)) {
return $labelPretty;
}
return $rowLabel;