Db
6 years ago
Handler
6 years ago
TableLogAction
6 years ago
Visit
6 years ago
Action.php
6 years ago
ActionPageview.php
6 years ago
Cache.php
6 years ago
Db.php
6 years ago
Failures.php
6 years ago
FingerprintSalt.php
6 years ago
GoalManager.php
6 years ago
Handler.php
6 years ago
IgnoreCookie.php
6 years ago
LogTable.php
6 years ago
Model.php
6 years ago
PageUrl.php
6 years ago
Request.php
5 years ago
RequestProcessor.php
6 years ago
RequestSet.php
6 years ago
Response.php
6 years ago
ScheduledTasksRunner.php
6 years ago
Settings.php
5 years ago
TableLogAction.php
6 years ago
TrackerCodeGenerator.php
6 years ago
TrackerConfig.php
6 years ago
Visit.php
5 years ago
VisitExcluded.php
6 years ago
VisitInterface.php
6 years ago
Visitor.php
6 years ago
VisitorNotFoundInDb.php
6 years ago
VisitorRecognizer.php
6 years ago
ActionPageview.php
105 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\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 | protected $timeGeneration = false; |
| 21 | |
| 22 | public function __construct(Request $request) |
| 23 | { |
| 24 | parent::__construct(Action::TYPE_PAGE_URL, $request); |
| 25 | |
| 26 | $url = $request->getParam('url'); |
| 27 | $this->setActionUrl($url); |
| 28 | |
| 29 | $actionName = $request->getParam('action_name'); |
| 30 | $actionName = $this->cleanupActionName($actionName); |
| 31 | $this->setActionName($actionName); |
| 32 | |
| 33 | $this->timeGeneration = $this->request->getPageGenerationTime(); |
| 34 | } |
| 35 | |
| 36 | protected function getActionsToLookup() |
| 37 | { |
| 38 | return array( |
| 39 | 'idaction_name' => array($this->getActionName(), Action::TYPE_PAGE_TITLE), |
| 40 | 'idaction_url' => $this->getUrlAndType() |
| 41 | ); |
| 42 | } |
| 43 | |
| 44 | public function getCustomFloatValue() |
| 45 | { |
| 46 | return $this->request->getPageGenerationTime(); |
| 47 | } |
| 48 | |
| 49 | public static function shouldHandle(Request $request) |
| 50 | { |
| 51 | return true; |
| 52 | } |
| 53 | |
| 54 | public function getIdActionUrlForEntryAndExitIds() |
| 55 | { |
| 56 | return $this->getIdActionUrl(); |
| 57 | } |
| 58 | |
| 59 | public function getIdActionNameForEntryAndExitIds() |
| 60 | { |
| 61 | return $this->getIdActionName(); |
| 62 | } |
| 63 | |
| 64 | private function cleanupActionName($actionName) |
| 65 | { |
| 66 | // get the delimiter, by default '/'; BC, we read the old action_category_delimiter first (see #1067) |
| 67 | $actionCategoryDelimiter = $this->getActionCategoryDelimiter(); |
| 68 | |
| 69 | if ($actionCategoryDelimiter === '') { |
| 70 | return $actionName; |
| 71 | } |
| 72 | |
| 73 | // create an array of the categories delimited by the delimiter |
| 74 | $split = explode($actionCategoryDelimiter, $actionName); |
| 75 | $split = $this->trimEveryCategory($split); |
| 76 | $split = $this->removeEmptyCategories($split); |
| 77 | |
| 78 | return $this->rebuildNameOfCleanedCategories($actionCategoryDelimiter, $split); |
| 79 | } |
| 80 | |
| 81 | private function rebuildNameOfCleanedCategories($actionCategoryDelimiter, $split) |
| 82 | { |
| 83 | return implode($actionCategoryDelimiter, $split); |
| 84 | } |
| 85 | |
| 86 | private function removeEmptyCategories($split) |
| 87 | { |
| 88 | return array_filter($split, 'strlen'); |
| 89 | } |
| 90 | |
| 91 | private function trimEveryCategory($split) |
| 92 | { |
| 93 | return array_map('trim', $split); |
| 94 | } |
| 95 | |
| 96 | private function getActionCategoryDelimiter() |
| 97 | { |
| 98 | if (isset(Config::getInstance()->General['action_category_delimiter'])) { |
| 99 | return Config::getInstance()->General['action_category_delimiter']; |
| 100 | } |
| 101 | |
| 102 | return Config::getInstance()->General['action_title_category_delimiter']; |
| 103 | } |
| 104 | } |
| 105 |