| Server IP : 213.186.33.4 / Your IP : 216.73.216.193 Web Server : Apache System : Linux webm006.cluster103.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64 User : awebpaca ( 35430) PHP Version : 8.5.0 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/a/w/e/awebpaca/piwik/plugins/Goals/Columns/Metrics/ |
Upload File : |
<?php
/**
* Matomo - free/libre analytics platform
*
* @link https://matomo.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
namespace Piwik\Plugins\Goals\Columns\Metrics;
use Piwik\API\Request;
use Piwik\Common;
use Piwik\DataTable\Row;
use Piwik\Piwik;
use Piwik\Plugin\ProcessedMetric;
use Piwik\Tracker\GoalManager;
/**
* Base class for processed metrics that are calculated using metrics that are
* specific to certain goals.
*/
abstract class GoalSpecificProcessedMetric extends ProcessedMetric
{
/**
* The ID of the goal to calculate metrics for.
*
* @var int
*/
protected $idGoal;
/**
* The ID of the site the goal belongs to.
*
* @var int
*/
protected $idSite;
/**
* Constructor.
*
* @param int|null $idSite The ID of the site the goal belongs to. If supplied, affects the formatting
* and translated name of the metric.
* @param int $idGoal The ID of the goal to calculate metrics for.
*/
public function __construct($idSite, $idGoal)
{
$this->idSite = $idSite;
$this->idGoal = $idGoal;
}
protected function getGoalMetrics(Row $row)
{
$allGoalMetrics = $this->getMetric($row, 'goals');
if (isset($allGoalMetrics[$this->idGoal])) {
return $allGoalMetrics[$this->idGoal];
} else {
$alternateKey = 'idgoal=' . $this->idGoal;
if (isset($allGoalMetrics[$alternateKey])) {
return $allGoalMetrics[$alternateKey];
} elseif ($this->idGoal === Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER) {
$alternateKey = GoalManager::IDGOAL_ORDER;
if (isset($allGoalMetrics[$alternateKey])) {
return $allGoalMetrics[$alternateKey];
}
} elseif ($this->idGoal === Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_CART) {
$alternateKey = GoalManager::IDGOAL_CART;
if (isset($allGoalMetrics[$alternateKey])) {
return $allGoalMetrics[$alternateKey];
}
} else {
return array();
}
}
}
protected function getGoalName()
{
if ($this->idGoal == Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER) {
return Piwik::translate('Goals_EcommerceOrder');
} else if ($this->idGoal == Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_CART) {
return Piwik::translate('Goals_AbandonedCart');
}
if (isset($this->idSite)) {
$allGoals = Request::processRequest('Goals.getGoals', ['idSite' => $this->idSite, 'filter_limit' => '-1'], $default = []);
$goalName = @$allGoals[$this->idGoal]['name'];
return Common::sanitizeInputValue($goalName);
} else {
return "";
}
}
protected function getGoalNameForDocs()
{
$goalName = $this->getGoalName();
if ($goalName == Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER) {
$goalName = '"' . $goalName . '"';
}
return $goalName;
}
}