Db
5 years ago
Handler
5 years ago
TableLogAction
5 years ago
Visit
5 years ago
Action.php
5 years ago
ActionPageview.php
5 years ago
Cache.php
5 years ago
Db.php
5 years ago
Failures.php
6 years ago
FingerprintSalt.php
6 years ago
GoalManager.php
5 years ago
Handler.php
5 years ago
IgnoreCookie.php
5 years ago
LogTable.php
5 years ago
Model.php
5 years ago
PageUrl.php
5 years ago
Request.php
5 years ago
RequestProcessor.php
5 years ago
RequestSet.php
5 years ago
Response.php
5 years ago
ScheduledTasksRunner.php
5 years ago
Settings.php
5 years ago
TableLogAction.php
5 years ago
TrackerCodeGenerator.php
5 years ago
TrackerConfig.php
5 years ago
Visit.php
5 years ago
VisitExcluded.php
5 years ago
VisitInterface.php
5 years ago
Visitor.php
5 years ago
VisitorNotFoundInDb.php
5 years ago
VisitorRecognizer.php
5 years ago
ActionPageview.php
96 lines
| 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 |