first commit
This commit is contained in:
commit
1218dd1517
12716 files changed
+989233
No files matched your search
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
namespace TYPO3\CMS\SysNote\Controller;
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Fluid\View\StandaloneView;
|
||||
use TYPO3\CMS\SysNote\Domain\Repository\SysNoteRepository;
|
||||
|
||||
/**
|
||||
* Renders notes for the current backend user
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class NoteController
|
||||
{
|
||||
/**
|
||||
* @var SysNoteRepository
|
||||
*/
|
||||
protected $notesRepository;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->notesRepository = GeneralUtility::makeInstance(SysNoteRepository::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render notes by single PID or PID list
|
||||
*
|
||||
* @param string $pids Single PID or comma separated list of PIDs
|
||||
* @param int|null $position null for no restriction, integer for defined position
|
||||
* @return string
|
||||
*/
|
||||
public function listAction($pids, int $position = null): string
|
||||
{
|
||||
if (empty($pids) || empty($GLOBALS['BE_USER']->user['uid'])) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$notes = $this->notesRepository->findByPidsAndAuthorId($pids, (int)$GLOBALS['BE_USER']->user['uid'], $position);
|
||||
if ($notes) {
|
||||
$view = GeneralUtility::makeInstance(StandaloneView::class);
|
||||
$view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName(
|
||||
'EXT:sys_note/Resources/Private/Templates/Note/List.html'
|
||||
));
|
||||
$view->setLayoutRootPaths(['EXT:sys_note/Resources/Private/Layouts']);
|
||||
$view->getRequest()->setControllerExtensionName('SysNote');
|
||||
$view->assign('notes', $notes);
|
||||
return $view->render();
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
namespace TYPO3\CMS\SysNote\Domain\Repository;
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
use TYPO3\CMS\Core\Database\Connection;
|
||||
use TYPO3\CMS\Core\Database\ConnectionPool;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
|
||||
/**
|
||||
* Sys_note repository
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class SysNoteRepository
|
||||
{
|
||||
const SYS_NOTE_POSITION_BOTTOM = 0;
|
||||
const SYS_NOTE_POSITION_TOP = 1;
|
||||
|
||||
/**
|
||||
* Find notes by given pids and author
|
||||
*
|
||||
* @param string $pids Single PID or comma separated list of PIDs
|
||||
* @param int $author author uid
|
||||
* @param int|null $position null for no restriction, integer for defined position
|
||||
* @return array
|
||||
*/
|
||||
public function findByPidsAndAuthorId($pids, int $author, int $position = null): array
|
||||
{
|
||||
$pids = GeneralUtility::intExplode(',', (string)$pids);
|
||||
|
||||
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
|
||||
->getQueryBuilderForTable('sys_note');
|
||||
$queryBuilder->getRestrictions()->removeAll();
|
||||
$res = $queryBuilder
|
||||
->select(
|
||||
'sys_note.*',
|
||||
'be_users.username AS authorUsername',
|
||||
'be_users.realName AS authorRealName',
|
||||
'be_users.disable AS authorDisabled',
|
||||
'be_users.deleted AS authorDeleted'
|
||||
)
|
||||
->from('sys_note')
|
||||
->leftJoin(
|
||||
'sys_note',
|
||||
'be_users',
|
||||
'be_users',
|
||||
$queryBuilder->expr()->eq('sys_note.cruser', $queryBuilder->quoteIdentifier('be_users.uid'))
|
||||
)
|
||||
->where(
|
||||
$queryBuilder->expr()->eq('sys_note.deleted', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)),
|
||||
$queryBuilder->expr()->in('sys_note.pid', $queryBuilder->createNamedParameter($pids, Connection::PARAM_INT_ARRAY)),
|
||||
$queryBuilder->expr()->orX(
|
||||
$queryBuilder->expr()->eq('sys_note.personal', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)),
|
||||
$queryBuilder->expr()->eq('sys_note.cruser', $queryBuilder->createNamedParameter($author, \PDO::PARAM_INT))
|
||||
)
|
||||
)
|
||||
->orderBy('sorting', 'asc')
|
||||
->addOrderBy('crdate', 'desc');
|
||||
|
||||
if ($position !== null) {
|
||||
$res->andWhere(
|
||||
$queryBuilder->expr()->eq('sys_note.position', $queryBuilder->createNamedParameter($position, \PDO::PARAM_INT))
|
||||
);
|
||||
}
|
||||
|
||||
return $res->execute()->fetchAll();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
namespace TYPO3\CMS\SysNote\Hook;
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\SysNote\Controller\NoteController;
|
||||
|
||||
/**
|
||||
* Hook for the info module
|
||||
* @internal This is a specific hook implementation and is not considered part of the Public TYPO3 API.
|
||||
*/
|
||||
class InfoModuleHook
|
||||
{
|
||||
/**
|
||||
* Add sys_notes as additional content to the footer of the info module
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$controller = GeneralUtility::makeInstance(NoteController::class);
|
||||
$id = (int)GeneralUtility::_GP('id');
|
||||
return $controller->listAction($id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
namespace TYPO3\CMS\SysNote\Hook;
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\SysNote\Controller\NoteController;
|
||||
use TYPO3\CMS\SysNote\Domain\Repository\SysNoteRepository;
|
||||
|
||||
/**
|
||||
* Hook for the page module
|
||||
* @internal This is a specific hook implementation and is not considered part of the Public TYPO3 API.
|
||||
*/
|
||||
class PageHook
|
||||
{
|
||||
|
||||
/**
|
||||
* Add sys_notes as additional content to the header of the page module
|
||||
*
|
||||
* @param array $params
|
||||
* @param \TYPO3\CMS\Backend\Controller\PageLayoutController $parentObject
|
||||
* @return string
|
||||
*/
|
||||
public function renderInHeader(array $params = [], \TYPO3\CMS\Backend\Controller\PageLayoutController $parentObject)
|
||||
{
|
||||
$controller = GeneralUtility::makeInstance(NoteController::class);
|
||||
return $controller->listAction($parentObject->id, SysNoteRepository::SYS_NOTE_POSITION_TOP);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add sys_notes as additional content to the footer of the page module
|
||||
*
|
||||
* @param array $params
|
||||
* @param \TYPO3\CMS\Backend\Controller\PageLayoutController $parentObject
|
||||
* @return string
|
||||
*/
|
||||
public function renderInFooter(array $params = [], \TYPO3\CMS\Backend\Controller\PageLayoutController $parentObject)
|
||||
{
|
||||
$controller = GeneralUtility::makeInstance(NoteController::class);
|
||||
return $controller->listAction($parentObject->id, SysNoteRepository::SYS_NOTE_POSITION_BOTTOM);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
namespace TYPO3\CMS\SysNote\Hook;
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\SysNote\Controller\NoteController;
|
||||
use TYPO3\CMS\SysNote\Domain\Repository\SysNoteRepository;
|
||||
|
||||
/**
|
||||
* Hook for the list module
|
||||
* @internal This is a specific hook implementation and is not considered part of the Public TYPO3 API.
|
||||
*/
|
||||
class RecordListHook
|
||||
{
|
||||
/**
|
||||
* Add sys_notes as additional content to the header of the list module
|
||||
*
|
||||
* @param array $params
|
||||
* @return string
|
||||
*/
|
||||
public function renderInHeader(array $params): string
|
||||
{
|
||||
/** @var ServerRequestInterface $request */
|
||||
$request = $params['request'];
|
||||
$id = (int)($request->getParsedBody()['id'] ?? $request->getQueryParams()['id'] ?? 0);
|
||||
$controller = GeneralUtility::makeInstance(NoteController::class);
|
||||
return $controller->listAction($id, SysNoteRepository::SYS_NOTE_POSITION_TOP);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add sys_notes as additional content to the footer of the list module
|
||||
*
|
||||
* @param array $params
|
||||
* @return string
|
||||
*/
|
||||
public function renderInFooter(array $params): string
|
||||
{
|
||||
/** @var ServerRequestInterface $request */
|
||||
$request = $params['request'];
|
||||
$id = (int)($request->getParsedBody()['id'] ?? $request->getQueryParams()['id'] ?? 0);
|
||||
$controller = GeneralUtility::makeInstance(NoteController::class);
|
||||
return $controller->listAction($id, SysNoteRepository::SYS_NOTE_POSITION_BOTTOM);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
namespace TYPO3\CMS\SysNote\ViewHelpers;
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
use TYPO3\CMS\Backend\Routing\UriBuilder;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
|
||||
|
||||
/**
|
||||
* ViewHelper to create a link to delete a note
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class DeleteLinkViewHelper extends AbstractViewHelper
|
||||
{
|
||||
use CompileWithRenderStatic;
|
||||
|
||||
/**
|
||||
* Initializes the arguments
|
||||
*/
|
||||
public function initializeArguments()
|
||||
{
|
||||
$this->registerArgument('id', 'int', 'uid of the note', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create link to delete a note
|
||||
*
|
||||
* @param array $arguments
|
||||
* @param \Closure $renderChildrenClosure
|
||||
* @param RenderingContextInterface $renderingContext
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
|
||||
{
|
||||
$urlParameters = [
|
||||
'cmd[sys_note][' . $arguments['id'] . '][delete]' => 1,
|
||||
'redirect' => GeneralUtility::getIndpEnv('REQUEST_URI')
|
||||
];
|
||||
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
|
||||
return (string)$uriBuilder->buildUriFromRoute('tce_db', $urlParameters);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user