This commit is contained in:
afornerot 2020-11-26 16:09:47 +01:00
parent d1a2131e0b
commit 8658bb5a23
10 changed files with 118 additions and 62 deletions

View File

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

View File

@ -79,7 +79,7 @@ h1{
color: #ECEFF1;
}
#sidebar .nav a .fa{
#sidebar .nav a i{
margin-right: 5px;
width: 20px;
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\HiddenType;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\HttpFoundation\Response;
class CropController extends AbstractController
{
private $appKernel;
public function __construct(KernelInterface $appKernel)
{
$this->appKernel = $appKernel;
}
// Etape 01 - Téléchargement de l'image
public function crop01($type,$reportinput)
{
@ -70,7 +79,7 @@ class CropController extends AbstractController
// Construction du formulaire
$submited=false;
$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('y',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
protected function getHeight($image) {
$size = getimagesize($image);

View File

@ -89,6 +89,7 @@
// Calcul couleur
$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));
}

View File

@ -66,12 +66,12 @@
{% elseif config.type=="hero" %}
<div style="margin:10px auto;">
<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>
{% elseif config.type=="image" %}
<div style="margin:10px auto;">
<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>
{% endif %}
{{ form_row(form.help) }}

View File

@ -5,27 +5,29 @@
{% endblock %}
{% block body %}
{{ form_start(form) }}
{{ form_widget(form.submit) }}
<button class="btn btn-secondary" onClick="closeModal();">Annuler</button>
{% if not submited %}
{{ form_start(form) }}
{{ form_widget(form.submit) }}
<button class="btn btn-secondary" onClick="closeModal();">Annuler</button>
{% if ratio=="1:1" %}
{% set class="width:90px; height:90px;" %}
{% elseif ratio=="16:9" %}
{% set class="width:160px; height:90px;" %}
{% elseif ratio=="16:2" %}
{% set class="width:160px; height:20px;" %}
{% endif %}
{% if ratio=="1:1" %}
{% set class="width:90px; height:90px;" %}
{% elseif ratio=="16:9" %}
{% set class="width:160px; height:90px;" %}
{% elseif ratio=="16:2" %}
{% set class="width:160px; height:20px;" %}
{% endif %}
<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' />
</div>
<div style="width:100%; margin:65px auto 0px auto;">
<div id="largeimg" style="width:800px;margin:auto;">
<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' />
</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 %}
@ -73,8 +75,8 @@
{% if reportinput == "refresh" %}
window.parent.location.reload();
{% elseif reportinput != "none" %}
window.parent.$("#{{ reportinput }}").val("thumb_{{ file }}");
window.parent.$("#{{ reportinput }}_img").attr("src","/{{ appAlias }}/uploads/{{ type }}/thumb_{{ file }}");
window.parent.$("{{ reportinput }}").val("thumb_{{ file }}");
window.parent.$("{{ reportinput }}_img").attr("src","/{{ appAlias }}/uploads/{{ type }}/thumb_{{ file }}");
{% endif %}
closeModal();
@ -85,33 +87,35 @@
}
$(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();
realwidth=$('#largeimg').width();
realheight=$('#largeimg').height();
realwidth=$('#largeimg').width();
if(realheight>505) { $('#largeimg').height(505); $('#largeimg').width("auto") }
if($('#largeimg').width() > 868) { $('#largeimg').width(868); $('#largeimg').height("auto") }
if(realheight>505) { $('#largeimg').height(505); $('#largeimg').width("auto") }
if($('#largeimg').width() > 868) { $('#largeimg').width(868); $('#largeimg').height("auto") }
resizeheight=$('#largeimg').height();
resizewidth=$('#largeimg').width();
resizeheight=$('#largeimg').height();
resizewidth=$('#largeimg').width();
$('#largeimg').CropSelectJs({
imageSrc: "/{{ appAlias }}/uploads/{{type}}/{{ file }}",
selectionResize: function(data) { resize(data); },
selectionMove: function(data) { move(data); },
});
$('#largeimg').CropSelectJs({
imageSrc: "/{{ appAlias }}/uploads/{{type}}/{{ file }}",
selectionResize: function(data) { resize(data); },
selectionMove: function(data) { move(data); },
});
{% if ratio=="1:1" %}
{% set nbratio=1 %}
{% elseif ratio=="16:9" %}
{% set nbratio=(16/9) %}
{% elseif nbratio=="16:2" %}
{% set class=(16/2) %}
{% if ratio=="1:1" %}
{% set nbratio=1 %}
{% elseif ratio=="16:9" %}
{% set nbratio=(16/9) %}
{% elseif nbratio=="16:2" %}
{% set class=(16/2) %}
{% endif %}
$('#largeimg').CropSelectJs('setSelectionAspectRatio',{{nbratio}});
{% endif %}
$('#largeimg').CropSelectJs('setSelectionAspectRatio',{{nbratio}});
});
{% endblock %}

View File

@ -83,19 +83,6 @@ les plus importants pour y ajouter le class imposée par Bootstrap 3 #}
</button>
{%- 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 #}
{% block choice_widget_collapsed %}
{% 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;
$("a[data-method]").on('click',function(){

View File

@ -13,6 +13,7 @@
--fontsizeh4: {{ app.session.get('fontsizeh4')~"px"|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 }};
}
@ -59,6 +60,10 @@ body .nav a{
color: var(--colorfttitledark);
}
body .table {
color: var(--colorftbodylight);
}
body .card {
background-color: var(--colorbgbodylight);
}
@ -80,6 +85,15 @@ body .page-item.active .page-link:hover {
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 {
}
@ -134,6 +148,15 @@ body.monocolor .card-header .custom-control {
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 */
body {
font-family: var(--fontbody);

View File

@ -48,7 +48,7 @@
<img id="user_avatar_img" src="{{ avatar|urlavatar }}" class="avatar big" >
{{ form_widget(form.avatar) }}
{% 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 %}
</div>