Welcome to mirror list, hosted at ThFree Co, Russian Federation.

ActionPageview.php « Tracker « core - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9088fc543a19a52e9033e7705137f2e805946716 (plain)
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
<?php
/**
 * Piwik - free/libre analytics platform
 *
 * @link http://piwik.org
 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 *
 */

namespace Piwik\Tracker;

use Piwik\Config;
use Piwik\Tracker;

/**
 * This class represents a page view, tracking URL, page title and generation time.
 *
 */
class ActionPageview extends Action
{
    protected $timeGeneration = false;

    function __construct(Request $request)
    {
        parent::__construct(Action::TYPE_PAGE_URL, $request);

        $url = $request->getParam('url');
        $this->setActionUrl($url);

        $actionName = $request->getParam('action_name');
        $actionName = $this->cleanupActionName($actionName);
        $this->setActionName($actionName);

        $this->timeGeneration = $this->request->getPageGenerationTime();
    }

    protected function getActionsToLookup()
    {
        return array(
            'idaction_name' => array($this->getActionName(), Action::TYPE_PAGE_TITLE),
            'idaction_url'  => $this->getUrlAndType()
        );
    }

    public function getCustomFloatValue()
    {
        return $this->request->getPageGenerationTime();
    }

    public static function shouldHandle(Request $request)
    {
        return true;
    }

    private function cleanupActionName($actionName)
    {
        // get the delimiter, by default '/'; BC, we read the old action_category_delimiter first (see #1067)
        $actionCategoryDelimiter = $this->getActionCategoryDelimiter();

        // create an array of the categories delimited by the delimiter
        $split = explode($actionCategoryDelimiter, $actionName);
        $split = $this->trimEveryCategory($split);
        $split = $this->removeEmptyCategories($split);

        return $this->rebuildNameOfCleanedCategories($actionCategoryDelimiter, $split);
    }

    private function rebuildNameOfCleanedCategories($actionCategoryDelimiter, $split)
    {
        return implode($actionCategoryDelimiter, $split);
    }

    private function removeEmptyCategories($split)
    {
        return array_filter($split, 'strlen');
    }

    private function trimEveryCategory($split)
    {
        return array_map('trim', $split);
    }

    private function getActionCategoryDelimiter()
    {
        if (isset(Config::getInstance()->General['action_category_delimiter'])) {
            return Config::getInstance()->General['action_category_delimiter'];
        }

        return Config::getInstance()->General['action_url_category_delimiter'];
    }

}