Db
2 years ago
Handler
2 years ago
Visit
2 years ago
Action.php
2 years ago
ActionPageview.php
2 years ago
Cache.php
2 years ago
Db.php
2 years ago
Failures.php
2 years ago
FingerprintSalt.php
2 years ago
GoalManager.php
2 years ago
Handler.php
2 years ago
IgnoreCookie.php
2 years ago
LogTable.php
2 years ago
Model.php
2 years ago
PageUrl.php
2 years ago
Request.php
2 years ago
RequestProcessor.php
2 years ago
RequestSet.php
2 years ago
Response.php
2 years ago
ScheduledTasksRunner.php
2 years ago
Settings.php
2 years ago
TableLogAction.php
2 years ago
TrackerCodeGenerator.php
2 years ago
TrackerConfig.php
2 years ago
Visit.php
2 years ago
VisitExcluded.php
2 years ago
VisitInterface.php
2 years ago
Visitor.php
2 years ago
VisitorNotFoundInDb.php
2 years ago
VisitorRecognizer.php
2 years ago
ActionPageview.php
77 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Matomo - free/libre analytics platform |
| 5 | * |
| 6 | * @link https://matomo.org |
| 7 | * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later |
| 8 | * |
| 9 | */ |
| 10 | namespace Piwik\Tracker; |
| 11 | |
| 12 | use Piwik\Config; |
| 13 | /** |
| 14 | * This class represents a page view, tracking URL, page title and generation time. |
| 15 | * |
| 16 | */ |
| 17 | class ActionPageview extends \Piwik\Tracker\Action |
| 18 | { |
| 19 | public function __construct(\Piwik\Tracker\Request $request) |
| 20 | { |
| 21 | parent::__construct(\Piwik\Tracker\Action::TYPE_PAGE_URL, $request); |
| 22 | $url = $request->getParam('url'); |
| 23 | $this->setActionUrl($url); |
| 24 | $actionName = $request->getParam('action_name'); |
| 25 | $actionName = $this->cleanupActionName($actionName); |
| 26 | $this->setActionName($actionName); |
| 27 | } |
| 28 | protected function getActionsToLookup() |
| 29 | { |
| 30 | return array('idaction_name' => array($this->getActionName(), \Piwik\Tracker\Action::TYPE_PAGE_TITLE), 'idaction_url' => $this->getUrlAndType()); |
| 31 | } |
| 32 | public static function shouldHandle(\Piwik\Tracker\Request $request) |
| 33 | { |
| 34 | return !\Piwik\Tracker\Action::isCustomActionRequest($request); |
| 35 | } |
| 36 | public function getIdActionUrlForEntryAndExitIds() |
| 37 | { |
| 38 | return $this->getIdActionUrl(); |
| 39 | } |
| 40 | public function getIdActionNameForEntryAndExitIds() |
| 41 | { |
| 42 | return $this->getIdActionName(); |
| 43 | } |
| 44 | private function cleanupActionName($actionName) |
| 45 | { |
| 46 | // get the delimiter, by default '/'; BC, we read the old action_category_delimiter first (see #1067) |
| 47 | $actionCategoryDelimiter = $this->getActionCategoryDelimiter(); |
| 48 | if ($actionCategoryDelimiter === '') { |
| 49 | return $actionName; |
| 50 | } |
| 51 | // create an array of the categories delimited by the delimiter |
| 52 | $split = explode($actionCategoryDelimiter, $actionName); |
| 53 | $split = $this->trimEveryCategory($split); |
| 54 | $split = $this->removeEmptyCategories($split); |
| 55 | return $this->rebuildNameOfCleanedCategories($actionCategoryDelimiter, $split); |
| 56 | } |
| 57 | private function rebuildNameOfCleanedCategories($actionCategoryDelimiter, $split) |
| 58 | { |
| 59 | return implode($actionCategoryDelimiter, $split); |
| 60 | } |
| 61 | private function removeEmptyCategories($split) |
| 62 | { |
| 63 | return array_filter($split, 'strlen'); |
| 64 | } |
| 65 | private function trimEveryCategory($split) |
| 66 | { |
| 67 | return array_map('trim', $split); |
| 68 | } |
| 69 | private function getActionCategoryDelimiter() |
| 70 | { |
| 71 | if (isset(Config::getInstance()->General['action_category_delimiter'])) { |
| 72 | return Config::getInstance()->General['action_category_delimiter']; |
| 73 | } |
| 74 | return Config::getInstance()->General['action_title_category_delimiter']; |
| 75 | } |
| 76 | } |
| 77 |