fonticon possible sur les pages
This commit is contained in:
parent
0c10081907
commit
87604176b2
|
@ -0,0 +1,95 @@
|
|||
<?php
|
||||
|
||||
namespace Cadoles\CoreBundle\Form\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\Form\FormView;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class IconChoiceType extends AbstractType
|
||||
{
|
||||
/**
|
||||
* Cache for multiple icon fields or sub-requests.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $choices;
|
||||
|
||||
private $fontawesomeIconsFile;
|
||||
|
||||
public function __construct($fontawesomeIconsFile)
|
||||
{
|
||||
// Liste des icones FontAwesome au format JSON
|
||||
// Récupéré depuis le dépôt officiel via la commande "make fetch-fontawesome-icons"
|
||||
// Voir service.yml
|
||||
$this->fontawesomeIconsFile = $fontawesomeIconsFile;
|
||||
}
|
||||
|
||||
public function buildView(FormView $view, FormInterface $form, array $options)
|
||||
{
|
||||
// Pass this flag is necessary to render the label as raw.
|
||||
// See below the twig field template for more details.
|
||||
$view->vars['raw_label'] = true;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'attr' => [
|
||||
// It's the key of the solution and can be done in many ways.
|
||||
// Now, the rendered <select> element will have a new font.
|
||||
'style' => "font-family: 'FontAwesome';",
|
||||
'class' => 'select2-icon',
|
||||
],
|
||||
'choices' => $this->getFontAwesomeIconChoices(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function getParent()
|
||||
{
|
||||
return ChoiceType::class;
|
||||
}
|
||||
|
||||
protected function getFontAwesomeIconChoices()
|
||||
{
|
||||
if (null !== $this->choices) {
|
||||
return $this->choices;
|
||||
}
|
||||
|
||||
$fileContent = file_get_contents($this->fontawesomeIconsFile);
|
||||
if (!$fileContent) {
|
||||
throw new \Error('Could not load fontawesome icons file');
|
||||
}
|
||||
|
||||
$icons = json_decode($fileContent, true);
|
||||
|
||||
foreach ($icons as $iconName => $iconMetadata) {
|
||||
foreach ($iconMetadata['free'] as $iconStyle) {
|
||||
if ('brands' === $iconStyle) {
|
||||
// On ne propose pas les icônes de marques déposées.
|
||||
continue;
|
||||
}
|
||||
$iconClass = '';
|
||||
switch ($iconStyle) {
|
||||
case 'solid':
|
||||
$iconClass .= ' fas';
|
||||
break;
|
||||
case 'regular':
|
||||
$iconClass .= ' far';
|
||||
break;
|
||||
case 'brands':
|
||||
|
||||
default:
|
||||
$iconClass .= ' fa';
|
||||
break;
|
||||
}
|
||||
$iconClass .= ' fa-' . $iconName;
|
||||
$this->choices[$iconMetadata['label'] . ' (' . $iconStyle . ')'] = trim($iconClass);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->choices;
|
||||
}
|
||||
}
|
|
@ -158,6 +158,16 @@ services:
|
|||
public: true
|
||||
class: Cadoles\CoreBundle\Service\samlAttributeMapperService
|
||||
|
||||
cadoles.form.icon_choice_type:
|
||||
class: Cadoles\CoreBundle\Form\Type\IconChoiceType
|
||||
|
||||
arguments:
|
||||
# Liste des icones FontAwesome au format JSON
|
||||
# Récupéré depuis le dépôt officiel via la commande "make fetch-fontawesome-icons"
|
||||
# Voir Makefile du MSE
|
||||
- "%kernel.root_dir%/../web/fonts/fontawesome/fontawesome-icons.json"
|
||||
tags:
|
||||
- { name: form.type }
|
||||
|
||||
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -192,3 +192,5 @@ les plus importants pour y ajouter le class imposée par Bootstrap 3 #}
|
|||
<input type="{{ type }}" {{ block('widget_attributes') }} />
|
||||
{% endspaceless %}
|
||||
{% endblock file_widget %}
|
||||
|
||||
|
||||
|
|
|
@ -91,6 +91,24 @@
|
|||
|
||||
|
||||
<script>
|
||||
|
||||
function iformat(icon) {
|
||||
return $('<span><i class="' + icon.id + '"></i> ' + icon.text + '</span>');
|
||||
}
|
||||
$('.select2-icon').select2({
|
||||
width: "100%",
|
||||
placeholder: 'choisir un icône',
|
||||
allowClear: true,
|
||||
templateSelection: iformat,
|
||||
templateResult: iformat,
|
||||
formatResult: iformat,
|
||||
allowHtml: true,
|
||||
escapeMarkup: function(m) {
|
||||
return m;
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
function seeUser(id) {
|
||||
{% if app.user %}
|
||||
$("#mymodal").find(".modal-title").html("FICHE UTILISATEUR");
|
||||
|
|
|
@ -46,6 +46,13 @@ class Page
|
|||
*/
|
||||
private $maxwidth;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="fonticon", type="string", nullable=true)
|
||||
*/
|
||||
private $fonticon;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
|
@ -585,4 +592,28 @@ class Page
|
|||
{
|
||||
return $this->templategroups;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set fonticon
|
||||
*
|
||||
* @param string $fonticon
|
||||
*
|
||||
* @return Page
|
||||
*/
|
||||
public function setFonticon($fonticon)
|
||||
{
|
||||
$this->fonticon = $fonticon;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get fonticon
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFonticon()
|
||||
{
|
||||
return $this->fonticon;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
|||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Tetranz\Select2EntityBundle\Form\Type\Select2EntityType;
|
||||
use Cadoles\CoreBundle\Form\Type\IconChoiceType;
|
||||
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
|
@ -56,6 +57,10 @@ class PageSubmitType extends AbstractType
|
|||
"disabled" => ($options["mode"]=="delete"?true:false),
|
||||
])
|
||||
|
||||
->add('fonticon', IconChoiceType::class, [
|
||||
'label' => 'Icône',
|
||||
'required' => false,
|
||||
])
|
||||
|
||||
->add('page',
|
||||
Select2EntityType::class, array(
|
||||
|
|
|
@ -12,6 +12,7 @@ use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
|||
use Ivory\CKEditorBundle\Form\Type\CKEditorType;
|
||||
use Tetranz\Select2EntityBundle\Form\Type\Select2EntityType;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Cadoles\CoreBundle\Form\Type\IconChoiceType;
|
||||
|
||||
class PageUpdateEditorType extends AbstractType
|
||||
{
|
||||
|
@ -31,6 +32,11 @@ class PageUpdateEditorType extends AbstractType
|
|||
'label' => 'Ordre'
|
||||
])
|
||||
|
||||
->add('fonticon', IconChoiceType::class, [
|
||||
'label' => 'Icône',
|
||||
'required' => false,
|
||||
])
|
||||
|
||||
->add('maxwidth', IntegerType::class, [
|
||||
'label' => "Largeur maximum (0 pour largeur de l'écran)",
|
||||
])
|
||||
|
|
|
@ -11,6 +11,7 @@ use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
|||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Tetranz\Select2EntityBundle\Form\Type\Select2EntityType;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Cadoles\CoreBundle\Form\Type\IconChoiceType;
|
||||
|
||||
class PageUpdateToolType extends AbstractType
|
||||
{
|
||||
|
@ -28,7 +29,13 @@ class PageUpdateToolType extends AbstractType
|
|||
|
||||
->add('roworder', IntegerType::class, [
|
||||
'label' => 'Ordre',
|
||||
]);
|
||||
])
|
||||
|
||||
->add('fonticon', IconChoiceType::class, [
|
||||
'label' => 'Icône',
|
||||
'required' => false,
|
||||
]);
|
||||
|
||||
|
||||
if($options["access"]=="config") {
|
||||
$builder
|
||||
|
|
|
@ -11,6 +11,7 @@ use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
|||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Tetranz\Select2EntityBundle\Form\Type\Select2EntityType;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Cadoles\CoreBundle\Form\Type\IconChoiceType;
|
||||
|
||||
class PageUpdateURLType extends AbstractType
|
||||
{
|
||||
|
@ -34,6 +35,11 @@ class PageUpdateURLType extends AbstractType
|
|||
'label' => 'Ordre',
|
||||
])
|
||||
|
||||
->add('fonticon', IconChoiceType::class, [
|
||||
'label' => 'Icône',
|
||||
'required' => false,
|
||||
])
|
||||
|
||||
->add('maxwidth', IntegerType::class, [
|
||||
'label' => "Largeur maximum (0 pour largeur de l'écran)",
|
||||
]);
|
||||
|
|
|
@ -12,6 +12,7 @@ use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
|||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Tetranz\Select2EntityBundle\Form\Type\Select2EntityType;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Cadoles\CoreBundle\Form\Type\IconChoiceType;
|
||||
|
||||
class PageUpdateWidgetType extends AbstractType
|
||||
{
|
||||
|
@ -31,6 +32,11 @@ class PageUpdateWidgetType extends AbstractType
|
|||
'label' => 'Ordre',
|
||||
])
|
||||
|
||||
->add('fonticon', IconChoiceType::class, [
|
||||
'label' => 'Icône',
|
||||
'required' => false,
|
||||
])
|
||||
|
||||
->add('maxwidth', IntegerType::class, [
|
||||
'label' => "Largeur maximum (0 pour largeur de l'écran)",
|
||||
])
|
||||
|
|
|
@ -14,9 +14,23 @@
|
|||
{% endif %}
|
||||
|
||||
{% if entity.id is defined and page.id==entity.id %}
|
||||
<li id="menupage-{{page.id}}" class="active" style="cursor:pointer"><a onClick="showPage({{ page.id }},{{ page.pagecategory.id }},'{{ page.canupdate }}','portal','{{forcereload}}')">{{ page.name }}</a></li>
|
||||
<li id="menupage-{{page.id}}" class="active" style="cursor:pointer">
|
||||
<a onClick="showPage({{ page.id }},{{ page.pagecategory.id }},'{{ page.canupdate }}','portal','{{forcereload}}')">
|
||||
{% if page.fonticon %}
|
||||
<i class="{{ page.fonticon }} fa-faw"></i>
|
||||
{% endif %}
|
||||
{{ page.name }}
|
||||
</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li id="menupage-{{page.id}}"><a style="cursor:pointer" onClick="showPage({{ page.id }},{{ page.pagecategory.id }},'{{ page.canupdate }}','portal','{{forcereload}}')">{{ page.name }}</a></li>
|
||||
<li id="menupage-{{page.id}}">
|
||||
<a style="cursor:pointer" onClick="showPage({{ page.id }},{{ page.pagecategory.id }},'{{ page.canupdate }}','portal','{{forcereload}}')">
|
||||
{% if page.fonticon %}
|
||||
<i class="{{ page.fonticon }} fa-faw"></i>
|
||||
{% endif %}
|
||||
{{ page.name }}
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
@ -29,9 +43,27 @@
|
|||
{% endif %}
|
||||
|
||||
{% if entity.id is defined and page.id==entity.id %}
|
||||
<li id="menupage-{{page.id}}" class="active" style="cursor:pointer"><a onClick="showPage({{ page.id }},{{ page.pagecategory.id }},'{{ page.canupdate }}','user','{{forcereload}}')"><i class="fa fa-user fa-fw"></i> {{ page.name }}</a></li>
|
||||
<li id="menupage-{{page.id}}" class="active" style="cursor:pointer">
|
||||
<a onClick="showPage({{ page.id }},{{ page.pagecategory.id }},'{{ page.canupdate }}','user','{{forcereload}}')">
|
||||
{% if page.fonticon %}
|
||||
<i class="{{ page.fonticon }} fa-faw"></i>
|
||||
{% else %}
|
||||
<i class="fa fa-user fa-fw"></i>
|
||||
{% endif %}
|
||||
{{ page.name }}
|
||||
</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li id="menupage-{{page.id}}"><a style="cursor:pointer" onClick="showPage({{ page.id }},{{ page.pagecategory.id }},'{{ page.canupdate }}','user','{{forcereload}}')"><i class="fa fa-user fa-fw"></i> {{ page.name }}</a></li>
|
||||
<li id="menupage-{{page.id}}">
|
||||
<a style="cursor:pointer" onClick="showPage({{ page.id }},{{ page.pagecategory.id }},'{{ page.canupdate }}','user','{{forcereload}}')">
|
||||
{% if page.fonticon %}
|
||||
<i class="{{ page.fonticon }} fa-faw"></i>
|
||||
{% else %}
|
||||
<i class="fa fa-user fa-fw"></i>
|
||||
{% endif %}
|
||||
{{ page.name }}
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
@ -45,7 +77,7 @@
|
|||
<ul id="pagesshared" class="nav navbar-top-links navbar-left">
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
|
||||
<i class="fa fa-users fa-fw"></i>Mes Groupes
|
||||
<i class="fa fa-users fa-fw"></i> Mes Groupes
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
|
||||
|
@ -67,7 +99,13 @@
|
|||
|
||||
<li id="menupage-{{page.id}}" {{ isactive }} style="cursor:pointer">
|
||||
<a data-group="{{groupshared.id}}" onClick="showPage({{ page.id }},{{ page.pagecategory.id }},'{{ page.canupdate }}','group','{{forcereload}}','{{groupshared.id}}')">
|
||||
<i class="fa fa-users fa-fw"></i> {{ groupshared.label }}
|
||||
{% if page.fonticon %}
|
||||
<i class="{{ page.fonticon }} fa-faw"></i>
|
||||
{% else %}
|
||||
<i class="fa fa-users fa-fw"></i>
|
||||
{% endif %}
|
||||
{{ groupshared.label }}
|
||||
|
||||
{% if page.counterread > 0 %}
|
||||
<span id="badge-{{groupshared.id}}" class="badge">{{page.counterread}}</span>
|
||||
{% endif %}
|
||||
|
@ -77,9 +115,11 @@
|
|||
<ul id="pagesshared" class="nav navbar-top-links navbar-left">
|
||||
<li class="dropdown{{submenu}}">
|
||||
<a data-group="{{groupshared.id}}" href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
|
||||
<i class="fa fa-users fa-fw"></i> {{ groupshared.label }}
|
||||
<i class="fa fa-users fa-fw"></i>
|
||||
{{ groupshared.label }}
|
||||
|
||||
{%if submenu is empty %}
|
||||
<span class="caret"></span>
|
||||
<span class="caret"></span>
|
||||
{% endif %}
|
||||
{% if groupshared.pagesshared[0].counterread > 0 %}
|
||||
<span id="badge-{{groupshared.id}}" class="badge">{{groupshared.pagesshared[0].counterread}}</span>
|
||||
|
@ -100,6 +140,9 @@
|
|||
|
||||
<li id="menupage-{{page.id}}" {{isactive}} style="cursor:pointer">
|
||||
<a onClick="showPage({{ page.id }},{{ page.pagecategory.id }},'{{ page.canupdate }}','group','{{forcereload}}','{{groupshared.id}}')">
|
||||
{% if page.fonticon %}
|
||||
<i class="{{ page.fonticon }} fa-faw"></i>
|
||||
{% endif %}
|
||||
{{ page.name }}
|
||||
</a>
|
||||
</li>
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
<div id="pagegroup">{{ form_row(form.page) }}</div>
|
||||
<div id="groupworkgroup">{{ form_row(form.groups) }}</div>
|
||||
{{ form_row(form.roworder) }}
|
||||
{{ form_row(form.fonticon) }}
|
||||
{{ form_row(form.maxwidth) }}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
|
||||
{{ form_row(form.name) }}
|
||||
{{ form_row(form.roworder) }}
|
||||
{{ form_row(form.fonticon) }}
|
||||
{{ form_row(form.maxwidth) }}
|
||||
{{ form_row(form.html) }}
|
||||
</div>
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
|
||||
{{ form_row(form.name) }}
|
||||
{{ form_row(form.roworder) }}
|
||||
{{ form_row(form.fonticon) }}
|
||||
</div>
|
||||
|
||||
{% if form.roles is defined %}
|
||||
|
|
|
@ -58,6 +58,7 @@
|
|||
<em>le mot clé #login# sera remplacé par le login de l'utilisateur</em><br>
|
||||
<em>Attention certains sites n'acceptent pas d'être encapsulés dans une frame.<br><br>
|
||||
{{ form_row(form.roworder) }}
|
||||
{{ form_row(form.fonticon) }}
|
||||
{{ form_row(form.maxwidth) }}
|
||||
</div>
|
||||
|
||||
|
|
|
@ -208,6 +208,7 @@
|
|||
|
||||
{{ form_row(form.name) }}
|
||||
{{ form_row(form.roworder) }}
|
||||
{{ form_row(form.fonticon) }}
|
||||
{{ form_row(form.maxwidth) }}
|
||||
{{ form_row(form.template) }}
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue