diff options
author | Thomas Steur <thomas.steur@googlemail.com> | 2014-06-13 11:59:45 +0400 |
---|---|---|
committer | Thomas Steur <thomas.steur@googlemail.com> | 2014-06-13 11:59:45 +0400 |
commit | fccdcc0c2c9416a283d35feb89fa689f9a32fcae (patch) | |
tree | 8157e7430be6d69c002aaee6ed65aff28360ed81 /plugins/CoreHome/Columns | |
parent | 83ee5a47ebf6227d7e0b898d506f230f07d9d815 (diff) |
moved more logic from core to plugins
Diffstat (limited to 'plugins/CoreHome/Columns')
-rw-r--r-- | plugins/CoreHome/Columns/VisitFirstActionTime.php | 36 | ||||
-rw-r--r-- | plugins/CoreHome/Columns/VisitLastActionTime.php | 53 | ||||
-rw-r--r-- | plugins/CoreHome/Columns/VisitorDaysSinceFirst.php | 45 | ||||
-rw-r--r-- | plugins/CoreHome/Columns/VisitorDaysSinceOrder.php | 41 | ||||
-rw-r--r-- | plugins/CoreHome/Columns/VisitsCount.php | 45 |
5 files changed, 220 insertions, 0 deletions
diff --git a/plugins/CoreHome/Columns/VisitFirstActionTime.php b/plugins/CoreHome/Columns/VisitFirstActionTime.php new file mode 100644 index 0000000000..e0b7078fb8 --- /dev/null +++ b/plugins/CoreHome/Columns/VisitFirstActionTime.php @@ -0,0 +1,36 @@ +<?php +/** + * Piwik - Open source web analytics + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + * + */ +namespace Piwik\Plugins\CoreHome\Columns; + +use Piwik\Plugin\VisitDimension; +use Piwik\Tracker\Action; +use Piwik\Tracker\Request; +use Piwik\Tracker; + +class VisitFirstActionTime extends VisitDimension +{ + protected $fieldName = 'visit_first_action_time'; + protected $fieldType = 'DATETIME NOT NULL'; + + public function getName() + { + return ''; + } + + /** + * @param Request $request + * @param array $visit + * @param Action|null $action + * @return int + */ + public function onNewVisit(Request $request, $visit, $action) + { + return Tracker::getDatetimeFromTimestamp($request->getCurrentTimestamp()); + } +}
\ No newline at end of file diff --git a/plugins/CoreHome/Columns/VisitLastActionTime.php b/plugins/CoreHome/Columns/VisitLastActionTime.php new file mode 100644 index 0000000000..5c45cb31a5 --- /dev/null +++ b/plugins/CoreHome/Columns/VisitLastActionTime.php @@ -0,0 +1,53 @@ +<?php +/** + * Piwik - Open source web analytics + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + * + */ +namespace Piwik\Plugins\CoreHome\Columns; + +use Piwik\Plugin\VisitDimension; +use Piwik\Tracker\Action; +use Piwik\Tracker\Request; +use Piwik\Tracker; + +class VisitLastActionTime extends VisitDimension +{ + protected $fieldName = 'visit_last_action_time'; + // we do not install or define column definition here as we need to create this column when installing as there is + // an index on it. Currently we do not define the index here... although we could overwrite the install() method + // and add column 'visit_last_action_time' and add index. Problem is there is also an index + // INDEX(idsite, config_id, visit_last_action_time) and we maybe not be sure whether config_id already exists at + // installing point (in case config_id is installed via dimension as well we do not know which column will be added + // first). + + public function getName() + { + return ''; + } + + /** + * @param Request $request + * @param array $visit + * @param Action|null $action + * @return int + */ + public function onNewVisit(Request $request, $visit, $action) + { + return Tracker::getDatetimeFromTimestamp($request->getCurrentTimestamp()); + } + + /** + * @param Request $request + * @param array $visit + * @param Action|null $action + * @return int + */ + public function onExistingVisit(Request $request, $visit, $action) + { + return $this->onNewVisit($request, $visit, $action); + } + +}
\ No newline at end of file diff --git a/plugins/CoreHome/Columns/VisitorDaysSinceFirst.php b/plugins/CoreHome/Columns/VisitorDaysSinceFirst.php new file mode 100644 index 0000000000..c418e6e764 --- /dev/null +++ b/plugins/CoreHome/Columns/VisitorDaysSinceFirst.php @@ -0,0 +1,45 @@ +<?php +/** + * Piwik - Open source web analytics + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + * + */ +namespace Piwik\Plugins\CoreHome\Columns; + +use Piwik\Plugin\VisitDimension; +use Piwik\Plugins\CoreHome\Segment; +use Piwik\Tracker\Action; +use Piwik\Tracker\Request; + +class VisitorDaysSinceFirst extends VisitDimension +{ + protected $fieldName = 'visitor_days_since_first'; + protected $fieldType = 'SMALLINT(5) UNSIGNED NOT NULL'; + + protected function init() + { + $segment = new Segment(); + $segment->setType(Segment::TYPE_METRIC); + $segment->setSegment('daysSinceFirstVisit'); + $segment->setName('General_DaysSinceFirstVisit'); + $this->addSegment($segment); + } + + public function getName() + { + return ''; + } + + /** + * @param Request $request + * @param array $visit + * @param Action|null $action + * @return int + */ + public function onNewVisit(Request $request, $visit, $action) + { + return $request->getDaysSinceFirstVisit(); + } +}
\ No newline at end of file diff --git a/plugins/CoreHome/Columns/VisitorDaysSinceOrder.php b/plugins/CoreHome/Columns/VisitorDaysSinceOrder.php new file mode 100644 index 0000000000..5597a426f7 --- /dev/null +++ b/plugins/CoreHome/Columns/VisitorDaysSinceOrder.php @@ -0,0 +1,41 @@ +<?php +/** + * Piwik - Open source web analytics + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + * + */ +namespace Piwik\Plugins\CoreHome\Columns; + +use Piwik\Plugin\VisitDimension; +use Piwik\Tracker\Action; +use Piwik\Tracker\Request; + +class VisitorDaysSinceOrder extends VisitDimension +{ + protected $fieldName = 'visitor_days_since_order'; + protected $fieldType = 'SMALLINT(5) UNSIGNED NOT NULL'; + + public function getName() + { + return ''; + } + + /** + * @param Request $request + * @param array $visit + * @param Action|null $action + * @return int + */ + public function onNewVisit(Request $request, $visit, $action) + { + $daysSinceLastOrder = $request->getDaysSinceLastOrder(); + + if ($daysSinceLastOrder === false) { + $daysSinceLastOrder = 0; + } + + return $daysSinceLastOrder; + } +}
\ No newline at end of file diff --git a/plugins/CoreHome/Columns/VisitsCount.php b/plugins/CoreHome/Columns/VisitsCount.php new file mode 100644 index 0000000000..6b900eefef --- /dev/null +++ b/plugins/CoreHome/Columns/VisitsCount.php @@ -0,0 +1,45 @@ +<?php +/** + * Piwik - Open source web analytics + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + * + */ +namespace Piwik\Plugins\CoreHome\Columns; + +use Piwik\Plugin\VisitDimension; +use Piwik\Plugins\CoreHome\Segment; +use Piwik\Tracker\Action; +use Piwik\Tracker\Request; + +class VisitsCount extends VisitDimension +{ + protected $fieldName = 'visitor_count_visits'; + protected $fieldType = 'SMALLINT(5) UNSIGNED NOT NULL'; + + public function getName() + { + return ''; + } + + protected function init() + { + $segment = new Segment(); + $segment->setType(Segment::TYPE_METRIC); + $segment->setSegment('visitCount'); + $segment->setName('General_NumberOfVisits'); + $this->addSegment($segment); + } + + /** + * @param Request $request + * @param array $visit + * @param Action|null $action + * @return int + */ + public function onNewVisit(Request $request, $visit, $action) + { + return $request->getVisitCount(); + } +}
\ No newline at end of file |