PluginProbe
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / 4.15.0
Matomo Analytics – Powerful, Privacy-First Insights for WordPress v4.15.0
5.13.0 5.12.1 5.12.0 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 All 83 releases
matomo / app / core / Tracker / ActionPageview.php
ActionPageview.php
96 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Matomo - 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\Tracker;
11
12 use Piwik\Config;
13
14 /**
15 * This class represents a page view, tracking URL, page title and generation time.
16 *
17 */
18 class ActionPageview extends Action
19 {
20 public function __construct(Request $request)
21 {
22 parent::__construct(Action::TYPE_PAGE_URL, $request);
23
24 $url = $request->getParam('url');
25 $this->setActionUrl($url);
26
27 $actionName = $request->getParam('action_name');
28 $actionName = $this->cleanupActionName($actionName);
29 $this->setActionName($actionName);
30 }
31
32 protected function getActionsToLookup()
33 {
34 return array(
35 'idaction_name' => array($this->getActionName(), Action::TYPE_PAGE_TITLE),
36 'idaction_url' => $this->getUrlAndType()
37 );
38 }
39
40 public static function shouldHandle(Request $request)
41 {
42 return !Action::isCustomActionRequest($request);
43 }
44
45 public function getIdActionUrlForEntryAndExitIds()
46 {
47 return $this->getIdActionUrl();
48 }
49
50 public function getIdActionNameForEntryAndExitIds()
51 {
52 return $this->getIdActionName();
53 }
54
55 private function cleanupActionName($actionName)
56 {
57 // get the delimiter, by default '/'; BC, we read the old action_category_delimiter first (see #1067)
58 $actionCategoryDelimiter = $this->getActionCategoryDelimiter();
59
60 if ($actionCategoryDelimiter === '') {
61 return $actionName;
62 }
63
64 // create an array of the categories delimited by the delimiter
65 $split = explode($actionCategoryDelimiter, $actionName);
66 $split = $this->trimEveryCategory($split);
67 $split = $this->removeEmptyCategories($split);
68
69 return $this->rebuildNameOfCleanedCategories($actionCategoryDelimiter, $split);
70 }
71
72 private function rebuildNameOfCleanedCategories($actionCategoryDelimiter, $split)
73 {
74 return implode($actionCategoryDelimiter, $split);
75 }
76
77 private function removeEmptyCategories($split)
78 {
79 return array_filter($split, 'strlen');
80 }
81
82 private function trimEveryCategory($split)
83 {
84 return array_map('trim', $split);
85 }
86
87 private function getActionCategoryDelimiter()
88 {
89 if (isset(Config::getInstance()->General['action_category_delimiter'])) {
90 return Config::getInstance()->General['action_category_delimiter'];
91 }
92
93 return Config::getInstance()->General['action_title_category_delimiter'];
94 }
95 }
96