use Lc\SovBundle\Field\CollectionField; | use Lc\SovBundle\Field\CollectionField; | ||||
use Lc\SovBundle\Field\GalleryManagerField; | use Lc\SovBundle\Field\GalleryManagerField; | ||||
use Lc\SovBundle\Form\Type\Crud\PositionType; | use Lc\SovBundle\Form\Type\Crud\PositionType; | ||||
use Lc\SovBundle\Translation\TranslatorAdmin; | |||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||||
use Symfony\Component\Form\Extension\Core\Type\CollectionType; | use Symfony\Component\Form\Extension\Core\Type\CollectionType; | ||||
use Symfony\Component\Form\Extension\Core\Type\TextType; | use Symfony\Component\Form\Extension\Core\Type\TextType; | ||||
{ | { | ||||
protected $session; | protected $session; | ||||
protected $request; | protected $request; | ||||
public function __construct(SessionInterface $session, RequestStack $request, EntityManager $em, Environment $twig) | |||||
{ | |||||
protected $translatorAdmin; | |||||
public function __construct( | |||||
SessionInterface $session, | |||||
RequestStack $request, | |||||
EntityManager $em, | |||||
Environment $twig, | |||||
TranslatorAdmin $translatorAdmin | |||||
) { | |||||
$this->session = $session; | $this->session = $session; | ||||
$this->request = $request; | $this->request = $request; | ||||
$this->em = $em; | $this->em = $em; | ||||
$this->twig = $twig; | $this->twig = $twig; | ||||
$this->translatorAdmin = $translatorAdmin; | |||||
} | } | ||||
public function configureActions(Actions $actions): Actions | public function configureActions(Actions $actions): Actions | ||||
$actionsArray[Crud::PAGE_INDEX] = [ | $actionsArray[Crud::PAGE_INDEX] = [ | ||||
Action::NEW => [ | Action::NEW => [ | ||||
'icon' => 'plus', | 'icon' => 'plus', | ||||
'label' => 'Créer', | |||||
'label' => $this->translatorAdmin->transAction('create'), | |||||
'add_class' => 'btn-sm' | 'add_class' => 'btn-sm' | ||||
], | ], | ||||
Action::EDIT => [ | Action::EDIT => [ | ||||
'class' => 'btn btn-sm btn-primary', | 'class' => 'btn btn-sm btn-primary', | ||||
'icon' => 'edit', | 'icon' => 'edit', | ||||
'label' => false, | 'label' => false, | ||||
'html_attributes' => array('data-toggle' => 'tooltip', 'title' => 'Éditer') | |||||
'html_attributes' => array( | |||||
'data-toggle' => 'tooltip', | |||||
'title' => $this->translatorAdmin->transAction('edit') | |||||
) | |||||
], | ], | ||||
Action::DELETE => [ | Action::DELETE => [ | ||||
'icon' => 'trash', | 'icon' => 'trash', | ||||
'dropdown' => true, | 'dropdown' => true, | ||||
'label' => $this->translatorAdmin->transAction('delete') | |||||
], | ], | ||||
Action::BATCH_DELETE => [ | Action::BATCH_DELETE => [ | ||||
'class' => 'btn btn-sm btn-danger', | 'class' => 'btn btn-sm btn-danger', | ||||
'icon' => 'trash', | 'icon' => 'trash', | ||||
'label' => $this->translatorAdmin->transAction('delete') | |||||
], | ], | ||||
]; | ]; | ||||
$actionSaveAndReturn = [ | $actionSaveAndReturn = [ | ||||
'add_class' => 'float-right', | 'add_class' => 'float-right', | ||||
'icon' => 'check', | 'icon' => 'check', | ||||
'label' => $this->translatorAdmin->transAction('save_and_return') | |||||
]; | ]; | ||||
$actionIndex = [ | $actionIndex = [ | ||||
'icon' => 'chevron-left', | 'icon' => 'chevron-left', | ||||
'class' => 'btn btn-link', | 'class' => 'btn btn-link', | ||||
'label' => $this->translatorAdmin->transAction('back_index') | |||||
]; | ]; | ||||
$actionsArray[Crud::PAGE_EDIT] = [ | $actionsArray[Crud::PAGE_EDIT] = [ | ||||
Action::SAVE_AND_CONTINUE => [ | Action::SAVE_AND_CONTINUE => [ | ||||
'class' => 'btn btn-info float-right', | 'class' => 'btn btn-info float-right', | ||||
'label' => $this->translatorAdmin->transAction('save_and_continue') | |||||
], | ], | ||||
Action::DELETE => [ | Action::DELETE => [ | ||||
'icon' => 'trash', | 'icon' => 'trash', | ||||
'class' => 'btn btn-outline-danger action-delete', | 'class' => 'btn btn-outline-danger action-delete', | ||||
'label' => $this->translatorAdmin->transAction('delete') | |||||
], | ], | ||||
Action::SAVE_AND_RETURN => $actionSaveAndReturn, | Action::SAVE_AND_RETURN => $actionSaveAndReturn, | ||||
Action::INDEX => $actionIndex, | Action::INDEX => $actionIndex, | ||||
$actionsArray[Crud::PAGE_NEW] = [ | $actionsArray[Crud::PAGE_NEW] = [ | ||||
Action::SAVE_AND_ADD_ANOTHER => [ | Action::SAVE_AND_ADD_ANOTHER => [ | ||||
'class' => 'btn btn-info float-right', | 'class' => 'btn btn-info float-right', | ||||
'label' => $this->translatorAdmin->transAction('save_and_add_another') | |||||
], | ], | ||||
Action::SAVE_AND_RETURN => $actionSaveAndReturn, | Action::SAVE_AND_RETURN => $actionSaveAndReturn, | ||||
Action::INDEX => $actionIndex, | Action::INDEX => $actionIndex, | ||||
$actions->add(Crud::PAGE_NEW, Action::INDEX); | $actions->add(Crud::PAGE_NEW, Action::INDEX); | ||||
if ($this->isInstanceOf(SortableInterface::class)) { | if ($this->isInstanceOf(SortableInterface::class)) { | ||||
$sortAction = Action::new('sort', 'Ordonner', 'fa fa-sort') | |||||
$sortAction = Action::new('sort', $this->translatorAdmin->transAction('sort'), 'fa fa-sort') | |||||
->linkToCrudAction('sort') | ->linkToCrudAction('sort') | ||||
->setCssClass('btn btn-sm btn-success') | ->setCssClass('btn btn-sm btn-success') | ||||
->createAsGlobalAction(); | ->createAsGlobalAction(); | ||||
if ($this->isInstanceOf(TreeInterface::class)) { | if ($this->isInstanceOf(TreeInterface::class)) { | ||||
$indexChildAction = Action::new('index_children', 'Afficher les enfants', 'fa fa-list') | |||||
$indexChildAction = Action::new( | |||||
'index_children', | |||||
$this->translatorAdmin->transAction('index_children'), | |||||
'fa fa-list' | |||||
) | |||||
->linkToCrudAction(Action::INDEX) | ->linkToCrudAction(Action::INDEX) | ||||
->setLabel('') | ->setLabel('') | ||||
->setHtmlAttributes(array('data-toggle' => 'tooltip', 'title' => 'Afficher les enfants')) | ->setHtmlAttributes(array('data-toggle' => 'tooltip', 'title' => 'Afficher les enfants')) | ||||
->setTemplatePath('@LcSov/adminlte/crud/action/index_children.html.twig') | ->setTemplatePath('@LcSov/adminlte/crud/action/index_children.html.twig') | ||||
->setCssClass('btn btn-sm btn-success'); | ->setCssClass('btn btn-sm btn-success'); | ||||
$backParentAction = Action::new('index_parent', 'Retour au parent', 'fa fa-chevron-left') | |||||
$backParentAction = Action::new( | |||||
'index_parent', | |||||
$this->translatorAdmin->transAction('index_parent'), | |||||
'fa fa-chevron-left' | |||||
) | |||||
->linkToCrudAction(Action::INDEX) | ->linkToCrudAction(Action::INDEX) | ||||
->setCssClass('btn btn-sm btn-info') | ->setCssClass('btn btn-sm btn-info') | ||||
->createAsGlobalAction(); | ->createAsGlobalAction(); | ||||
public function configureResponseParameters(KeyValueStore $responseParameters): KeyValueStore | public function configureResponseParameters(KeyValueStore $responseParameters): KeyValueStore | ||||
{ | { | ||||
// fields sur la page index | |||||
if (Crud::PAGE_INDEX === $responseParameters->get('pageName')) { | if (Crud::PAGE_INDEX === $responseParameters->get('pageName')) { | ||||
$responseParameters->set('fields', $this->configureFields('index')); | $responseParameters->set('fields', $this->configureFields('index')); | ||||
} | } | ||||
{ | { | ||||
if ($this->isInstanceOf(SortableInterface::class)) { | if ($this->isInstanceOf(SortableInterface::class)) { | ||||
$seoPanel = [ | $seoPanel = [ | ||||
FormField::addPanel('Seo')->setTemplateName('crud/field/generic'), | |||||
FormField::addPanel('seo')->setTemplateName('crud/field/generic'), | |||||
TextField::new('metaTitle')->setLabel('Meta Title')->setHelp( | TextField::new('metaTitle')->setLabel('Meta Title')->setHelp( | ||||
'Affiché dans les résultats de recherche Google' | 'Affiché dans les résultats de recherche Google' | ||||
)->hideOnIndex(), | )->hideOnIndex(), | ||||
if ($this->isInstanceOf(DevAliasInterface::class)) { | if ($this->isInstanceOf(DevAliasInterface::class)) { | ||||
$confPanel = [ | $confPanel = [ | ||||
FormField::addPanel('Conf')->setTemplateName('crud/field/generic'), | |||||
FormField::addPanel('configuration')->setTemplateName('crud/field/generic'), | |||||
TextField::new('devAlias')->hideOnIndex(), | TextField::new('devAlias')->hideOnIndex(), | ||||
]; | ]; | ||||
} | } | ||||
->getForm(); | ->getForm(); | ||||
$entityManager = $this->getDoctrine()->getManagerForClass($this->getEntityFqcn()); | $entityManager = $this->getDoctrine()->getManagerForClass($this->getEntityFqcn()); | ||||
dump($entityManager); | |||||
$repository = $entityManager->getRepository($this->getEntityFqcn()); | $repository = $entityManager->getRepository($this->getEntityFqcn()); | ||||
$sortableForm->handleRequest($context->getRequest()); | $sortableForm->handleRequest($context->getRequest()); | ||||
$url = $this->get(AdminUrlGenerator::class) | $url = $this->get(AdminUrlGenerator::class) | ||||
->setAction(Action::INDEX) | ->setAction(Action::INDEX) | ||||
->generateUrl(); | ->generateUrl(); | ||||
$this->addFlash('success', 'Position modifié', array()); | |||||
$this->addFlash('success', $this->translatorAdmin->transFlashMessage('sort'), array()); | |||||
return $this->redirect($url); | return $this->redirect($url); | ||||
} | } | ||||
public function edit(AdminContext $context) | public function edit(AdminContext $context) | ||||
{ | { | ||||
$response = parent::edit($context); ; | |||||
$response = parent::edit($context);; | |||||
// on vide le flash bag si édition en ajax (notification déjà affichée en Javascript) | // on vide le flash bag si édition en ajax (notification déjà affichée en Javascript) | ||||
if ($context->getRequest()->isXmlHttpRequest()) { | if ($context->getRequest()->isXmlHttpRequest()) { | ||||
$this->session->getFlashBag()->clear() ; | |||||
$this->session->getFlashBag()->clear(); | |||||
} | } | ||||
return $response ; | |||||
return $response; | |||||
} | } | ||||
public function isInstanceOf(string $interfaceName): bool | public function isInstanceOf(string $interfaceName): bool |
// the path defined in this method is passed to the Twig asset() function | // the path defined in this method is passed to the Twig asset() function | ||||
->setFaviconPath('favicon.svg') | ->setFaviconPath('favicon.svg') | ||||
// the domain used by default is 'messages' | // the domain used by default is 'messages' | ||||
->setTranslationDomain('lcadmin'); | |||||
->setTranslationDomain('admin'); | |||||
} | } | ||||
public function configureAssets(): Assets | public function configureAssets(): Assets |
namespace Lc\SovBundle\Controller\Admin; | namespace Lc\SovBundle\Controller\Admin; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider; | |||||
use Lc\SovBundle\Doctrine\EntityManager; | use Lc\SovBundle\Doctrine\EntityManager; | ||||
use Lc\SovBundle\Form\Type\User\ChangePasswordFormType; | use Lc\SovBundle\Form\Type\User\ChangePasswordFormType; | ||||
use Lc\SovBundle\Form\Type\User\ProfileFormType; | use Lc\SovBundle\Form\Type\User\ProfileFormType; | ||||
use Lc\SovBundle\Model\User\User; | |||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||||
use Symfony\Component\HttpFoundation\Request; | use Symfony\Component\HttpFoundation\Request; | ||||
use Symfony\Component\HttpFoundation\Response; | use Symfony\Component\HttpFoundation\Response; | ||||
class UserController extends AbstractController | class UserController extends AbstractController | ||||
{ | { | ||||
protected $em; | protected $em; | ||||
public function __construct(EntityManager $em) | public function __construct(EntityManager $em) | ||||
return $this->render( | return $this->render( | ||||
'@LcSov/user/profile.html.twig', | '@LcSov/user/profile.html.twig', | ||||
[ | [ | ||||
'form' => $form->createView() | |||||
'form' => $form->createView(), | |||||
] | ] | ||||
); | ); | ||||
} | } | ||||
if ($form->isSubmitted() && $form->isValid()) { | if ($form->isSubmitted() && $form->isValid()) { | ||||
$user = $form->getData(); | $user = $form->getData(); | ||||
$plainPassword = $form->get('plainPassword')->getData(); | |||||
$plainPassword = $form->get('plain_password')->getData(); | |||||
// @TODO : créer UserManager | // @TODO : créer UserManager | ||||
$newPasswordEncoded = $passwordEncoder->encodePassword($user, $plainPassword); | $newPasswordEncoded = $passwordEncoder->encodePassword($user, $plainPassword); | ||||
return $this->render( | return $this->render( | ||||
'@LcSov/user/change_password.html.twig', | '@LcSov/user/change_password.html.twig', | ||||
[ | [ | ||||
'entity_class' => User::class, | |||||
'form' => $form->createView() | 'form' => $form->createView() | ||||
] | ] | ||||
); | ); |
public function flashMessageAfterPersist(AfterEntityPersistedEvent $event): void | public function flashMessageAfterPersist(AfterEntityPersistedEvent $event): void | ||||
{ | { | ||||
$this->session->getFlashBag()->add('success', new TranslatableMessage('content_admin.flash_message.create', [ | |||||
$this->session->getFlashBag()->add('success', new TranslatableMessage('flash_message.create', [ | |||||
'%name%' => (string) $event->getEntityInstance(), | '%name%' => (string) $event->getEntityInstance(), | ||||
], 'admin')); | |||||
])); | |||||
} | } | ||||
public function flashMessageAfterUpdate(AfterEntityUpdatedEvent $event): void | public function flashMessageAfterUpdate(AfterEntityUpdatedEvent $event): void | ||||
{ | { | ||||
$this->session->getFlashBag()->add('success', new TranslatableMessage('content_admin.flash_message.update', [ | |||||
$this->session->getFlashBag()->add('success', new TranslatableMessage('flash_message.update', [ | |||||
'%name%' => (string) $event->getEntityInstance(), | '%name%' => (string) $event->getEntityInstance(), | ||||
], 'admin')); | |||||
])); | |||||
} | } | ||||
public function flashMessageAfterDelete(AfterEntityDeletedEvent $event): void | public function flashMessageAfterDelete(AfterEntityDeletedEvent $event): void | ||||
{ | { | ||||
$this->session->getFlashBag()->add('success', new TranslatableMessage('content_admin.flash_message.delete', [ | |||||
$this->session->getFlashBag()->add('success', new TranslatableMessage('flash_message.delete', [ | |||||
'%name%' => (string) $event->getEntityInstance(), | '%name%' => (string) $event->getEntityInstance(), | ||||
], 'admin')); | |||||
])); | |||||
} | } | ||||
} | } |
->setLabel($label) | ->setLabel($label) | ||||
->setTemplatePath('@LcSov/adminlte/crud/field/file.html.twig') | ->setTemplatePath('@LcSov/adminlte/crud/field/file.html.twig') | ||||
->addWebpackEncoreEntries('adminlte-field-filemanager') | ->addWebpackEncoreEntries('adminlte-field-filemanager') | ||||
->setCustomOption('managerDir', 'file') | |||||
->setCustomOption('type', 'file') | |||||
->setFormType(FileManagerType::class) | ->setFormType(FileManagerType::class) | ||||
->addCssClass('field-text') | ->addCssClass('field-text') | ||||
->setCustomOption(self::OPTION_MAX_LENGTH, null) | ->setCustomOption(self::OPTION_MAX_LENGTH, null) |
->setTemplatePath('@LcSov/adminlte/crud/field/image.html.twig') | ->setTemplatePath('@LcSov/adminlte/crud/field/image.html.twig') | ||||
->addWebpackEncoreEntries('adminlte-field-filemanager') | ->addWebpackEncoreEntries('adminlte-field-filemanager') | ||||
->setFormType(FileManagerType::class) | ->setFormType(FileManagerType::class) | ||||
->setCustomOption('managerDir', 'image') | |||||
->setCustomOption('type', 'image') | |||||
->addCssClass('field-text') | ->addCssClass('field-text') | ||||
->setCustomOption(self::OPTION_MAX_LENGTH, null) | ->setCustomOption(self::OPTION_MAX_LENGTH, null) | ||||
->setCustomOption(self::OPTION_RENDER_AS_HTML, false); | ->setCustomOption(self::OPTION_RENDER_AS_HTML, false); |
use Lc\SovBundle\Doctrine\EntityManager; | use Lc\SovBundle\Doctrine\EntityManager; | ||||
use Lc\SovBundle\Model\User\UserInterface; | use Lc\SovBundle\Model\User\UserInterface; | ||||
use Lc\SovBundle\Translation\TranslatorAdmin; | |||||
use Symfony\Component\Form\AbstractType; | use Symfony\Component\Form\AbstractType; | ||||
use Symfony\Component\Form\Extension\Core\Type\PasswordType; | use Symfony\Component\Form\Extension\Core\Type\PasswordType; | ||||
use Symfony\Component\Form\Extension\Core\Type\RepeatedType; | use Symfony\Component\Form\Extension\Core\Type\RepeatedType; | ||||
use Symfony\Component\Form\FormBuilderInterface; | use Symfony\Component\Form\FormBuilderInterface; | ||||
use Symfony\Component\OptionsResolver\OptionsResolver; | use Symfony\Component\OptionsResolver\OptionsResolver; | ||||
use Symfony\Component\Security\Core\Validator\Constraints\UserPassword; | use Symfony\Component\Security\Core\Validator\Constraints\UserPassword; | ||||
use Symfony\Component\Translation\TranslatableMessage; | |||||
use Symfony\Component\Validator\Constraints\NotBlank; | use Symfony\Component\Validator\Constraints\NotBlank; | ||||
class ChangePasswordFormType extends AbstractType | class ChangePasswordFormType extends AbstractType | ||||
{ | { | ||||
protected $em ; | |||||
protected $em; | |||||
protected $translatorAdmin; | |||||
public function __construct(EntityManager $em) | |||||
public function __construct(EntityManager $em, TranslatorAdmin $translatorAdmin) | |||||
{ | { | ||||
$this->em = $em ; | |||||
$this->em = $em; | |||||
$this->translatorAdmin = $translatorAdmin; | |||||
} | } | ||||
/** | /** | ||||
'current_password', | 'current_password', | ||||
PasswordType::class, | PasswordType::class, | ||||
[ | [ | ||||
'label' => 'Mot de passe actuel', | |||||
'label' => 'form.change_password.current_password', | |||||
'mapped' => false, | 'mapped' => false, | ||||
'constraints' => [ | 'constraints' => [ | ||||
new NotBlank(), | new NotBlank(), | ||||
[ | [ | ||||
'type' => PasswordType::class, | 'type' => PasswordType::class, | ||||
'mapped' => false, | 'mapped' => false, | ||||
'first_options' => ['label' => 'Nouveau mot de passe'], | |||||
'second_options' => ['label' => 'Nouveau mot de passe (confirmation)'], | |||||
'first_options' => ['label' => 'form.change_password.new_password'], | |||||
'second_options' => ['label' => 'form.change_password.new_password_repeat'], | |||||
'invalid_message' => 'Les deux mots de passe ne correspondent pas.', | 'invalid_message' => 'Les deux mots de passe ne correspondent pas.', | ||||
] | ] | ||||
); | ); | ||||
'submit', | 'submit', | ||||
SubmitType::class, | SubmitType::class, | ||||
array( | array( | ||||
'label' => 'Sauvegarder' | |||||
'label' => $this->translatorAdmin->transAction('save') | |||||
) | ) | ||||
); | ); | ||||
} | } |
use Lc\SovBundle\Doctrine\EntityManager; | use Lc\SovBundle\Doctrine\EntityManager; | ||||
use Lc\SovBundle\Model\File\FileInterface; | use Lc\SovBundle\Model\File\FileInterface; | ||||
use Lc\SovBundle\Model\User\UserInterface; | use Lc\SovBundle\Model\User\UserInterface; | ||||
use Lc\SovBundle\Translation\TranslatorAdmin; | |||||
use Symfony\Component\Form\AbstractType; | use Symfony\Component\Form\AbstractType; | ||||
use Symfony\Component\Form\Extension\Core\Type\EmailType; | use Symfony\Component\Form\Extension\Core\Type\EmailType; | ||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType; | use Symfony\Component\Form\Extension\Core\Type\SubmitType; | ||||
use Symfony\Component\Form\Extension\Core\Type\TextType; | use Symfony\Component\Form\Extension\Core\Type\TextType; | ||||
use Symfony\Component\Form\FormBuilderInterface; | use Symfony\Component\Form\FormBuilderInterface; | ||||
use Symfony\Component\OptionsResolver\OptionsResolver; | use Symfony\Component\OptionsResolver\OptionsResolver; | ||||
use Symfony\Component\Translation\TranslatableMessage; | |||||
class ProfileFormType extends AbstractType | class ProfileFormType extends AbstractType | ||||
{ | { | ||||
protected $em ; | |||||
protected $em; | |||||
protected $translatorAdmin; | |||||
public function __construct(EntityManager $em) | |||||
public function __construct(EntityManager $em, TranslatorAdmin $translatorAdmin) | |||||
{ | { | ||||
$this->em = $em ; | |||||
$this->em = $em; | |||||
$this->translatorAdmin = $translatorAdmin; | |||||
} | } | ||||
public function buildForm(FormBuilderInterface $builder, array $options) | public function buildForm(FormBuilderInterface $builder, array $options) | ||||
{ | { | ||||
$entityName = $this->em->getEntityName(UserInterface::class) ; | |||||
$entityName = $this->em->getEntityName(UserInterface::class); | |||||
$builder->add( | $builder->add( | ||||
'firstname', | 'firstname', | ||||
TextType::class, | |||||
array( | |||||
'label' => 'Prénom' | |||||
) | |||||
TextType::class | |||||
); | ); | ||||
$builder->add( | $builder->add( | ||||
'lastname', | 'lastname', | ||||
TextType::class, | |||||
array( | |||||
'label' => 'Nom' | |||||
) | |||||
TextType::class | |||||
); | ); | ||||
$builder->add( | $builder->add( | ||||
'email', | 'email', | ||||
EmailType::class, | |||||
array( | |||||
'label' => 'Email' | |||||
) | |||||
EmailType::class | |||||
); | ); | ||||
if(property_exists($entityName, 'phone')) { | |||||
if (property_exists($entityName, 'phone')) { | |||||
$builder->add( | $builder->add( | ||||
'phone', | 'phone', | ||||
TextType::class, | |||||
array( | |||||
'label' => 'Téléphone' | |||||
) | |||||
TextType::class | |||||
); | ); | ||||
} | } | ||||
$builder->add( | $builder->add( | ||||
'submit', | 'submit', | ||||
SubmitType::class, | SubmitType::class, | ||||
array( | |||||
'label' => 'Sauvegarder' | |||||
) | |||||
[ | |||||
'label' => $this->translatorAdmin->transAction('save') | |||||
] | |||||
); | ); | ||||
} | } | ||||
function initCollectionWidget() { | function initCollectionWidget() { | ||||
Tools.log('czefe'); | |||||
$('.field-collection[data-prototype]').each(function (i, collectionWidget) { | $('.field-collection[data-prototype]').each(function (i, collectionWidget) { | ||||
setCollectionWidgetSortable($(collectionWidget)); | setCollectionWidgetSortable($(collectionWidget)); | ||||
} | } | ||||
function reindexKeyCollectionWidget($collectionWidget) { | function reindexKeyCollectionWidget($collectionWidget) { | ||||
Tools.log('ncncnc'); | |||||
if ($collectionWidget.data('reindex-key')) { | if ($collectionWidget.data('reindex-key')) { | ||||
Tools.log('ncncnc'); | |||||
$collectionWidget.find('.field-collection-item').each(function (i, item) { | $collectionWidget.find('.field-collection-item').each(function (i, item) { | ||||
$(item).find('input,textarea').each(function (y, field) { | $(item).find('input,textarea').each(function (y, field) { | ||||
let $field = $(field); | let $field = $(field); |
let $field = $(this); | let $field = $(this); | ||||
$('#' + $field.data('id')).val(""); | $('#' + $field.data('id')).val(""); | ||||
$('#' + $field.data('id') + '_preview').prop('src',""); | $('#' + $field.data('id') + '_preview').prop('src',""); | ||||
$('#' + $field.data('id') + '_preview_text').html('Aucun fichier'); | |||||
}); | }); | ||||
$('.lc-filemanager-open').off('click'); | $('.lc-filemanager-open').off('click'); | ||||
$('.lc-filemanager-open').on('click', function (e) { | $('.lc-filemanager-open').on('click', function (e) { | ||||
var path = $(this).attr('data-path') | var path = $(this).attr('data-path') | ||||
$('#' + $field.data('id')).val(path); | $('#' + $field.data('id')).val(path); | ||||
$('#' + $field.data('id') + '_preview').prop('src',path); | $('#' + $field.data('id') + '_preview').prop('src',path); | ||||
$('#' + $field.data('id') + '_preview_text').html(path); | |||||
$('#lc-filemanager-modal').modal('hide'); | $('#lc-filemanager-modal').modal('hide'); | ||||
}); | }); | ||||
}); | }); |
content_admin: | |||||
flash_message: | |||||
create: Le contenu "%name%" a été créé avec succès. | |||||
update: Le contenu "%name%" a été mis à jour avec succès. | |||||
delete: Le contenu "%name%" a été supprimé avec succès. | |||||
menu: | |||||
dashboard: Tableau de bord | |||||
page: Pages | |||||
user: Utilisateurs | |||||
user_index: Liste | |||||
account: Mon compte | |||||
account_profile: Informations personnelles | |||||
account_password: Mot de passe | |||||
title: | |||||
dashboard: Tableau de bord | |||||
index: '%label_plurial%' | |||||
sort: Ordonner "%label_plurial%" | |||||
new: Ajouter "%label%" | |||||
edit: Modifier "%label%" (#%id%) | |||||
detail: Voir "%label%" (#%id%) | |||||
account: | |||||
profile: Mes informations personnelles | |||||
change_password: Changer de mot de passe | |||||
action: | |||||
create: Créer | |||||
edit: Éditer | |||||
save: Sauvegarder | |||||
sort: Ordonner | |||||
delete: Supprimer | |||||
index_children: Afficher les enfants | |||||
index_parent: Retour au parent | |||||
back_index: Retour à la liste | |||||
save_and_return: Sauvegarder les modifications | |||||
save_and_continue: Sauvegarder et continuer l'édition | |||||
save_and_add_another: Créer et ajouter un nouvel élément | |||||
flash_message: | |||||
create: Le contenu "%name%" a été créé avec succès. | |||||
update: Le contenu "%name%" a été mis à jour avec succès. | |||||
delete: Le contenu "%name%" a été supprimé avec succès. | |||||
sort: Position modifiée | |||||
entity: | |||||
User: | |||||
label: Utilisateur | |||||
label_plurial: Utilisateurs | |||||
fields: | |||||
firstname: Prénom | |||||
lastname: Nom | |||||
Page: | |||||
label: Page | |||||
label_plurial: Pages | |||||
default: | |||||
fields: | |||||
title: Titre | |||||
position: Position | |||||
position_help: Position help | |||||
description: Description | |||||
description_help: Description help | |||||
file: Fichier | |||||
status: Statut | |||||
email: Email | |||||
metaTitle: Meta title | |||||
metaTitle_help: Affiché dans les résultats de recherche Google | |||||
metaDescription: Meta description | |||||
metaDescription_help: Affiché dans les résultats de recherche Google | |||||
oldUrls: Anciennes urls | |||||
devAlias: Alias | |||||
gallery: Galerie | |||||
panels: | |||||
general: Général | |||||
configuration: Configuration | |||||
gallery: Galerie | |||||
seo: Référencement | |||||
form: | |||||
change_password: | |||||
current_password: Mot de passe actuel | |||||
new_password: Nouveau mot de passe | |||||
new_password_repeat: Nouveau mot de passe (confirmer) |
{# @var ea \EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext #} | {# @var ea \EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext #} | ||||
{% macro render_menu_item(item, is_sub_item = false) %} | {% macro render_menu_item(item, is_sub_item = false) %} | ||||
{% if item.isMenuSection %} | {% if item.isMenuSection %} | ||||
{% if item.icon is not empty %} | {% if item.icon is not empty %} | ||||
<i class="fa fa-{{ item.icon }}"></i> | <i class="fa fa-{{ item.icon }}"></i> | ||||
{% if item.icon is not empty %} | {% if item.icon is not empty %} | ||||
<i class="far fa-{{ item.icon }} nav-icon"></i> | <i class="far fa-{{ item.icon }} nav-icon"></i> | ||||
{% endif %} | {% endif %} | ||||
<p>{{ item.label|raw }}</p> | |||||
<p>{{ item.label|lc_trans_admin_menu }}</p> | |||||
{% if item.hasSubItems %}<i class="right fas fa-angle-left"></i>{% endif %} | {% if item.hasSubItems %}<i class="right fas fa-angle-left"></i>{% endif %} | ||||
</a> | </a> | ||||
{% endif %} | {% endif %} |
{% for _locale in app_locales %} | {% for _locale in app_locales %} | ||||
<a class="{{ isIncludedInDropdown|default(false) ? 'dropdown-item' }} {{ action.cssClass }}" | <a class="{{ isIncludedInDropdown|default(false) ? 'dropdown-item' }} {{ action.cssClass }}" | ||||
href="{{ action.linkUrl }}&_locale={{ _locale }}" | href="{{ action.linkUrl }}&_locale={{ _locale }}" | ||||
{% for name, value in action.htmlAttributes %}{{ name }}="{{ value|e('html_attr') }}" {% endfor %}> | |||||
{%- if action.icon %}<i class="action-icon {{ action.icon }}"></i> {% endif -%} | |||||
{%- if action.label is not empty -%}{{ action.label }} {{ _locale }}{%- endif -%} | |||||
{% for name, value in action.htmlAttributes %}{{ name }}="{{ value|e('html_attr') }}" {% endfor %}> | |||||
{%- if action.icon %}<i class="action-icon {{ action.icon }}"></i> {% endif -%} | |||||
{%- if action.label is not empty -%}{{ action.label }} {%- endif -%} | |||||
{{ _locale }} | |||||
</a> | </a> | ||||
{% endfor %} | {% endfor %} | ||||
{% elseif 'button' == action.htmlElement %} | {% elseif 'button' == action.htmlElement %} | ||||
<button class="{{ action.cssClass }}" {% for name, value in action.htmlAttributes %}{{ name }}="{{ value|e('html_attr') }}" {% endfor %}> | <button class="{{ action.cssClass }}" {% for name, value in action.htmlAttributes %}{{ name }}="{{ value|e('html_attr') }}" {% endfor %}> | ||||
<span class="btn-label"> | |||||
<span class="btn-label"> | |||||
{%- if action.icon %}<i class="action-icon {{ action.icon }}"></i> {% endif -%} | {%- if action.icon %}<i class="action-icon {{ action.icon }}"></i> {% endif -%} | ||||
{%- if action.label is not empty -%}{{ action.label }}{%- endif -%} | |||||
{%- if action.label is not empty -%}{{ action.label }}{%- endif -%} | |||||
</span> | </span> | ||||
</button> | </button> | ||||
{% endif %} | {% endif %} |
{% block body_class 'ea-edit ea-edit-' ~ entity.name %} | {% block body_class 'ea-edit ea-edit-' ~ entity.name %} | ||||
{% block content_title %} | {% block content_title %} | ||||
{%- apply spaceless -%} | |||||
{{ ea.crud.customPageTitle is null | |||||
? (ea.crud.defaultPageTitle|trans(ea.i18n.translationParameters, 'EasyAdminBundle'))|raw | |||||
: ea.crud.customPageTitle|trans(ea.i18n.translationParameters)|raw }} | |||||
{%- endapply -%} | |||||
{{ 'edit'|lc_trans_admin_title(ea.getEntity().getFqcn(), {id: ea.getEntity().getInstance().getId()}) }} | |||||
{% endblock %} | {% endblock %} | ||||
{% block delete_form %} | {% block delete_form %} |
{# @var ea \EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext #} | {# @var ea \EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext #} | ||||
{% use '@EasyAdmin/crud/form_theme.html.twig' %} | {% use '@EasyAdmin/crud/form_theme.html.twig' %} | ||||
{% block form_row %} | |||||
{% set row_attr = row_attr|merge({ | |||||
class: row_attr.class|default('') ~ ' form-group' | |||||
}) %} | |||||
<div {% with { attr: row_attr } %}{{ block('attributes') }}{% endwith %}> | |||||
{{- form_label(form) -}} | |||||
<div class="form-widget"> | |||||
{% set has_prepend_html = ea.field.prepend_html|default(null) is not null %} | |||||
{% set has_append_html = ea.field.append_html|default(null) is not null %} | |||||
{% set has_input_groups = has_prepend_html or has_append_html %} | |||||
{% if has_input_groups %} | |||||
<div class="input-group">{% endif %} | |||||
{% if has_prepend_html %} | |||||
<div class="input-group-prepend"> | |||||
<span class="input-group-text">{{ ea.field.prepend_html|raw }}</span> | |||||
</div> | |||||
{% endif %} | |||||
{{ form_widget(form) }} | |||||
{% if has_append_html %} | |||||
<div class="input-group-append"> | |||||
<span class="input-group-text">{{ ea.field.append_html|raw }}</span> | |||||
</div> | |||||
{% endif %} | |||||
{% if has_input_groups %}</div>{% endif %} | |||||
{% set nullable_fields_fqcn = [ | |||||
'EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField', | |||||
'EasyCorp\Bundle\EasyAdminBundle\Field\DateField', | |||||
'EasyCorp\Bundle\EasyAdminBundle\Field\TimeField', | |||||
] %} | |||||
{% if form.vars.ea_crud_form.ea_field.fieldFqcn|default(false) in nullable_fields_fqcn and ea.field.nullable|default(false) %} | |||||
<div class="nullable-control"> | |||||
<label> | |||||
<input type="checkbox" {% if data is null %}checked="checked"{% endif %}> | |||||
{{ 'label.nullable_field'|trans({}, 'EasyAdminBundle') }} | |||||
</label> | |||||
</div> | |||||
{% endif %} | |||||
{% set help_message = name|lc_trans_admin_help(form.parent.vars.data) %} | |||||
{% if help_message != '' %} | |||||
<small class="form-help">{{ help_message }}</small> | |||||
{% endif %} | |||||
{{- form_errors(form) -}} | |||||
</div> | |||||
</div> | |||||
{% endblock form_row %} | |||||
{% block form_label -%} | |||||
{% if label is same as(false) -%} | |||||
<label>{# the empty <label> is needed to not break the form design #}</label> | |||||
{%- else -%} | |||||
{%- if compound is defined and compound -%} | |||||
{%- set element = 'legend' -%} | |||||
{%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' col-form-label')|trim}) -%} | |||||
{%- else -%} | |||||
{%- set label_attr = label_attr|merge({for: id, class: (label_attr.class|default('') ~ ' form-control-label')|trim}) -%} | |||||
{%- endif -%} | |||||
{% if required -%} | |||||
{% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' required')|trim}) %} | |||||
{%- endif -%} | |||||
{% if label is empty -%} | |||||
{%- if label_format is not empty -%} | |||||
{% set label = label_format|replace({ | |||||
'%name%': name, | |||||
'%id%': id, | |||||
}) %} | |||||
{%- else -%} | |||||
{# {% set label = name|humanize %} #} | |||||
{%- endif -%} | |||||
{%- endif -%} | |||||
{# <{{ element|default('label') }}{% if label_attr %}{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}{% endif %}>{{ (translation_domain is same as(false)) ? label : label|lower|lc_trans_admin_field(ea.getEntity().getFqcn()) }}</{{ element|default('label') }}> #} | |||||
<{{ element|default('label') }}{% if label_attr %}{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}{% endif %}>{{ (label is not empty and '.' in label) ? label|trans({}, 'admin') : name|lc_trans_admin_field(form.parent.vars.data) }}</{{ element|default('label') }}> | |||||
{%- endif -%} | |||||
{%- endblock form_label %} | |||||
{% block gallery_manager_row %} | {% block gallery_manager_row %} | ||||
{{ block('collection_row') }} | {{ block('collection_row') }} | ||||
{% endblock gallery_manager_row %} | {% endblock gallery_manager_row %} | ||||
{{ block('collection_widget') }} | {{ block('collection_widget') }} | ||||
{% endblock gallery_manager_widget %} | {% endblock gallery_manager_widget %} | ||||
{% block collection_row %} | {% block collection_row %} | ||||
{% if prototype is defined and not prototype.rendered %} | {% if prototype is defined and not prototype.rendered %} | ||||
{% set row_attr = row_attr|merge({ 'data-prototype': form_row(prototype) }) %} | {% set row_attr = row_attr|merge({ 'data-prototype': form_row(prototype) }) %} | ||||
{% block file_manager_widget %} | {% block file_manager_widget %} | ||||
{% set managerDir = form.vars.ea_crud_form.ea_field.customOptions.get('managerDir') %} | |||||
{% set type = form.vars.ea_crud_form.ea_field.customOptions.get('type') %} | |||||
<div class="lc-filemanager row"> | <div class="lc-filemanager row"> | ||||
{% if type == 'image' %} | |||||
<div class="col-md-3 col-xs-12 form-group"> | <div class="col-md-3 col-xs-12 form-group"> | ||||
<div class="lc-filemenager-preview card"> | |||||
<div class="no-image"> | |||||
<i class="fa fa-image"></i> | |||||
</div> | |||||
<img src="{{ form.path.vars.value }}" id="{{ form.path.vars.id }}_preview" alt="" class="card-img-top"> | |||||
<div class="lc-filemenager-preview card"> | |||||
<div class="no-image"> | |||||
<i class="fa fa-image"></i> | |||||
</div> | </div> | ||||
<img src="{{ form.path.vars.value }}" id="{{ form.path.vars.id }}_preview" alt="" class="card-img-top"> | |||||
</div> | </div> | ||||
<div class="col-12"> | |||||
<div class="input-group"> | |||||
<div class="input-group-prepend"> | |||||
{% if form.parent.vars['row_attr']['data-sortable'] is defined %} | |||||
<button type="button" class="btn btn-success lc-btn-sortable" data-toggle="tooltip" | |||||
title="Trier les images"> | |||||
<i class="fa fa-arrows-alt"></i> | |||||
</button> | |||||
{% endif %} | |||||
<button type="button" class="btn btn-primary lc-filemanager-open" data-id="{{ form.path.vars.id }}" | |||||
data-toggle="tooltip" title="Sélectionner un fichier" | |||||
data-target="{{ path('file_manager', {module:1, conf:'default'})|raw }}"> | |||||
<i class="fa fa-folder-open"></i> | |||||
</button> | |||||
</div> | |||||
{{ form_widget(form.legend) }} | |||||
<div class="input-group-append"> | |||||
<button type="button" class="btn btn-danger lc-filemanager-delete" data-toggle="tooltip" | |||||
title="Supprimer l'image" | |||||
data-id="{{ form.path.vars.id }}"> | |||||
<i class="fa fa-trash"></i> | |||||
</div> | |||||
{% else %} | |||||
<div class="callout callout-success"> | |||||
<h5><i class="fa fa-file-alt"></i> | |||||
<span id="{{ form.path.vars.id }}_preview_text">{{ form.path.vars.value }}</span> | |||||
</h5> | |||||
</div> | |||||
{% endif %} | |||||
<div class="col-12"> | |||||
<div class="input-group"> | |||||
<div class="input-group-prepend"> | |||||
{% if form.parent.vars['row_attr']['data-sortable'] is defined %} | |||||
<button type="button" class="btn btn-success lc-btn-sortable" data-toggle="tooltip" | |||||
title="Trier les images"> | |||||
<i class="fa fa-arrows-alt"></i> | |||||
</button> | </button> | ||||
</div> | |||||
{% endif %} | |||||
<button type="button" class="btn btn-primary lc-filemanager-open" data-id="{{ form.path.vars.id }}" | |||||
data-toggle="tooltip" title="Sélectionner un fichier" | |||||
data-target="{{ path('file_manager', {module:1, conf: managerDir})|raw }}"> | |||||
<i class="fa fa-folder-open"></i> | |||||
</button> | |||||
</div> | |||||
{{ form_widget(form.legend) }} | |||||
<div class="input-group-append"> | |||||
<button type="button" class="btn btn-danger lc-filemanager-delete" data-toggle="tooltip" | |||||
title="Supprimer l'image" | |||||
data-id="{{ form.path.vars.id }}"> | |||||
<i class="fa fa-trash"></i> | |||||
</button> | |||||
</div> | |||||
{{ form_rest(form) }} | |||||
</div> | |||||
{{ form_rest(form) }} | |||||
</div> | </div> | ||||
</div> | </div> | ||||
</div> | |||||
{% endblock file_manager_widget %} | {% endblock file_manager_widget %} | ||||
{% block checkbox_radio_label -%} | {% block checkbox_radio_label -%} | ||||
{#- Do not display the label if widget is not defined in order to prevent double label rendering -#} | |||||
{#- Do not display the label if widget is not defined in order to prevent double label rendering -#} | |||||
{%- if widget is defined -%} | {%- if widget is defined -%} | ||||
{% set is_parent_custom = parent_label_class is defined and ('checkbox-custom' in parent_label_class or 'radio-custom' in parent_label_class or 'switch-custom' in parent_label_class) %} | {% set is_parent_custom = parent_label_class is defined and ('checkbox-custom' in parent_label_class or 'radio-custom' in parent_label_class or 'switch-custom' in parent_label_class) %} | ||||
{% set is_custom = label_attr.class is defined and ('checkbox-custom' in label_attr.class or 'radio-custom' in label_attr.class or 'switch-custom' in label_attr.class) %} | {% set is_custom = label_attr.class is defined and ('checkbox-custom' in label_attr.class or 'radio-custom' in label_attr.class or 'switch-custom' in label_attr.class) %} | ||||
{{ name|lc_trad(easyadmin['entity']['name'], 'field') }} | {{ name|lc_trad(easyadmin['entity']['name'], 'field') }} | ||||
{% else %} #} | {% else %} #} | ||||
{{- label is not same as(false) ? (translation_domain is same as(false) ? label : label|trans(label_translation_parameters, translation_domain))|raw -}} | {{- label is not same as(false) ? (translation_domain is same as(false) ? label : label|trans(label_translation_parameters, translation_domain))|raw -}} | ||||
{# {% endif %} #} | {# {% endif %} #} | ||||
{{- form_errors(form) -}} | {{- form_errors(form) -}} | ||||
</label> | </label> | ||||
{{ parent() }} | {{ parent() }} | ||||
{% if ea_crud_form.form_panels is defined %} | {% if ea_crud_form.form_panels is defined %} | ||||
<div class="card card-outline"> | <div class="card card-outline"> | ||||
<div class="card-header p-0 border-bottom-0"> | <div class="card-header p-0 border-bottom-0"> | ||||
<ul id="nav-params" class="nav nav-pills" role="navigation"> | <ul id="nav-params" class="nav nav-pills" role="navigation"> | ||||
{% for panel_name, panel_config in ea_crud_form.form_panels|filter(panel_config => not panel_config.form_tab or panel_config.form_tab == tab_name) %} | {% for panel_name, panel_config in ea_crud_form.form_panels|filter(panel_config => not panel_config.form_tab or panel_config.form_tab == tab_name) %} | ||||
{% set panel_has_header = panel_config.label|default(false) or panel_config.icon|default(false) %} | {% set panel_has_header = panel_config.label|default(false) or panel_config.icon|default(false) %} | ||||
<li class="nav-item"> | <li class="nav-item"> | ||||
<a href="#panel-{{ panel_name }} " class="nav-link {{ panel_name == 1 ? 'active' }}" data-toggle="tab" role="tab" | |||||
<a href="#panel-{{ panel_name }} " class="nav-link {{ panel_name == 1 ? 'active' }}" | |||||
data-toggle="tab" role="tab" | |||||
aria-controls="panel-{{ panel_name }}"> | aria-controls="panel-{{ panel_name }}"> | ||||
{{ panel_config.label|raw }} | |||||
<i class="fa fa-exclamation-circle invalid-form"></i> | |||||
{{ panel_config.label|lc_trans_admin_panel(ea.getEntity().getFqcn()) }} | |||||
<i class="fa fa-exclamation-circle invalid-form"></i> | |||||
</a> | </a> | ||||
</li> | </li> | ||||
{% endfor %} | {% endfor %} | ||||
{% if panel_config.icon|default(false) %} | {% if panel_config.icon|default(false) %} | ||||
<i class="{{ panel_config.icon }}"></i> | <i class="{{ panel_config.icon }}"></i> | ||||
{% endif %} | {% endif %} | ||||
{{ panel_config.label|raw }} | |||||
{{ panel_config.label|lc_trans_admin_panel(ea.getEntity().getFqcn()) }} | |||||
{% if collapsible %} | {% if collapsible %} | ||||
</a> | </a> |
{% block body_class 'index' ~ (entities|length > 0 ? ' index-' ~ entities|first.name : '') %} | {% block body_class 'index' ~ (entities|length > 0 ? ' index-' ~ entities|first.name : '') %} | ||||
{% block content_title %} | {% block content_title %} | ||||
{%- apply spaceless -%} | |||||
{% set default_title = ea.crud.defaultPageTitle('index')|trans(ea.i18n.translationParameters, 'EasyAdminBundle') %} | |||||
{{ ea.crud.customPageTitle is null ? default_title|raw : ea.crud.customPageTitle('index')|trans(ea.i18n.translationParameters)|raw }} | |||||
{%- endapply -%} | |||||
{{ 'index'|lc_trans_admin_title(ea.getEntity().getFqcn()) }} | |||||
{% endblock %} | {% endblock %} | ||||
{% block content_breadcrumb %} | {% block content_breadcrumb %} | ||||
{% endblock page_actions %} | {% endblock page_actions %} | ||||
{% block main %} | {% block main %} | ||||
{# sort can be multiple; let's consider the sorting field the first one #} | {# sort can be multiple; let's consider the sorting field the first one #} | ||||
{% set sort_field_name = app.request.get('sort')|keys|first %} | {% set sort_field_name = app.request.get('sort')|keys|first %} | ||||
{% set sort_order = app.request.get('sort')|first %} | {% set sort_order = app.request.get('sort')|first %} | ||||
class="fa fa-fw {{ column_icon }}"></i> | class="fa fa-fw {{ column_icon }}"></i> | ||||
</a> | </a> | ||||
{% else %} | {% else %} | ||||
<span>{{ field.label ? field.label|raw : field.getProperty|raw }}</span> | |||||
<span>{{ field.getProperty|lc_trans_admin_field(ea.getEntity().getFqcn()) }}</span> | |||||
{% endif %} | {% endif %} | ||||
</th> | </th> | ||||
{% endif %} | {% endif %} | ||||
{{ parent() }} | {{ parent() }} | ||||
<script type="text/javascript"> | <script type="text/javascript"> | ||||
$(function () { | $(function () { | ||||
/* $('.action-delete').on('click', function (e) { | /* $('.action-delete').on('click', function (e) { |
{% block body_class 'ea-new ea-new-' ~ entity.name %} | {% block body_class 'ea-new ea-new-' ~ entity.name %} | ||||
{% block content_title %} | {% block content_title %} | ||||
{%- apply spaceless -%} | |||||
{% set default_title = ea.crud.defaultPageTitle('new')|trans(ea.i18n.translationParameters, 'EasyAdminBundle') %} | |||||
{{ ea.crud.customPageTitle is null ? default_title|raw : ea.crud.customPageTitle('new')|trans(ea.i18n.translationParameters)|raw }} | |||||
{%- endapply -%} | |||||
{{ 'new'|lc_trans_admin_title(ea.getEntity().getFqcn()) }} | |||||
{% endblock %} | {% endblock %} | ||||
{% block body_javascript %} | {% block body_javascript %} | ||||
{{ parent() }} | {{ parent() }} | ||||
{% block body_class 'index' ~ (entities|length > 0 ? ' index-' ~ entities|first.name : '') %} | {% block body_class 'index' ~ (entities|length > 0 ? ' index-' ~ entities|first.name : '') %} | ||||
{% block content_title %} | {% block content_title %} | ||||
Édition position | |||||
{{ 'sort'|lc_trans_admin_title(ea.getEntity().getFqcn()) }} | |||||
{% endblock %} | {% endblock %} | ||||
{% block content_breadcrumb %} | {% block content_breadcrumb %} | ||||
{{ include('@LcSov/adminlte/block/breadcrumb.html.twig') }} | {{ include('@LcSov/adminlte/block/breadcrumb.html.twig') }} | ||||
{% endblock content_breadcrumb %} | {% endblock content_breadcrumb %} |
{% extends '@LcSov/adminlte/layout.html.twig' %} | {% extends '@LcSov/adminlte/layout.html.twig' %} | ||||
{% block content_title 'SovBundle' %} | |||||
{% block content_title %} | |||||
{{ 'dashboard'|lc_trans_admin_title }} | |||||
{% endblock %} | |||||
{% block main %} | {% block main %} | ||||
Tableau de bord par défaut. | Tableau de bord par défaut. |
{% endfor %} | {% endfor %} | ||||
{% for webpack_encore_entry in ea.assets.webpackEncoreEntries ?? [] %} | {% for webpack_encore_entry in ea.assets.webpackEncoreEntries ?? [] %} | ||||
{{ ea_call_function_if_exists('encore_entry_script_tags', webpack_encore_entry) }} | |||||
{{ ea_call_function_if_exists('encore_entry_script_tags', webpack_encore_entry, null, '_default', {'defer': false}) }} | |||||
{% endfor %} | {% endfor %} | ||||
{% endblock %} | {% endblock %} | ||||
{% if app.session is not null and app.session.started %} | {% if app.session is not null and app.session.started %} | ||||
{% set flash_messages = app.session.flashbag.all %} | {% set flash_messages = app.session.flashbag.all %} | ||||
{% if flash_messages|length > 0 %} | {% if flash_messages|length > 0 %} | ||||
{% for label, messages in flash_messages %} | |||||
{% for message in messages %} | |||||
<script type="text/javascript"> | |||||
Notification.add("{{ label }}", "{{ message|trans|raw|replace({'"': '\"'}) }}") ; | |||||
</script> | |||||
<script type="text/javascript"> | |||||
$(document).ready(function() { | |||||
{% for label, messages in flash_messages %} | |||||
{% for message in messages %} | |||||
Notification.add("{{ label }}", "{{ message|trans|raw|replace({'"': '\"'}) }}"); | |||||
{% endfor %} | |||||
{% endfor %} | {% endfor %} | ||||
{% endfor %} | |||||
}); | |||||
</script> | |||||
{% endif %} | {% endif %} | ||||
{% endif %} | {% endif %} | ||||
{% extends '@LcSov/adminlte/layout.html.twig' %} | {% extends '@LcSov/adminlte/layout.html.twig' %} | ||||
{% block content_title %} | {% block content_title %} | ||||
Changer de mot de passe | |||||
{{ 'account.change_password'|lc_trans_admin_title }} | |||||
{% endblock %} | {% endblock %} | ||||
{% block main %} | {% block main %} |
{% extends '@LcSov/adminlte/layout.html.twig' %} | {% extends '@LcSov/adminlte/layout.html.twig' %} | ||||
{% block content_title %} | {% block content_title %} | ||||
Mes informations personnelles | |||||
{{ 'account.profile'|lc_trans_admin_title }} | |||||
{% endblock %} | {% endblock %} | ||||
{% block main %} | {% block main %} |
<?php | |||||
namespace Lc\SovBundle\Translation; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; | |||||
use Symfony\Contracts\Translation\TranslatorInterface; | |||||
class TranslatorAdmin | |||||
{ | |||||
protected $translator; | |||||
const DOMAIN = 'admin'; | |||||
public function __construct(TranslatorInterface $translator) | |||||
{ | |||||
$this->translator = $translator; | |||||
} | |||||
public function transAction($action) | |||||
{ | |||||
return $this->trans('action.' . $action); | |||||
} | |||||
public function transMenu($menu) | |||||
{ | |||||
return $this->trans('menu.' . $menu); | |||||
} | |||||
public function transFlashMessage($name) | |||||
{ | |||||
return $this->trans('flash_message.' . $name); | |||||
} | |||||
public function transField($fieldName, $entityClass): string | |||||
{ | |||||
return $this->transEntityThenDefault( | |||||
$this->buildTransIdField($fieldName, $entityClass), | |||||
$this->buildTransIdField($fieldName, $entityClass, true) | |||||
); | |||||
} | |||||
public function transHelp($fieldName, $entityClass): string | |||||
{ | |||||
$fieldName = $fieldName . '_help'; | |||||
return $this->transEntityThenDefault( | |||||
$this->buildTransIdField($fieldName, $entityClass), | |||||
$this->buildTransIdField($fieldName, $entityClass, true), | |||||
true | |||||
); | |||||
} | |||||
public function transPanel($panelName, $entityClass): string | |||||
{ | |||||
return $this->transEntityThenDefault( | |||||
$this->buildTransIdPanel($panelName, $entityClass), | |||||
$this->buildTransIdPanel($panelName, $entityClass, true) | |||||
); | |||||
} | |||||
public function transTitle($pageName, $entityClass = null, $params = []) | |||||
{ | |||||
$entityName = $this->getEntityName($entityClass); | |||||
$paramsTranslation = []; | |||||
if ($entityName) { | |||||
$baseIdEntityLabel = 'entity.' . $entityName; | |||||
$paramsTranslation = [ | |||||
'%label%' => $this->trans($baseIdEntityLabel . '.label'), | |||||
'%label_plurial%' => $this->trans($baseIdEntityLabel . '.label_plurial'), | |||||
]; | |||||
} | |||||
if (isset($params['id'])) { | |||||
$paramsTranslation['%id%'] = $params['id']; | |||||
} | |||||
return $this->trans( | |||||
'title.' . $pageName, | |||||
$paramsTranslation | |||||
); | |||||
} | |||||
private function transEntityThenDefault($idTranslationEntity, $idTranslationDefault, $returnEmpty = false): string | |||||
{ | |||||
$translation = $this->trans($idTranslationEntity); | |||||
if ($translation == $idTranslationEntity) { | |||||
$translation = $this->trans($idTranslationDefault); | |||||
if ($translation == $idTranslationDefault) { | |||||
if ($returnEmpty) { | |||||
$translation = ''; | |||||
} else { | |||||
$translation = $idTranslationEntity; | |||||
} | |||||
} | |||||
} | |||||
return $translation; | |||||
} | |||||
private function buildTransIdField($fieldName, $entityClass, $default = false): string | |||||
{ | |||||
return $this->buildTransIdEntitySection($fieldName, $entityClass, 'fields', $default); | |||||
} | |||||
private function buildTransIdPanel($panelName, $entityClass, $default = false): string | |||||
{ | |||||
return $this->buildTransIdEntitySection($panelName, $entityClass, 'panels', $default); | |||||
} | |||||
private function buildTransIdEntitySection($name, $entityClass, $entitySection, $default): string | |||||
{ | |||||
if ($default) { | |||||
$entityName = 'default'; | |||||
} else { | |||||
$entityName = $this->getEntityName($entityClass); | |||||
} | |||||
return 'entity.' . $entityName . '.' . $entitySection . '.' . $name; | |||||
} | |||||
private function trans($id, $params = [], $domain = self::DOMAIN): string | |||||
{ | |||||
return $this->translator->trans($id, $params, $domain); | |||||
} | |||||
private function getEntityName($entityClass): string | |||||
{ | |||||
if (is_object($entityClass)) { | |||||
$entityClass = get_class($entityClass); | |||||
} | |||||
if (is_string($entityClass)) { | |||||
$entityNameExplode = explode('\\', $entityClass); | |||||
return $entityNameExplode[count($entityNameExplode) - 1]; | |||||
} | |||||
return 'default'; | |||||
} | |||||
} | |||||
?> |
namespace Lc\SovBundle\Twig; | namespace Lc\SovBundle\Twig; | ||||
use Doctrine\ORM\EntityManagerInterface; | use Doctrine\ORM\EntityManagerInterface; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; | |||||
use Lc\SovBundle\Translation\TranslatorAdmin; | |||||
use Liip\ImagineBundle\Imagine\Cache\CacheManager; | use Liip\ImagineBundle\Imagine\Cache\CacheManager; | ||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; | use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; | ||||
use Symfony\Component\HttpFoundation\RequestStack; | use Symfony\Component\HttpFoundation\RequestStack; | ||||
use Symfony\Component\HttpKernel\KernelInterface; | use Symfony\Component\HttpKernel\KernelInterface; | ||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface; | use Symfony\Component\Routing\Generator\UrlGeneratorInterface; | ||||
use Symfony\Contracts\Translation\TranslatorInterface; | |||||
use Twig\Extension\AbstractExtension; | use Twig\Extension\AbstractExtension; | ||||
use Twig\TwigFilter; | use Twig\TwigFilter; | ||||
use Twig\TwigFunction; | use Twig\TwigFunction; | ||||
class TwigExtension extends AbstractExtension | class TwigExtension extends AbstractExtension | ||||
{ | { | ||||
protected $em; | |||||
protected $kernel; | |||||
protected $parameterBag; | |||||
protected $cacheManager; | |||||
protected $requestStack; | |||||
protected $router; | |||||
public function __construct(KernelInterface $kernel, ParameterBagInterface $parameterBag, CacheManager $cacheManager, EntityManagerInterface $entityManager, RequestStack $requestStack,UrlGeneratorInterface $router) | |||||
{ | |||||
$this->kernel = $kernel; | |||||
$this->parameterBag = $parameterBag; | |||||
$this->cacheManager = $cacheManager; | |||||
$this->em = $entityManager; | |||||
$this->requestStack = $requestStack; | |||||
$this->router = $router; | |||||
protected $em; | |||||
protected $kernel; | |||||
protected $parameterBag; | |||||
protected $cacheManager; | |||||
protected $requestStack; | |||||
protected $router; | |||||
protected $translator; | |||||
protected $translatorAdmin; | |||||
public function __construct( | |||||
KernelInterface $kernel, | |||||
ParameterBagInterface $parameterBag, | |||||
CacheManager $cacheManager, | |||||
EntityManagerInterface $entityManager, | |||||
RequestStack $requestStack, | |||||
UrlGeneratorInterface $router, | |||||
TranslatorInterface $translator, | |||||
TranslatorAdmin $translatorAdmin | |||||
) { | |||||
$this->kernel = $kernel; | |||||
$this->parameterBag = $parameterBag; | |||||
$this->cacheManager = $cacheManager; | |||||
$this->em = $entityManager; | |||||
$this->requestStack = $requestStack; | |||||
$this->router = $router; | |||||
$this->translator = $translator; | |||||
$this->translatorAdmin = $translatorAdmin; | |||||
} | |||||
public function getFunctions() | |||||
{ | |||||
return array( | |||||
new TwigFunction('lc_liip', [$this, 'lcLiip']), | |||||
new TwigFunction('homepage_route', [$this, 'homepageRoute']), | |||||
new TwigFunction('page_by_dev_alias', [$this, 'getPageByDevAlias']), | |||||
new TwigFunction('translated_urls', [$this, 'getTranslatedUrls']) | |||||
); | |||||
} | |||||
public function getFilters() | |||||
{ | |||||
return [ | |||||
new TwigFilter('lc_cache', [$this, 'lcCache']), | |||||
new TwigFilter('lc_trans_admin_field', [$this, 'lcTransAdminField']), | |||||
new TwigFilter('lc_trans_admin_help', [$this, 'lcTransAdminHelp']), | |||||
new TwigFilter('lc_trans_admin_panel', [$this, 'lcTransAdminPanel']), | |||||
new TwigFilter('lc_trans_admin_menu', [$this, 'lcTransAdminMenu']), | |||||
new TwigFilter('lc_trans_admin_title', [$this, 'lcTransAdminTitle']), | |||||
new TwigFilter('lc_trans_admin_action', [$this, 'lcTransAdminAction']), | |||||
]; | |||||
} | |||||
public function lcCache($file) | |||||
{ | |||||
$cacheTime = filemtime($this->kernel->getProjectDir() . '/public' . $file); | |||||
if ($cacheTime) { | |||||
return $file . '?c=' . $cacheTime; | |||||
} else { | |||||
return $file . "?c=0"; | |||||
} | } | ||||
public function getFunctions() | |||||
{ | |||||
return array( | |||||
new TwigFunction('lc_liip', [$this, 'lcLiip']), | |||||
new TwigFunction('homepage_route', [$this, 'homepageRoute']), | |||||
new TwigFunction('page_by_dev_alias', [$this, 'getPageByDevAlias']), | |||||
new TwigFunction('translated_urls', [$this, 'getTranslatedUrls']) | |||||
); | |||||
} | |||||
public function lcTransAdminField($fieldName, $entityClass) | |||||
{ | |||||
return $this->translatorAdmin->transField($fieldName, $entityClass) ; | |||||
} | |||||
public function lcTransAdminHelp($fieldName, $entityClass) | |||||
{ | |||||
return $this->translatorAdmin->transHelp($fieldName, $entityClass) ; | |||||
} | |||||
public function lcTransAdminPanel($panelName, $entityClass) | |||||
{ | |||||
return $this->translatorAdmin->transPanel($panelName, $entityClass) ; | |||||
} | |||||
public function lcTransAdminMenu($menuName) | |||||
{ | |||||
return $this->translatorAdmin->transMenu($menuName);; | |||||
} | |||||
public function lcTransAdminAction($actionName) | |||||
{ | |||||
return $this->translatorAdmin->transAction($actionName);; | |||||
} | |||||
public function lcTransAdminTitle($pageName, $entityClass = null, $params = []) | |||||
{ | |||||
return $this->translatorAdmin->transTitle($pageName, $entityClass, $params) ; | |||||
} | |||||
public function lcLiip($path, $thumb = 'tile', $default = 'default.jpg') | |||||
{ | |||||
if (substr($path, 0, 1) === '/') { | |||||
$path = substr($path, 1); | |||||
} | } | ||||
if ($path) { | |||||
$fileManagerFolder = substr($this->getFileManagerFolder(), 1); | |||||
public function getFilters() | |||||
{ | |||||
return [ | |||||
new TwigFilter('lc_cache', [$this, 'lcCache']), | |||||
]; | |||||
} | |||||
if (strpos($path, $fileManagerFolder) === false) { | |||||
$path = $fileManagerFolder . '/' . $path; | |||||
} | |||||
public function lcCache($file) | |||||
{ | |||||
$cacheTime = filemtime($this->kernel->getProjectDir() . '/public' . $file); | |||||
if ($cacheTime) { | |||||
return $file . '?c=' . $cacheTime; | |||||
} else { | |||||
return $file . "?c=0"; | |||||
} | |||||
if (file_exists($path)) { | |||||
return $this->cacheManager->getBrowserPath($path, $thumb); | |||||
} | |||||
} | } | ||||
public function lcLiip($path, $thumb = 'tile', $default = 'default.jpg') | |||||
{ | |||||
if (substr($path, 0, 1) === '/') $path = substr($path, 1); | |||||
if ($path) { | |||||
$fileManagerFolder = substr($this->getFileManagerFolder(), 1) ; | |||||
return $this->cacheManager->getBrowserPath($this->getFileManagerFolder() . '/' . $default, $thumb); | |||||
} | |||||
if (strpos($path, $fileManagerFolder) === false) { | |||||
$path = $fileManagerFolder . '/' . $path; | |||||
} | |||||
function getTranslatedUrls() | |||||
{ | |||||
$ret = array(); | |||||
$langs = $this->parameterBag->get('app.locales'); | |||||
$currentRoute = $this->requestStack->getCurrentRequest()->get('_route'); | |||||
if (file_exists($path)) { | |||||
return $this->cacheManager->getBrowserPath($path, $thumb); | |||||
} | |||||
} | |||||
$params = array_merge((array)$this->requestStack->getCurrentRequest()->get('_route_params'), $_GET); | |||||
return $this->cacheManager->getBrowserPath($this->getFileManagerFolder() . '/' . $default, $thumb); | |||||
if ($currentRoute) { | |||||
foreach ($langs as $lg) { | |||||
$ret[$lg] = $this->router->generate($currentRoute, array_merge($params, array('_locale' => $lg))); | |||||
} | |||||
} | } | ||||
function getTranslatedUrls() | |||||
{ | |||||
$ret = array(); | |||||
$langs = $this->parameterBag->get('app.locales'); | |||||
$currentRoute = $this->requestStack->getCurrentRequest()->get('_route'); | |||||
return $ret; | |||||
} | |||||
$params = array_merge((array)$this->requestStack->getCurrentRequest()->get('_route_params'), $_GET); | |||||
public function getFileManagerFolder() | |||||
{ | |||||
return $this->parameterBag->get('app.path_uploads'); | |||||
} | |||||
if ($currentRoute) { | |||||
foreach($langs as $lg) { | |||||
$ret[$lg] = $this->router->generate($currentRoute, array_merge($params, array('_locale'=>$lg))); | |||||
} | |||||
} | |||||
return $ret; | |||||
} | |||||
public function getFileManagerFolder() | |||||
{ | |||||
return $this->parameterBag->get('app.path_uploads'); | |||||
} | |||||
public function homepageRoute(){ | |||||
return $this->parameterBag->get('lc_sov.homepage_route'); | |||||
} | |||||
public function homepageRoute() | |||||
{ | |||||
return $this->parameterBag->get('lc_sov.homepage_route'); | |||||
} | |||||
} | } |