first commit
This commit is contained in:
commit
e81864e683
2984 files changed
+267797
No files matched your search
+62
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace In2code\Femanager\ViewHelpers\Be;
|
||||
|
||||
use TYPO3\CMS\Fluid\Core\Rendering\RenderingContext;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\Exception as FluidViewHelperException;
|
||||
|
||||
/**
|
||||
* Class GetClassNameOnActionViewHelper
|
||||
*/
|
||||
class GetClassNameOnActionViewHelper extends AbstractViewHelper
|
||||
{
|
||||
/**
|
||||
* Return className if actionName fits to current action
|
||||
*
|
||||
* @return string
|
||||
* @throws FluidViewHelperException
|
||||
*/
|
||||
public function render(): string
|
||||
{
|
||||
$actionName = $this->arguments['actionName'];
|
||||
$className = $this->arguments['className'];
|
||||
$fallbackClassName = $this->arguments['fallbackClassName'];
|
||||
|
||||
if ($this->getCurrentActionName() === $actionName) {
|
||||
return $className;
|
||||
}
|
||||
|
||||
return $fallbackClassName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current action name from the controller context
|
||||
*
|
||||
* @return string
|
||||
* @throws FluidViewHelperException
|
||||
*/
|
||||
protected function getCurrentActionName(): string
|
||||
{
|
||||
if (! $this->renderingContext instanceof RenderingContext) {
|
||||
throw new FluidViewHelperException(
|
||||
'Something went wrong; RenderingContext should be available in ViewHelper',
|
||||
1638341674
|
||||
);
|
||||
}
|
||||
return $this->renderingContext->getRequest()->getControllerActionName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register all arguments for this viewhelper
|
||||
*/
|
||||
public function initializeArguments()
|
||||
{
|
||||
parent::initializeArguments();
|
||||
$this->registerArgument('actionName', 'string', 'action name to compare with current action', true);
|
||||
$this->registerArgument('className', 'string', 'classname that should be returned if action fits', false, ' btn-info');
|
||||
$this->registerArgument('fallbackClassName', 'string', 'fallback classname if action does not fit', false, '');
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace In2code\Femanager\ViewHelpers\Be;
|
||||
|
||||
use In2code\Femanager\Utility\ConfigurationUtility;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
|
||||
/**
|
||||
* Class IsConfirmationModuleActivatedViewHelper
|
||||
*/
|
||||
class IsConfirmationModuleActivatedViewHelper extends AbstractViewHelper
|
||||
{
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function render(): bool
|
||||
{
|
||||
return ConfigurationUtility::isConfirmationModuleActive();
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace In2code\Femanager\ViewHelpers\Be;
|
||||
|
||||
use In2code\Femanager\Utility\ConfigurationUtility;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
|
||||
/**
|
||||
* Class IsConfirmationModuleActivatedViewHelper
|
||||
*/
|
||||
class IsResendUserConfirmationRequestActivatedViewHelper extends AbstractViewHelper
|
||||
{
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function render(): bool
|
||||
{
|
||||
return ConfigurationUtility::IsResendUserConfirmationRequestActive();
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace In2code\Femanager\ViewHelpers\Condition;
|
||||
|
||||
use In2code\Femanager\Utility\BackendUserUtility;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
|
||||
/**
|
||||
* Class IsBackendAdministratorAuthenticationViewHelper
|
||||
*/
|
||||
class IsBackendAdministratorAuthenticationViewHelper extends AbstractViewHelper
|
||||
{
|
||||
/**
|
||||
* Check if a backenduser-administrator is logged in
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return BackendUserUtility::isAdminAuthentication();
|
||||
}
|
||||
}
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace In2code\Femanager\ViewHelpers\Form;
|
||||
|
||||
use SJBR\StaticInfoTables\Domain\Repository\CountryRepository;
|
||||
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Extbase\Reflection\ObjectAccess;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
|
||||
/**
|
||||
* Class GetCountriesFromStaticInfoTablesViewHelper
|
||||
*/
|
||||
class GetCountriesFromStaticInfoTablesViewHelper extends AbstractViewHelper
|
||||
{
|
||||
/**
|
||||
* @var CountryRepository
|
||||
*/
|
||||
protected $countryRepository;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
if (ExtensionManagementUtility::isLoaded('static_info_tables')) {
|
||||
$this->countryRepository = GeneralUtility::makeInstance(CountryRepository::class);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build an country array
|
||||
*
|
||||
* @param string $sorting
|
||||
* @return array
|
||||
*/
|
||||
public function render(): array
|
||||
{
|
||||
if (null === $this->countryRepository) {
|
||||
return ['ERROR: static_info_tables is not loaded'];
|
||||
}
|
||||
$key = $this->arguments['key'];
|
||||
$value = $this->arguments['value'];
|
||||
$sortbyField = $this->arguments['sortbyField'];
|
||||
$sorting = $this->arguments['sorting'];
|
||||
|
||||
$countries = $this->countryRepository->findAllOrderedBy($sortbyField, $sorting);
|
||||
$countriesArray = [];
|
||||
if ($this->arguments['preferredCountries']) {
|
||||
foreach ($this->countryRepository->findAllowedByIsoCodeA3($this->arguments['preferredCountries']) as $country) {
|
||||
$countriesArray[ObjectAccess::getProperty($country, $key)] = ObjectAccess::getProperty($country, $value);
|
||||
}
|
||||
$countriesArray['---'] = '---';
|
||||
}
|
||||
|
||||
if ($this->arguments['limitCountries']) {
|
||||
foreach ($this->countryRepository->findAllowedByIsoCodeA3($this->arguments['limitCountries']) as $country) {
|
||||
$countriesArray[ObjectAccess::getProperty($country, $key)] = ObjectAccess::getProperty($country, $value);
|
||||
}
|
||||
|
||||
return $countriesArray;
|
||||
}
|
||||
|
||||
foreach ($countries as $country) {
|
||||
/** @var $country \SJBR\StaticInfoTables\Domain\Model\Country */
|
||||
$countriesArray[ObjectAccess::getProperty($country, $key)] = ObjectAccess::getProperty($country, $value);
|
||||
}
|
||||
|
||||
return $countriesArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize
|
||||
*/
|
||||
public function initializeArguments()
|
||||
{
|
||||
parent::initializeArguments();
|
||||
$this->registerArgument('key', 'string', 'country isoCode', false, 'isoCodeA3');
|
||||
$this->registerArgument('value', 'string', 'shortNameLocal', false, 'shortNameLocal');
|
||||
$this->registerArgument('sortbyField', 'string', 'shortNameLocal', false, 'shortNameLocal');
|
||||
$this->registerArgument('sorting', 'string', 'value to prepend', false, 'asc');
|
||||
$this->registerArgument('preferredCountries', 'string', 'comma separated list of countries (iso3 code) to show on top of select', false, '');
|
||||
$this->registerArgument('limitCountries', 'string', 'comma separated list of countries (iso3 code) to show only in select', false, '');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,279 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace In2code\Femanager\ViewHelpers\Form;
|
||||
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
|
||||
/**
|
||||
* Class GetCountriesViewHelper
|
||||
*/
|
||||
class GetCountriesViewHelper extends AbstractViewHelper
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $countries = [
|
||||
'AND' => 'Andorra',
|
||||
'ARE' => 'الإمارات العربيّة المتّحدة',
|
||||
'AFG' => 'افغانستان',
|
||||
'ATG' => 'Antigua and Barbuda',
|
||||
'AIA' => 'Anguilla',
|
||||
'ALB' => 'Shqipëria',
|
||||
'ARM' => 'Հայաստան',
|
||||
'ANT' => 'Nederlandse Antillen',
|
||||
'AGO' => 'Angola',
|
||||
'ATA' => 'Antarctica',
|
||||
'ARG' => 'Argentina',
|
||||
'ASM' => 'Amerika Samoa',
|
||||
'AUT' => 'Österreich',
|
||||
'AUS' => 'Australia',
|
||||
'ABW' => 'Aruba',
|
||||
'AZE' => 'Azərbaycan',
|
||||
'BIH' => 'BiH/БиХ',
|
||||
'BRB' => 'Barbados',
|
||||
'BGD' => 'বাংলাদেশ',
|
||||
'BEL' => 'Belgique',
|
||||
'BFA' => 'Burkina',
|
||||
'BGR' => 'България (Bulgaria)',
|
||||
'BHR' => 'البحري',
|
||||
'BDI' => 'Burundi',
|
||||
'BEN' => 'Bénin',
|
||||
'BMU' => 'Bermuda',
|
||||
'BRN' => 'دارالسلام',
|
||||
'BOL' => 'Bolivia',
|
||||
'BRA' => 'Brasil',
|
||||
'BHS' => 'The Bahamas',
|
||||
'BTN' => 'Druk-Yul',
|
||||
'BVT' => 'Bouvet Island',
|
||||
'BWA' => 'Botswana',
|
||||
'BLR' => 'Беларусь',
|
||||
'BLZ' => 'Belize',
|
||||
'CAN' => 'Canada',
|
||||
'CCK' => 'Cocos (Keeling) Islands',
|
||||
'COD' => 'Congo',
|
||||
'CAF' => 'Centrafrique',
|
||||
'COG' => 'Congo-Brazzaville',
|
||||
'CHE' => 'Schweiz',
|
||||
'CIV' => 'Côte d’Ivoire',
|
||||
'COK' => 'Cook Islands',
|
||||
'CHL' => 'Chile',
|
||||
'CMR' => 'Cameroun',
|
||||
'CHN' => '中华',
|
||||
'COL' => 'Colombia',
|
||||
'CRI' => 'Costa Rica',
|
||||
'CUB' => 'Cuba',
|
||||
'CPV' => 'Cabo Verde',
|
||||
'CXR' => 'Christmas Island',
|
||||
'CYP' => 'Κύπρος / Kıbrıs',
|
||||
'CZE' => 'Česko',
|
||||
'DEU' => 'Deutschland',
|
||||
'DJI' => 'Djibouti',
|
||||
'DNK' => 'Danmark',
|
||||
'DMA' => 'Dominica',
|
||||
'DOM' => 'Quisqueya',
|
||||
'DZA' => 'الجزائ',
|
||||
'ECU' => 'Ecuador',
|
||||
'EST' => 'Eesti',
|
||||
'EGY' => 'مصر',
|
||||
'ESH' => 'الصحراء الغربي',
|
||||
'ERI' => 'ኤርትራ',
|
||||
'ESP' => 'España',
|
||||
'ETH' => 'ኢትዮጵያ',
|
||||
'FIN' => 'Suomi',
|
||||
'FJI' => 'Fiji / Viti',
|
||||
'FLK' => 'Falkland Islands',
|
||||
'FSM' => 'Micronesia',
|
||||
'FRO' => 'Føroyar / Færøerne',
|
||||
'FRA' => 'France',
|
||||
'GAB' => 'Gabon',
|
||||
'GBR' => 'United Kingdom',
|
||||
'GRD' => 'Grenada',
|
||||
'GEO' => 'საქართველო',
|
||||
'GUF' => 'Guyane française',
|
||||
'GHA' => 'Ghana',
|
||||
'GIB' => 'Gibraltar',
|
||||
'GRL' => 'Grønland',
|
||||
'GMB' => 'Gambia',
|
||||
'GIN' => 'Guinée',
|
||||
'GLP' => 'Guadeloupe',
|
||||
'GNQ' => 'Guinea Ecuatorial',
|
||||
'GRC' => 'Ελλάδα',
|
||||
'SGS' => 'South Georgia and the South Sandwich Islands',
|
||||
'GTM' => 'Guatemala',
|
||||
'GUM' => 'Guåhån',
|
||||
'GNB' => 'Guiné-Bissau',
|
||||
'GUY' => 'Guyana',
|
||||
'HKG' => '香港',
|
||||
'HND' => 'Honduras',
|
||||
'HRV' => 'Hrvatska',
|
||||
'HTI' => 'Ayiti',
|
||||
'HUN' => 'Magyarország',
|
||||
'IDN' => 'Indonesia',
|
||||
'IRL' => 'Éire',
|
||||
'ISR' => 'ישראל',
|
||||
'IND' => 'India',
|
||||
'IOT' => 'British Indian Ocean Territory',
|
||||
'IRQ' => 'العراق / عيَراق',
|
||||
'IRN' => 'ايران',
|
||||
'ISL' => 'Ísland',
|
||||
'ITA' => 'Italia',
|
||||
'JAM' => 'Jamaica',
|
||||
'JOR' => 'أردنّ',
|
||||
'JPN' => '日本',
|
||||
'KEN' => 'Kenya',
|
||||
'KGZ' => 'Кыргызстан',
|
||||
'KHM' => 'Kâmpŭchea',
|
||||
'KIR' => 'Kiribati',
|
||||
'COM' => 'اتحاد القمر',
|
||||
'KNA' => 'Saint Kitts and Nevis',
|
||||
'PRK' => '북조선',
|
||||
'KOR' => '한국',
|
||||
'KWT' => 'الكويت',
|
||||
'CYM' => 'Cayman Islands',
|
||||
'KAZ' => 'Қазақстан /Казахстан',
|
||||
'LAO' => 'ເມືອງລາວ',
|
||||
'LBN' => 'لبنان',
|
||||
'LCA' => 'Saint Lucia',
|
||||
'LIE' => 'Liechtenstein',
|
||||
'LKA' => 'ශ්රී ලංකා / இலங்கை',
|
||||
'LBR' => 'Liberia',
|
||||
'LSO' => 'Lesotho',
|
||||
'LTU' => 'Lietuva',
|
||||
'LUX' => 'Luxemburg',
|
||||
'LVA' => 'Latvija',
|
||||
'LBY' => 'ليبيا',
|
||||
'MAR' => 'المغربية',
|
||||
'MCO' => 'Monaco',
|
||||
'MDA' => 'Moldova',
|
||||
'MDG' => 'Madagascar',
|
||||
'MHL' => 'Marshall Islands',
|
||||
'MKD' => 'Македонија',
|
||||
'MLI' => 'Mali',
|
||||
'MMR' => 'Myanmar',
|
||||
'MNG' => 'Монгол Улс',
|
||||
'MAC' => '澳門 / Macau',
|
||||
'MNP' => 'Northern Marianas',
|
||||
'MTQ' => 'Martinique',
|
||||
'MRT' => 'الموريتانية',
|
||||
'MSR' => 'Montserrat',
|
||||
'MLT' => 'Malta',
|
||||
'MUS' => 'Mauritius',
|
||||
'MDV' => 'ޖުމުހޫރިއްޔ',
|
||||
'MWI' => 'Malawi',
|
||||
'MEX' => 'México',
|
||||
'MYS' => 'مليسيا',
|
||||
'MOZ' => 'Moçambique',
|
||||
'NAM' => 'Namibia',
|
||||
'NCL' => 'Nouvelle-Calédonie',
|
||||
'NER' => 'Niger',
|
||||
'NFK' => 'Norfolk Island',
|
||||
'NGA' => 'Nigeria',
|
||||
'NIC' => 'Nicaragua',
|
||||
'NLD' => 'Nederland',
|
||||
'NOR' => 'Norge',
|
||||
'NPL' => 'नेपाल',
|
||||
'NRU' => 'Naoero',
|
||||
'NIU' => 'Niue',
|
||||
'NZL' => 'New Zealand / Aotearoa',
|
||||
'OMN' => 'عُمان',
|
||||
'PAN' => 'Panamá',
|
||||
'PER' => 'Perú',
|
||||
'PYF' => 'Polynésie française',
|
||||
'PNG' => 'Papua New Guinea / Papua Niugini',
|
||||
'PHL' => 'Philippines',
|
||||
'PAK' => 'پاکستان',
|
||||
'POL' => 'Polska',
|
||||
'SPM' => 'Saint-Pierre-et-Miquelon',
|
||||
'PCN' => 'Pitcairn Islands',
|
||||
'PRI' => 'Puerto Rico',
|
||||
'PRT' => 'Portugal',
|
||||
'PLW' => 'Belau / Palau',
|
||||
'PRY' => 'Paraguay',
|
||||
'QAT' => 'قطر',
|
||||
'REU' => 'Réunion',
|
||||
'ROU' => 'România',
|
||||
'RUS' => 'Россия',
|
||||
'RWA' => 'Rwanda',
|
||||
'SAU' => 'السعودية',
|
||||
'SLB' => 'Solomon Islands',
|
||||
'SYC' => 'Seychelles',
|
||||
'SDN' => 'Sénégal',
|
||||
'SWE' => 'Sverige',
|
||||
'SGP' => 'Singapore',
|
||||
'SHN' => 'Saint Helena, Ascension and Tristan da Cunha',
|
||||
'SVN' => 'Slovenija',
|
||||
'SJM' => 'Svalbard',
|
||||
'SVK' => 'Slovensko',
|
||||
'SLE' => 'Sierra Leone',
|
||||
'SMR' => 'San Marino',
|
||||
'SEN' => 'Sénégal',
|
||||
'SOM' => 'Soomaaliya',
|
||||
'SUR' => 'Suriname',
|
||||
'STP' => 'São Tomé e Príncipe',
|
||||
'SLV' => 'El Salvador',
|
||||
'SYR' => 'سوري',
|
||||
'SWZ' => 'weSwatini',
|
||||
'TCA' => 'Turks and Caicos Islands',
|
||||
'TCD' => 'Tchad',
|
||||
'ATF' => 'Terres australes fran‡aises',
|
||||
'TGO' => 'Togo',
|
||||
'THA' => 'ไทย',
|
||||
'TJK' => 'Тоҷикистон',
|
||||
'TKL' => 'Tokelau',
|
||||
'TKM' => 'Türkmenistan',
|
||||
'TUN' => 'التونسية',
|
||||
'TON' => 'Tonga',
|
||||
'TLS' => 'Timor Lorosa\'e',
|
||||
'TUR' => 'Türkiye',
|
||||
'TTO' => 'Trinidad and Tobago',
|
||||
'TUV' => 'Tuvalu',
|
||||
'TWN' => '中華',
|
||||
'TZA' => 'Tanzania',
|
||||
'UKR' => 'Україна',
|
||||
'UGA' => 'Uganda',
|
||||
'UMI' => 'United States Minor Outlying Islands',
|
||||
'USA' => 'United States',
|
||||
'URY' => 'Uruguay',
|
||||
'UZB' => 'O‘zbekiston',
|
||||
'VAT' => 'Vaticano',
|
||||
'VCT' => 'Saint Vincent and the Grenadines',
|
||||
'VEN' => 'Venezuela',
|
||||
'VGB' => 'British Virgin Islands',
|
||||
'VIR' => 'US Virgin Islands',
|
||||
'VNM' => 'Việt Nam',
|
||||
'VUT' => 'Vanuatu',
|
||||
'WLF' => 'Wallis and Futuna',
|
||||
'WSM' => 'Samoa',
|
||||
'YEM' => 'اليمنية',
|
||||
'MYT' => 'Mayotte',
|
||||
'ZAF' => 'Afrika-Borwa',
|
||||
'ZMB' => 'Zambia',
|
||||
'ZWE' => 'Zimbabwe',
|
||||
'PSE' => 'فلسطين',
|
||||
'CSG' => 'Србија и Црна Гора',
|
||||
'ALA' => 'Åland',
|
||||
'HMD' => 'Heard Island and McDonald Islands',
|
||||
'MNE' => 'Crna Gora',
|
||||
'SRB' => 'Srbija',
|
||||
'JEY' => 'Jersey',
|
||||
'GGY' => 'Guernsey',
|
||||
'IMN' => 'Mann / Mannin',
|
||||
'MAF' => 'Saint-Martin',
|
||||
'BLM' => 'Saint-Barthélemy',
|
||||
'BES' => 'Bonaire, Sint Eustatius en Saba',
|
||||
'CUW' => 'Curaçao',
|
||||
'SXM' => 'Sint Maarten',
|
||||
'SSD' => 'South Sudan'
|
||||
];
|
||||
|
||||
/**
|
||||
* Build an country array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function render(): array
|
||||
{
|
||||
return $this->countries;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace In2code\Femanager\ViewHelpers\Form;
|
||||
|
||||
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
|
||||
use TYPO3\CMS\Fluid\Core\Rendering\RenderingContext;
|
||||
use TYPO3\CMS\Fluid\ViewHelpers\Form\SelectViewHelper as OriginalSelectViewHelper;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\Exception as FluidViewHelperException;
|
||||
|
||||
/**
|
||||
* Class SelectViewHelper
|
||||
*/
|
||||
class SelectViewHelper extends OriginalSelectViewHelper
|
||||
{
|
||||
/**
|
||||
* Initialize
|
||||
* @throws FluidViewHelperException
|
||||
*/
|
||||
public function initialize()
|
||||
{
|
||||
parent::initialize();
|
||||
|
||||
$this->tag->addAttribute('data-selected-value', $this->getSelectedValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize
|
||||
*/
|
||||
public function initializeArguments()
|
||||
{
|
||||
parent::initializeArguments();
|
||||
$this->registerArgument('defaultOption', 'string', 'value to prepend', false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Options
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
$options = parent::getOptions();
|
||||
if (!empty($this->arguments['defaultOption'])) {
|
||||
$options = ['' => $this->arguments['defaultOption']] + $options;
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the selected value(s)
|
||||
*
|
||||
* @return mixed value string or an array of strings
|
||||
* @throws FluidViewHelperException
|
||||
*/
|
||||
protected function getSelectedValue()
|
||||
{
|
||||
$selectedValue = parent::getSelectedValue();
|
||||
|
||||
// set preselection from TypoScript
|
||||
if (empty($selectedValue)) {
|
||||
if (! $this->renderingContext instanceof RenderingContext) {
|
||||
throw new FluidViewHelperException(
|
||||
'Something went wrong; RenderingContext should be available in ViewHelper',
|
||||
1638341673
|
||||
);
|
||||
}
|
||||
$controllerName = strtolower($this->renderingContext->getRequest()->getControllerName());
|
||||
$contentObject = $this->configurationManager->getContentObject();
|
||||
$typoScript = $this->configurationManager->getConfiguration(
|
||||
ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT
|
||||
);
|
||||
|
||||
$prefillTypoScript =
|
||||
$typoScript['plugin.']['tx_femanager.']['settings.'][$controllerName . '.']['prefill.'] ?? [];
|
||||
|
||||
if (!empty($prefillTypoScript[$this->getFieldName()])) {
|
||||
$selectedValue = $contentObject->cObjGetSingle(
|
||||
$prefillTypoScript[$this->getFieldName()],
|
||||
$prefillTypoScript[$this->getFieldName() . '.']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $selectedValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Field name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getFieldName()
|
||||
{
|
||||
preg_match_all('/\[.*?\]/i', $this->getNameWithoutPrefix(), $name);
|
||||
return str_replace(['[', ']'], '', $name[0][0]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace In2code\Femanager\ViewHelpers\Form;
|
||||
|
||||
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
|
||||
use TYPO3\CMS\Fluid\Core\Rendering\RenderingContext;
|
||||
use TYPO3\CMS\Fluid\ViewHelpers\Form\TextfieldViewHelper as OriginalTextfieldViewHelper;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\Exception as FluidViewHelperException;
|
||||
|
||||
/**
|
||||
* Class TextfieldViewHelper
|
||||
*/
|
||||
class TextfieldViewHelper extends OriginalTextfieldViewHelper
|
||||
{
|
||||
/**
|
||||
* Get the value of this form element (changed to prefill from TypoScript)
|
||||
* Either returns arguments['value'], or the correct value for Object Access.
|
||||
*
|
||||
* @return mixed Value
|
||||
* @throws FluidViewHelperException
|
||||
*/
|
||||
protected function getValueAttribute()
|
||||
{
|
||||
$value = parent::getValueAttribute();
|
||||
|
||||
// prefill value from TypoScript
|
||||
if (empty($value) && $this->getValueFromTypoScript()) {
|
||||
$value = $this->getValueFromTypoScript();
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read value from TypoScript
|
||||
*
|
||||
* @return string Value from TypoScript
|
||||
* @throws FluidViewHelperException
|
||||
*/
|
||||
protected function getValueFromTypoScript(): string
|
||||
{
|
||||
if (! $this->renderingContext instanceof RenderingContext) {
|
||||
throw new FluidViewHelperException(
|
||||
'Something went wrong; RenderingContext should be available in ViewHelper',
|
||||
1638341334
|
||||
);
|
||||
}
|
||||
$controllerName = strtolower($this->renderingContext->getRequest()->getControllerName());
|
||||
$contentObject = $this->configurationManager->getContentObject();
|
||||
$typoScript = $this->configurationManager->getConfiguration(
|
||||
ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT
|
||||
);
|
||||
$prefillTypoScript = $typoScript['plugin.']['tx_femanager.']['settings.'][$controllerName . '.']['prefill.'] ?? 0;
|
||||
$value = $contentObject->cObjGetSingle(
|
||||
$prefillTypoScript[$this->arguments['property']] ?? '',
|
||||
$prefillTypoScript[$this->arguments['property'] . '.'] ?? ''
|
||||
);
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace In2code\Femanager\ViewHelpers\Misc;
|
||||
|
||||
use In2code\Femanager\Utility\BackendUtility;
|
||||
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
|
||||
|
||||
/**
|
||||
* Class BackendEditLinkViewHelper
|
||||
*/
|
||||
class BackendEditLinkViewHelper extends AbstractViewHelper
|
||||
{
|
||||
use CompileWithRenderStatic;
|
||||
|
||||
/**
|
||||
* initialize arguments
|
||||
*/
|
||||
public function initializeArguments()
|
||||
{
|
||||
$this->registerArgument('tableName', 'string', 'Records table name (like "fe_users")', true);
|
||||
$this->registerArgument('identifier', 'integer', 'Record identifier to edit', true);
|
||||
$this->registerArgument('addReturnUrl', 'bool', 'Add current URI as returnUrl', false, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an URI for backend edit
|
||||
*
|
||||
* @param array $arguments
|
||||
* @param \Closure $renderChildrenClosure
|
||||
* @param RenderingContextInterface $renderingContext
|
||||
* @return string
|
||||
*/
|
||||
public static function renderStatic(
|
||||
array $arguments,
|
||||
\Closure $renderChildrenClosure,
|
||||
RenderingContextInterface $renderingContext
|
||||
): string {
|
||||
return BackendUtility::getBackendEditUri($arguments['tableName'], $arguments['identifier'], $arguments['addReturnUrl']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace In2code\Femanager\ViewHelpers\Misc;
|
||||
|
||||
use In2code\Femanager\Utility\BackendUtility;
|
||||
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
|
||||
|
||||
/**
|
||||
* Class BackendNewLinkViewHelper
|
||||
*/
|
||||
class BackendNewLinkViewHelper extends AbstractViewHelper
|
||||
{
|
||||
use CompileWithRenderStatic;
|
||||
|
||||
/**
|
||||
* initialize arguments
|
||||
*/
|
||||
public function initializeArguments()
|
||||
{
|
||||
$this->registerArgument('tableName', 'string', 'Records table name (like "fe_users")', true);
|
||||
$this->registerArgument('addReturnUrl', 'bool', 'Add current URI as returnUrl', false, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an URI for new records in backend
|
||||
*
|
||||
* @param array $arguments
|
||||
* @param \Closure $renderChildrenClosure
|
||||
* @param RenderingContextInterface $renderingContext
|
||||
* @return string
|
||||
*/
|
||||
public static function renderStatic(
|
||||
array $arguments,
|
||||
\Closure $renderChildrenClosure,
|
||||
RenderingContextInterface $renderingContext
|
||||
): string {
|
||||
return BackendUtility::getBackendNewUri($arguments['tableName'], BackendUtility::getPageIdentifier(), $arguments['addReturnUrl']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace In2code\Femanager\ViewHelpers\Misc;
|
||||
|
||||
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
|
||||
use TYPO3\CMS\Fluid\Core\Rendering\RenderingContext;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\Exception as FluidViewHelperException;
|
||||
|
||||
/**
|
||||
* Look if captcha is enabled
|
||||
*/
|
||||
class CaptchaEnabledViewHelper extends AbstractViewHelper
|
||||
{
|
||||
public function initializeArguments()
|
||||
{
|
||||
parent::initializeArguments();
|
||||
$this->registerArgument('settings', 'bool', 'array $settings TypoScript', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if captcha is enabled
|
||||
* @return bool
|
||||
* @throws FluidViewHelperException
|
||||
*/
|
||||
public function render(): bool
|
||||
{
|
||||
if (! $this->renderingContext instanceof RenderingContext) {
|
||||
throw new FluidViewHelperException(
|
||||
'Something went wrong; RenderingContext should be available in ViewHelper',
|
||||
1638341672
|
||||
);
|
||||
}
|
||||
$controllerName = strtolower($this->renderingContext->getRequest()->getControllerName());
|
||||
|
||||
return ExtensionManagementUtility::isLoaded('sr_freecap')
|
||||
&& $this->templateVariableContainer->getByPath('settings.' . $controllerName . '.validation.captcha.captcha');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace In2code\Femanager\ViewHelpers\Misc;
|
||||
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
|
||||
/**
|
||||
* Class ExplodeViewHelper
|
||||
*/
|
||||
class ExplodeViewHelper extends AbstractViewHelper
|
||||
{
|
||||
public function initializeArguments()
|
||||
{
|
||||
parent::initializeArguments();
|
||||
$this->registerArgument('string', 'string', 'Any list (e.g. "a,b,c,d")', false);
|
||||
$this->registerArgument('seperator', 'string', 'Separator sign (e.g. ",")', false, ',');
|
||||
$this->registerArgument('trim', 'bool', 'Should be trimmed?', false, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* View helper to explode a list
|
||||
* @return array
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$string = $this->arguments['string'];
|
||||
$separator = $this->arguments['seperator'];
|
||||
$trim = $this->arguments['trim'];
|
||||
|
||||
return $trim ? GeneralUtility::trimExplode($separator, $string, true) : explode($separator, $string);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace In2code\Femanager\ViewHelpers\Misc;
|
||||
|
||||
use TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper;
|
||||
|
||||
/**
|
||||
* Class GetFirstViewHelper
|
||||
*/
|
||||
class GetFirstViewHelper extends AbstractFormFieldViewHelper
|
||||
{
|
||||
/**
|
||||
* Initialize the arguments.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function initializeArguments()
|
||||
{
|
||||
parent::initializeArguments();
|
||||
$this->registerUniversalTagAttributes();
|
||||
$this->registerArgument('objectStorage', 'object', 'first subobject of objectstorage', false);
|
||||
}
|
||||
|
||||
/**
|
||||
* View helper to get first subobject of objectstorage
|
||||
*
|
||||
* @return \mixed
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$objectStorage = $this->arguments['objectStorage'];
|
||||
if ($objectStorage === null) {
|
||||
return null;
|
||||
}
|
||||
foreach ($objectStorage as $object) {
|
||||
return $object;
|
||||
}
|
||||
|
||||
// try to get value from originalRequest
|
||||
if ($this->configurationManager->isFeatureEnabled('rewrittenPropertyMapper')) {
|
||||
// seperate if version is 6.2 or lower
|
||||
if ((method_exists($this, 'hasMappingErrorOccured') && $this->hasMappingErrorOccured()) ||
|
||||
(method_exists($this, 'hasMappingErrorOccurred') && $this->hasMappingErrorOccurred())
|
||||
) {
|
||||
return $this->getValueAttribute();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace In2code\Femanager\ViewHelpers\Misc;
|
||||
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
|
||||
/**
|
||||
* Class JsonEncodeViewHelper
|
||||
*/
|
||||
class JsonEncodeViewHelper extends AbstractViewHelper
|
||||
{
|
||||
/**
|
||||
* @var null
|
||||
*/
|
||||
protected $escapeOutput = false;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function render(): string
|
||||
{
|
||||
$array = $this->arguments['array'];
|
||||
|
||||
return json_encode($array);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the arguments.
|
||||
*/
|
||||
public function initializeArguments()
|
||||
{
|
||||
parent::initializeArguments();
|
||||
$this->registerArgument('array', 'array ', 'Json array', false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace In2code\Femanager\ViewHelpers\Misc;
|
||||
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
|
||||
/**
|
||||
* Class RequestViewHelper
|
||||
*/
|
||||
class RequestViewHelper extends AbstractViewHelper
|
||||
{
|
||||
/**
|
||||
* @var array|string
|
||||
*/
|
||||
protected $variable = [];
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $depth = 1;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $testVariables;
|
||||
|
||||
/**
|
||||
* Get a GET or POST parameter
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render(): string
|
||||
{
|
||||
$parameter = $this->arguments['parameter'];
|
||||
$htmlspecialchars = $this->arguments['htmlspecialchars'];
|
||||
|
||||
$parts = $this->init($parameter);
|
||||
$result = $this->getVariableFromDepth($parts);
|
||||
if ($htmlspecialchars === true) {
|
||||
if (is_string($result)) {
|
||||
$result = htmlspecialchars($result);
|
||||
}
|
||||
}
|
||||
if (is_array($result) or $result === null) {
|
||||
// ensure that the return value is always as string
|
||||
$result='';
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $param
|
||||
* @return array|string
|
||||
*/
|
||||
protected function getVariableFromDepth(array $param)
|
||||
{
|
||||
if (is_array($this->variable)) {
|
||||
$this->variable = $this->variable[$param[$this->depth]] ?? null;
|
||||
$this->depth++;
|
||||
$this->getVariableFromDepth($param);
|
||||
}
|
||||
|
||||
return $this->variable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initially sets $this->variable
|
||||
*
|
||||
* @param $parameter
|
||||
* @return array
|
||||
*/
|
||||
protected function init($parameter)
|
||||
{
|
||||
$parts = explode('|', $parameter);
|
||||
$this->variable = GeneralUtility::_GP($parts[0]);
|
||||
if ($this->testVariables) {
|
||||
$this->variable = $this->testVariables[$parts[0]];
|
||||
}
|
||||
|
||||
return $parts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register all arguments for this viewhelper
|
||||
*/
|
||||
public function initializeArguments()
|
||||
{
|
||||
parent::initializeArguments();
|
||||
$this->registerArgument('parameter', 'string', 'like tx_ext_pi1|list|field', false, '');
|
||||
$this->registerArgument('htmlspecialchars', 'bool', 'Enable/Disable htmlspecialchars', false, true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace In2code\Femanager\ViewHelpers\Misc;
|
||||
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
|
||||
/**
|
||||
* Class UpperViewHelper
|
||||
*/
|
||||
class UpperViewHelper extends AbstractViewHelper
|
||||
{
|
||||
public function initializeArguments()
|
||||
{
|
||||
parent::initializeArguments();
|
||||
$this->registerArgument('string', 'string', 'string', false);
|
||||
}
|
||||
|
||||
public function render(): string
|
||||
{
|
||||
return ucfirst((string)($this->arguments['string'] ?? ''));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace In2code\Femanager\ViewHelpers\Pagination;
|
||||
|
||||
use Closure;
|
||||
use In2code\Femanager\Exception\NotPaginatableException;
|
||||
use TYPO3\CMS\Core\Pagination\ArrayPaginator;
|
||||
use TYPO3\CMS\Core\Pagination\PaginationInterface;
|
||||
use TYPO3\CMS\Core\Pagination\PaginatorInterface;
|
||||
use TYPO3\CMS\Core\Pagination\SimplePagination;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Extbase\Pagination\QueryResultPaginator;
|
||||
use TYPO3\CMS\Extbase\Persistence\QueryResultInterface;
|
||||
use TYPO3\CMS\Extbase\Service\ExtensionService;
|
||||
use TYPO3\CMS\Fluid\Core\Rendering\RenderingContext;
|
||||
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\Exception as FluidViewHelperException;
|
||||
|
||||
/**
|
||||
* PaginateViewHelper
|
||||
*/
|
||||
class PaginateViewHelper extends AbstractViewHelper
|
||||
{
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $escapeOutput = false;
|
||||
|
||||
public function initializeArguments()
|
||||
{
|
||||
parent::initializeArguments();
|
||||
$this->registerArgument('objects', 'mixed', 'array or queryresult', true);
|
||||
$this->registerArgument('as', 'string', 'new variable name', true);
|
||||
$this->registerArgument('itemsPerPage', 'int', 'items per page', false, 10);
|
||||
$this->registerArgument('name', 'string', 'unique identification - will take "as" as fallback', false, '');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $arguments
|
||||
* @param Closure $renderChildrenClosure
|
||||
* @param RenderingContextInterface $renderingContext
|
||||
* @return string
|
||||
* @throws NotPaginatableException
|
||||
*/
|
||||
public static function renderStatic(
|
||||
array $arguments,
|
||||
Closure $renderChildrenClosure,
|
||||
RenderingContextInterface $renderingContext
|
||||
): string {
|
||||
if ($arguments['objects'] === null) {
|
||||
return $renderChildrenClosure();
|
||||
}
|
||||
$templateVariableContainer = $renderingContext->getVariableProvider();
|
||||
$templateVariableContainer->add($arguments['as'], [
|
||||
'pagination' => self::getPagination($arguments, $renderingContext),
|
||||
'paginator' => self::getPaginator($arguments, $renderingContext),
|
||||
'name' => self::getName($arguments)
|
||||
]);
|
||||
$output = $renderChildrenClosure();
|
||||
$templateVariableContainer->remove($arguments['as']);
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $arguments
|
||||
* @param RenderingContextInterface $renderingContext
|
||||
* @return PaginationInterface
|
||||
* @throws NotPaginatableException
|
||||
*/
|
||||
protected static function getPagination(
|
||||
array $arguments,
|
||||
RenderingContextInterface $renderingContext
|
||||
): PaginationInterface {
|
||||
$paginator = self::getPaginator($arguments, $renderingContext);
|
||||
return GeneralUtility::makeInstance(SimplePagination::class, $paginator);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $arguments
|
||||
* @param RenderingContextInterface $renderingContext
|
||||
* @return PaginatorInterface
|
||||
* @throws NotPaginatableException
|
||||
* @throws FluidViewHelperException
|
||||
*/
|
||||
protected static function getPaginator(
|
||||
array $arguments,
|
||||
RenderingContextInterface $renderingContext
|
||||
): PaginatorInterface {
|
||||
if (is_array($arguments['objects'])) {
|
||||
$paginatorClass = ArrayPaginator::class;
|
||||
} elseif (is_a($arguments['objects'], QueryResultInterface::class)) {
|
||||
$paginatorClass = QueryResultPaginator::class;
|
||||
} else {
|
||||
throw new NotPaginatableException('Given object is not supported for pagination', 1634132847);
|
||||
}
|
||||
return GeneralUtility::makeInstance(
|
||||
$paginatorClass,
|
||||
$arguments['objects'],
|
||||
self::getPageNumber($arguments, $renderingContext),
|
||||
$arguments['itemsPerPage']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $arguments
|
||||
* @param RenderingContextInterface $renderingContext
|
||||
* @return int
|
||||
* @throws FluidViewHelperException
|
||||
*/
|
||||
protected static function getPageNumber(array $arguments, RenderingContextInterface $renderingContext): int
|
||||
{
|
||||
if (! $renderingContext instanceof RenderingContext) {
|
||||
throw new FluidViewHelperException(
|
||||
'Something went wrong; RenderingContext should be available in ViewHelper',
|
||||
1637986936
|
||||
);
|
||||
}
|
||||
$extensionName = $renderingContext->getRequest()->getControllerExtensionName();
|
||||
$pluginName = $renderingContext->getRequest()->getPluginName();
|
||||
$extensionService = GeneralUtility::makeInstance(ExtensionService::class);
|
||||
$pluginNamespace = $extensionService->getPluginNamespace($extensionName, $pluginName);
|
||||
$variables = GeneralUtility::_GP($pluginNamespace);
|
||||
if ($variables !== null) {
|
||||
if (!empty($variables[self::getName($arguments)]['currentPage'])) {
|
||||
return (int)$variables[self::getName($arguments)]['currentPage'];
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $arguments
|
||||
* @return string
|
||||
*/
|
||||
protected static function getName(array $arguments): string
|
||||
{
|
||||
return $arguments['name'] ?: $arguments['as'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace In2code\Femanager\ViewHelpers\Pagination;
|
||||
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Extbase\Service\ExtensionService;
|
||||
use TYPO3\CMS\Fluid\Core\Rendering\RenderingContext;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\Exception as FluidViewHelperException;
|
||||
|
||||
/**
|
||||
* UriViewHelper
|
||||
*/
|
||||
class UriViewHelper extends AbstractTagBasedViewHelper
|
||||
{
|
||||
/**
|
||||
* Initialize arguments
|
||||
*/
|
||||
public function initializeArguments()
|
||||
{
|
||||
parent::initializeArguments();
|
||||
$this->registerArgument('name', 'string', 'identifier important if more widgets on same page', false, 'widget');
|
||||
$this->registerArgument('arguments', 'array', 'Arguments', false, []);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build an uri to current action with &tx_ext_plugin[currentPage]=2
|
||||
*
|
||||
* @return string The rendered uri
|
||||
* @throws FluidViewHelperException
|
||||
*/
|
||||
public function render(): string
|
||||
{
|
||||
if (! $this->renderingContext instanceof RenderingContext) {
|
||||
throw new FluidViewHelperException(
|
||||
'Something went wrong; RenderingContext should be available in ViewHelper',
|
||||
1638341671
|
||||
);
|
||||
}
|
||||
$uriBuilder = $this->renderingContext->getUriBuilder();
|
||||
$extensionName = $this->renderingContext->getRequest()->getControllerExtensionName();
|
||||
$pluginName = $this->renderingContext->getRequest()->getPluginName();
|
||||
$extensionService = GeneralUtility::makeInstance(ExtensionService::class);
|
||||
$pluginNamespace = $extensionService->getPluginNamespace($extensionName, $pluginName);
|
||||
$argumentPrefix = $pluginNamespace . '[' . $this->arguments['name'] . ']';
|
||||
$arguments = $this->hasArgument('arguments') ? $this->arguments['arguments'] : [];
|
||||
if ($this->hasArgument('action')) {
|
||||
$arguments['action'] = $this->arguments['action'];
|
||||
}
|
||||
if ($this->hasArgument('format') && $this->arguments['format'] !== '') {
|
||||
$arguments['format'] = $this->arguments['format'];
|
||||
}
|
||||
$uriBuilder->reset()
|
||||
->setArguments([$argumentPrefix => $arguments])
|
||||
->setAddQueryString(true)
|
||||
->setArgumentsToBeExcludedFromQueryString([$argumentPrefix, 'cHash']);
|
||||
return $uriBuilder->build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace In2code\Femanager\ViewHelpers\Repository;
|
||||
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
|
||||
/**
|
||||
* Class GetFirstViewHelper
|
||||
*/
|
||||
class GetFirstViewHelper extends AbstractViewHelper
|
||||
{
|
||||
/**
|
||||
* Call getFirst() method of object storage
|
||||
*
|
||||
* @return object|null
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$objects = $this->arguments['objects'];
|
||||
if (method_exists($objects, 'getFirst')) {
|
||||
return $objects->getFirst();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the arguments.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function initializeArguments()
|
||||
{
|
||||
parent::initializeArguments();
|
||||
$this->registerUniversalTagAttributes();
|
||||
$this->registerArgument('objects', 'object ', 'Call getFirst() method of object storage', true);
|
||||
}
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace In2code\Femanager\ViewHelpers\Validation;
|
||||
|
||||
use TYPO3\CMS\Fluid\Core\Rendering\RenderingContext;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\Exception as FluidViewHelperException;
|
||||
|
||||
/**
|
||||
* Class AbstractValidationViewHelper
|
||||
*/
|
||||
abstract class AbstractValidationViewHelper extends AbstractViewHelper
|
||||
{
|
||||
/**
|
||||
* Get key for typoscript configuration "validation"
|
||||
*
|
||||
* @return string
|
||||
* @throws FluidViewHelperException
|
||||
*/
|
||||
protected function getValidationName(): string
|
||||
{
|
||||
$validationName = 'validation';
|
||||
|
||||
// special case for second step in invitation
|
||||
if (! $this->renderingContext instanceof RenderingContext) {
|
||||
throw new FluidViewHelperException(
|
||||
'Something went wrong; RenderingContext should be available in ViewHelper',
|
||||
1638341336
|
||||
);
|
||||
}
|
||||
if ($this->getControllerName() === 'invitation' &&
|
||||
$this->renderingContext->getRequest()->getControllerActionName() === 'edit') {
|
||||
$validationName = 'validationEdit';
|
||||
}
|
||||
|
||||
return $validationName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return controllername in lowercase
|
||||
*
|
||||
* @return string "new", "edit", "invitation"
|
||||
* @throws FluidViewHelperException
|
||||
*/
|
||||
protected function getControllerName(): string
|
||||
{
|
||||
if (! $this->renderingContext instanceof RenderingContext) {
|
||||
throw new FluidViewHelperException(
|
||||
'Something went wrong; RenderingContext should be available in ViewHelper',
|
||||
1638341335
|
||||
);
|
||||
}
|
||||
return strtolower($this->renderingContext->getRequest()->getControllerName());
|
||||
}
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace In2code\Femanager\ViewHelpers\Validation;
|
||||
|
||||
use In2code\Femanager\Domain\Service\ValidationSettingsService;
|
||||
use Psr\Log\LoggerAwareInterface;
|
||||
use Psr\Log\LoggerAwareTrait;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
|
||||
/**
|
||||
* Class FormValidationDataViewHelper
|
||||
*/
|
||||
class FormValidationDataViewHelper extends AbstractValidationViewHelper implements LoggerAwareInterface
|
||||
{
|
||||
use LoggerAwareTrait;
|
||||
|
||||
/**
|
||||
* Set javascript validation data for input fields
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$settings = $this->arguments['settings'];
|
||||
$fieldName = $this->arguments['fieldName'];
|
||||
$additionalAttributes = $this->arguments['additionalAttributes'];
|
||||
|
||||
if ($settings !== []) {
|
||||
$this->logger->debug(
|
||||
'Settings should not be filled any more in field partials. Pls update your femanager partial files.'
|
||||
);
|
||||
}
|
||||
$validationService = GeneralUtility::makeInstance(
|
||||
ValidationSettingsService::class,
|
||||
$this->getControllerName(),
|
||||
$this->getValidationName()
|
||||
);
|
||||
if ($validationService->isValidationEnabled('client')) {
|
||||
$validationString = $validationService->getValidationStringForField($fieldName);
|
||||
if (!empty($validationString)) {
|
||||
if (!empty($additionalAttributes['data-validation'])) {
|
||||
$additionalAttributes['data-validation'] .= ',' . $validationString;
|
||||
} else {
|
||||
$additionalAttributes['data-validation'] = $validationString;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $additionalAttributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the arguments.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function initializeArguments()
|
||||
{
|
||||
parent::initializeArguments();
|
||||
$this->registerArgument('settings', 'array ', 'all TypoScript settings for this form', true);
|
||||
$this->registerArgument('fieldName', 'string ', 'Fieldname which should get validated', true);
|
||||
$this->registerArgument('additionalAttributes', 'array ', '$additionalAttributes for this field', false);
|
||||
}
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace In2code\Femanager\ViewHelpers\Validation;
|
||||
|
||||
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
|
||||
|
||||
/**
|
||||
* Class IsRequiredFieldViewHelper
|
||||
*/
|
||||
class IsRequiredFieldViewHelper extends AbstractValidationViewHelper
|
||||
{
|
||||
protected ConfigurationManagerInterface $configurationManager;
|
||||
|
||||
/**
|
||||
* @param ConfigurationManagerInterface $configurationManager
|
||||
*/
|
||||
public function __construct(ConfigurationManagerInterface $configurationManager)
|
||||
{
|
||||
$this->configurationManager = $configurationManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if this field is a required field
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$fieldName = $this->arguments['fieldName'];
|
||||
$settings = $this->getSettingsConfiguration();
|
||||
|
||||
return !empty($settings[$this->getControllerName()][$this->getValidationName()][$fieldName]['required']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function getSettingsConfiguration()
|
||||
{
|
||||
return (array)$this->configurationManager->getConfiguration(
|
||||
ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS,
|
||||
'Femanager',
|
||||
'Pi1'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the arguments.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function initializeArguments()
|
||||
{
|
||||
parent::initializeArguments();
|
||||
$this->registerArgument('fieldName', 'string ', 'Check if this field is a required field', true);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user