Zwischenstand
This commit is contained in:
parent
ce6b9e38dc
commit
508d3d2759
41
Classes/Controller/AbstractController.php
Normal file
41
Classes/Controller/AbstractController.php
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
namespace WapplerSystems\BookmarksLikesRatings\Controller;
|
||||||
|
|
||||||
|
use TYPO3\CMS\Frontend\Exception;
|
||||||
|
use WapplerSystems\BookmarksLikesRatings\Domain\Repository\BookmarkRepository;
|
||||||
|
use WapplerSystems\BookmarksLikesRatings\Domain\Repository\LikeRepository;
|
||||||
|
|
||||||
|
class AbstractController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
|
||||||
|
|
||||||
|
|
||||||
|
/** @var BookmarkRepository */
|
||||||
|
protected $bookmarkRepository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \WapplerSystems\BookmarksLikesRatings\Domain\Repository\BookmarkRepository $bookmarkRepository
|
||||||
|
*/
|
||||||
|
public function injectBookmarkRepository(BookmarkRepository $bookmarkRepository) {
|
||||||
|
$this->bookmarkRepository = $bookmarkRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** @var LikeRepository */
|
||||||
|
protected $likeRepository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \WapplerSystems\BookmarksLikesRatings\Domain\Repository\LikeRepository $bookmarkRepository
|
||||||
|
*/
|
||||||
|
public function injectLikeRepository(LikeRepository $likeRepository) {
|
||||||
|
$this->likeRepository = $likeRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected function getCurrentUser() : array {
|
||||||
|
if (!$GLOBALS['TSFE']->fe_user) {
|
||||||
|
throw new Exception('no access');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $GLOBALS['TSFE']->fe_user->user;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
132
Classes/Controller/BookmarkController.php
Normal file
132
Classes/Controller/BookmarkController.php
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace WapplerSystems\BookmarksLikesRatings\Controller;
|
||||||
|
|
||||||
|
use TYPO3\CMS\Backend\Utility\BackendUtility;
|
||||||
|
use TYPO3\CMS\Core\Utility\DebugUtility;
|
||||||
|
use TYPO3\CMS\Extbase\Mvc\View\JsonView;
|
||||||
|
use WapplerSystems\BookmarksLikesRatings\Domain\Model\Bookmark;
|
||||||
|
use WapplerSystems\BookmarksLikesRatings\Domain\Model\Bookmarks;
|
||||||
|
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plugin controller
|
||||||
|
*/
|
||||||
|
class BookmarkController extends AbstractController
|
||||||
|
{
|
||||||
|
|
||||||
|
public function initializeStatusAction()
|
||||||
|
{
|
||||||
|
$this->defaultViewObjectName = JsonView::class;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $objectUid
|
||||||
|
* @param string $tablename
|
||||||
|
* @throws \TYPO3\CMS\Frontend\Exception
|
||||||
|
*/
|
||||||
|
public function statusAction(int $objectUid,string $tablename) {
|
||||||
|
|
||||||
|
$user = $this->getCurrentUser();
|
||||||
|
|
||||||
|
$this->view->setVariablesToRender(['status']);
|
||||||
|
$this->view->assignMultiple([
|
||||||
|
'status' => ['status' => $this->bookmarkRepository->countByUserTablenameObjectUid($user['uid'],$tablename,$objectUid) === 0? 'false':'true']
|
||||||
|
]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function initializeToggleAction()
|
||||||
|
{
|
||||||
|
$this->defaultViewObjectName = JsonView::class;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $objectUid
|
||||||
|
* @param string $tablename
|
||||||
|
* @throws \TYPO3\CMS\Frontend\Exception
|
||||||
|
*/
|
||||||
|
public function toggleAction(int $objectUid, string $tablename)
|
||||||
|
{
|
||||||
|
|
||||||
|
$user = $this->getCurrentUser();
|
||||||
|
|
||||||
|
$this->view->setVariablesToRender(['status']);
|
||||||
|
|
||||||
|
if ($this->bookmarkRepository->countByUserTablenameObjectUid($user['uid'], $tablename, $objectUid) === 0) {
|
||||||
|
|
||||||
|
$bookmark = new Bookmark();
|
||||||
|
$bookmark->setUser($user['uid']);
|
||||||
|
$bookmark->setTablename($tablename);
|
||||||
|
$bookmark->setObjectUid($objectUid);
|
||||||
|
|
||||||
|
$this->bookmarkRepository->add($bookmark);
|
||||||
|
|
||||||
|
$this->view->assignMultiple([
|
||||||
|
'status' => ['status' => 'true']
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
$this->bookmarkRepository->removeByUserTablenameObjectUid($user['uid'], $tablename, $objectUid);
|
||||||
|
|
||||||
|
$this->view->assignMultiple([
|
||||||
|
'status' => ['status' => 'false']
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $objectUid
|
||||||
|
* @param string $tablename
|
||||||
|
* @throws \TYPO3\CMS\Frontend\Exception
|
||||||
|
*/
|
||||||
|
public function deleteAction(int $objectUid, string $tablename)
|
||||||
|
{
|
||||||
|
|
||||||
|
$user = $this->getCurrentUser();
|
||||||
|
$this->bookmarkRepository->removeByUserTablenameObjectUid($user['uid'], $tablename, $objectUid);
|
||||||
|
$this->forward('personalList');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public function personalListAction()
|
||||||
|
{
|
||||||
|
|
||||||
|
$user = $this->getCurrentUser();
|
||||||
|
|
||||||
|
$bookmarks = [];
|
||||||
|
|
||||||
|
$objs = $this->bookmarkRepository->findByUser($user['uid']);
|
||||||
|
|
||||||
|
/** @var Bookmark $obj */
|
||||||
|
foreach ($objs as $obj) {
|
||||||
|
$bookmark = [];
|
||||||
|
$bookmark['tablename'] = $obj->getTablename();
|
||||||
|
$bookmark['object_uid'] = $obj->getObjectUid();
|
||||||
|
|
||||||
|
if ($obj->getTablename() === 'pages') {
|
||||||
|
|
||||||
|
$page = BackendUtility::getRecord('pages',$obj->getObjectUid(),'title');
|
||||||
|
if ($page) {
|
||||||
|
|
||||||
|
$bookmark['title'] = $page['title'];
|
||||||
|
$bookmark['url'] = $this->uriBuilder->reset()->setTargetPageUid($obj->getObjectUid())->buildFrontendUri();
|
||||||
|
}
|
||||||
|
|
||||||
|
$bookmarks[] = $bookmark;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->view->assignMultiple([
|
||||||
|
'bookmarks' => $bookmarks
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -1,109 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the package buepro/bookmark_pages.
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please read the
|
|
||||||
* LICENSE file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace WapplerSystems\BookmarksLikesRatings\Controller;
|
|
||||||
|
|
||||||
use WapplerSystems\BookmarksLikesRatings\Model\Bookmark;
|
|
||||||
use WapplerSystems\BookmarksLikesRatings\Model\Bookmarks;
|
|
||||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
|
||||||
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Plugin controller
|
|
||||||
*/
|
|
||||||
class BookmarksController extends ActionController
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* display bookmarks list
|
|
||||||
*/
|
|
||||||
public function indexAction()
|
|
||||||
{
|
|
||||||
$bookmark = Bookmark::createFromCurrent();
|
|
||||||
$this->view->assignMultiple([
|
|
||||||
'bookmark' => $bookmark->toArray()
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds the current page as bookmark and renders/returns updated list as html
|
|
||||||
*
|
|
||||||
* This is meant to be called by ajax (typoscript_rendering)
|
|
||||||
*
|
|
||||||
* @param array $localBookmarks
|
|
||||||
*/
|
|
||||||
public function bookmarkAction($localBookmarks = [])
|
|
||||||
{
|
|
||||||
// use the parameter directly and ignore chash because url is submitted by JS
|
|
||||||
$url = GeneralUtility::_GP('url');
|
|
||||||
$url = $url ? $url : null;
|
|
||||||
|
|
||||||
$bookmark = Bookmark::createFromCurrent($url);
|
|
||||||
|
|
||||||
$bookmarks = new Bookmarks();
|
|
||||||
$bookmarks->merge($localBookmarks);
|
|
||||||
$bookmarks->addBookmark($bookmark);
|
|
||||||
$bookmarks->persist();
|
|
||||||
|
|
||||||
$this->updateAndSendList($bookmarks);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove a bookmark from list and renders/returns updated list as html
|
|
||||||
*
|
|
||||||
* This is meant to be called by ajax (typoscript_rendering)
|
|
||||||
*
|
|
||||||
* @param string $id
|
|
||||||
* @param array $localBookmarks
|
|
||||||
*/
|
|
||||||
public function deleteAction($id = '', $localBookmarks = [])
|
|
||||||
{
|
|
||||||
$bookmarks = new Bookmarks();
|
|
||||||
$bookmarks->merge($localBookmarks);
|
|
||||||
if ($id) {
|
|
||||||
$bookmarks->removeBookmark($id);
|
|
||||||
$bookmarks->persist();
|
|
||||||
}
|
|
||||||
$this->updateAndSendList($bookmarks);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Action to get bookmark list
|
|
||||||
*
|
|
||||||
* @param array $localBookmarks
|
|
||||||
*/
|
|
||||||
public function listEntriesAction($localBookmarks = [])
|
|
||||||
{
|
|
||||||
$bookmarks = new Bookmarks();
|
|
||||||
$bookmarks->merge($localBookmarks);
|
|
||||||
$this->updateAndSendList($bookmarks);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This is for ajax requests
|
|
||||||
*
|
|
||||||
* @param Bookmarks $bookmarks
|
|
||||||
*/
|
|
||||||
public function updateAndSendList(Bookmarks $bookmarks)
|
|
||||||
{
|
|
||||||
// check if we bookmarked the current page
|
|
||||||
$bookmark = Bookmark::createFromCurrent();
|
|
||||||
$isBookmarked = $bookmarks->bookmarkExists($bookmark);
|
|
||||||
|
|
||||||
// build the ajax response data
|
|
||||||
$response = [
|
|
||||||
'isBookmarked' => $isBookmarked,
|
|
||||||
'bookmarks' => $bookmarks->getBookmarksForLocalStorage()
|
|
||||||
];
|
|
||||||
|
|
||||||
header('Content-Type: application/json');
|
|
||||||
echo json_encode($response);
|
|
||||||
die();
|
|
||||||
}
|
|
||||||
}
|
|
1368
Classes/Controller/LikeController.php
Normal file
1368
Classes/Controller/LikeController.php
Normal file
File diff suppressed because it is too large
Load Diff
@ -10,13 +10,26 @@
|
|||||||
namespace WapplerSystems\BookmarksLikesRatings\Domain\Model;
|
namespace WapplerSystems\BookmarksLikesRatings\Domain\Model;
|
||||||
|
|
||||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||||
|
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class Bookmark
|
class Bookmark extends AbstractEntity
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/** @var int */
|
||||||
|
protected $user;
|
||||||
|
|
||||||
|
/** @var string */
|
||||||
|
protected $tablename;
|
||||||
|
|
||||||
|
/** @var int */
|
||||||
|
protected $objectUid;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
@ -29,15 +42,64 @@ class Bookmark
|
|||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $url;
|
protected $url;
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
protected $pid;
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $parameter;
|
protected $parameter;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getUser(): int
|
||||||
|
{
|
||||||
|
return $this->user;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $user
|
||||||
|
*/
|
||||||
|
public function setUser(int $user): void
|
||||||
|
{
|
||||||
|
$this->user = $user;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getTablename(): string
|
||||||
|
{
|
||||||
|
return $this->tablename;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $tablename
|
||||||
|
*/
|
||||||
|
public function setTablename(string $tablename): void
|
||||||
|
{
|
||||||
|
$this->tablename = $tablename;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getObjectUid(): int
|
||||||
|
{
|
||||||
|
return $this->objectUid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $objectUid
|
||||||
|
*/
|
||||||
|
public function setObjectUid(int $objectUid): void
|
||||||
|
{
|
||||||
|
$this->objectUid = $objectUid;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bookmark constructor.
|
* Bookmark constructor.
|
||||||
* Initialize the bookmark with data
|
* Initialize the bookmark with data
|
||||||
@ -47,7 +109,7 @@ class Bookmark
|
|||||||
* @param null $pid page id
|
* @param null $pid page id
|
||||||
* @param null $parameter
|
* @param null $parameter
|
||||||
*/
|
*/
|
||||||
public function __construct($url, $title = null, $pid = null, $parameter = null)
|
public function construct2($url, $title = null, $pid = null, $parameter = null)
|
||||||
{
|
{
|
||||||
if (is_array($url)) {
|
if (is_array($url)) {
|
||||||
$this->id = $url['id'];
|
$this->id = $url['id'];
|
||||||
@ -169,22 +231,6 @@ class Bookmark
|
|||||||
$this->url = $url;
|
$this->url = $url;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function getPid()
|
|
||||||
{
|
|
||||||
return $this->pid;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param int $pid
|
|
||||||
*/
|
|
||||||
public function setPid($pid)
|
|
||||||
{
|
|
||||||
$this->pid = $pid;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
73
Classes/Domain/Model/Like.php
Normal file
73
Classes/Domain/Model/Like.php
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace WapplerSystems\BookmarksLikesRatings\Domain\Model;
|
||||||
|
|
||||||
|
|
||||||
|
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class Like extends AbstractEntity
|
||||||
|
{
|
||||||
|
|
||||||
|
/** @var int */
|
||||||
|
protected $user;
|
||||||
|
|
||||||
|
/** @var string */
|
||||||
|
protected $tablename;
|
||||||
|
|
||||||
|
/** @var int */
|
||||||
|
protected $objectUid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getUser(): int
|
||||||
|
{
|
||||||
|
return $this->user;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $user
|
||||||
|
*/
|
||||||
|
public function setUser(int $user): void
|
||||||
|
{
|
||||||
|
$this->user = $user;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getTablename(): string
|
||||||
|
{
|
||||||
|
return $this->tablename;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $tablename
|
||||||
|
*/
|
||||||
|
public function setTablename(string $tablename): void
|
||||||
|
{
|
||||||
|
$this->tablename = $tablename;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getObjectUid(): int
|
||||||
|
{
|
||||||
|
return $this->objectUid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $objectUid
|
||||||
|
*/
|
||||||
|
public function setObjectUid(int $objectUid): void
|
||||||
|
{
|
||||||
|
$this->objectUid = $objectUid;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
130
Classes/Domain/Repository/BookmarkRepository.php
Normal file
130
Classes/Domain/Repository/BookmarkRepository.php
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace WapplerSystems\BookmarksLikesRatings\Domain\Repository;
|
||||||
|
|
||||||
|
use TYPO3\CMS\Extbase\Persistence\QueryInterface;
|
||||||
|
use WapplerSystems\BookmarksLikesRatings\Domain\Model\Rating;
|
||||||
|
use WapplerSystems\BookmarksLikesRatings\Domain\Model\Vote;
|
||||||
|
use WapplerSystems\BookmarksLikesRatings\Domain\Model\Voter;
|
||||||
|
use TYPO3\CMS\Extbase\Persistence\Repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
class BookmarkRepository extends Repository
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
public function countByUserTablenameObjectUid($userUid, $tablename, $objectUid)
|
||||||
|
{
|
||||||
|
$query = $this->createQuery();
|
||||||
|
|
||||||
|
return $query->matching(
|
||||||
|
$query->logicalAnd(
|
||||||
|
[
|
||||||
|
$query->equals('user', $userUid),
|
||||||
|
$query->equals('tablename', $tablename),
|
||||||
|
$query->equals('objectUid', $objectUid)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
)->execute()->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function removeByUserTablenameObjectUid($userUid, $tablename, $objectUid)
|
||||||
|
{
|
||||||
|
$query = $this->createQuery();
|
||||||
|
|
||||||
|
$objs = $query->matching(
|
||||||
|
$query->logicalAnd(
|
||||||
|
[
|
||||||
|
$query->equals('user', $userUid),
|
||||||
|
$query->equals('tablename', $tablename),
|
||||||
|
$query->equals('objectUid', $objectUid)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
)->execute()->toArray();
|
||||||
|
|
||||||
|
foreach ($objs as $obj) {
|
||||||
|
$this->remove($obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize this repository
|
||||||
|
*/
|
||||||
|
public function initializeObject(): void
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds the voting by giving the rating and voter objects
|
||||||
|
*
|
||||||
|
* @param Rating|null $rating The concerned ratingobject
|
||||||
|
* @param Voter|null $voter The Uid of the rated row
|
||||||
|
* @return Vote|object The voting
|
||||||
|
*/
|
||||||
|
public function findMatchingRatingAndVoter($rating = null, $voter = null)
|
||||||
|
{
|
||||||
|
/** @var QueryInterface $query */
|
||||||
|
$query = $this->createQuery();
|
||||||
|
|
||||||
|
return $query->matching(
|
||||||
|
$query->logicalAnd(
|
||||||
|
[
|
||||||
|
$query->equals('rating', $rating),
|
||||||
|
$query->equals('voter', $voter)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
)->execute()->getFirst();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Counts all votings by giving the rating and ratingstep
|
||||||
|
*
|
||||||
|
* @param Rating $rating The concerned ratingobject
|
||||||
|
* @param \WapplerSystems\BookmarksLikesRatings\Domain\Model\Stepconf $stepconf The stepconf object
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function countByMatchingRatingAndVote($rating = null, $stepconf = null): int
|
||||||
|
{
|
||||||
|
$query = $this->createQuery();
|
||||||
|
$query->matching($query->logicalAnd(
|
||||||
|
[
|
||||||
|
$query->equals('rating', $rating->getUid()),
|
||||||
|
$query->equals('vote', $stepconf->getUid())
|
||||||
|
]
|
||||||
|
));
|
||||||
|
|
||||||
|
return count($query->execute());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Counts all anonymous votings by giving the rating and ratingstep
|
||||||
|
*
|
||||||
|
* @param Rating $rating The concerned ratingobject
|
||||||
|
* @param \WapplerSystems\BookmarksLikesRatings\Domain\Model\Stepconf $stepconf The stepconf object
|
||||||
|
* @param int $anonymousVoter UID of the anonymous account
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function countAnonymousByMatchingRatingAndVote($rating = null, $stepconf = null, $anonymousVoter = null): int
|
||||||
|
{
|
||||||
|
/** @var int $count */
|
||||||
|
$count = 0;
|
||||||
|
|
||||||
|
if ($anonymousVoter !== null) {
|
||||||
|
$query = $this->createQuery();
|
||||||
|
$query->matching(
|
||||||
|
$query->logicalAnd([
|
||||||
|
$query->equals('rating', $rating->getUid()),
|
||||||
|
$query->equals('vote', $stepconf->getUid()),
|
||||||
|
$query->equals('voter', $anonymousVoter),
|
||||||
|
])
|
||||||
|
);
|
||||||
|
$count = count($query->execute());
|
||||||
|
}
|
||||||
|
|
||||||
|
return $count;
|
||||||
|
}
|
||||||
|
}
|
75
Classes/Domain/Repository/LikeRepository.php
Normal file
75
Classes/Domain/Repository/LikeRepository.php
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace WapplerSystems\BookmarksLikesRatings\Domain\Repository;
|
||||||
|
|
||||||
|
use TYPO3\CMS\Core\Database\ConnectionPool;
|
||||||
|
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
|
||||||
|
use TYPO3\CMS\Core\Utility\DebugUtility;
|
||||||
|
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||||
|
use WapplerSystems\BookmarksLikesRatings\Domain\Model\Rating;
|
||||||
|
use WapplerSystems\BookmarksLikesRatings\Domain\Model\Vote;
|
||||||
|
use WapplerSystems\BookmarksLikesRatings\Domain\Model\Voter;
|
||||||
|
use TYPO3\CMS\Extbase\Persistence\Repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
class LikeRepository extends Repository
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
public function countByUserTablenameObjectUid($userUid, $tablename, $objectUid)
|
||||||
|
{
|
||||||
|
$query = $this->createQuery();
|
||||||
|
|
||||||
|
return $query->matching(
|
||||||
|
$query->logicalAnd(
|
||||||
|
[
|
||||||
|
$query->equals('user', $userUid),
|
||||||
|
$query->equals('tablename', $tablename),
|
||||||
|
$query->equals('objectUid', $objectUid)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
)->execute()->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function removeByUserTablenameObjectUid($userUid, $tablename, $objectUid)
|
||||||
|
{
|
||||||
|
$query = $this->createQuery();
|
||||||
|
|
||||||
|
$objs = $query->matching(
|
||||||
|
$query->logicalAnd(
|
||||||
|
[
|
||||||
|
$query->equals('user', $userUid),
|
||||||
|
$query->equals('tablename', $tablename),
|
||||||
|
$query->equals('objectUid', $objectUid)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
)->execute()->toArray();
|
||||||
|
|
||||||
|
foreach ($objs as $obj) {
|
||||||
|
$this->remove($obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function getTop($limit)
|
||||||
|
{
|
||||||
|
|
||||||
|
/** @var QueryBuilder $queryBuilder */
|
||||||
|
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tx_bookmarkslikesratings_domain_model_like');
|
||||||
|
|
||||||
|
return $queryBuilder
|
||||||
|
->select('tablename')
|
||||||
|
->addSelect('object_uid')
|
||||||
|
->addSelectLiteral('count(*) as number')
|
||||||
|
->from('tx_bookmarkslikesratings_domain_model_like')
|
||||||
|
->groupBy('tablename')
|
||||||
|
->addGroupBy('object_uid')
|
||||||
|
->orderBy('number', 'DESC')
|
||||||
|
->setMaxResults($limit)
|
||||||
|
->execute()->fetchAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
245
Classes/ViewHelpers/Bookmark2ViewHelper.php
Normal file
245
Classes/ViewHelpers/Bookmark2ViewHelper.php
Normal file
@ -0,0 +1,245 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the package thucke/th-rating.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please read the
|
||||||
|
* LICENSE file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace WapplerSystems\BookmarksLikesRatings\ViewHelpers;
|
||||||
|
|
||||||
|
use TYPO3\CMS\Core\Log\LogLevel;
|
||||||
|
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||||
|
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
|
||||||
|
use TYPO3\CMS\Extbase\Object\ObjectManager;
|
||||||
|
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
|
||||||
|
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
|
||||||
|
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
|
||||||
|
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||||
|
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class Bookmark2ViewHelper extends AbstractViewHelper
|
||||||
|
{
|
||||||
|
use CompileWithRenderStatic;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable escaping of this node's output
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
protected $escapeOutput = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @noinspection PhpUnnecessaryFullyQualifiedNameInspection
|
||||||
|
* @var \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController
|
||||||
|
* contains a backup of the current['TSFE'] if used in BE mode
|
||||||
|
*/
|
||||||
|
protected static $tsfeBackup;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @noinspection PhpFullyQualifiedNameUsageInspection
|
||||||
|
* @var \TYPO3\CMS\Core\Log\Logger $logger
|
||||||
|
*/
|
||||||
|
protected $logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $typoScriptSetup;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @noinspection PhpUnnecessaryFullyQualifiedNameInspection
|
||||||
|
* @var \WapplerSystems\BookmarksLikesRatings\Service\ExtensionHelperService
|
||||||
|
*/
|
||||||
|
protected $extensionHelperService;
|
||||||
|
|
||||||
|
public function initializeArguments(): void
|
||||||
|
{
|
||||||
|
$this->registerArgument('action', 'string', 'The rating action');
|
||||||
|
$this->registerArgument('ratetable', 'string', 'The rating tablename');
|
||||||
|
$this->registerArgument('ratefield', 'string', 'The rating fieldname');
|
||||||
|
$this->registerArgument('ratedobjectuid', 'integer', 'The ratingobject uid', true);
|
||||||
|
$this->registerArgument('ratingobject', 'integer', 'The ratingobject');
|
||||||
|
$this->registerArgument('display', 'string', 'The display configuration');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renders the ratingView
|
||||||
|
*
|
||||||
|
* @param array $arguments
|
||||||
|
* @param \Closure $renderChildrenClosure
|
||||||
|
* @param RenderingContextInterface $renderingContext
|
||||||
|
* @return mixed
|
||||||
|
* @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception
|
||||||
|
* @noinspection PhpFullyQualifiedNameUsageInspection
|
||||||
|
*/
|
||||||
|
public static function renderStatic(
|
||||||
|
array $arguments,
|
||||||
|
\Closure $renderChildrenClosure,
|
||||||
|
RenderingContextInterface $renderingContext
|
||||||
|
) {
|
||||||
|
$typoscriptObjectPath = 'plugin.tx_thrating';
|
||||||
|
$ratedobjectuid = $arguments['ratedobjectuid'];
|
||||||
|
$action = $arguments['action'];
|
||||||
|
$ratingobject = $arguments['ratingobject'];
|
||||||
|
$ratetable = $arguments['ratetable'];
|
||||||
|
$ratefield = $arguments['ratefield'];
|
||||||
|
$display = $arguments['display'];
|
||||||
|
$extensionHelperService = static::getExtensionHelperService();
|
||||||
|
$contentObjectRenderer = static::getContentObjectRenderer();
|
||||||
|
|
||||||
|
//instantiate the logger
|
||||||
|
$logger = $extensionHelperService->getLogger(__CLASS__);
|
||||||
|
$logger->log(
|
||||||
|
LogLevel::DEBUG,
|
||||||
|
'Entry point',
|
||||||
|
[
|
||||||
|
'Viewhelper parameters' => [
|
||||||
|
'action' => $action,
|
||||||
|
'ratingobject' => $ratingobject,
|
||||||
|
'ratetable' => $ratetable,
|
||||||
|
'ratefield' => $ratefield,
|
||||||
|
'ratedobjectuid' => $ratedobjectuid,
|
||||||
|
'display' => $display, ],
|
||||||
|
'typoscript' => static::getConfigurationManager()
|
||||||
|
->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
if (TYPO3_MODE === 'BE') {
|
||||||
|
static::simulateFrontendEnvironment();
|
||||||
|
}
|
||||||
|
$contentObjectRenderer->start([]);
|
||||||
|
|
||||||
|
$pathSegments = GeneralUtility::trimExplode('.', $typoscriptObjectPath);
|
||||||
|
$lastSegment = array_pop($pathSegments);
|
||||||
|
$setup = static::getConfigurationManager()
|
||||||
|
->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
|
||||||
|
foreach ($pathSegments as $segment) {
|
||||||
|
if (!array_key_exists($segment . '.', $setup)) {
|
||||||
|
$logger->log(
|
||||||
|
LogLevel::CRITICAL,
|
||||||
|
'TypoScript object path does not exist',
|
||||||
|
[
|
||||||
|
'Typoscript object path' => htmlspecialchars($typoscriptObjectPath),
|
||||||
|
'Setup' => $setup,
|
||||||
|
'errorCode' => 1253191023, ]
|
||||||
|
);
|
||||||
|
|
||||||
|
throw new \TYPO3Fluid\Fluid\Core\ViewHelper\Exception(
|
||||||
|
'TypoScript object path "' . $typoscriptObjectPath . '" does not exist',
|
||||||
|
1549388144
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$setup = $setup[$segment . '.'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($setup[$lastSegment])) {
|
||||||
|
throw new \TYPO3Fluid\Fluid\Core\ViewHelper\Exception(
|
||||||
|
'No Content Object definition found at TypoScript object path "' . $typoscriptObjectPath . '"',
|
||||||
|
1549388123
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($action)) {
|
||||||
|
$setup[$lastSegment . '.']['action'] = $action;
|
||||||
|
$setup[$lastSegment . '.']['switchableControllerActions.']['Vote.']['1'] = $action;
|
||||||
|
}
|
||||||
|
if (!empty($ratingobject)) {
|
||||||
|
$setup[$lastSegment . '.']['settings.']['ratingobject'] = $ratingobject;
|
||||||
|
} elseif (!empty($ratetable) && !empty($ratefield)) {
|
||||||
|
$setup[$lastSegment . '.']['settings.']['ratetable'] = $ratetable;
|
||||||
|
$setup[$lastSegment . '.']['settings.']['ratefield'] = $ratefield;
|
||||||
|
} else {
|
||||||
|
$logger->log(
|
||||||
|
LogLevel::CRITICAL,
|
||||||
|
'ratingobject not specified or ratetable/ratfield not set',
|
||||||
|
['errorCode' => 1399727698]
|
||||||
|
);
|
||||||
|
throw new Exception('ratingobject not specified or ratetable/ratfield not set', 1399727698);
|
||||||
|
}
|
||||||
|
if (!empty($ratedobjectuid)) {
|
||||||
|
$setup[$lastSegment . '.']['settings.']['ratedobjectuid'] = $ratedobjectuid;
|
||||||
|
} else {
|
||||||
|
$logger->log(LogLevel::CRITICAL, 'ratedobjectuid not set', ['errorCode' => 1304624408]);
|
||||||
|
throw new Exception('ratedobjectuid not set', 1304624408);
|
||||||
|
}
|
||||||
|
if (!empty($display)) {
|
||||||
|
$setup[$lastSegment . '.']['settings.']['display'] = $display;
|
||||||
|
}
|
||||||
|
|
||||||
|
$logger->log(
|
||||||
|
LogLevel::DEBUG,
|
||||||
|
'Single contentObjectRenderer to get',
|
||||||
|
[
|
||||||
|
'contentObjectRenderer type' => $setup[$lastSegment],
|
||||||
|
'cOjb config' => $setup[$lastSegment . '.'], ]
|
||||||
|
);
|
||||||
|
|
||||||
|
$content = $contentObjectRenderer->cObjGetSingle($setup[$lastSegment], $setup[$lastSegment . '.'] ?? []);
|
||||||
|
if (TYPO3_MODE === 'BE') {
|
||||||
|
static::resetFrontendEnvironment();
|
||||||
|
}
|
||||||
|
|
||||||
|
$logger->log(LogLevel::INFO, 'Generated content', ['content' => $content]);
|
||||||
|
$logger->log(LogLevel::DEBUG, 'Exit point');
|
||||||
|
|
||||||
|
return $content;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \WapplerSystems\BookmarksLikesRatings\Service\ExtensionHelperService
|
||||||
|
*/
|
||||||
|
protected static function getExtensionHelperService(): ExtensionHelperService
|
||||||
|
{
|
||||||
|
return GeneralUtility::makeInstance(ObjectManager::class)->get(ExtensionHelperService::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return object|\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface
|
||||||
|
*/
|
||||||
|
protected static function getConfigurationManager()
|
||||||
|
{
|
||||||
|
return GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
|
||||||
|
*/
|
||||||
|
protected static function getContentObjectRenderer(): ContentObjectRenderer
|
||||||
|
{
|
||||||
|
return GeneralUtility::makeInstance(
|
||||||
|
ContentObjectRenderer::class,
|
||||||
|
$GLOBALS['TSFE'] ?? GeneralUtility::makeInstance(TypoScriptFrontendController::class, null, 0, 0)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the $TSFE->cObjectDepthCounter in Backend mode
|
||||||
|
* This somewhat hacky work around is currently needed because the cObjGetSingle() function
|
||||||
|
* of \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer relies on this setting
|
||||||
|
*/
|
||||||
|
protected static function simulateFrontendEnvironment(): void
|
||||||
|
{
|
||||||
|
static::$tsfeBackup = $GLOBALS['TSFE'] ?? null;
|
||||||
|
/** @noinspection PhpFullyQualifiedNameUsageInspection */
|
||||||
|
$GLOBALS['TSFE'] = new \stdClass();
|
||||||
|
$GLOBALS['TSFE']->cObj = GeneralUtility::makeInstance(ContentObjectRenderer::class);
|
||||||
|
$GLOBALS['TSFE']->cObjectDepthCounter = 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets $GLOBALS['TSFE'] if it was previously changed by simulateFrontendEnvironment()
|
||||||
|
*
|
||||||
|
* @see simulateFrontendEnvironment()
|
||||||
|
*/
|
||||||
|
protected static function resetFrontendEnvironment(): void
|
||||||
|
{
|
||||||
|
$GLOBALS['TSFE'] = static::$tsfeBackup;
|
||||||
|
}
|
||||||
|
}
|
@ -12,11 +12,13 @@ namespace WapplerSystems\BookmarksLikesRatings\ViewHelpers;
|
|||||||
use TYPO3\CMS\Core\Log\LogLevel;
|
use TYPO3\CMS\Core\Log\LogLevel;
|
||||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||||
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
|
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
|
||||||
|
use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder;
|
||||||
use TYPO3\CMS\Extbase\Object\ObjectManager;
|
use TYPO3\CMS\Extbase\Object\ObjectManager;
|
||||||
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
|
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
|
||||||
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
|
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
|
||||||
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
|
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
|
||||||
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
|
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||||
|
use TYPO3Fluid\Fluid\Core\ViewHelper\TagBuilder;
|
||||||
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
|
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -25,47 +27,21 @@ use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
|
|||||||
*/
|
*/
|
||||||
class BookmarkViewHelper extends AbstractViewHelper
|
class BookmarkViewHelper extends AbstractViewHelper
|
||||||
{
|
{
|
||||||
use CompileWithRenderStatic;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Disable escaping of this node's output
|
|
||||||
*
|
|
||||||
* @var bool
|
|
||||||
*/
|
|
||||||
protected $escapeOutput = false;
|
protected $escapeOutput = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @noinspection PhpUnnecessaryFullyQualifiedNameInspection
|
|
||||||
* @var \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController
|
|
||||||
* contains a backup of the current['TSFE'] if used in BE mode
|
|
||||||
*/
|
|
||||||
protected static $tsfeBackup;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @noinspection PhpFullyQualifiedNameUsageInspection
|
|
||||||
* @var \TYPO3\CMS\Core\Log\Logger $logger
|
|
||||||
*/
|
|
||||||
protected $logger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $typoScriptSetup;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @noinspection PhpUnnecessaryFullyQualifiedNameInspection
|
|
||||||
* @var \WapplerSystems\BookmarksLikesRatings\Service\ExtensionHelperService
|
* @var \WapplerSystems\BookmarksLikesRatings\Service\ExtensionHelperService
|
||||||
*/
|
*/
|
||||||
protected $extensionHelperService;
|
protected $extensionHelperService;
|
||||||
|
|
||||||
public function initializeArguments(): void
|
public function initializeArguments(): void
|
||||||
{
|
{
|
||||||
$this->registerArgument('action', 'string', 'The rating action');
|
$this->registerArgument('table', 'string', 'The rating tablename');
|
||||||
$this->registerArgument('ratetable', 'string', 'The rating tablename');
|
$this->registerArgument('uid', 'integer', 'The uid of the object', true);
|
||||||
$this->registerArgument('ratefield', 'string', 'The rating fieldname');
|
$this->registerArgument('class', 'string', 'The class', true);
|
||||||
$this->registerArgument('ratedobjectuid', 'integer', 'The ratingobject uid', true);
|
$this->registerArgument('id', 'string', 'The id');
|
||||||
$this->registerArgument('ratingobject', 'integer', 'The ratingobject');
|
|
||||||
$this->registerArgument('display', 'string', 'The display configuration');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -83,163 +59,29 @@ class BookmarkViewHelper extends AbstractViewHelper
|
|||||||
\Closure $renderChildrenClosure,
|
\Closure $renderChildrenClosure,
|
||||||
RenderingContextInterface $renderingContext
|
RenderingContextInterface $renderingContext
|
||||||
) {
|
) {
|
||||||
$typoscriptObjectPath = 'plugin.tx_thrating';
|
|
||||||
$ratedobjectuid = $arguments['ratedobjectuid'];
|
|
||||||
$action = $arguments['action'];
|
|
||||||
$ratingobject = $arguments['ratingobject'];
|
|
||||||
$ratetable = $arguments['ratetable'];
|
|
||||||
$ratefield = $arguments['ratefield'];
|
|
||||||
$display = $arguments['display'];
|
|
||||||
$extensionHelperService = static::getExtensionHelperService();
|
|
||||||
$contentObjectRenderer = static::getContentObjectRenderer();
|
|
||||||
|
|
||||||
//instantiate the logger
|
$tagBuilder = new TagBuilder('button');
|
||||||
$logger = $extensionHelperService->getLogger(__CLASS__);
|
if ($arguments['id']) {
|
||||||
$logger->log(
|
$tagBuilder->addAttribute('id',$arguments['id']);
|
||||||
LogLevel::DEBUG,
|
|
||||||
'Entry point',
|
|
||||||
[
|
|
||||||
'Viewhelper parameters' => [
|
|
||||||
'action' => $action,
|
|
||||||
'ratingobject' => $ratingobject,
|
|
||||||
'ratetable' => $ratetable,
|
|
||||||
'ratefield' => $ratefield,
|
|
||||||
'ratedobjectuid' => $ratedobjectuid,
|
|
||||||
'display' => $display, ],
|
|
||||||
'typoscript' => static::getConfigurationManager()
|
|
||||||
->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT),
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
if (TYPO3_MODE === 'BE') {
|
|
||||||
static::simulateFrontendEnvironment();
|
|
||||||
}
|
}
|
||||||
$contentObjectRenderer->start([]);
|
$tagBuilder->addAttribute('class',$arguments['class']);
|
||||||
|
$tagBuilder->addAttribute('data-table',$arguments['table']);
|
||||||
|
$tagBuilder->addAttribute('data-uid',$arguments['uid']);
|
||||||
|
$tagBuilder->addAttribute('data-blr-type','bookmark');
|
||||||
|
|
||||||
$pathSegments = GeneralUtility::trimExplode('.', $typoscriptObjectPath);
|
/** @var UriBuilder $uriBuilder */
|
||||||
$lastSegment = array_pop($pathSegments);
|
$uriBuilder = $renderingContext->getControllerContext()->getUriBuilder();
|
||||||
$setup = static::getConfigurationManager()
|
$uriBuilder->reset();
|
||||||
->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
|
$uriBuilder->setTargetPageType(874655);
|
||||||
foreach ($pathSegments as $segment) {
|
$tagBuilder->addAttribute('data-status-url',$uriBuilder->buildFrontendUri());
|
||||||
if (!array_key_exists($segment . '.', $setup)) {
|
|
||||||
$logger->log(
|
|
||||||
LogLevel::CRITICAL,
|
|
||||||
'TypoScript object path does not exist',
|
|
||||||
[
|
|
||||||
'Typoscript object path' => htmlspecialchars($typoscriptObjectPath),
|
|
||||||
'Setup' => $setup,
|
|
||||||
'errorCode' => 1253191023, ]
|
|
||||||
);
|
|
||||||
|
|
||||||
throw new \TYPO3Fluid\Fluid\Core\ViewHelper\Exception(
|
$uriBuilder->reset();
|
||||||
'TypoScript object path "' . $typoscriptObjectPath . '" does not exist',
|
$uriBuilder->setTargetPageType(874654);
|
||||||
1549388144
|
$tagBuilder->addAttribute('data-toggle-url',$uriBuilder->buildFrontendUri());
|
||||||
);
|
|
||||||
}
|
$tagBuilder->setContent((string)$renderChildrenClosure());
|
||||||
$setup = $setup[$segment . '.'];
|
|
||||||
|
return $tagBuilder->render();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($setup[$lastSegment])) {
|
|
||||||
throw new \TYPO3Fluid\Fluid\Core\ViewHelper\Exception(
|
|
||||||
'No Content Object definition found at TypoScript object path "' . $typoscriptObjectPath . '"',
|
|
||||||
1549388123
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($action)) {
|
|
||||||
$setup[$lastSegment . '.']['action'] = $action;
|
|
||||||
$setup[$lastSegment . '.']['switchableControllerActions.']['Vote.']['1'] = $action;
|
|
||||||
}
|
|
||||||
if (!empty($ratingobject)) {
|
|
||||||
$setup[$lastSegment . '.']['settings.']['ratingobject'] = $ratingobject;
|
|
||||||
} elseif (!empty($ratetable) && !empty($ratefield)) {
|
|
||||||
$setup[$lastSegment . '.']['settings.']['ratetable'] = $ratetable;
|
|
||||||
$setup[$lastSegment . '.']['settings.']['ratefield'] = $ratefield;
|
|
||||||
} else {
|
|
||||||
$logger->log(
|
|
||||||
LogLevel::CRITICAL,
|
|
||||||
'ratingobject not specified or ratetable/ratfield not set',
|
|
||||||
['errorCode' => 1399727698]
|
|
||||||
);
|
|
||||||
throw new Exception('ratingobject not specified or ratetable/ratfield not set', 1399727698);
|
|
||||||
}
|
|
||||||
if (!empty($ratedobjectuid)) {
|
|
||||||
$setup[$lastSegment . '.']['settings.']['ratedobjectuid'] = $ratedobjectuid;
|
|
||||||
} else {
|
|
||||||
$logger->log(LogLevel::CRITICAL, 'ratedobjectuid not set', ['errorCode' => 1304624408]);
|
|
||||||
throw new Exception('ratedobjectuid not set', 1304624408);
|
|
||||||
}
|
|
||||||
if (!empty($display)) {
|
|
||||||
$setup[$lastSegment . '.']['settings.']['display'] = $display;
|
|
||||||
}
|
|
||||||
|
|
||||||
$logger->log(
|
|
||||||
LogLevel::DEBUG,
|
|
||||||
'Single contentObjectRenderer to get',
|
|
||||||
[
|
|
||||||
'contentObjectRenderer type' => $setup[$lastSegment],
|
|
||||||
'cOjb config' => $setup[$lastSegment . '.'], ]
|
|
||||||
);
|
|
||||||
|
|
||||||
$content = $contentObjectRenderer->cObjGetSingle($setup[$lastSegment], $setup[$lastSegment . '.'] ?? []);
|
|
||||||
if (TYPO3_MODE === 'BE') {
|
|
||||||
static::resetFrontendEnvironment();
|
|
||||||
}
|
|
||||||
|
|
||||||
$logger->log(LogLevel::INFO, 'Generated content', ['content' => $content]);
|
|
||||||
$logger->log(LogLevel::DEBUG, 'Exit point');
|
|
||||||
|
|
||||||
return $content;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return \WapplerSystems\BookmarksLikesRatings\Service\ExtensionHelperService
|
|
||||||
*/
|
|
||||||
protected static function getExtensionHelperService(): ExtensionHelperService
|
|
||||||
{
|
|
||||||
return GeneralUtility::makeInstance(ObjectManager::class)->get(ExtensionHelperService::class);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return object|\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface
|
|
||||||
*/
|
|
||||||
protected static function getConfigurationManager()
|
|
||||||
{
|
|
||||||
return GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
|
|
||||||
*/
|
|
||||||
protected static function getContentObjectRenderer(): ContentObjectRenderer
|
|
||||||
{
|
|
||||||
return GeneralUtility::makeInstance(
|
|
||||||
ContentObjectRenderer::class,
|
|
||||||
$GLOBALS['TSFE'] ?? GeneralUtility::makeInstance(TypoScriptFrontendController::class, null, 0, 0)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the $TSFE->cObjectDepthCounter in Backend mode
|
|
||||||
* This somewhat hacky work around is currently needed because the cObjGetSingle() function
|
|
||||||
* of \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer relies on this setting
|
|
||||||
*/
|
|
||||||
protected static function simulateFrontendEnvironment(): void
|
|
||||||
{
|
|
||||||
static::$tsfeBackup = $GLOBALS['TSFE'] ?? null;
|
|
||||||
/** @noinspection PhpFullyQualifiedNameUsageInspection */
|
|
||||||
$GLOBALS['TSFE'] = new \stdClass();
|
|
||||||
$GLOBALS['TSFE']->cObj = GeneralUtility::makeInstance(ContentObjectRenderer::class);
|
|
||||||
$GLOBALS['TSFE']->cObjectDepthCounter = 100;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Resets $GLOBALS['TSFE'] if it was previously changed by simulateFrontendEnvironment()
|
|
||||||
*
|
|
||||||
* @see simulateFrontendEnvironment()
|
|
||||||
*/
|
|
||||||
protected static function resetFrontendEnvironment(): void
|
|
||||||
{
|
|
||||||
$GLOBALS['TSFE'] = static::$tsfeBackup;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -12,11 +12,13 @@ namespace WapplerSystems\BookmarksLikesRatings\ViewHelpers;
|
|||||||
use TYPO3\CMS\Core\Log\LogLevel;
|
use TYPO3\CMS\Core\Log\LogLevel;
|
||||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||||
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
|
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
|
||||||
|
use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder;
|
||||||
use TYPO3\CMS\Extbase\Object\ObjectManager;
|
use TYPO3\CMS\Extbase\Object\ObjectManager;
|
||||||
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
|
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
|
||||||
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
|
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
|
||||||
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
|
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
|
||||||
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
|
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||||
|
use TYPO3Fluid\Fluid\Core\ViewHelper\TagBuilder;
|
||||||
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
|
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -25,47 +27,21 @@ use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
|
|||||||
*/
|
*/
|
||||||
class LikeViewHelper extends AbstractViewHelper
|
class LikeViewHelper extends AbstractViewHelper
|
||||||
{
|
{
|
||||||
use CompileWithRenderStatic;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Disable escaping of this node's output
|
|
||||||
*
|
|
||||||
* @var bool
|
|
||||||
*/
|
|
||||||
protected $escapeOutput = false;
|
protected $escapeOutput = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @noinspection PhpUnnecessaryFullyQualifiedNameInspection
|
|
||||||
* @var \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController
|
|
||||||
* contains a backup of the current['TSFE'] if used in BE mode
|
|
||||||
*/
|
|
||||||
protected static $tsfeBackup;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @noinspection PhpFullyQualifiedNameUsageInspection
|
|
||||||
* @var \TYPO3\CMS\Core\Log\Logger $logger
|
|
||||||
*/
|
|
||||||
protected $logger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $typoScriptSetup;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @noinspection PhpUnnecessaryFullyQualifiedNameInspection
|
|
||||||
* @var \WapplerSystems\BookmarksLikesRatings\Service\ExtensionHelperService
|
* @var \WapplerSystems\BookmarksLikesRatings\Service\ExtensionHelperService
|
||||||
*/
|
*/
|
||||||
protected $extensionHelperService;
|
protected $extensionHelperService;
|
||||||
|
|
||||||
public function initializeArguments(): void
|
public function initializeArguments(): void
|
||||||
{
|
{
|
||||||
$this->registerArgument('action', 'string', 'The rating action');
|
$this->registerArgument('table', 'string', 'The rating tablename');
|
||||||
$this->registerArgument('ratetable', 'string', 'The rating tablename');
|
$this->registerArgument('uid', 'integer', 'The uid of the object', true);
|
||||||
$this->registerArgument('ratefield', 'string', 'The rating fieldname');
|
$this->registerArgument('class', 'string', 'The class', true);
|
||||||
$this->registerArgument('ratedobjectuid', 'integer', 'The ratingobject uid', true);
|
$this->registerArgument('id', 'string', 'The id');
|
||||||
$this->registerArgument('ratingobject', 'integer', 'The ratingobject');
|
|
||||||
$this->registerArgument('display', 'string', 'The display configuration');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -83,163 +59,31 @@ class LikeViewHelper extends AbstractViewHelper
|
|||||||
\Closure $renderChildrenClosure,
|
\Closure $renderChildrenClosure,
|
||||||
RenderingContextInterface $renderingContext
|
RenderingContextInterface $renderingContext
|
||||||
) {
|
) {
|
||||||
$typoscriptObjectPath = 'plugin.tx_thrating';
|
|
||||||
$ratedobjectuid = $arguments['ratedobjectuid'];
|
|
||||||
$action = $arguments['action'];
|
|
||||||
$ratingobject = $arguments['ratingobject'];
|
|
||||||
$ratetable = $arguments['ratetable'];
|
|
||||||
$ratefield = $arguments['ratefield'];
|
|
||||||
$display = $arguments['display'];
|
|
||||||
$extensionHelperService = static::getExtensionHelperService();
|
|
||||||
$contentObjectRenderer = static::getContentObjectRenderer();
|
|
||||||
|
|
||||||
//instantiate the logger
|
$tagBuilder = new TagBuilder('button');
|
||||||
$logger = $extensionHelperService->getLogger(__CLASS__);
|
if ($arguments['id']) {
|
||||||
$logger->log(
|
$tagBuilder->addAttribute('id',$arguments['id']);
|
||||||
LogLevel::DEBUG,
|
|
||||||
'Entry point',
|
|
||||||
[
|
|
||||||
'Viewhelper parameters' => [
|
|
||||||
'action' => $action,
|
|
||||||
'ratingobject' => $ratingobject,
|
|
||||||
'ratetable' => $ratetable,
|
|
||||||
'ratefield' => $ratefield,
|
|
||||||
'ratedobjectuid' => $ratedobjectuid,
|
|
||||||
'display' => $display, ],
|
|
||||||
'typoscript' => static::getConfigurationManager()
|
|
||||||
->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT),
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
if (TYPO3_MODE === 'BE') {
|
|
||||||
static::simulateFrontendEnvironment();
|
|
||||||
}
|
}
|
||||||
$contentObjectRenderer->start([]);
|
$tagBuilder->addAttribute('class',$arguments['class']);
|
||||||
|
$tagBuilder->addAttribute('data-table',$arguments['table']);
|
||||||
|
$tagBuilder->addAttribute('data-uid',$arguments['uid']);
|
||||||
|
$tagBuilder->addAttribute('data-blr-type','like');
|
||||||
|
|
||||||
$pathSegments = GeneralUtility::trimExplode('.', $typoscriptObjectPath);
|
/** @var UriBuilder $uriBuilder */
|
||||||
$lastSegment = array_pop($pathSegments);
|
$uriBuilder = $renderingContext->getControllerContext()->getUriBuilder();
|
||||||
$setup = static::getConfigurationManager()
|
$uriBuilder->reset();
|
||||||
->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
|
$uriBuilder->setTargetPageType(874645);
|
||||||
foreach ($pathSegments as $segment) {
|
$tagBuilder->addAttribute('data-status-url',$uriBuilder->buildFrontendUri());
|
||||||
if (!array_key_exists($segment . '.', $setup)) {
|
|
||||||
$logger->log(
|
|
||||||
LogLevel::CRITICAL,
|
|
||||||
'TypoScript object path does not exist',
|
|
||||||
[
|
|
||||||
'Typoscript object path' => htmlspecialchars($typoscriptObjectPath),
|
|
||||||
'Setup' => $setup,
|
|
||||||
'errorCode' => 1253191023, ]
|
|
||||||
);
|
|
||||||
|
|
||||||
throw new \TYPO3Fluid\Fluid\Core\ViewHelper\Exception(
|
$uriBuilder->reset();
|
||||||
'TypoScript object path "' . $typoscriptObjectPath . '" does not exist',
|
$uriBuilder->setTargetPageType(874644);
|
||||||
1549388144
|
$tagBuilder->addAttribute('data-toggle-url',$uriBuilder->buildFrontendUri());
|
||||||
);
|
|
||||||
}
|
$tagBuilder->setContent((string)$renderChildrenClosure());
|
||||||
$setup = $setup[$segment . '.'];
|
|
||||||
|
return $tagBuilder->render();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($setup[$lastSegment])) {
|
|
||||||
throw new \TYPO3Fluid\Fluid\Core\ViewHelper\Exception(
|
|
||||||
'No Content Object definition found at TypoScript object path "' . $typoscriptObjectPath . '"',
|
|
||||||
1549388123
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($action)) {
|
|
||||||
$setup[$lastSegment . '.']['action'] = $action;
|
|
||||||
$setup[$lastSegment . '.']['switchableControllerActions.']['Vote.']['1'] = $action;
|
|
||||||
}
|
|
||||||
if (!empty($ratingobject)) {
|
|
||||||
$setup[$lastSegment . '.']['settings.']['ratingobject'] = $ratingobject;
|
|
||||||
} elseif (!empty($ratetable) && !empty($ratefield)) {
|
|
||||||
$setup[$lastSegment . '.']['settings.']['ratetable'] = $ratetable;
|
|
||||||
$setup[$lastSegment . '.']['settings.']['ratefield'] = $ratefield;
|
|
||||||
} else {
|
|
||||||
$logger->log(
|
|
||||||
LogLevel::CRITICAL,
|
|
||||||
'ratingobject not specified or ratetable/ratfield not set',
|
|
||||||
['errorCode' => 1399727698]
|
|
||||||
);
|
|
||||||
throw new Exception('ratingobject not specified or ratetable/ratfield not set', 1399727698);
|
|
||||||
}
|
|
||||||
if (!empty($ratedobjectuid)) {
|
|
||||||
$setup[$lastSegment . '.']['settings.']['ratedobjectuid'] = $ratedobjectuid;
|
|
||||||
} else {
|
|
||||||
$logger->log(LogLevel::CRITICAL, 'ratedobjectuid not set', ['errorCode' => 1304624408]);
|
|
||||||
throw new Exception('ratedobjectuid not set', 1304624408);
|
|
||||||
}
|
|
||||||
if (!empty($display)) {
|
|
||||||
$setup[$lastSegment . '.']['settings.']['display'] = $display;
|
|
||||||
}
|
|
||||||
|
|
||||||
$logger->log(
|
|
||||||
LogLevel::DEBUG,
|
|
||||||
'Single contentObjectRenderer to get',
|
|
||||||
[
|
|
||||||
'contentObjectRenderer type' => $setup[$lastSegment],
|
|
||||||
'cOjb config' => $setup[$lastSegment . '.'], ]
|
|
||||||
);
|
|
||||||
|
|
||||||
$content = $contentObjectRenderer->cObjGetSingle($setup[$lastSegment], $setup[$lastSegment . '.'] ?? []);
|
|
||||||
if (TYPO3_MODE === 'BE') {
|
|
||||||
static::resetFrontendEnvironment();
|
|
||||||
}
|
|
||||||
|
|
||||||
$logger->log(LogLevel::INFO, 'Generated content', ['content' => $content]);
|
|
||||||
$logger->log(LogLevel::DEBUG, 'Exit point');
|
|
||||||
|
|
||||||
return $content;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return \WapplerSystems\BookmarksLikesRatings\Service\ExtensionHelperService
|
|
||||||
*/
|
|
||||||
protected static function getExtensionHelperService(): ExtensionHelperService
|
|
||||||
{
|
|
||||||
return GeneralUtility::makeInstance(ObjectManager::class)->get(ExtensionHelperService::class);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return object|\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface
|
|
||||||
*/
|
|
||||||
protected static function getConfigurationManager()
|
|
||||||
{
|
|
||||||
return GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
|
|
||||||
*/
|
|
||||||
protected static function getContentObjectRenderer(): ContentObjectRenderer
|
|
||||||
{
|
|
||||||
return GeneralUtility::makeInstance(
|
|
||||||
ContentObjectRenderer::class,
|
|
||||||
$GLOBALS['TSFE'] ?? GeneralUtility::makeInstance(TypoScriptFrontendController::class, null, 0, 0)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the $TSFE->cObjectDepthCounter in Backend mode
|
|
||||||
* This somewhat hacky work around is currently needed because the cObjGetSingle() function
|
|
||||||
* of \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer relies on this setting
|
|
||||||
*/
|
|
||||||
protected static function simulateFrontendEnvironment(): void
|
|
||||||
{
|
|
||||||
static::$tsfeBackup = $GLOBALS['TSFE'] ?? null;
|
|
||||||
/** @noinspection PhpFullyQualifiedNameUsageInspection */
|
|
||||||
$GLOBALS['TSFE'] = new \stdClass();
|
|
||||||
$GLOBALS['TSFE']->cObj = GeneralUtility::makeInstance(ContentObjectRenderer::class);
|
|
||||||
$GLOBALS['TSFE']->cObjectDepthCounter = 100;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Resets $GLOBALS['TSFE'] if it was previously changed by simulateFrontendEnvironment()
|
|
||||||
*
|
|
||||||
* @see simulateFrontendEnvironment()
|
|
||||||
*/
|
|
||||||
protected static function resetFrontendEnvironment(): void
|
|
||||||
{
|
|
||||||
$GLOBALS['TSFE'] = static::$tsfeBackup;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -5,34 +5,52 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace WapplerSystems\BookmarksLikesRatings\Widgets\Provider;
|
namespace WapplerSystems\BookmarksLikesRatings\Widgets\Provider;
|
||||||
|
|
||||||
use TYPO3\CMS\Core\Database\Connection;
|
use TYPO3\CMS\Backend\Utility\BackendUtility;
|
||||||
use TYPO3\CMS\Core\Database\ConnectionPool;
|
use TYPO3\CMS\Core\Utility\DebugUtility;
|
||||||
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
|
use WapplerSystems\BookmarksLikesRatings\Domain\Repository\LikeRepository;
|
||||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
|
||||||
use TYPO3\CMS\Dashboard\Widgets\ListDataProviderInterface;
|
|
||||||
|
|
||||||
class TopLikesDataProvider implements ListDataProviderInterface
|
class TopLikesDataProvider
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/** @var LikeRepository */
|
||||||
|
protected $likeRepository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \WapplerSystems\BookmarksLikesRatings\Domain\Repository\LikeRepository $bookmarkRepository
|
||||||
|
*/
|
||||||
|
public function injectLikeRepository(LikeRepository $likeRepository) {
|
||||||
|
$this->likeRepository = $likeRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function getItems(): array
|
public function getItems()
|
||||||
{
|
{
|
||||||
/** @var QueryBuilder $queryBuilder */
|
|
||||||
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('be_users');
|
|
||||||
return $queryBuilder
|
$objs = $this->likeRepository->getTop(10);
|
||||||
->count('*')
|
|
||||||
->from('be_users')
|
$items = [];
|
||||||
->where(
|
|
||||||
$queryBuilder->expr()->eq(
|
foreach ($objs as $obj) {
|
||||||
'admin',
|
$title = '';
|
||||||
$queryBuilder->createNamedParameter(0, Connection::PARAM_INT)
|
if ($obj['tablename'] === 'pages') {
|
||||||
)
|
|
||||||
)
|
$page = BackendUtility::getRecord('pages',$obj['object_uid'],'title');
|
||||||
->execute();
|
if ($page) {
|
||||||
|
$title = $page['title'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$items[] = [
|
||||||
|
'title' => $title,
|
||||||
|
'number' => $obj['number']
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $items;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
namespace WapplerSystems\BookmarksLikesRatings\Widgets;
|
namespace WapplerSystems\BookmarksLikesRatings\Widgets;
|
||||||
|
|
||||||
use TYPO3\CMS\Dashboard\Widgets\ButtonProviderInterface;
|
use TYPO3\CMS\Dashboard\Widgets\ButtonProviderInterface;
|
||||||
use TYPO3\CMS\Dashboard\Widgets\ListDataProviderInterface;
|
|
||||||
use TYPO3\CMS\Dashboard\Widgets\WidgetConfigurationInterface;
|
use TYPO3\CMS\Dashboard\Widgets\WidgetConfigurationInterface;
|
||||||
use TYPO3\CMS\Dashboard\Widgets\WidgetInterface;
|
use TYPO3\CMS\Dashboard\Widgets\WidgetInterface;
|
||||||
use TYPO3\CMS\Fluid\View\StandaloneView;
|
use TYPO3\CMS\Fluid\View\StandaloneView;
|
||||||
@ -53,9 +52,9 @@ class TopLikesWidget implements WidgetInterface
|
|||||||
|
|
||||||
public function renderWidgetContent(): string
|
public function renderWidgetContent(): string
|
||||||
{
|
{
|
||||||
$this->view->setTemplate('Widget/ListWidget');
|
$this->view->setTemplate('TopLikesWidget');
|
||||||
$this->view->assignMultiple([
|
$this->view->assignMultiple([
|
||||||
'items' => $this->getItems(),
|
'items' => $this->dataProvider->getItems(),
|
||||||
'options' => $this->options,
|
'options' => $this->options,
|
||||||
'button' => $this->buttonProvider,
|
'button' => $this->buttonProvider,
|
||||||
'configuration' => $this->configuration,
|
'configuration' => $this->configuration,
|
||||||
@ -63,8 +62,4 @@ class TopLikesWidget implements WidgetInterface
|
|||||||
return $this->view->render();
|
return $this->view->render();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getItems(): array
|
|
||||||
{
|
|
||||||
return $this->dataProvider->getTopLikes();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,6 @@ services:
|
|||||||
groupNames: 'ratings'
|
groupNames: 'ratings'
|
||||||
title: 'LLL:EXT:bookmarks_likes_ratings/Resources/Private/Language/locallang.xlf:widgets.bookmarks_likes_ratings.topLikes.title'
|
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'
|
description: 'LLL:EXT:bookmarks_likes_ratings/Resources/Private/Language/locallang.xlf:widgets.bookmarks_likes_ratings.topLikes.description'
|
||||||
iconIdentifier: 'content-widget-ratings'
|
iconIdentifier: 'content-widget-text'
|
||||||
height: 'large'
|
height: 'large'
|
||||||
width: 'medium'
|
width: 'medium'
|
||||||
|
0
Configuration/TCA/Overrides/fe_users.php
Normal file
0
Configuration/TCA/Overrides/fe_users.php
Normal file
@ -12,4 +12,4 @@ defined('TYPO3') || die('Access denied.');
|
|||||||
/**
|
/**
|
||||||
* add TypoScript to template record
|
* add TypoScript to template record
|
||||||
*/
|
*/
|
||||||
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile('bookmarks_likes_ratings', 'Configuration/TypoScript/', 'Bookmark Pages');
|
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile('bookmarks_likes_ratings', 'Configuration/TypoScript/', 'Bookmarks/Likes/Pages');
|
||||||
|
@ -1,12 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the package buepro/bookmark_pages.
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please read the
|
|
||||||
* LICENSE file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
defined('TYPO3') || die('Access denied.');
|
defined('TYPO3') || die('Access denied.');
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
@ -17,12 +9,18 @@ defined('TYPO3') || die('Access denied.');
|
|||||||
'Bookmark Pages'
|
'Bookmark Pages'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
|
||||||
|
'BookmarksLikesRatings',
|
||||||
|
'PersonalBookmarks',
|
||||||
|
'Personal bookmarks of a user'
|
||||||
|
);
|
||||||
|
|
||||||
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist']['bookmarkpages_bookmarks'] = 'pi_flexform';
|
|
||||||
|
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist']['bookmarkslikesratings_bookmarks'] = 'pi_flexform';
|
||||||
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue(
|
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue(
|
||||||
'bookmarkpages_bookmarks',
|
'bookmarkslikesratings_bookmarks',
|
||||||
'FILE:EXT:bookmarks_likes_ratings/Configuration/FlexForms/Bookmarks.xml'
|
'FILE:EXT:bookmarks_likes_ratings/Configuration/FlexForms/Bookmarks.xml'
|
||||||
);
|
);
|
||||||
|
|
||||||
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist']['bookmarkpages_bookmarks'] = 'recursive,select_key,pages';
|
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist']['bookmarkslikesratings_bookmarks'] = 'recursive,select_key,pages';
|
||||||
})();
|
})();
|
||||||
|
@ -0,0 +1,97 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'ctrl' => [
|
||||||
|
'title' => 'LLL:EXT:bookmarks_likes_ratings/Resources/Private/Language/locallang.xlf:tca.model.bookmark.title',
|
||||||
|
'label' => 'uid',
|
||||||
|
'label_alt' => 'rating,fe_user,vote',
|
||||||
|
'label_userFunc' => 'WapplerSystems\\BookmarksLikesRatings\\Userfuncs\\Tca->getVoteRecordTitle',
|
||||||
|
'tstamp' => 'tstamp',
|
||||||
|
'crdate' => 'crdate',
|
||||||
|
'cruser_id' => 'cruser_id',
|
||||||
|
'adminOnly' => true,
|
||||||
|
'hideTable' => true,
|
||||||
|
'editlock' => 'rating',
|
||||||
|
'enablecolumns' => [
|
||||||
|
'disabled' => 'hidden',
|
||||||
|
],
|
||||||
|
'iconfile' => 'EXT:bookmarks_likes_ratings/Resources/Public/Icons/tx_bookmarkslikesratings_domain_model_vote.gif',
|
||||||
|
],
|
||||||
|
'interface' => [
|
||||||
|
'showRecordFieldList' => 'hidden, rating, user, vote',
|
||||||
|
],
|
||||||
|
'columns' => [
|
||||||
|
'pid' => [
|
||||||
|
'exclude' => 1,
|
||||||
|
'config' => [
|
||||||
|
'type' => 'none',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'hidden' => [
|
||||||
|
'exclude' => 1,
|
||||||
|
'label' => 'LLL:EXT:lang/Resources/Private/Language/locallang_general.xlf:LGL.hidden',
|
||||||
|
'config' => [
|
||||||
|
'type' => 'check',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'tablename' => [
|
||||||
|
'exclude' => 1,
|
||||||
|
'label' => 'LLL:EXT:bookmarks_likes_ratings/Resources/Private/Language/locallang.xlf:tca.model.vote.tablename',
|
||||||
|
'config' => [
|
||||||
|
'type' => 'input',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'object_uid' => [
|
||||||
|
'exclude' => 1,
|
||||||
|
'label' => 'LLL:EXT:bookmarks_likes_ratings/Resources/Private/Language/locallang.xlf:tca.model.vote.object_uid',
|
||||||
|
'config' => [
|
||||||
|
'type' => 'input',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'user' => [
|
||||||
|
'exclude' => 1,
|
||||||
|
'label' => 'LLL:EXT:bookmarks_likes_ratings/Resources/Private/Language/locallang.xlf:tca.model.vote.user',
|
||||||
|
'config' => [
|
||||||
|
'type' => 'select',
|
||||||
|
'renderType' => 'selectSingle',
|
||||||
|
'foreign_table' => 'fe_users',
|
||||||
|
'foreign_table_where' => 'ORDER BY fe_users.username',
|
||||||
|
'items' => [
|
||||||
|
[
|
||||||
|
'--div--', 0
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'fieldControl' => [
|
||||||
|
'editPopup' => [
|
||||||
|
'disabled' => false,
|
||||||
|
],
|
||||||
|
'addRecord' => [
|
||||||
|
'disabled' => false,
|
||||||
|
'options' => [
|
||||||
|
'setValue' => 'prepend',
|
||||||
|
],
|
||||||
|
'listModule' => [
|
||||||
|
'disabled' => false,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'uid' => [
|
||||||
|
'label' => 'LLL:EXT:bookmarks_likes_ratings/Resources/Private/Language/locallang.xlf:tca.model.vote.uid',
|
||||||
|
'config' => [
|
||||||
|
'type' => 'none'
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'types' => [
|
||||||
|
'1' => [
|
||||||
|
'showitem' => 'hidden, rating, user, vote'
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'palettes' => [
|
||||||
|
'1' => [
|
||||||
|
'showitem' => ''
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
@ -0,0 +1,97 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'ctrl' => [
|
||||||
|
'title' => 'LLL:EXT:bookmarks_likes_ratings/Resources/Private/Language/locallang.xlf:tca.model.like.title',
|
||||||
|
'label' => 'uid',
|
||||||
|
'label_alt' => 'rating,fe_user,vote',
|
||||||
|
'label_userFunc' => 'WapplerSystems\\BookmarksLikesRatings\\Userfuncs\\Tca->getVoteRecordTitle',
|
||||||
|
'tstamp' => 'tstamp',
|
||||||
|
'crdate' => 'crdate',
|
||||||
|
'cruser_id' => 'cruser_id',
|
||||||
|
'adminOnly' => true,
|
||||||
|
'hideTable' => true,
|
||||||
|
'editlock' => 'rating',
|
||||||
|
'enablecolumns' => [
|
||||||
|
'disabled' => 'hidden',
|
||||||
|
],
|
||||||
|
'iconfile' => 'EXT:bookmarks_likes_ratings/Resources/Public/Icons/tx_bookmarkslikesratings_domain_model_vote.gif',
|
||||||
|
],
|
||||||
|
'interface' => [
|
||||||
|
'showRecordFieldList' => 'hidden, rating, voter, vote',
|
||||||
|
],
|
||||||
|
'columns' => [
|
||||||
|
'pid' => [
|
||||||
|
'exclude' => 1,
|
||||||
|
'config' => [
|
||||||
|
'type' => 'none',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'hidden' => [
|
||||||
|
'exclude' => 1,
|
||||||
|
'label' => 'LLL:EXT:lang/Resources/Private/Language/locallang_general.xlf:LGL.hidden',
|
||||||
|
'config' => [
|
||||||
|
'type' => 'check',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'tablename' => [
|
||||||
|
'exclude' => 1,
|
||||||
|
'label' => 'LLL:EXT:bookmarks_likes_ratings/Resources/Private/Language/locallang.xlf:tca.model.vote.tablename',
|
||||||
|
'config' => [
|
||||||
|
'type' => 'input',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'object_uid' => [
|
||||||
|
'exclude' => 1,
|
||||||
|
'label' => 'LLL:EXT:bookmarks_likes_ratings/Resources/Private/Language/locallang.xlf:tca.model.vote.object_uid',
|
||||||
|
'config' => [
|
||||||
|
'type' => 'input',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'user' => [
|
||||||
|
'exclude' => 1,
|
||||||
|
'label' => 'LLL:EXT:bookmarks_likes_ratings/Resources/Private/Language/locallang.xlf:tca.model.vote.user',
|
||||||
|
'config' => [
|
||||||
|
'type' => 'select',
|
||||||
|
'renderType' => 'selectSingle',
|
||||||
|
'foreign_table' => 'fe_users',
|
||||||
|
'foreign_table_where' => 'ORDER BY fe_users.username',
|
||||||
|
'items' => [
|
||||||
|
[
|
||||||
|
'--div--', 0
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'fieldControl' => [
|
||||||
|
'editPopup' => [
|
||||||
|
'disabled' => false,
|
||||||
|
],
|
||||||
|
'addRecord' => [
|
||||||
|
'disabled' => false,
|
||||||
|
'options' => [
|
||||||
|
'setValue' => 'prepend',
|
||||||
|
],
|
||||||
|
'listModule' => [
|
||||||
|
'disabled' => false,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'uid' => [
|
||||||
|
'label' => 'LLL:EXT:bookmarks_likes_ratings/Resources/Private/Language/locallang.xlf:tca.model.vote.uid',
|
||||||
|
'config' => [
|
||||||
|
'type' => 'none'
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'types' => [
|
||||||
|
'1' => [
|
||||||
|
'showitem' => 'hidden, rating, voter, vote'
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'palettes' => [
|
||||||
|
'1' => [
|
||||||
|
'showitem' => ''
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
@ -47,9 +47,9 @@ return [
|
|||||||
'disableNoMatchingValueElement' => 1,
|
'disableNoMatchingValueElement' => 1,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'voter' => [
|
'user' => [
|
||||||
'exclude' => 1,
|
'exclude' => 1,
|
||||||
'label' => 'LLL:EXT:bookmarks_likes_ratings/Resources/Private/Language/locallang.xlf:tca.model.vote.voter',
|
'label' => 'LLL:EXT:bookmarks_likes_ratings/Resources/Private/Language/locallang.xlf:tca.model.vote.user',
|
||||||
'config' => [
|
'config' => [
|
||||||
'type' => 'select',
|
'type' => 'select',
|
||||||
'renderType' => 'selectSingle',
|
'renderType' => 'selectSingle',
|
||||||
|
104
Configuration/TypoScript/Ajax/ajax.typoscript
Normal file
104
Configuration/TypoScript/Ajax/ajax.typoscript
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
|
||||||
|
|
||||||
|
blrToggleLike = PAGE
|
||||||
|
blrToggleLike {
|
||||||
|
typeNum = 874644
|
||||||
|
|
||||||
|
config {
|
||||||
|
disableAllHeaderCode = 1
|
||||||
|
additionalHeaders = Content-type:application/json
|
||||||
|
xhtml_cleaning = 0
|
||||||
|
admPanel = 0
|
||||||
|
debug = 0
|
||||||
|
no_cache = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
10 = USER
|
||||||
|
10 {
|
||||||
|
userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
|
||||||
|
extensionName = BookmarksLikesRatings
|
||||||
|
pluginName = ToggleLike
|
||||||
|
vendorName = WapplerSystems
|
||||||
|
controller = Like
|
||||||
|
action = toggle
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
blrStatusLike = PAGE
|
||||||
|
blrStatusLike {
|
||||||
|
typeNum = 874645
|
||||||
|
|
||||||
|
config {
|
||||||
|
disableAllHeaderCode = 1
|
||||||
|
additionalHeaders = Content-type:application/json
|
||||||
|
xhtml_cleaning = 0
|
||||||
|
admPanel = 0
|
||||||
|
debug = 0
|
||||||
|
no_cache = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
10 = USER
|
||||||
|
10 {
|
||||||
|
userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
|
||||||
|
extensionName = BookmarksLikesRatings
|
||||||
|
pluginName = StatusLike
|
||||||
|
vendorName = WapplerSystems
|
||||||
|
controller = Like
|
||||||
|
action = status
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
blrToggleBookmark = PAGE
|
||||||
|
blrToggleBookmark {
|
||||||
|
typeNum = 874654
|
||||||
|
|
||||||
|
config {
|
||||||
|
disableAllHeaderCode = 1
|
||||||
|
additionalHeaders = Content-type:application/json
|
||||||
|
xhtml_cleaning = 0
|
||||||
|
admPanel = 0
|
||||||
|
debug = 0
|
||||||
|
no_cache = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
10 = USER
|
||||||
|
10 {
|
||||||
|
userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
|
||||||
|
extensionName = BookmarksLikesRatings
|
||||||
|
pluginName = ToggleBookmark
|
||||||
|
vendorName = WapplerSystems
|
||||||
|
controller = Bookmark
|
||||||
|
action = toggle
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
blrStatusBookmark = PAGE
|
||||||
|
blrStatusBookmark {
|
||||||
|
typeNum = 874655
|
||||||
|
|
||||||
|
config {
|
||||||
|
disableAllHeaderCode = 1
|
||||||
|
additionalHeaders = Content-type:application/json
|
||||||
|
xhtml_cleaning = 0
|
||||||
|
admPanel = 0
|
||||||
|
debug = 0
|
||||||
|
no_cache = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
10 = USER
|
||||||
|
10 {
|
||||||
|
userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
|
||||||
|
extensionName = BookmarksLikesRatings
|
||||||
|
pluginName = StatusBookmark
|
||||||
|
vendorName = WapplerSystems
|
||||||
|
controller = Bookmark
|
||||||
|
action = status
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,9 +1,13 @@
|
|||||||
plugin.tx_wsbookmarkpages {
|
plugin.tx_wsbookmarkpages {
|
||||||
view {
|
view {
|
||||||
|
templateRootPaths.0 = EXT:bookmarks_likes_ratings/Resources/Private/Templates/
|
||||||
templateRootPaths.10 = {$plugin.tx_wsbookmarkpages.view.templateRootPath}
|
templateRootPaths.10 = {$plugin.tx_wsbookmarkpages.view.templateRootPath}
|
||||||
|
partialRootPaths.0 = EXT:bookmarks_likes_ratings/Resources/Private/Partials/
|
||||||
partialRootPaths.10 = {$plugin.tx_wsbookmarkpages.view.partialRootPath}
|
partialRootPaths.10 = {$plugin.tx_wsbookmarkpages.view.partialRootPath}
|
||||||
|
layoutRootPaths.0 = EXT:bookmarks_likes_ratings/Resources/Private/Layouts/
|
||||||
layoutRootPaths.10 = {$plugin.tx_wsbookmarkpages.view.layoutRootPath}
|
layoutRootPaths.10 = {$plugin.tx_wsbookmarkpages.view.layoutRootPath}
|
||||||
}
|
}
|
||||||
|
|
||||||
settings {
|
settings {
|
||||||
storeLocal = {$plugin.tx_wsbookmarkpages.settings.storeLocal}
|
storeLocal = {$plugin.tx_wsbookmarkpages.settings.storeLocal}
|
||||||
localStorageTTL = {$plugin.tx_wsbookmarkpages.settings.localStorageTTL}
|
localStorageTTL = {$plugin.tx_wsbookmarkpages.settings.localStorageTTL}
|
||||||
@ -11,24 +15,9 @@ plugin.tx_wsbookmarkpages {
|
|||||||
}
|
}
|
||||||
|
|
||||||
page.includeJSFooterlibs {
|
page.includeJSFooterlibs {
|
||||||
bookmark_pages_jquery = https://code.jquery.com/jquery-2.2.4.min.js
|
|
||||||
bookmark_pages_jquery {
|
blr = EXT:bookmarks_likes_ratings/Resources/Public/JavaScript/scripts.js
|
||||||
excludeFromConcatenation = 1
|
|
||||||
disableCompression = 1
|
|
||||||
external = 1
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tt_content.login.stdWrap.postCObject = TEXT
|
<INCLUDE_TYPOSCRIPT: source="DIR:EXT:bookmarks_likes_ratings/Configuration/TypoScript/Ajax/" extensions="typoscript">
|
||||||
tt_content.login.stdWrap.postCObject.value (
|
|
||||||
<script type="text/javascript">
|
|
||||||
document.addEventListener('DOMContentLoaded', function(event) {
|
|
||||||
let button = document.querySelector('.frame-type-login [type="submit"]');
|
|
||||||
if (button) {
|
|
||||||
button.addEventListener('click', function () {
|
|
||||||
localStorage.setItem('txBookmarkPagesReload', '1');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
)
|
|
||||||
|
@ -1,23 +1,4 @@
|
|||||||
<f:if condition="{settings.isComplementary as integer} === 1">
|
|
||||||
<f:then>
|
|
||||||
<div class="bookmark-pages">
|
|
||||||
<f:render section="main" />
|
|
||||||
</div>
|
|
||||||
</f:then>
|
|
||||||
<f:else>
|
|
||||||
<div class="bookmark-pages"
|
|
||||||
data-settings='{settings -> f:format.json()}'
|
|
||||||
data-bookmark='{bookmark -> f:format.json()}'
|
|
||||||
data-add-ajaxuri="{t:uri.ajaxAction(action: 'bookmark')}"
|
|
||||||
data-remove-ajaxuri="{t:uri.ajaxAction(action: 'delete')}"
|
|
||||||
data-update-ajaxuri="{t:uri.ajaxAction(action: 'listEntries')}"
|
|
||||||
id="bookmarks">
|
|
||||||
|
|
||||||
|
<div class="tx_bookmarkslikespages">
|
||||||
<f:render section="main" />
|
<f:render section="main" />
|
||||||
<template id="bookmark-template">
|
|
||||||
<f:render partial="ListItem" arguments="{bookmark: bookmark}" />
|
|
||||||
</template>
|
|
||||||
</div>
|
</div>
|
||||||
</f:else>
|
|
||||||
</f:if>
|
|
||||||
<f:asset.script identifier="bookmarkPages" src="EXT:bookmarks_likes_ratings/Resources/Public/Scripts/JavaScript/bookmarks_likes_ratings.js" />
|
|
||||||
|
21
Resources/Private/Templates/Bookmark/PersonalList.html
Normal file
21
Resources/Private/Templates/Bookmark/PersonalList.html
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<html data-namespace-typo3-fluid="true"
|
||||||
|
xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://typo3.org/ns/fluid/ViewHelpers">
|
||||||
|
|
||||||
|
<f:layout name="Default"/>
|
||||||
|
|
||||||
|
<f:section name="main">
|
||||||
|
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<f:for each="{bookmarks}" as="bookmark">
|
||||||
|
<li>
|
||||||
|
<span><f:link.action action="delete" arguments="{object_uid:bookmark.object_uid, tablename: bookmark.tablename}">[Löschen]</f:link.action></span>
|
||||||
|
<a href="{bookmark.url}">{bookmark.title}</a>
|
||||||
|
</li>
|
||||||
|
</f:for>
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</f:section>
|
||||||
|
|
||||||
|
</html>
|
@ -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>
|
1
Resources/Public/Icons/Extension.svg
Normal file
1
Resources/Public/Icons/Extension.svg
Normal file
@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><path fill="#A4276A" d="M0 0h64v64H0z"/><path opacity=".5" fill="#FFF" d="M40 16h10v-1c0-.5-.5-1-1-1h-9v2z"/><path opacity=".75" fill="#FFF" d="M28 14h10v2H28z"/><path fill="#FFF" d="M40 18H26v-4H15c-.5 0-1 .5-1 1v34c0 .5.5 1 1 1h34c.5 0 1-.5 1-1V18H40z"/><path fill="#A4276A" d="M38 22h8v14h-8z"/><path fill-rule="evenodd" clip-rule="evenodd" fill="#A4276A" d="M18 22h18v14H18z"/><path opacity=".5" fill="#FFF" d="M38 24h8v12h-8z"/><path opacity=".5" fill-rule="evenodd" clip-rule="evenodd" fill="#FFF" d="M36 36H18v-4l6-2 4 2 4-2 4-6z"/><path fill="#A4276A" d="M28 40h18v2H28zM28 44h10v2H28zM18 40h8v6h-8z"/><path opacity=".5" fill="#FFF" d="M18 42h8v4h-8z"/></svg>
|
After Width: | Height: | Size: 728 B |
99
Resources/Public/JavaScript/scripts.js
Normal file
99
Resources/Public/JavaScript/scripts.js
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
|
||||||
|
let BookmarkLikeRating = function () {
|
||||||
|
function initButtons() {
|
||||||
|
$('button[data-blr-type=bookmark]').each(function (n) {
|
||||||
|
let btn = $(this);
|
||||||
|
$.ajax({
|
||||||
|
cache: false,
|
||||||
|
method: 'POST',
|
||||||
|
url: btn.attr('data-status-url'),
|
||||||
|
success: function (data) {
|
||||||
|
if (data.status === 'true') {
|
||||||
|
btn.addClass('active');
|
||||||
|
$('*',btn).addClass('active');
|
||||||
|
} else {
|
||||||
|
btn.removeClass('active');
|
||||||
|
$('*',btn).removeClass('active');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data: 'tx_bookmarkslikesratings_statusbookmark[objectUid]='+btn.attr('data-uid')+'&tx_bookmarkslikesratings_statusbookmark[tablename]='+btn.attr('data-table')
|
||||||
|
});
|
||||||
|
|
||||||
|
$(this).on('click',function() {
|
||||||
|
let btn = $(this);
|
||||||
|
$.ajax({
|
||||||
|
cache: false,
|
||||||
|
method: 'POST',
|
||||||
|
url: btn.attr('data-toggle-url'),
|
||||||
|
success: function (data) {
|
||||||
|
if (data.status === 'true') {
|
||||||
|
btn.addClass('active');
|
||||||
|
$('*',btn).addClass('active');
|
||||||
|
} else {
|
||||||
|
btn.removeClass('active');
|
||||||
|
$('*',btn).removeClass('active');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data: 'tx_bookmarkslikesratings_togglebookmark[objectUid]='+btn.attr('data-uid')+'&tx_bookmarkslikesratings_togglebookmark[tablename]='+btn.attr('data-table')
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
$('button[data-blr-type=like]').each(function (n) {
|
||||||
|
let btn = $(this);
|
||||||
|
$.ajax({
|
||||||
|
cache: false,
|
||||||
|
method: 'POST',
|
||||||
|
url: btn.attr('data-status-url'),
|
||||||
|
success: function (data) {
|
||||||
|
if (data.status === 'true') {
|
||||||
|
btn.addClass('active');
|
||||||
|
$('*',btn).addClass('active');
|
||||||
|
} else {
|
||||||
|
btn.removeClass('active');
|
||||||
|
$('*',btn).removeClass('active');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data: 'tx_bookmarkslikesratings_statuslike[objectUid]='+btn.attr('data-uid')+'&tx_bookmarkslikesratings_statuslike[tablename]='+btn.attr('data-table')
|
||||||
|
});
|
||||||
|
|
||||||
|
$(this).on('click',function() {
|
||||||
|
let btn = $(this);
|
||||||
|
$.ajax({
|
||||||
|
cache: false,
|
||||||
|
method: 'POST',
|
||||||
|
url: btn.attr('data-toggle-url'),
|
||||||
|
success: function (data) {
|
||||||
|
if (data.status === 'true') {
|
||||||
|
btn.addClass('active');
|
||||||
|
$('*',btn).addClass('active');
|
||||||
|
} else {
|
||||||
|
btn.removeClass('active');
|
||||||
|
$('*',btn).removeClass('active');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data: 'tx_bookmarkslikesratings_togglelike[objectUid]='+btn.attr('data-uid')+'&tx_bookmarkslikesratings_togglelike[tablename]='+btn.attr('data-table')
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateStatus() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
init: function () {
|
||||||
|
initButtons();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
|
||||||
|
jQuery(document).ready(function () {
|
||||||
|
|
||||||
|
BookmarkLikeRating.init();
|
||||||
|
});
|
BIN
ext_icon.png
BIN
ext_icon.png
Binary file not shown.
Before Width: | Height: | Size: 5.5 KiB |
@ -11,14 +11,72 @@ defined('TYPO3') or die('Access denied.');
|
|||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
|
|
||||||
|
|
||||||
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
|
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
|
||||||
'BookmarkPages',
|
'BookmarksLikesRatings',
|
||||||
'Bookmarks',
|
'StatusBookmark',
|
||||||
[
|
[
|
||||||
\WapplerSystems\BookmarksLikesRatings\Controller\BookmarksController::class => 'index, bookmark, delete, listEntries'
|
\WapplerSystems\BookmarksLikesRatings\Controller\BookmarkController::class => 'status'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
\WapplerSystems\BookmarksLikesRatings\Controller\BookmarksController::class => 'bookmark, delete, listEntries'
|
\WapplerSystems\BookmarksLikesRatings\Controller\BookmarkController::class => 'status'
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
|
||||||
|
'BookmarksLikesRatings',
|
||||||
|
'ToggleBookmark',
|
||||||
|
[
|
||||||
|
\WapplerSystems\BookmarksLikesRatings\Controller\BookmarkController::class => 'toggle'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
\WapplerSystems\BookmarksLikesRatings\Controller\BookmarkController::class => 'toggle'
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
|
||||||
|
'BookmarksLikesRatings',
|
||||||
|
'StatusLike',
|
||||||
|
[
|
||||||
|
\WapplerSystems\BookmarksLikesRatings\Controller\LikeController::class => 'status'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
\WapplerSystems\BookmarksLikesRatings\Controller\LikeController::class => 'status'
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
|
||||||
|
'BookmarksLikesRatings',
|
||||||
|
'ToggleLike',
|
||||||
|
[
|
||||||
|
\WapplerSystems\BookmarksLikesRatings\Controller\LikeController::class => 'toggle'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
\WapplerSystems\BookmarksLikesRatings\Controller\LikeController::class => 'toggle'
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
|
||||||
|
'BookmarksLikesRatings',
|
||||||
|
'Bookmarks',
|
||||||
|
[
|
||||||
|
\WapplerSystems\BookmarksLikesRatings\Controller\BookmarkController::class => 'index, bookmark, delete, listEntries'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
\WapplerSystems\BookmarksLikesRatings\Controller\BookmarkController::class => 'bookmark, delete, listEntries'
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
|
||||||
|
'BookmarksLikesRatings',
|
||||||
|
'PersonalBookmarks',
|
||||||
|
[
|
||||||
|
\WapplerSystems\BookmarksLikesRatings\Controller\BookmarkController::class => 'personalList, delete'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
\WapplerSystems\BookmarksLikesRatings\Controller\BookmarkController::class => 'personalList, delete'
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1,17 +1,3 @@
|
|||||||
#
|
|
||||||
# Add field to table 'fe_users'
|
|
||||||
#
|
|
||||||
CREATE TABLE fe_users
|
|
||||||
(
|
|
||||||
tx_bookmarks_pages blob
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE tx_bookmarkslikesratings_model_bookmark
|
|
||||||
(
|
|
||||||
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Table structure for table 'tx_bookmarkslikesratings_domain_model_ratingobject'
|
# Table structure for table 'tx_bookmarkslikesratings_domain_model_ratingobject'
|
||||||
#
|
#
|
||||||
@ -142,3 +128,46 @@ CREATE TABLE tx_bookmarkslikesratings_domain_model_vote
|
|||||||
KEY phpunit_dummy (is_dummy_record),
|
KEY phpunit_dummy (is_dummy_record),
|
||||||
INDEX tx_bookmarkslikesratings_domain_model_vote_i1 (rating, voter)
|
INDEX tx_bookmarkslikesratings_domain_model_vote_i1 (rating, voter)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
CREATE TABLE tx_bookmarkslikesratings_domain_model_bookmark
|
||||||
|
(
|
||||||
|
uid int(11) unsigned DEFAULT '0' NOT NULL auto_increment,
|
||||||
|
pid int(11) DEFAULT '0' NOT NULL,
|
||||||
|
|
||||||
|
tablename varchar(250) NOT NULL,
|
||||||
|
object_uid int(11) NOT NULL,
|
||||||
|
user int(11) NOT NULL,
|
||||||
|
seen_on_page int(11) DEFAULT NULL,
|
||||||
|
|
||||||
|
tstamp int(11) unsigned DEFAULT '0' NOT NULL,
|
||||||
|
crdate int(11) unsigned DEFAULT '0' NOT NULL,
|
||||||
|
cruser_id int(11) DEFAULT '0' NOT NULL,
|
||||||
|
deleted tinyint(4) unsigned DEFAULT '0' NOT NULL,
|
||||||
|
hidden tinyint(4) unsigned DEFAULT '0' NOT NULL,
|
||||||
|
|
||||||
|
PRIMARY KEY (uid),
|
||||||
|
KEY parent (pid),
|
||||||
|
INDEX tx_bookmarkslikesratings_domain_model_bookmark_i1 (tablename, object_uid, user)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE tx_bookmarkslikesratings_domain_model_like
|
||||||
|
(
|
||||||
|
uid int(11) unsigned DEFAULT '0' NOT NULL auto_increment,
|
||||||
|
pid int(11) DEFAULT '0' NOT NULL,
|
||||||
|
|
||||||
|
tablename varchar(250) NOT NULL,
|
||||||
|
object_uid int(11) NOT NULL,
|
||||||
|
user int(11) NOT NULL,
|
||||||
|
seen_on_page int(11) DEFAULT NULL,
|
||||||
|
|
||||||
|
tstamp int(11) unsigned DEFAULT '0' NOT NULL,
|
||||||
|
crdate int(11) unsigned DEFAULT '0' NOT NULL,
|
||||||
|
cruser_id int(11) DEFAULT '0' NOT NULL,
|
||||||
|
deleted tinyint(4) unsigned DEFAULT '0' NOT NULL,
|
||||||
|
hidden tinyint(4) unsigned DEFAULT '0' NOT NULL,
|
||||||
|
|
||||||
|
PRIMARY KEY (uid),
|
||||||
|
KEY parent (pid),
|
||||||
|
INDEX tx_bookmarkslikesratings_domain_model_like_i1 (tablename, object_uid, user)
|
||||||
|
);
|
||||||
|
7
ext_typoscript_setup.txt
Executable file
7
ext_typoscript_setup.txt
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
module.tx_dashboard {
|
||||||
|
view {
|
||||||
|
templateRootPaths {
|
||||||
|
123131 = EXT:bookmarks_likes_ratings/Resources/Private/Templates/Dashboard/Widgets/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user