This commit is contained in:
afornerot 2020-11-26 16:09:11 +01:00
parent c0def72147
commit e4fe1d90b4
10 changed files with 113 additions and 61 deletions

View File

@ -81,6 +81,10 @@ app_crop02:
path: /user/crop02/{type}/{reportinput} path: /user/crop02/{type}/{reportinput}
defaults: { _controller: App\Controller\CropController:crop02 } defaults: { _controller: App\Controller\CropController:crop02 }
app_ckupload:
path: /user/ckupload
defaults: { _controller: App\Controller\CropController:ckupload }
oneup_uploader: oneup_uploader:
resource: . resource: .
type: uploader type: uploader

View File

@ -84,7 +84,7 @@ h1{
color: #ECEFF1; color: #ECEFF1;
} }
#sidebar .nav a .fa{ #sidebar .nav a i{
margin-right: 5px; margin-right: 5px;
width: 20px; width: 20px;
text-align: center; text-align: center;

View File

@ -7,9 +7,18 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType; use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\HttpFoundation\Response;
class CropController extends AbstractController class CropController extends AbstractController
{ {
private $appKernel;
public function __construct(KernelInterface $appKernel)
{
$this->appKernel = $appKernel;
}
// Etape 01 - Téléchargement de l'image // Etape 01 - Téléchargement de l'image
public function crop01($type,$reportinput) public function crop01($type,$reportinput)
{ {
@ -50,7 +59,7 @@ class CropController extends AbstractController
$max_width=1600; $max_width=1600;
$ratio="16:9"; $ratio="16:9";
break; break;
case "image": case "image":
$max_height=1600; $max_height=1600;
$max_width=1600; $max_width=1600;
@ -70,7 +79,7 @@ class CropController extends AbstractController
// Construction du formulaire // Construction du formulaire
$submited=false; $submited=false;
$form = $this->createFormBuilder() $form = $this->createFormBuilder()
->add('submit',SubmitType::class,array("label" => "Valider","attr" => array("class" => "btn btn-success","onclick" => "reportThumb()"))) ->add('submit',SubmitType::class,array("label" => "Valider","attr" => array("class" => "btn btn-success")))
->add('x',HiddenType::class) ->add('x',HiddenType::class)
->add('y',HiddenType::class) ->add('y',HiddenType::class)
->add('w',HiddenType::class) ->add('w',HiddenType::class)
@ -105,6 +114,32 @@ class CropController extends AbstractController
]); ]);
} }
// Upload ckeditor
public function ckupload(Request $request) {
// Fichier temporaire uploadé
$tmpfile = $request->files->get('upload');
$extention = $tmpfile->getClientOriginalExtension();
// Répertoire de Destination
$fs = new Filesystem();
$rootdir = $this->appKernel->getProjectDir()."/public";
$fs->mkdir($rootdir."/uploads/ckeditor");
// Fichier cible
$targetName = uniqid().".".$extention;
$targetFile = $rootdir."/uploads/ckeditor/".$targetName;
$targetUrl = "/".$this->getParameter('appAlias')."/uploads/ckeditor/".$targetName;
$message = "";
move_uploaded_file($tmpfile,$targetFile);
$output["uploaded"]=1;
$output["fileName"]=$targetName;
$output["url"]=$targetUrl;
return new Response(json_encode($output));
}
// Calcul de la hauteur // Calcul de la hauteur
protected function getHeight($image) { protected function getHeight($image) {
$size = getimagesize($image); $size = getimagesize($image);

View File

@ -89,6 +89,7 @@
// Calcul couleur // Calcul couleur
$this->session->set("colorbgbodylight-darker", $this->adjustBrightness($this->session->get("colorbgbodylight"),-10)); $this->session->set("colorbgbodylight-darker", $this->adjustBrightness($this->session->get("colorbgbodylight"),-10));
$this->session->set("colorbgbodydark-darker", $this->adjustBrightness($this->session->get("colorbgbodydark"),-50));
$this->session->set("colorfttitlelight-darker", $this->adjustBrightness($this->session->get("colorfttitlelight"),-50)); $this->session->set("colorfttitlelight-darker", $this->adjustBrightness($this->session->get("colorfttitlelight"),-50));
} }

View File

@ -66,12 +66,12 @@
{% elseif config.type=="hero" %} {% elseif config.type=="hero" %}
<div style="margin:10px auto;"> <div style="margin:10px auto;">
<img id="config_value_img" src="/{{ appAlias }}/uploads/hero/{{ config.value }}" style="width:100%;margin:auto;display:block;"> <img id="config_value_img" src="/{{ appAlias }}/uploads/hero/{{ config.value }}" style="width:100%;margin:auto;display:block;">
<a class="btn btn-info" style="width:100%" onClick="ModalLoad('mymodallarge','Carrousel','{{ path('app_crop01', {"type": "hero", "reportinput": "config_value" }) }}');" title='Ajouter une Bannière'>Modifier</a> <a class="btn btn-info" style="width:100%" onClick="ModalLoad('mymodallarge','Carrousel','{{ path('app_crop01', {"type": "hero", "reportinput": "#config_value" }) }}');" title='Ajouter une Bannière'>Modifier</a>
</div> </div>
{% elseif config.type=="image" %} {% elseif config.type=="image" %}
<div style="margin:10px auto;"> <div style="margin:10px auto;">
<img id="config_value_img" src="/{{ appAlias }}/uploads/hero/{{ config.value }}" style="width:100%;margin:auto;display:block;"> <img id="config_value_img" src="/{{ appAlias }}/uploads/hero/{{ config.value }}" style="width:100%;margin:auto;display:block;">
<a class="btn btn-info" style="width:100%" onClick="ModalLoad('mymodallarge','Image','{{ path('app_crop01', {"type": "image", "reportinput": "config_value" }) }}');" title='Ajouter une Image'>Modifier</a> <a class="btn btn-info" style="width:100%" onClick="ModalLoad('mymodallarge','Image','{{ path('app_crop01', {"type": "image", "reportinput": "#config_value" }) }}');" title='Ajouter une Image'>Modifier</a>
</div> </div>
{% endif %} {% endif %}
{{ form_row(form.help) }} {{ form_row(form.help) }}

View File

@ -5,27 +5,29 @@
{% endblock %} {% endblock %}
{% block body %} {% block body %}
{{ form_start(form) }} {% if not submited %}
{{ form_widget(form.submit) }} {{ form_start(form) }}
<button class="btn btn-secondary" onClick="closeModal();">Annuler</button> {{ form_widget(form.submit) }}
<button class="btn btn-secondary" onClick="closeModal();">Annuler</button>
{% if ratio=="1:1" %} {% if ratio=="1:1" %}
{% set class="width:90px; height:90px;" %} {% set class="width:90px; height:90px;" %}
{% elseif ratio=="16:9" %} {% elseif ratio=="16:9" %}
{% set class="width:160px; height:90px;" %} {% set class="width:160px; height:90px;" %}
{% elseif ratio=="16:2" %} {% elseif ratio=="16:2" %}
{% set class="width:160px; height:20px;" %} {% set class="width:160px; height:20px;" %}
{% endif %} {% endif %}
<div id='preview' style='overflow:hidden; {{class}} position: absolute; top: 0px; right: 10px;'> <div id='preview' style='overflow:hidden; {{class}} position: absolute; top: 0px; right: 10px;'>
<img src="/{{ appAlias }}/uploads/{{type}}/{{ file }}" style='position: relative;' alt='Thumbnail Preview' /> <img src="/{{ appAlias }}/uploads/{{type}}/{{ file }}" style='position: relative;' alt='Thumbnail Preview' />
</div>
<div style="width:100%; margin:65px auto 0px auto;">
<div id="largeimg" style="width:800px;margin:auto;">
</div> </div>
</div>
{{ form_end(form) }} <div style="width:100%; margin:65px auto 0px auto;">
<div id="largeimg" style="width:800px;margin:auto;">
</div>
</div>
{{ form_end(form) }}
{% endif %}
{% endblock %} {% endblock %}
@ -73,8 +75,8 @@
{% if reportinput == "refresh" %} {% if reportinput == "refresh" %}
window.parent.location.reload(); window.parent.location.reload();
{% elseif reportinput != "none" %} {% elseif reportinput != "none" %}
window.parent.$("#{{ reportinput }}").val("thumb_{{ file }}"); window.parent.$("{{ reportinput }}").val("thumb_{{ file }}");
window.parent.$("#{{ reportinput }}_img").attr("src","/{{ appAlias }}/uploads/{{ type }}/thumb_{{ file }}"); window.parent.$("{{ reportinput }}_img").attr("src","/{{ appAlias }}/uploads/{{ type }}/thumb_{{ file }}");
{% endif %} {% endif %}
closeModal(); closeModal();
@ -85,33 +87,35 @@
} }
$(document).ready(function() { $(document).ready(function() {
window.parent.$(".modal-title").html("ETAPE 2 - Découper votre image"); {% if submited %}
reportThumb();
{% else %}
window.parent.$(".modal-title").html("ETAPE 2 - Découper votre image");
realheight=$('#largeimg').height(); realheight=$('#largeimg').height();
realwidth=$('#largeimg').width(); realwidth=$('#largeimg').width();
if(realheight>505) { $('#largeimg').height(505); $('#largeimg').width("auto") } if(realheight>505) { $('#largeimg').height(505); $('#largeimg').width("auto") }
if($('#largeimg').width() > 868) { $('#largeimg').width(868); $('#largeimg').height("auto") } if($('#largeimg').width() > 868) { $('#largeimg').width(868); $('#largeimg').height("auto") }
resizeheight=$('#largeimg').height(); resizeheight=$('#largeimg').height();
resizewidth=$('#largeimg').width(); resizewidth=$('#largeimg').width();
$('#largeimg').CropSelectJs({ $('#largeimg').CropSelectJs({
imageSrc: "/{{ appAlias }}/uploads/{{type}}/{{ file }}", imageSrc: "/{{ appAlias }}/uploads/{{type}}/{{ file }}",
selectionResize: function(data) { resize(data); }, selectionResize: function(data) { resize(data); },
selectionMove: function(data) { move(data); }, selectionMove: function(data) { move(data); },
}); });
{% if ratio=="1:1" %} {% if ratio=="1:1" %}
{% set nbratio=1 %} {% set nbratio=1 %}
{% elseif ratio=="16:9" %} {% elseif ratio=="16:9" %}
{% set nbratio=(16/9) %} {% set nbratio=(16/9) %}
{% elseif nbratio=="16:2" %} {% elseif nbratio=="16:2" %}
{% set class=(16/2) %} {% set class=(16/2) %}
{% endif %}
$('#largeimg').CropSelectJs('setSelectionAspectRatio',{{nbratio}});
{% endif %} {% endif %}
$('#largeimg').CropSelectJs('setSelectionAspectRatio',{{nbratio}});
}); });
{% endblock %} {% endblock %}

View File

@ -83,19 +83,6 @@ les plus importants pour y ajouter le class imposée par Bootstrap 3 #}
</button> </button>
{%- endblock button_widget %} {%- endblock button_widget %}
{# Personnalisation des attributs des boutons #}
{% block button_attributes -%}
{% if type is defined and type == 'submit' -%}
{% set class = 'btn-primary' %}
{% else %}
{% set class = 'btn-default' %}
{%- endif -%}
{% set attr = attr|merge({'class': (attr.class|default('') ~ ' btn ' ~ class)|trim}) %}
{{ parent() }}
{%- endblock button_attributes %}
{# Personnalisation des select #} {# Personnalisation des select #}
{% block choice_widget_collapsed %} {% block choice_widget_collapsed %}
{% set attr = attr|merge({'class': (attr.class|default('') ~ ' form-control')|trim}) %} {% set attr = attr|merge({'class': (attr.class|default('') ~ ' form-control')|trim}) %}

View File

@ -7,6 +7,8 @@ $(document).ready(function() {
} }
); );
$(".pick-a-color").attr("autocomplete","off");
var doit = true; var doit = true;
$("a[data-method]").on('click',function(){ $("a[data-method]").on('click',function(){

View File

@ -13,6 +13,7 @@
--fontsizeh4: {{ app.session.get('fontsizeh4')~"px"|raw }}; --fontsizeh4: {{ app.session.get('fontsizeh4')~"px"|raw }};
--colorbgbodylight-darker: {{ app.session.get('colorbgbodylight-darker')|raw }}; --colorbgbodylight-darker: {{ app.session.get('colorbgbodylight-darker')|raw }};
--colorbgbodydark-darker: {{ app.session.get('colorbgbodydark-darker')|raw }};
--colorfttitlelight-darker: {{ app.session.get('colorfttitlelight-darker')|raw }}; --colorfttitlelight-darker: {{ app.session.get('colorfttitlelight-darker')|raw }};
} }
@ -84,6 +85,15 @@ body .page-item.active .page-link:hover {
border-color: var(--colorfttitlelight); border-color: var(--colorfttitlelight);
} }
body .btn-primary {
background-color: var(--colorbgbodydark);
border-color: var(--colorbgbodydark);
}
body .btn-primary:hover {
background-color: var(--colorbgbodydark-darker);
border-color: var(--colorbgbodydark-darker);
}
body .modal-title { body .modal-title {
} }
@ -138,6 +148,15 @@ body.monocolor .card-header .custom-control {
font-size: 80%; font-size: 80%;
} }
body.monocolor .btn-primary {
background-color: var(--colorbgbodylight);
border-color: var(--colorbgbodylight);
}
body.monocolor .btn-primary:hover {
background-color: var(--colorbgbodylight-darker);
border-color: var(--colorbgbodylight-darker);
}
/* FONT */ /* FONT */
body { body {
font-family: var(--fontbody); font-family: var(--fontbody);

View File

@ -48,7 +48,7 @@
<img id="user_avatar_img" src="{{ avatar|urlavatar }}" class="avatar big" > <img id="user_avatar_img" src="{{ avatar|urlavatar }}" class="avatar big" >
{{ form_widget(form.avatar) }} {{ form_widget(form.avatar) }}
{% if appMasteridentity=="LDAP" or appMasteridentity=="SQL" %} {% if appMasteridentity=="LDAP" or appMasteridentity=="SQL" %}
<bouton class="btn btn-info" style="width:100%; margin-bottom:15px;" onClick="ModalLoad('mymodallarge','Avatar','{{ path('app_crop01', {"type": "avatar", "reportinput": "user_avatar" }) }}');" title='Ajouter un avatar'>Modifier</bouton> <bouton class="btn btn-info" style="width:100%; margin-bottom:15px;" onClick="ModalLoad('mymodallarge','Avatar','{{ path('app_crop01', {"type": "avatar", "reportinput": "#user_avatar" }) }}');" title='Ajouter un avatar'>Modifier</bouton>
{% endif %} {% endif %}
</div> </div>