diff --git a/Classes/Dashboard/Widgets/NewestPageviewsList.php b/Classes/Dashboard/Widgets/NewestPageviewsList.php
new file mode 100644
index 0000000..9984812
--- /dev/null
+++ b/Classes/Dashboard/Widgets/NewestPageviewsList.php
@@ -0,0 +1,102 @@
+
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+use DanielSiepmann\Tracking\Extension;
+use TYPO3\CMS\Core\Database\Connection;
+use TYPO3\CMS\Core\Database\Query\QueryBuilder;
+use TYPO3\CMS\Core\Utility\ArrayUtility;
+use TYPO3\CMS\Dashboard\Widgets\AbstractListWidget;
+
+class NewestPageviewsList extends AbstractListWidget
+{
+ protected $title = Extension::LANGUAGE_PATH . ':dashboard.widgets.newestPageviewsList.title';
+
+ protected $description = Extension::LANGUAGE_PATH . ':dashboard.widgets.newestPageviewsList.description';
+
+ protected $width = 2;
+
+ protected $height = 4;
+
+ /**
+ * @var QueryBuilder
+ */
+ protected $queryBuilder;
+
+ /**
+ * @var \ArrayObject
+ */
+ private $settings;
+
+ public function __construct(
+ string $identifier,
+ QueryBuilder $queryBuilder,
+ \ArrayObject $settings
+ ) {
+ parent::__construct($identifier);
+
+ $this->queryBuilder = $queryBuilder;
+ $this->settings = $settings;
+ }
+
+ public function renderWidgetContent(): string
+ {
+ $this->generateItems();
+ return parent::renderWidgetContent();
+ }
+
+ protected function generateItems(): void
+ {
+ $constraints = [];
+ if (count($this->settings['blackListedPages'])) {
+ $constraints[] = $this->queryBuilder->expr()->notIn(
+ 'tx_tracking_pageview.pid',
+ $this->queryBuilder->createNamedParameter(
+ $this->settings['blackListedPages'],
+ Connection::PARAM_INT_ARRAY
+ )
+ );
+ }
+
+ $this->queryBuilder
+ ->select('*')
+ ->from('tx_tracking_pageview')
+ ->orderBy('crdate desc')
+ ->setMaxResults($this->settings['maxResults']);
+
+ if ($constraints !== []) {
+ $this->queryBuilder->where(... $constraints);
+ }
+
+ $items = $this->queryBuilder->execute()->fetchAll();
+ foreach ($items as $item) {
+ $this->items[] = [
+ 'link' => $item['url'],
+ 'title' => sprintf(
+ '%s - %s',
+ $item['url'],
+ $item['user_agent']
+ ),
+ ];
+ }
+ }
+}
diff --git a/Classes/Dashboard/Widgets/SettingsFactory.php b/Classes/Dashboard/Widgets/SettingsFactory.php
index a51a849..0892d80 100644
--- a/Classes/Dashboard/Widgets/SettingsFactory.php
+++ b/Classes/Dashboard/Widgets/SettingsFactory.php
@@ -36,6 +36,10 @@ class SettingsFactory
'blackListedPages' => [],
'maxResults' => 6,
],
+ 'newestPageviewsList' => [
+ 'blackListedPages' => [],
+ 'maxResults' => 6,
+ ],
];
public function fromArray(string $widgetIdentifier, array $settings): \ArrayObject
diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml
index 245218d..64c4626 100644
--- a/Configuration/Services.yaml
+++ b/Configuration/Services.yaml
@@ -23,6 +23,13 @@ services:
arguments:
$widgetIdentifier: 'pageViewsPerPageDoughnut'
$settings: []
+ DanielSiepmann\Tracking\DI\Dashboard\Widgets\Settings\NewestPageviewsList:
+ factory:
+ - '@DanielSiepmann\Tracking\Dashboard\Widgets\SettingsFactory'
+ - 'fromArray'
+ arguments:
+ $widgetIdentifier: 'newestPageviewsList'
+ $settings: []
DanielSiepmann\Tracking\DI\DatabaseConnection\Pageview:
factory:
@@ -75,3 +82,14 @@ services:
- name: 'dashboard.widget'
identifier: 'pageViewsPerPageDoughnut'
widgetGroups: 'tracking'
+
+ DanielSiepmann\Tracking\Dashboard\Widgets\NewestPageviewsList:
+ class: 'DanielSiepmann\Tracking\Dashboard\Widgets\NewestPageviewsList'
+ arguments:
+ $identifier: 'newestPageviewsList'
+ $queryBuilder: '@DanielSiepmann\Tracking\DI\QueryBuilder\PageView'
+ $settings: '@DanielSiepmann\Tracking\DI\Dashboard\Widgets\Settings\NewestPageviewsList'
+ tags:
+ - name: 'dashboard.widget'
+ identifier: 'newestPageviewsList'
+ widgetGroups: 'tracking'
diff --git a/Resources/Private/Language/locallang.xlf b/Resources/Private/Language/locallang.xlf
index b1d2f3b..af57387 100644
--- a/Resources/Private/Language/locallang.xlf
+++ b/Resources/Private/Language/locallang.xlf
@@ -21,6 +21,12 @@
+
+
+
+
+
+