-
Notifications
You must be signed in to change notification settings - Fork 0
/
API.php
96 lines (84 loc) · 3.27 KB
/
API.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
/**
* Copyright (C) Piwik PRO - All rights reserved.
*
* Using this code requires that you first get a license from Piwik PRO.
* Unauthorized copying of this file, via any medium is strictly prohibited.
*
* @link http://piwik.pro
*/
namespace Piwik\Plugins\NewspaperReporting;
use Piwik\DataTable\Row;
use Piwik\Piwik;
use Piwik\Date;
use Piwik\DataTable;
use Piwik\Archive;
/**
* API for plugin NewspaperReporting
*
* @method static \Piwik\Plugins\NewspaperReporting\API getInstance()
*/
class API extends \Piwik\Plugin\API
{
protected function getDataTable($name, $idSite, $period, $date, $segment, $expanded, $flat, $idSubtable)
{
$dataTable = Archive::createDataTableFromArchive($name, $idSite, $period, $date, $segment, $expanded, $flat, $idSubtable);
$dataTable->queueFilter('ColumnDelete', 'nb_uniq_visitors');
$dataTable->queueFilter('ColumnCallbackReplace', array( 'label', function ($label) use ($name, $idSubtable) {
if ($name === Archiver::NEWSPAPERREPORTING_ARTICLE_ARCHIVE_RECORD || $idSubtable) {
return sprintf(Piwik::translate('NewspaperReporting_NArticle'), $label);
}
if ($name === Archiver::NEWSPAPERREPORTING_PAYWALL_ARCHIVE_RECORD) {
return sprintf(Piwik::translate('NewspaperReporting_NPaywall'), $label);
}
return Piwik::translate('VisitHoursEvenOdd_UnknownError');
}));
$dataTable->queueFilter('ReplaceColumnNames');
return $dataTable;
}
/**
* Another example method that returns a data table.
* @param int $idSite
* @param string $period
* @param string $date
* @param bool|string $segment
* @return DataTable
*/
public function getNewspaperReport($idSite, $period, $date, $segment = false)
{
Piwik::checkUserHasViewAccess($idSite);
$dataTable = $this->getDataTable(Archiver::NEWSPAPERREPORTING_PAYWALL_ARCHIVE_RECORD, $idSite, $period, $date, $segment, $expanded = false, $flat = false, $idSubtable = null);
$dataTable->applyQueuedFilters();
return $dataTable;
}
/**
* Another example method that returns a data table.
* @param int $idSite
* @param string $period
* @param string $date
* @param bool|string $segment
* @return DataTable
*/
public function getArticleReport($idSite, $period, $date, $segment = false)
{
Piwik::checkUserHasViewAccess($idSite);
$dataTable = $this->getDataTable(Archiver::NEWSPAPERREPORTING_ARTICLE_ARCHIVE_RECORD, $idSite, $period, $date, $segment, $expanded = false, $flat = false, $idSubtable = null);
$dataTable->applyQueuedFilters();
return $dataTable;
}
/**
* @param int $idSite
* @param string $period
* @param Date $date
* @param int $idSubtable
* @param string|bool $segment
* @param bool $_leavePriceViewedColumn
*
* @return DataTable|DataTable\Map
*/
public function getCustomVariablesValuesFromNameId($idSite, $period, $date, $idSubtable, $segment = false)
{
$dataTable = $this->getDataTable(Archiver::NEWSPAPERREPORTING_PAYWALL_ARCHIVE_RECORD, $idSite, $period, $date, $segment, $expanded = false, $flat = false, $idSubtable);
return $dataTable;
}
}