use Symfony\Component\Security\Core\Security; | use Symfony\Component\Security\Core\Security; | ||||
use Symfony\Component\Security\Http\Authenticator\AbstractLoginFormAuthenticator; | use Symfony\Component\Security\Http\Authenticator\AbstractLoginFormAuthenticator; | ||||
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\CsrfTokenBadge; | use Symfony\Component\Security\Http\Authenticator\Passport\Badge\CsrfTokenBadge; | ||||
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\RememberMeBadge; | |||||
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge; | use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge; | ||||
use Symfony\Component\Security\Http\Authenticator\Passport\Credentials\PasswordCredentials; | use Symfony\Component\Security\Http\Authenticator\Passport\Credentials\PasswordCredentials; | ||||
use Symfony\Component\Security\Http\Authenticator\Passport\Passport; | use Symfony\Component\Security\Http\Authenticator\Passport\Passport; | ||||
return $this->userStore->getOneByEmail($userIdentifier); | return $this->userStore->getOneByEmail($userIdentifier); | ||||
}), | }), | ||||
new PasswordCredentials($password), | new PasswordCredentials($password), | ||||
[new CsrfTokenBadge('authenticate', $csrfToken)] | |||||
[ | |||||
new CsrfTokenBadge('authenticate', $csrfToken), | |||||
new RememberMeBadge() | |||||
] | |||||
); | ); | ||||
} | } | ||||
$path = substr($path, 1); | $path = substr($path, 1); | ||||
} | } | ||||
// gestion des accents et des espaces | |||||
$path = urldecode($path); | |||||
if ($path) { | if ($path) { | ||||
$fileManagerFolder = substr($this->getFileManagerFolder(), 1); | $fileManagerFolder = substr($this->getFileManagerFolder(), 1); |
namespace Lc\SovBundle\Container; | namespace Lc\SovBundle\Container; | ||||
use Lc\SovBundle\Component\ArrayComponent; | |||||
use Lc\SovBundle\Component\CitiesComponent; | use Lc\SovBundle\Component\CitiesComponent; | ||||
use Lc\SovBundle\Component\CookieComponent; | use Lc\SovBundle\Component\CookieComponent; | ||||
use Lc\SovBundle\Component\DateComponent; | use Lc\SovBundle\Component\DateComponent; |
use Lc\SovBundle\Container\User\GroupUserContainer; | use Lc\SovBundle\Container\User\GroupUserContainer; | ||||
use Lc\SovBundle\Container\User\UserContainer; | use Lc\SovBundle\Container\User\UserContainer; | ||||
use Lc\SovBundle\Field\Filter\FilterManager; | use Lc\SovBundle\Field\Filter\FilterManager; | ||||
use Lc\SovBundle\Generator\PdfGenerator; | |||||
use Lc\SovBundle\Repository\EntityRepository; | use Lc\SovBundle\Repository\EntityRepository; | ||||
use Lc\SovBundle\Solver\Setting\SettingSolver; | use Lc\SovBundle\Solver\Setting\SettingSolver; | ||||
use Lc\SovBundle\Translation\FlashBagTranslator; | use Lc\SovBundle\Translation\FlashBagTranslator; | ||||
use Symfony\Component\HttpFoundation\Session\SessionInterface; | use Symfony\Component\HttpFoundation\Session\SessionInterface; | ||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface; | use Symfony\Component\Routing\Generator\UrlGeneratorInterface; | ||||
use Symfony\Component\Security\Core\Security; | use Symfony\Component\Security\Core\Security; | ||||
use Symfony\Component\Security\Http\RememberMe\TokenBasedRememberMeServices; | |||||
use Symfony\Contracts\Translation\TranslatorInterface; | use Symfony\Contracts\Translation\TranslatorInterface; | ||||
use Twig\Environment; | use Twig\Environment; | ||||
LoggerInterface::class => LoggerInterface::class, | LoggerInterface::class => LoggerInterface::class, | ||||
ParameterBagInterface::class => ParameterBagInterface::class, | ParameterBagInterface::class => ParameterBagInterface::class, | ||||
TranslatorInterface::class => TranslatorInterface::class, | TranslatorInterface::class => TranslatorInterface::class, | ||||
PdfGenerator::class => PdfGenerator::class, | |||||
TranslatorAdmin::class => TranslatorAdmin::class, | TranslatorAdmin::class => TranslatorAdmin::class, | ||||
FilterManager::class => FilterManager::class, | FilterManager::class => FilterManager::class, | ||||
FlashBagTranslator::class => FlashBagTranslator::class, | FlashBagTranslator::class => FlashBagTranslator::class, | ||||
return $this->get(TranslatorInterface::class); | return $this->get(TranslatorInterface::class); | ||||
} | } | ||||
public function getPdfGenerator(): PdfGenerator | |||||
{ | |||||
return $this->get(PdfGenerator::class); | |||||
} | |||||
public function getTranslatorAdmin(): TranslatorAdmin | public function getTranslatorAdmin(): TranslatorAdmin | ||||
{ | { | ||||
return $this->get(TranslatorAdmin::class); | return $this->get(TranslatorAdmin::class); | ||||
return $this->get(SiteSettingContainer::class); | return $this->get(SiteSettingContainer::class); | ||||
} | } | ||||
public function setNoMemoryAndTimeLimit(): void | |||||
{ | |||||
ini_set('memory_limit', '-1'); | |||||
set_time_limit(0); | |||||
} | |||||
} | } |
]; | ]; | ||||
} | } | ||||
public function configurePanelMain(): array | |||||
public function configurePanelGeneral(): array | |||||
{ | { | ||||
return [ | return [ | ||||
'title', | 'title', | ||||
public function configurePanels(): array | public function configurePanels(): array | ||||
{ | { | ||||
return ['main', 'seo', 'conf']; | |||||
return ['general', 'seo', 'conf']; | |||||
} | } | ||||
public function configureFields(): array | public function configureFields(): array |
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; | use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; | ||||
class LcSovExtension extends Extension implements PrependExtensionInterface | |||||
class LcSovExtension extends Extension implements PrependExtensionInterface | |||||
{ | { | ||||
public function load(array $configs, ContainerBuilder $container) | |||||
{ | |||||
$configuration = new Configuration(); | |||||
$config = $this->processConfiguration($configuration, $configs); | |||||
public function load(array $configs, ContainerBuilder $container) | |||||
{ | |||||
$configuration = new Configuration(); | |||||
$config = $this->processConfiguration($configuration, $configs); | |||||
foreach ($config as $parameter => $value) | |||||
$container->setParameter(sprintf('lc_sov.%s', $parameter), $value); | |||||
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); | |||||
$loader->load('services.yaml'); | |||||
foreach ($config as $parameter => $value) { | |||||
$container->setParameter(sprintf('lc_sov.%s', $parameter), $value); | |||||
} | } | ||||
public function prepend(ContainerBuilder $container) | |||||
{ | |||||
/*$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config/easy_admin')); | |||||
$loader->load('base.yaml'); | |||||
$loader->load('entities/merchant.yaml');*/ | |||||
} | |||||
$loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); | |||||
$loader->load('services.yaml'); | |||||
} | |||||
public function prepend(ContainerBuilder $container) | |||||
{ | |||||
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config/packages')); | |||||
$loader->load('ch_cookie_consent.yaml'); | |||||
/*$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config/easy_admin')); | |||||
$loader->load('base.yaml'); | |||||
$loader->load('entities/merchant.yaml');*/ | |||||
} | |||||
} | } |
<?php | |||||
namespace Lc\SovBundle\Form\Common; | |||||
use ConnectHolland\CookieConsentBundle\Cookie\CookieChecker; | |||||
use Symfony\Component\Form\AbstractTypeExtension; | |||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; | |||||
use Symfony\Component\Form\FormBuilderInterface; | |||||
use ConnectHolland\CookieConsentBundle\Form\CookieConsentType as BaseCookieConsentType; | |||||
class CookieConsentTypeExtension extends AbstractTypeExtension | |||||
{ | |||||
/** | |||||
* @var CookieChecker | |||||
*/ | |||||
protected $cookieChecker; | |||||
/** | |||||
* @var array | |||||
*/ | |||||
protected $cookieCategories; | |||||
/** | |||||
* @var bool | |||||
*/ | |||||
protected $cookieConsentSimplified; | |||||
public function __construct( | |||||
CookieChecker $cookieChecker, | |||||
array $cookieCategories = [], | |||||
bool $cookieConsentSimplified = null | |||||
) { | |||||
$this->cookieChecker = $cookieChecker; | |||||
$this->cookieCategories = $cookieCategories; | |||||
$this->cookieConsentSimplified = $cookieConsentSimplified; | |||||
} | |||||
public function buildForm(FormBuilderInterface $builder, array $options) | |||||
{ | |||||
foreach ($this->cookieCategories as $category) { | |||||
$builder->remove($category); | |||||
$data = 'true'; | |||||
if ($this->cookieChecker->isCookieConsentSavedByUser() && !$this->cookieChecker->isCategoryAllowedByUser( | |||||
$category | |||||
)) { | |||||
$data = 'false'; | |||||
} | |||||
$builder->add( | |||||
$category, | |||||
ChoiceType::class, | |||||
[ | |||||
'expanded' => true, | |||||
'multiple' => false, | |||||
'data' => $data, | |||||
'choices' => [ | |||||
['ch_cookie_consent.yes' => 'true'], | |||||
['ch_cookie_consent.no' => 'false'], | |||||
], | |||||
] | |||||
); | |||||
} | |||||
} | |||||
public static function getExtendedTypes(): iterable | |||||
{ | |||||
return [BaseCookieConsentType::class]; | |||||
} | |||||
} |
$this->em = $entityManager; | $this->em = $entityManager; | ||||
} | } | ||||
public function buildForm(FormBuilderInterface $builder, array $options) | public function buildForm(FormBuilderInterface $builder, array $options) | ||||
{ | { | ||||
$builder->add('path', HiddenType::class, array( | $builder->add('path', HiddenType::class, array( |
<?php | |||||
namespace Lc\SovBundle\Form\Common; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Form\DataTransformer\StringToFileTransformer; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Form\Type\Model\FileUploadState; | |||||
use Lc\SovBundle\Model\File\FileInterface; | |||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; | |||||
use Symfony\Component\Form\DataMapperInterface; | |||||
use Symfony\Component\Form\DataTransformerInterface; | |||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType; | |||||
use Symfony\Component\Form\FormInterface; | |||||
use Symfony\Component\HttpFoundation\File\File; | |||||
use Lc\SovBundle\Doctrine\EntityManager; | |||||
use Symfony\Component\Form\AbstractType; | |||||
use Symfony\Component\Form\Extension\Core\Type\FileType; | |||||
use Symfony\Component\Form\Extension\Core\Type\TextType; | |||||
use Symfony\Component\Form\FormBuilderInterface; | |||||
use Symfony\Component\HttpFoundation\File\UploadedFile; | |||||
use Symfony\Component\OptionsResolver\Exception\InvalidArgumentException; | |||||
use Symfony\Component\OptionsResolver\Options; | |||||
use Symfony\Component\OptionsResolver\OptionsResolver; | |||||
use Symfony\Component\String\Slugger\AsciiSlugger; | |||||
use Symfony\Component\Uid\Ulid; | |||||
use Symfony\Component\Uid\Uuid; | |||||
class FileUploadType extends AbstractType implements DataMapperInterface, DataTransformerInterface | |||||
{ | |||||
protected string $projectDir; | |||||
protected EntityManager $entityManager; | |||||
public function __construct(EntityManager $entityManager, ParameterBagInterface $parameterBag) | |||||
{ | |||||
$this->projectDir = $parameterBag->get('kernel.project_dir'); | |||||
$this->entityManager = $entityManager; | |||||
} | |||||
public function buildForm(FormBuilderInterface $builder, array $options) | |||||
{ | |||||
$uploadDir = $options['upload_dir']; | |||||
$uploadFilename = $options['upload_filename']; | |||||
$uploadValidate = $options['upload_validate']; | |||||
$allowAdd = $options['allow_add']; | |||||
unset($options['upload_dir'], $options['upload_new'], $options['upload_delete'], $options['upload_filename'], $options['upload_validate'], $options['download_path'], $options['allow_add'], $options['allow_delete'], $options['compound']); | |||||
$builder->add('path', FileType::class, $options); | |||||
$builder->add('legend', TextType::class, array( | |||||
'attr' => [ | |||||
"placeholder" => 'Légende' | |||||
], | |||||
'label' => false | |||||
)); | |||||
$builder->add('delete', CheckboxType::class, ['required' => false, 'mapped' => false]); | |||||
$builder->setDataMapper($this); | |||||
$builder->setAttribute('state', new FileUploadState($allowAdd)); | |||||
$builder->addModelTransformer(new StringToFileTransformer($uploadDir, $uploadFilename, $uploadValidate, $options['multiple'])); | |||||
/* | |||||
$builder->add('path', FileType::class, array( | |||||
'block_prefix' => 'file_manager_image', | |||||
'label' => false | |||||
)); | |||||
$builder->add('legend', TextType::class, array( | |||||
'block_prefix' => 'file_upload_legend', | |||||
'attr' => array( | |||||
"placeholder" => 'Légende' | |||||
), | |||||
'label' => false | |||||
)); | |||||
$builder->add('position', HiddenType::class, array( | |||||
'block_prefix' => 'file_upload_position', | |||||
'empty_data' => 0, | |||||
'required' => true, | |||||
'attr' => array( | |||||
'class' => 'field-position' | |||||
), | |||||
'label' => false | |||||
)); | |||||
*/ | |||||
} | |||||
/** | |||||
* {@inheritdoc} | |||||
*/ | |||||
public function configureOptions(OptionsResolver $resolver): void | |||||
{ | |||||
$uploadNew = static function (UploadedFile $file, string $uploadDir, string $fileName) { | |||||
$file->move($uploadDir, $fileName); | |||||
}; | |||||
$uploadDelete = static function (File $file) { | |||||
unlink($file->getPathname()); | |||||
}; | |||||
$uploadFilename = static function (UploadedFile $file): string { | |||||
return $file->getClientOriginalName(); | |||||
}; | |||||
$uploadValidate = static function (string $filename): string { | |||||
if (!file_exists($filename)) { | |||||
return $filename; | |||||
} | |||||
$index = 1; | |||||
$pathInfo = pathinfo($filename); | |||||
while (file_exists($filename = sprintf('%s/%s_%d.%s', $pathInfo['dirname'], $pathInfo['filename'], $index, $pathInfo['extension']))) { | |||||
++$index; | |||||
} | |||||
return $filename; | |||||
}; | |||||
$downloadPath = function (Options $options) { | |||||
return mb_substr($options['upload_dir'], mb_strlen($this->projectDir.'/public/')); | |||||
}; | |||||
$allowAdd = static function (Options $options) { | |||||
return $options['multiple']; | |||||
}; | |||||
$dataClass = static function (Options $options) { | |||||
return $options['multiple'] ? null : File::class; | |||||
}; | |||||
$emptyData = static function (Options $options) { | |||||
return $options['multiple'] ? [] : null; | |||||
}; | |||||
$resolver->setDefaults([ | |||||
'upload_dir' => $this->projectDir.'/public/uploads/files/', | |||||
'upload_new' => $uploadNew, | |||||
'upload_delete' => $uploadDelete, | |||||
'upload_filename' => $uploadFilename, | |||||
'upload_validate' => $uploadValidate, | |||||
'download_path' => $downloadPath, | |||||
'allow_add' => $allowAdd, | |||||
'allow_delete' => true, | |||||
//'data_class' => $dataClass, | |||||
'data_class' => $this->entityManager->getEntityName(FileInterface::class), | |||||
'empty_data' => $emptyData, | |||||
'multiple' => false, | |||||
'required' => false, | |||||
'error_bubbling' => false, | |||||
'allow_file_upload' => true, | |||||
]); | |||||
$resolver->setAllowedTypes('upload_dir', 'string'); | |||||
$resolver->setAllowedTypes('upload_new', 'callable'); | |||||
$resolver->setAllowedTypes('upload_delete', 'callable'); | |||||
$resolver->setAllowedTypes('upload_filename', ['string', 'callable']); | |||||
$resolver->setAllowedTypes('upload_validate', 'callable'); | |||||
$resolver->setAllowedTypes('download_path', ['null', 'string']); | |||||
$resolver->setAllowedTypes('allow_add', 'bool'); | |||||
$resolver->setAllowedTypes('allow_delete', 'bool'); | |||||
$resolver->setNormalizer('upload_dir', function (Options $options, string $value): string { | |||||
if (\DIRECTORY_SEPARATOR !== mb_substr($value, -1)) { | |||||
$value .= \DIRECTORY_SEPARATOR; | |||||
} | |||||
if (0 !== mb_strpos($value, $this->projectDir)) { | |||||
$value = $this->projectDir.'/'.$value; | |||||
} | |||||
if ('' !== $value && (!is_dir($value) || !is_writable($value))) { | |||||
throw new InvalidArgumentException(sprintf('Invalid upload directory "%s" it does not exist or is not writable.', $value)); | |||||
} | |||||
return $value; | |||||
}); | |||||
$resolver->setNormalizer('upload_filename', static function (Options $options, $fileNamePatternOrCallable) { | |||||
if (\is_callable($fileNamePatternOrCallable)) { | |||||
return $fileNamePatternOrCallable; | |||||
} | |||||
return static function (UploadedFile $file) use ($fileNamePatternOrCallable) { | |||||
return strtr($fileNamePatternOrCallable, [ | |||||
'[contenthash]' => sha1_file($file->getRealPath()), | |||||
'[day]' => date('d'), | |||||
'[extension]' => $file->guessClientExtension(), | |||||
'[month]' => date('m'), | |||||
'[name]' => pathinfo($file->getClientOriginalName(), \PATHINFO_FILENAME), | |||||
'[randomhash]' => bin2hex(random_bytes(20)), | |||||
'[slug]' => (new AsciiSlugger()) | |||||
->slug(pathinfo($file->getClientOriginalName(), \PATHINFO_FILENAME)) | |||||
->lower() | |||||
->toString(), | |||||
'[timestamp]' => time(), | |||||
'[uuid]' => Uuid::v4()->toRfc4122(), | |||||
'[ulid]' => new Ulid(), | |||||
'[year]' => date('Y'), | |||||
]); | |||||
}; | |||||
}); | |||||
$resolver->setNormalizer('allow_add', static function (Options $options, string $value): bool { | |||||
if ($value && !$options['multiple']) { | |||||
throw new InvalidArgumentException('Setting "allow_add" option to "true" when "multiple" option is "false" is not supported.'); | |||||
} | |||||
return $value; | |||||
}); | |||||
} | |||||
/** | |||||
* {@inheritdoc} | |||||
*/ | |||||
public function mapDataToForms($currentFiles, $forms): void | |||||
{ | |||||
/** @var FormInterface $fileForm */ | |||||
$fileForm = current(iterator_to_array($forms)); | |||||
$fileForm->setData($currentFiles); | |||||
} | |||||
/** | |||||
* {@inheritdoc} | |||||
*/ | |||||
public function mapFormsToData($forms, &$currentFiles): void | |||||
{ | |||||
/** @var FormInterface[] $children */ | |||||
$children = iterator_to_array($forms); | |||||
$uploadedFiles = $children['path']->getData(); | |||||
/** @var FileUploadState $state */ | |||||
$state = $children['path']->getParent()->getConfig()->getAttribute('state'); | |||||
$state->setCurrentFiles($currentFiles); | |||||
$state->setUploadedFiles($uploadedFiles); | |||||
$state->setDelete($children['delete']->getData()); | |||||
if (!$state->isModified()) { | |||||
return; | |||||
} | |||||
if ($state->isAddAllowed() && !$state->isDelete()) { | |||||
$currentFiles = array_merge($currentFiles, $uploadedFiles); | |||||
} else { | |||||
$currentFiles = $uploadedFiles; | |||||
} | |||||
} | |||||
/** | |||||
* {@inheritdoc} | |||||
*/ | |||||
public function transform($data) | |||||
{ | |||||
return $data; | |||||
} | |||||
/** | |||||
* {@inheritdoc} | |||||
*/ | |||||
public function reverseTransform($data) | |||||
{ | |||||
return null === $data ? '' : $data; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Generator; | |||||
use Dompdf\Dompdf; | |||||
use Dompdf\Options; | |||||
use Twig\Environment; | |||||
class PdfGenerator | |||||
{ | |||||
protected Environment $templating; | |||||
public function __construct(Environment $templating) | |||||
{ | |||||
$this->templating = $templating; | |||||
} | |||||
public function render($filename, $view, $viewParams) | |||||
{ | |||||
$pdfOptions = new Options(); | |||||
$pdfOptions->set('defaultFont', 'Arial'); | |||||
$dompdf = new Dompdf($pdfOptions); | |||||
$html = $this->templating->render($view, $viewParams); | |||||
$dompdf->loadHtml($html); | |||||
$dompdf->setPaper('A4', 'portrait'); | |||||
$dompdf->render(); | |||||
$dompdf->stream($filename, [ | |||||
"Attachment" => true | |||||
]); | |||||
die(); | |||||
} | |||||
} |
class LcSovBundle extends Bundle | class LcSovBundle extends Bundle | ||||
{ | { | ||||
public function getContainerExtension() | |||||
{ | |||||
return new LcSovExtension(); | |||||
} | |||||
public function getContainerExtension() | |||||
{ | |||||
return new LcSovExtension(); | |||||
} | |||||
} | } |
{ | { | ||||
return $this->andWhere('.status >= 0'); | return $this->andWhere('.status >= 0'); | ||||
} | } | ||||
/* | |||||
* POSITION | |||||
*/ | |||||
public function filterByPositionBiggerThan(int $position) | |||||
{ | |||||
return $this->andWhere('.position > :position')->setParameter('position', $position); | |||||
} | |||||
public function filterByPositionSmallerThan(int $position) | |||||
{ | |||||
return $this->andWhere('.position < :position')->setParameter('position', $position); | |||||
} | |||||
} | } | ||||
public function joinUsers(): self | public function joinUsers(): self | ||||
{ | { | ||||
if (!$this->isJoinUsers) { | if (!$this->isJoinUsers) { | ||||
$this->isJoinUsers = true; | $this->isJoinUsers = true; | ||||
return $this | return $this | ||||
->innerJoin('.users', 'users'); | |||||
->leftJoin('.users', 'users'); | |||||
} | } | ||||
return $this; | return $this; | ||||
} | } |
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; | use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; | ||||
use Symfony\Component\HttpFoundation\RequestStack; | |||||
class UrlResolver | class UrlResolver | ||||
{ | { | ||||
protected ParameterBagInterface $parameterBag; | protected ParameterBagInterface $parameterBag; | ||||
protected RequestStack $requestStack; | |||||
public function __construct(ParameterBagInterface $parameterBag) | |||||
public function __construct(ParameterBagInterface $parameterBag, RequestStack $requestStack) | |||||
{ | { | ||||
$this->parameterBag = $parameterBag; | $this->parameterBag = $parameterBag; | ||||
$this->requestStack = $requestStack; | |||||
} | } | ||||
public function isServerLocalhost(): bool | public function isServerLocalhost(): bool | ||||
} | } | ||||
} | } | ||||
public function isRouteAdmin(): bool | |||||
{ | |||||
return $this->testRoute(['admin_', 'file_manager']); | |||||
} | |||||
public function isRouteLogin(): bool | |||||
{ | |||||
return $this->testRoute(['sov_login', 'sov_logout', 'frontend_security_login']) ; | |||||
} | |||||
public function testRoute($mixed, $route = null): bool | |||||
{ | |||||
if(is_null($route)) { | |||||
$route = $this->getRouteCurrentRequest(); | |||||
} | |||||
if(!$route) { | |||||
return false; | |||||
} | |||||
if(is_array($mixed)) { | |||||
foreach($mixed as $testRoute) { | |||||
if($this->testRoute($testRoute, $route)) { | |||||
return true; | |||||
} | |||||
} | |||||
return false; | |||||
} | |||||
return strpos($route, $mixed) !== false; | |||||
} | |||||
public function getRouteCurrentRequest(): ?string | |||||
{ | |||||
$requestAttributes = $this->requestStack->getCurrentRequest()->attributes->all(); | |||||
$route = isset($requestAttributes['_route']) ? $requestAttributes['_route'] : null; | |||||
return $route; | |||||
} | |||||
} | } |
window.addEventListener('load', (event) => { | window.addEventListener('load', (event) => { | ||||
$(document).on('select2:open', () => { | |||||
// @TODO : cela met le focus sur le premier select2 du document | |||||
/*$(document).on('select2:open', () => { | |||||
document.querySelector('.select2-search__field').focus(); | document.querySelector('.select2-search__field').focus(); | ||||
}); | |||||
});*/ | |||||
SovNotification.init(); | SovNotification.init(); | ||||
.logo-admin { | |||||
max-width: 100%; | |||||
} | |||||
nav.main-header { | nav.main-header { | ||||
ul.navbar-nav { | ul.navbar-nav { | ||||
li.nav-item-user-menu { | li.nav-item-user-menu { |
if ($select.data('width')) { | if ($select.data('width')) { | ||||
options.width = 'auto' | options.width = 'auto' | ||||
} | } | ||||
if ($select.find('option[value=""]')) { | |||||
// @TODO : génère une erreur | |||||
/*if ($select.find('option[value=""]')) { | |||||
options.placeholder = $select.find('option[value=""]').html() | options.placeholder = $select.find('option[value=""]').html() | ||||
} | |||||
}*/ | |||||
options.placeholder = ""; | |||||
var myselect = $select.select2(options); | var myselect = $select.select2(options); | ||||
var event = new Event('change'); | var event = new Event('change'); | ||||
e.target.dispatchEvent(event); | e.target.dispatchEvent(event); | ||||
}); | }); | ||||
myselect.on('select2:unselect', function (e) { | myselect.on('select2:unselect', function (e) { | ||||
var event = new Event('change'); | var event = new Event('change'); | ||||
e.target.dispatchEvent(event); | e.target.dispatchEvent(event); | ||||
}); | }); | ||||
SovTools.log(myselect); | |||||
myselect.off('select2:open') | myselect.off('select2:open') | ||||
ch_cookie_consent: | |||||
theme: 'light' # light, dark | |||||
categories: # Below are the default supported categories | |||||
- 'piwik' | |||||
use_logger: true # Logs user actions to database | |||||
position: 'bottom' # top, bottom | |||||
simplified: false # When set to true the user can only deny or accept all cookies at once |
lc_sov_bundle: | lc_sov_bundle: | ||||
resource: "@LcSovBundle/Controller" | resource: "@LcSovBundle/Controller" | ||||
type: annotation | |||||
type: annotation | |||||
ch_cookie_consent: | |||||
resource: "@CHCookieConsentBundle/Resources/config/routing.yaml" |
parameters: | |||||
app.admin.logo: 'laclic.png' | |||||
app.admin.logo_sidebar: 'laclic.png' | |||||
app.site_name: 'laclic-sov' | |||||
app.mail_debug: '' | |||||
services: | services: | ||||
_defaults: | _defaults: | ||||
autowire: true # Automatically injects dependencies in your services. | autowire: true # Automatically injects dependencies in your services. | ||||
tags: | tags: | ||||
- { name: kernel.event_listener, event: kernel.exception } | - { name: kernel.event_listener, event: kernel.exception } | ||||
parameters: | |||||
app.admin.logo: 'laclic.png' | |||||
app.site_name: 'laclic-sov' | |||||
app.mail_debug: '' | |||||
#Form par défaut du cookie consent | |||||
app.form.extension.type.cookie_consent: | |||||
class: Lc\SovBundle\Form\Common\CookieConsentTypeExtension | |||||
tags: | |||||
- { name: form.type_extension, extended_type: ConnectHolland\CookieConsentBundle\Form\CookieConsentType } | |||||
arguments: | |||||
- '@ConnectHolland\CookieConsentBundle\Cookie\CookieChecker' | |||||
- '%ch_cookie_consent.categories%' | |||||
- '%ch_cookie_consent.simplified%' |
account_password: Mot de passe | account_password: Mot de passe | ||||
tickets: Tickets <span class="float-right badge badge-info">%total_ticket_open%</span> | tickets: Tickets <span class="float-right badge badge-info">%total_ticket_open%</span> | ||||
setting_global: Global | setting_global: Global | ||||
blocs: Blocs | |||||
title: | title: | ||||
dashboard: Tableau de bord | dashboard: Tableau de bord | ||||
ProductFamily: | ProductFamily: | ||||
label: Produit | label: Produit | ||||
label_plurial: Produits | label_plurial: Produits | ||||
Block: | |||||
label: Bloc | |||||
label_plurial: Blocs | |||||
default: | default: | ||||
fields: | fields: | ||||
id: Id | id: Id | ||||
user: Utilisateur | user: Utilisateur | ||||
firstname: Prénom | firstname: Prénom | ||||
lastname: Nom | lastname: Nom | ||||
page: Page | |||||
translations: Traductions | |||||
roles: Roles | roles: Roles | ||||
title: Titre | title: Titre | ||||
subtitle: Sous-titre | |||||
position: Position | position: Position | ||||
description: Description | description: Description | ||||
file: Fichier | file: Fichier | ||||
status: Statut | |||||
status: En ligne | |||||
email: Email | email: Email | ||||
value: Valeur | value: Valeur | ||||
metaTitle: "Meta : titre" | metaTitle: "Meta : titre" | ||||
panels: | panels: | ||||
general: Général | general: Général | ||||
configuration: Configuration | configuration: Configuration | ||||
conf: Configuration | |||||
gallery: Galerie | gallery: Galerie | ||||
seo: Référencement | seo: Référencement | ||||
opengraph: Opengraph | opengraph: Opengraph |
{{ form_widget(form) }} | {{ form_widget(form) }} | ||||
{% endblock file_manager_position_row %} | {% endblock file_manager_position_row %} | ||||
{% block file_manager_widget %} | {% block file_manager_widget %} | ||||
{% if form.vars.ea_crud_form.ea_field is not null %} | {% if form.vars.ea_crud_form.ea_field is not null %} | ||||
{% set managerDir = form.vars.ea_crud_form.ea_field.customOptions.get('managerDir') %} | {% set managerDir = form.vars.ea_crud_form.ea_field.customOptions.get('managerDir') %} |
{% for css_asset in ea.assets.cssFiles ?? [] %} | {% for css_asset in ea.assets.cssFiles ?? [] %} | ||||
<link rel="stylesheet" href="{{ asset(css_asset) }}"> | <link rel="stylesheet" href="{{ asset(css_asset) }}"> | ||||
{% endfor %} | {% endfor %} | ||||
{% for webpack_encore_entry in ea.assets.webpackEncoreAssets ?? [] %} | {% for webpack_encore_entry in ea.assets.webpackEncoreAssets ?? [] %} | ||||
{{ ea_call_function_if_exists('encore_entry_link_tags', webpack_encore_entry) }} | {{ ea_call_function_if_exists('encore_entry_link_tags', webpack_encore_entry) }} | ||||
{% endfor %} | {% endfor %} |
{% if chcookieconsent_isCookieConsentSavedByUser() == false %} | |||||
{{ render_esi(path('ch_cookie_consent.show')) }} | |||||
{% endif %} | |||||
{% if chcookieconsent_isCategoryAllowedByUser('piwik') == true %} | |||||
<!-- Matomo --> | |||||
<script> | |||||
var _paq = window._paq = window._paq || []; | |||||
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */ | |||||
_paq.push(['trackPageView']); | |||||
_paq.push(['enableLinkTracking']); | |||||
(function () { | |||||
var u = "//statistiques.laclic.fr/"; | |||||
_paq.push(['setTrackerUrl', u + 'matomo.php']); | |||||
_paq.push(['setSiteId', '5']); | |||||
var d = document, g = d.createElement('script'), s = d.getElementsByTagName('script')[0]; | |||||
g.async = true; | |||||
g.src = u + 'matomo.js'; | |||||
s.parentNode.insertBefore(g, s); | |||||
})(); | |||||
</script> | |||||
<!-- End Matomo Code --> | |||||
{% endif %} |
new TwigFunction('ea_url_short', [$this, 'generateEaUrl']), | new TwigFunction('ea_url_short', [$this, 'generateEaUrl']), | ||||
new TwigFunction('is_instance_of', [$this, 'isInstanceOf']), | new TwigFunction('is_instance_of', [$this, 'isInstanceOf']), | ||||
new TwigFunction('logo_admin', [$this, 'getLogoAdmin']), | new TwigFunction('logo_admin', [$this, 'getLogoAdmin']), | ||||
new TwigFunction('asset_url', [$this, 'getAssetUrl']), | |||||
]; | ]; | ||||
} | } | ||||
]; | ]; | ||||
} | } | ||||
public function getAssetUrl($path) | |||||
{ | |||||
$context = $this->router->getContext(); | |||||
$host = $context->getScheme().'://'.$context->getHost().'/'; | |||||
return $host.$path; | |||||
} | |||||
public function rot13(string $string): string | public function rot13(string $string): string | ||||
{ | { | ||||
return str_rot13($string); | return str_rot13($string); | ||||
public function getLogoAdmin(): string | public function getLogoAdmin(): string | ||||
{ | { | ||||
return '<img class="logo-admin" src="assets/img/' . $this->getParameter('app.admin.logo') . '" >'; | |||||
$image = $this->getParameter('app.admin.logo_sidebar'); | |||||
if(!$image) { | |||||
$image = $this->getParameter('app.admin.logo'); | |||||
} | |||||
return '<img class="logo-admin" src="assets/img/' . $image . '" >'; | |||||
} | } | ||||
} | } |
{ | |||||
"devDependencies": { | |||||
"@symfony/webpack-encore": "^1.3.0", | |||||
"sass": "^1.32.12", | |||||
"sass-loader": "^11.0.0", | |||||
"webpack-notifier": "^1.6.0" | |||||
} | |||||
} |
const Encore = require('@symfony/webpack-encore'); | |||||
// Manually configure the runtime environment if not already configured yet by the "encore" command. | |||||
// It's useful when you use tools that rely on webpack.config.js file. | |||||
if (!Encore.isRuntimeEnvironmentConfigured()) { | |||||
Encore.configureRuntimeEnvironment(process.env.NODE_ENV || 'dev'); | |||||
} | |||||
Encore | |||||
// directory where compiled assets will be stored | |||||
.setOutputPath('Resources/public/build/') | |||||
// public path used by the web server to access the output path | |||||
.setPublicPath('/build') | |||||
// only needed for CDN's or sub-directory deploy | |||||
//.setManifestKeyPrefix('build/') | |||||
.enableSassLoader() | |||||
/* | |||||
* ENTRY CONFIG | |||||
* | |||||
* Add 1 entry for each "page" of your app | |||||
* (including one that's included on every page - e.g. "app") | |||||
* | |||||
* Each entry will result in one JavaScript file (e.g. app.js) | |||||
* and one CSS file (e.g. app.css) if your JavaScript imports CSS. | |||||
*/ | |||||
.addEntry('backend-common', './Resources/assets/apps/backend/common/app.common.js') | |||||
//.addEntry('page1', './assets/page1.js') | |||||
//.addEntry('page2', './assets/page2.js') | |||||
// When enabled, Webpack "splits" your files into smaller pieces for greater optimization. | |||||
.splitEntryChunks() | |||||
// will require an extra script tag for runtime.js | |||||
// but, you probably want this, unless you're building a single-page app | |||||
.enableSingleRuntimeChunk() | |||||
/* | |||||
* FEATURE CONFIG | |||||
* | |||||
* Enable & configure other features below. For a full | |||||
* list of features, see: | |||||
* https://symfony.com/doc/current/frontend.html#adding-more-features | |||||
*/ | |||||
.cleanupOutputBeforeBuild() | |||||
.enableBuildNotifications() | |||||
.enableSourceMaps(!Encore.isProduction()) | |||||
// enables hashed filenames (e.g. app.abc123.css) | |||||
.enableVersioning(Encore.isProduction()) | |||||
// enables @babel/preset-env polyfills | |||||
.configureBabelPresetEnv((config) => { | |||||
config.useBuiltIns = 'usage'; | |||||
config.corejs = 3; | |||||
}) | |||||
// enables Sass/SCSS support | |||||
//.enableSassLoader() | |||||
// uncomment if you use TypeScript | |||||
//.enableTypeScriptLoader() | |||||
// uncomment to get integrity="..." attributes on your script & link tags | |||||
// requires WebpackEncoreBundle 1.4 or higher | |||||
//.enableIntegrityHashes(Encore.isProduction()) | |||||
// uncomment if you're having problems with a jQuery plugin | |||||
//.autoProvidejQuery() | |||||
// uncomment if you use API Platform Admin (composer require api-admin) | |||||
//.enableReactPreset() | |||||
//.addEntry('admin', './assets/admin.js') | |||||
; | |||||
module.exports = Encore.getWebpackConfig(); |