90 lines
2.9 KiB
PHP
90 lines
2.9 KiB
PHP
<?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\Mvc\Web\Routing\UriBuilder;
|
|
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\TagBuilder;
|
|
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
|
|
|
|
/**
|
|
*
|
|
*
|
|
*/
|
|
class LikeViewHelper extends AbstractViewHelper
|
|
{
|
|
|
|
protected $escapeOutput = false;
|
|
|
|
/**
|
|
* @var \WapplerSystems\BookmarksLikesRatings\Service\ExtensionHelperService
|
|
*/
|
|
protected $extensionHelperService;
|
|
|
|
public function initializeArguments(): void
|
|
{
|
|
$this->registerArgument('table', 'string', 'The rating tablename');
|
|
$this->registerArgument('uid', 'integer', 'The uid of the object', true);
|
|
$this->registerArgument('class', 'string', 'The class', true);
|
|
$this->registerArgument('id', 'string', 'The id');
|
|
|
|
}
|
|
|
|
/**
|
|
* 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
|
|
) {
|
|
|
|
$tagBuilder = new TagBuilder('button');
|
|
if ($arguments['id']) {
|
|
$tagBuilder->addAttribute('id',$arguments['id']);
|
|
}
|
|
$tagBuilder->addAttribute('class',$arguments['class']);
|
|
$tagBuilder->addAttribute('data-table',$arguments['table']);
|
|
$tagBuilder->addAttribute('data-uid',$arguments['uid']);
|
|
$tagBuilder->addAttribute('data-blr-type','like');
|
|
|
|
/** @var UriBuilder $uriBuilder */
|
|
$uriBuilder = $renderingContext->getControllerContext()->getUriBuilder();
|
|
$uriBuilder->reset();
|
|
$uriBuilder->setTargetPageType(874645);
|
|
$tagBuilder->addAttribute('data-status-url',$uriBuilder->buildFrontendUri());
|
|
|
|
$uriBuilder->reset();
|
|
$uriBuilder->setTargetPageType(874644);
|
|
$tagBuilder->addAttribute('data-toggle-url',$uriBuilder->buildFrontendUri());
|
|
|
|
$tagBuilder->setContent((string)$renderChildrenClosure());
|
|
|
|
return $tagBuilder->render();
|
|
}
|
|
|
|
|
|
|
|
}
|