1
0
قرینه از https://github.com/matomo-org/matomo.git synced 2025-08-22 15:07:44 +00:00
Files
matomo/plugins/CoreHome/Columns/VisitIp.php
Michal Kleiner 9a3ef94df6 [Coding Style] Enable rule PSR12.Files.FileHeader + unify file headers (#22132)
* [Coding Style] Enable rule PSR12.Files.FileHeader

* Apply CS

* Replace Piwik with Matomo in file headers

* Unify file headers (position, no. of lines, https links)

* Rebuild dist files

* Apply CS

* Fix system test that relies on line numbers in a file that had the file header updated

---------

Co-authored-by: Stefan Giehl <stefan@matomo.org>
2024-04-20 20:50:47 +02:00

49 خطوط
1.7 KiB
PHP

<?php
/**
* Matomo - free/libre analytics platform
*
* @link https://matomo.org
* @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
namespace Piwik\Plugins\CoreHome\Columns;
use Piwik\Columns\DimensionSegmentFactory;
use Piwik\Common;
use Piwik\Metrics\Formatter;
use Matomo\Network\IPUtils;
use Piwik\Plugin\Dimension\VisitDimension;
use Piwik\Plugin\Segment;
use Piwik\Segment\SegmentsList;
/**
* Dimension for the log_visit.location_ip column. This column is added in the CREATE TABLE
* statement, so this dimension exists only to configure a segment.
*/
class VisitIp extends VisitDimension
{
protected $columnName = 'location_ip';
protected $type = self::TYPE_BINARY;
protected $allowAnonymous = false;
protected $segmentName = 'visitIp';
protected $nameSingular = 'General_VisitorIP';
protected $namePlural = 'General_VisitorIPs';
protected $acceptValues = '13.54.122.1. </code>Select IP ranges with notation: <code>visitIp>13.54.122.0;visitIp<13.54.122.255';
protected $sqlFilterValue = array('Matomo\Network\IPUtils', 'stringToBinaryIP');
public function formatValue($value, $idSite, Formatter $formatter)
{
$value = Common::hex2bin($value);
$value = IPUtils::binaryToStringIP($value);
return $value;
}
public function configureSegments(SegmentsList $segmentsList, DimensionSegmentFactory $dimensionSegmentFactory)
{
$segment = new Segment();
$segment->setType(Segment::TYPE_METRIC); // we cannot remove this for now as it would assign dimension based on text type
$segmentsList->addSegment($dimensionSegmentFactory->createSegment($segment));
}
}