Zwischenstand
This commit is contained in:
parent
bb12a00ef5
commit
95b29228a0
@ -2,6 +2,9 @@
|
||||
|
||||
namespace WapplerSystems\BookmarksLikesRatings\Domain\Repository;
|
||||
|
||||
use TYPO3\CMS\Core\Database\ConnectionPool;
|
||||
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Extbase\Persistence\QueryInterface;
|
||||
use WapplerSystems\BookmarksLikesRatings\Domain\Model\Rating;
|
||||
use WapplerSystems\BookmarksLikesRatings\Domain\Model\Vote;
|
||||
@ -52,6 +55,25 @@ class BookmarkRepository extends Repository
|
||||
}
|
||||
|
||||
|
||||
public function getTop($limit)
|
||||
{
|
||||
|
||||
/** @var QueryBuilder $queryBuilder */
|
||||
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tx_bookmarkslikesratings_domain_model_bookmark');
|
||||
|
||||
return $queryBuilder
|
||||
->select('tablename')
|
||||
->addSelect('object_uid')
|
||||
->addSelectLiteral('count(*) as number')
|
||||
->from('tx_bookmarkslikesratings_domain_model_bookmark')
|
||||
->groupBy('tablename')
|
||||
->addGroupBy('object_uid')
|
||||
->orderBy('number', 'DESC')
|
||||
->setMaxResults($limit)
|
||||
->execute()->fetchAll();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialize this repository
|
||||
*/
|
||||
|
51
Classes/Widgets/Provider/TopBookmarksDataProvider.php
Normal file
51
Classes/Widgets/Provider/TopBookmarksDataProvider.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
namespace WapplerSystems\BookmarksLikesRatings\Widgets\Provider;
|
||||
|
||||
use TYPO3\CMS\Backend\Utility\BackendUtility;
|
||||
use WapplerSystems\BookmarksLikesRatings\Domain\Repository\BookmarkRepository;
|
||||
|
||||
class TopBookmarksDataProvider
|
||||
{
|
||||
|
||||
/** @var BookmarkRepository */
|
||||
protected $bookmarkRepository;
|
||||
|
||||
public function injectBookmarkRepository(BookmarkRepository $bookmarkRepository) {
|
||||
$this->bookmarkRepository = $bookmarkRepository;
|
||||
}
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public function getItems()
|
||||
{
|
||||
|
||||
$objs = $this->bookmarkRepository->getTop(10);
|
||||
|
||||
$items = [];
|
||||
|
||||
foreach ($objs as $obj) {
|
||||
$title = '';
|
||||
if ($obj['tablename'] === 'pages') {
|
||||
|
||||
$page = BackendUtility::getRecord('pages',$obj['object_uid'],'title');
|
||||
if ($page) {
|
||||
$title = $page['title'];
|
||||
}
|
||||
}
|
||||
$items[] = [
|
||||
'title' => $title,
|
||||
'number' => $obj['number']
|
||||
];
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
}
|
@ -6,7 +6,6 @@ declare(strict_types=1);
|
||||
namespace WapplerSystems\BookmarksLikesRatings\Widgets\Provider;
|
||||
|
||||
use TYPO3\CMS\Backend\Utility\BackendUtility;
|
||||
use TYPO3\CMS\Core\Utility\DebugUtility;
|
||||
use WapplerSystems\BookmarksLikesRatings\Domain\Repository\LikeRepository;
|
||||
|
||||
class TopLikesDataProvider
|
||||
@ -16,7 +15,7 @@ class TopLikesDataProvider
|
||||
protected $likeRepository;
|
||||
|
||||
/**
|
||||
* @param \WapplerSystems\BookmarksLikesRatings\Domain\Repository\LikeRepository $bookmarkRepository
|
||||
* @param \WapplerSystems\BookmarksLikesRatings\Domain\Repository\LikeRepository $likeRepository
|
||||
*/
|
||||
public function injectLikeRepository(LikeRepository $likeRepository) {
|
||||
$this->likeRepository = $likeRepository;
|
||||
|
65
Classes/Widgets/TopBookmarksWidget.php
Normal file
65
Classes/Widgets/TopBookmarksWidget.php
Normal file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace WapplerSystems\BookmarksLikesRatings\Widgets;
|
||||
|
||||
use TYPO3\CMS\Dashboard\Widgets\ButtonProviderInterface;
|
||||
use TYPO3\CMS\Dashboard\Widgets\WidgetConfigurationInterface;
|
||||
use TYPO3\CMS\Dashboard\Widgets\WidgetInterface;
|
||||
use TYPO3\CMS\Fluid\View\StandaloneView;
|
||||
use WapplerSystems\BookmarksLikesRatings\Widgets\Provider\TopBookmarksDataProvider;
|
||||
|
||||
class TopBookmarksWidget implements WidgetInterface
|
||||
{
|
||||
/**
|
||||
* @var WidgetConfigurationInterface
|
||||
*/
|
||||
private $configuration;
|
||||
|
||||
/**
|
||||
* @var StandaloneView
|
||||
*/
|
||||
private $view;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $options;
|
||||
/**
|
||||
* @var ButtonProviderInterface|null
|
||||
*/
|
||||
private $buttonProvider;
|
||||
|
||||
/**
|
||||
* @var TopBookmarksDataProvider
|
||||
*/
|
||||
private $dataProvider;
|
||||
|
||||
public function __construct(
|
||||
WidgetConfigurationInterface $configuration,
|
||||
TopBookmarksDataProvider $dataProvider,
|
||||
StandaloneView $view,
|
||||
$buttonProvider = null,
|
||||
array $options = []
|
||||
)
|
||||
{
|
||||
$this->configuration = $configuration;
|
||||
$this->view = $view;
|
||||
$this->options = $options;
|
||||
$this->buttonProvider = $buttonProvider;
|
||||
$this->dataProvider = $dataProvider;
|
||||
}
|
||||
|
||||
public function renderWidgetContent(): string
|
||||
{
|
||||
$this->view->setTemplate('TopBookmarksWidget');
|
||||
$this->view->assignMultiple([
|
||||
'items' => $this->dataProvider->getItems(),
|
||||
'options' => $this->options,
|
||||
'button' => $this->buttonProvider,
|
||||
'configuration' => $this->configuration,
|
||||
]);
|
||||
return $this->view->render();
|
||||
}
|
||||
|
||||
}
|
@ -7,10 +7,25 @@ services:
|
||||
$dataProvider: '@WapplerSystems\BookmarksLikesRatings\Widgets\Provider\TopLikesDataProvider'
|
||||
tags:
|
||||
- name: dashboard.widget
|
||||
identifier: 'bookmarks_likes_ratings'
|
||||
identifier: 'bookmarks_likes_ratings_likes'
|
||||
groupNames: 'ratings'
|
||||
title: 'LLL:EXT:bookmarks_likes_ratings/Resources/Private/Language/locallang.xlf:widgets.bookmarks_likes_ratings.topLikes.title'
|
||||
description: 'LLL:EXT:bookmarks_likes_ratings/Resources/Private/Language/locallang.xlf:widgets.bookmarks_likes_ratings.topLikes.description'
|
||||
iconIdentifier: 'content-widget-text'
|
||||
height: 'large'
|
||||
width: 'medium'
|
||||
|
||||
dashboard.widget.bookmarkslikesratingsTopBookmarks:
|
||||
class: 'WapplerSystems\BookmarksLikesRatings\Widgets\TopBookmarksWidget'
|
||||
arguments:
|
||||
$view: '@dashboard.views.widget'
|
||||
$dataProvider: '@WapplerSystems\BookmarksLikesRatings\Widgets\Provider\TopBookmarksDataProvider'
|
||||
tags:
|
||||
- name: dashboard.widget
|
||||
identifier: 'bookmarks_likes_ratings_bookmarks'
|
||||
groupNames: 'ratings'
|
||||
title: 'LLL:EXT:bookmarks_likes_ratings/Resources/Private/Language/locallang.xlf:widgets.bookmarks_likes_ratings.topBookmarks.title'
|
||||
description: 'LLL:EXT:bookmarks_likes_ratings/Resources/Private/Language/locallang.xlf:widgets.bookmarks_likes_ratings.topBookmarks.description'
|
||||
iconIdentifier: 'content-widget-text'
|
||||
height: 'large'
|
||||
width: 'medium'
|
||||
|
@ -6,13 +6,15 @@
|
||||
<body>
|
||||
|
||||
|
||||
|
||||
<trans-unit id="widget_group.ratings">
|
||||
<source>Ratings</source>
|
||||
</trans-unit>
|
||||
<trans-unit id="widgets.bookmarks_likes_ratings.topLikes.title">
|
||||
<source>Top likes</source>
|
||||
</trans-unit>
|
||||
<trans-unit id="widgets.bookmarks_likes_ratings.topBookmarks.title">
|
||||
<source>Top bookmarks</source>
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
||||
|
@ -0,0 +1,24 @@
|
||||
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">
|
||||
<f:layout name="Widget/Widget" />
|
||||
<f:section name="main">
|
||||
|
||||
<div class="widget-table-wrapper">
|
||||
<table class="widget-table">
|
||||
<f:for each="{items}" as="item">
|
||||
<tr>
|
||||
<td>
|
||||
<p>{item.title -> f:format.crop(maxCharacters: 180)}</p>
|
||||
</td>
|
||||
<td>
|
||||
{item.number}
|
||||
</td>
|
||||
</tr>
|
||||
</f:for>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</f:section>
|
||||
<f:section name="footer">
|
||||
|
||||
</f:section>
|
||||
</html>
|
@ -15,7 +15,7 @@ $EM_CONF[$_EXTKEY] = [
|
||||
'author_email' => 'typo3@wappler.systems',
|
||||
'author_company' => 'WapplerSystems',
|
||||
'version' => '0.0.0',
|
||||
'state' => 'stable',
|
||||
'state' => 'alpha',
|
||||
'uploadfolder' => 0,
|
||||
'createDirs' => '',
|
||||
'modify_tables' => '',
|
||||
|
Loading…
Reference in New Issue
Block a user