PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / 1.3.1
Matomo Analytics – Powerful, Privacy-First Insights for WordPress v1.3.1
5.11.1 5.11.0 5.10.2 5.10.1 trunk 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.3.2 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.1.0 4.1.1 4.1.2 4.1.3 4.10.0 4.11.0 4.12.0 4.13.0 4.13.2 4.13.3 4.13.4 4.13.5 4.14.0 4.14.1 4.14.2 4.15.0 4.15.1 4.15.2 4.15.3 4.2.0 4.3.0 4.3.1 4.4.1 4.4.2 4.5.0 4.6.0 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 5.0.8 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.1.7 5.10.0 5.2.0 5.2.1 5.2.2 5.3.0 5.3.1 5.3.2 5.3.3 5.6.0 5.6.1 5.7.0 5.7.1 5.8.0 5.8.1 5.8.2
matomo / app / core / ArchiveProcessor / Parameters.php
matomo / app / core / ArchiveProcessor Last commit date
ArchivingStatus.php 6 years ago Loader.php 6 years ago Parameters.php 6 years ago PluginsArchiver.php 6 years ago PluginsArchiverException.php 6 years ago Rules.php 6 years ago
Parameters.php
267 lines
1 <?php
2 /**
3 * Piwik - free/libre analytics platform
4 *
5 * @link https://matomo.org
6 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
7 *
8 */
9
10 namespace Piwik\ArchiveProcessor;
11
12 use Piwik\Date;
13 use Piwik\Log;
14 use Piwik\Period;
15 use Piwik\Piwik;
16 use Piwik\Segment;
17 use Piwik\Site;
18
19 /**
20 * Contains the analytics parameters for the reports that are currently being archived. The analytics
21 * parameters include the **website** the reports describe, the **period** of time the reports describe
22 * and the **segment** used to limit the visit set.
23 */
24 class Parameters
25 {
26 /**
27 * @var Site
28 */
29 private $site = null;
30
31 /**
32 * @var Period
33 */
34 private $period = null;
35
36 /**
37 * @var Segment
38 */
39 private $segment = null;
40
41 /**
42 * @var string Plugin name which triggered this archive processor
43 */
44 private $requestedPlugin = false;
45
46 private $onlyArchiveRequestedPlugin = false;
47
48 /**
49 * @var bool
50 */
51 private $isRootArchiveRequest = true;
52
53 /**
54 * Constructor.
55 *
56 * @ignore
57 */
58 public function __construct(Site $site, Period $period, Segment $segment)
59 {
60 $this->site = $site;
61 $this->period = $period;
62 $this->segment = $segment;
63 }
64
65 /**
66 * @ignore
67 */
68 public function setRequestedPlugin($plugin)
69 {
70 $this->requestedPlugin = $plugin;
71 }
72
73 /**
74 * @ignore
75 */
76 public function onlyArchiveRequestedPlugin()
77 {
78 $this->onlyArchiveRequestedPlugin = true;
79 }
80
81 /**
82 * @ignore
83 */
84 public function shouldOnlyArchiveRequestedPlugin()
85 {
86 return $this->onlyArchiveRequestedPlugin;
87 }
88
89 /**
90 * @ignore
91 */
92 public function getRequestedPlugin()
93 {
94 return $this->requestedPlugin;
95 }
96
97 /**
98 * Returns the period we are computing statistics for.
99 *
100 * @return Period
101 * @api
102 */
103 public function getPeriod()
104 {
105 return $this->period;
106 }
107
108 /**
109 * Returns the array of Period which make up this archive.
110 *
111 * @return \Piwik\Period[]
112 * @ignore
113 */
114 public function getSubPeriods()
115 {
116 if ($this->getPeriod()->getLabel() == 'day') {
117 return array( $this->getPeriod() );
118 }
119 return $this->getPeriod()->getSubperiods();
120 }
121
122 /**
123 * @return array
124 * @ignore
125 */
126 public function getIdSites()
127 {
128 $idSite = $this->getSite()->getId();
129
130 $idSites = array($idSite);
131
132 Piwik::postEvent('ArchiveProcessor.Parameters.getIdSites', array(&$idSites, $this->getPeriod()));
133
134 return $idSites;
135 }
136
137 /**
138 * Returns the site we are computing statistics for.
139 *
140 * @return Site
141 * @api
142 */
143 public function getSite()
144 {
145 return $this->site;
146 }
147
148 /**
149 * The Segment used to limit the set of visits that are being aggregated.
150 *
151 * @return Segment
152 * @api
153 */
154 public function getSegment()
155 {
156 return $this->segment;
157 }
158
159 /**
160 * Returns the end day of the period in the site's timezone.
161 *
162 * @return Date
163 */
164 public function getDateEnd()
165 {
166 return $this->getPeriod()->getDateEnd()->setTimezone($this->getSite()->getTimezone());
167 }
168
169 /**
170 * Returns the start day of the period in the site's timezone.
171 *
172 * @return Date
173 */
174 public function getDateStart()
175 {
176 return $this->getPeriod()->getDateStart()->setTimezone($this->getSite()->getTimezone());
177 }
178
179 /**
180 * Returns the start day of the period in the site's timezone (includes the time of day).
181 *
182 * @return Date
183 */
184 public function getDateTimeStart()
185 {
186 return $this->getPeriod()->getDateTimeStart()->setTimezone($this->getSite()->getTimezone());
187 }
188
189 /**
190 * Returns the end day of the period in the site's timezone (includes the time of day).
191 *
192 * @return Date
193 */
194 public function getDateTimeEnd()
195 {
196 return $this->getPeriod()->getDateTimeEnd()->setTimezone($this->getSite()->getTimezone());
197 }
198
199 /**
200 * @return bool
201 */
202 public function isSingleSiteDayArchive()
203 {
204 return $this->isDayArchive() && $this->isSingleSite();
205 }
206
207 /**
208 * @return bool
209 */
210 public function isDayArchive()
211 {
212 $period = $this->getPeriod();
213 $secondsInPeriod = $period->getDateEnd()->getTimestampUTC() - $period->getDateStart()->getTimestampUTC();
214 $oneDay = $secondsInPeriod < Date::NUM_SECONDS_IN_DAY;
215
216 return $oneDay;
217 }
218
219 public function isSingleSite()
220 {
221 return count($this->getIdSites()) == 1;
222 }
223
224 public function logStatusDebug()
225 {
226 $temporary = 'definitive archive';
227 Log::debug(
228 "%s archive, idSite = %d (%s), segment '%s', report = '%s', UTC datetime [%s -> %s]",
229 $this->getPeriod()->getLabel(),
230 $this->getSite()->getId(),
231 $temporary,
232 $this->getSegment()->getString(),
233 $this->getRequestedPlugin(),
234 $this->getDateStart()->getDateStartUTC(),
235 $this->getDateEnd()->getDateEndUTC()
236 );
237 }
238
239 /**
240 * Returns `true` if these parameters are part of an initial archiving request.
241 * Returns `false` if these parameters are for an archiving request that was initiated
242 * during archiving.
243 *
244 * @return bool
245 */
246 public function isRootArchiveRequest()
247 {
248 return $this->isRootArchiveRequest;
249 }
250
251 /**
252 * Sets whether these parameters are part of the initial archiving request or if they are
253 * for a request that was initiated during archiving.
254 *
255 * @param $isRootArchiveRequest
256 */
257 public function setIsRootArchiveRequest($isRootArchiveRequest)
258 {
259 $this->isRootArchiveRequest = $isRootArchiveRequest;
260 }
261
262 public function __toString()
263 {
264 return "[idSite = {$this->getSite()->getId()}, period = {$this->getPeriod()->getLabel()} {$this->getPeriod()->getRangeString()}, segment = {$this->getSegment()->getString()}]";
265 }
266 }
267