first commit

This commit is contained in:
2023-07-20 11:56:10 +02:00
parent 08c221d3d5
commit f624b15207
341 changed files with 64075 additions and 103 deletions

124
templates/Form/fields.html.twig Executable file
View File

@ -0,0 +1,124 @@
{% extends 'form_div_layout.html.twig' %}
{# Voir https://github.com/symfony/symfony/blob/master/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig #}
{# On commence par simplement ajouter le form-group au row de nos formulaires #}
{% block form_row -%}
{% set attr = attr|merge({'help': (attr.help|default(true)) }) %}
<div class="form-group {{ errors|length > 0 ? 'has-error' : '' }} mt-3">
{{- form_label(form) }}
{{- form_widget(form) }}
{{ form_errors(form) }}
</div>
{%- endblock form_row %}
{# Puis on modifie très simplement nos input et textarea les plus importants pour y ajouter le class imposée par Bootstrap 3 #}
{% block textarea_widget %}
{% set attr = attr|merge({'class': attr.class|default('') ~ ' form-control'}) %}
{{ parent() }}
{% endblock textarea_widget %}
{% block form_widget_simple %}
{% set attr = attr|merge({'class': attr.class|default('') ~ ' form-control'}) %}
{{ parent() }}
{% endblock form_widget_simple %}
{% block form_label -%}
{% set label_attr = label_attr|merge({'class': (label_attr.class|default('') ~ ' control-label')|trim}) %}
{% if 'checkbox' not in block_prefixes %}
{% if label is not same as(false) -%}
{% if not compound -%}
{% set label_attr = label_attr|merge({'for': id}) %}
{%- endif %}
{% if required -%}
{% set label_attr = label_attr|merge({'class': (label_attr.class|default('') ~ ' required')|trim}) %}
{%- endif %}
{% if label is empty -%}
{% set label = name|humanize %}
{%- endif -%}
<label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>
{{ label|trans({}, translation_domain)|raw }}
<span class="mandatory">{% if required %}*{% endif %}</span>
</label>
{%- endif %}
{% endif %}
{%- endblock form_label %}
{# et enfin les erreurs #}
{% block form_errors %}
{% if errors|length > 0 %}
{% if attr.help is defined and attr.help %}
<p class="help-block text-danger">
{% for error in errors %}
{{ error.message }}<br />
{% endfor %}
</p>
{% else %}
<div class="alert alert-danger alert-dismissible">
<button type="button" class="close" data-dismiss="alert">
<span aria-hidden="true">&times;</span>
<span class="sr-only">Close</span>
</button>
{% for error in errors %}
{{ error.message|raw }}<br />
{% endfor %}
</div>
{% endif %}
{% endif %}
{% endblock form_errors %}
{# Personnalisation des boutons #}
{% block button_widget -%}
{% if label is empty -%}
{% set label = name|humanize %}
{%- endif -%}
{% set attr = attr|merge({'class': (attr.class|default('') ~ '')|trim}) %}
<button type="{{ type|default('button') }}" {{ block('button_attributes') }}>{{
label|trans({}, translation_domain) }}
{% if type is defined and type == 'submit' -%}
{% endif %}
</button>
{%- endblock button_widget %}
{# Personnalisation des select #}
{% block choice_widget_collapsed %}
{% set attr = attr|merge({'class': (attr.class|default('') ~ ' form-control')|trim}) %}
{{ parent() }}
{%- endblock choice_widget_collapsed %}
{% block choice_widget %}
{% if expanded %}
<ul {{ block('widget_container_attributes') }} style="list-style: none; padding-left: 0">
{% for child in form %}
<li>
{{ form_widget(child) }}
{{ form_label(child) }}
</li>
{% endfor %}
</ul>
{% else %}
{{ parent() }}
{% endif %}
{% endblock choice_widget %}
{% block checkbox_widget %}
<label for="{{ id }}">
<input type="checkbox" {{ block('widget_attributes') }}{% if value is defined %} value="{{ value }}"{% endif %}{% if checked %} checked="checked"{% endif %} />
{{ label|trans({}, translation_domain) }}</label>
{% endblock checkbox_widget %}
{% block radio_widget %}
<label for="{{ id }}">
<input type="radio" {{ block('widget_attributes') }}{% if value is defined %} value="{{ value }}"{% endif %}{% if checked %} checked="checked"{% endif %} />
{{ label|trans({}, translation_domain) }}
</label>&nbsp;&nbsp;
{% endblock radio_widget %}
{% block file_widget %}
{% set type = type|default('file') %}
<input type="{{ type }}" {{ block('widget_attributes') }} />
{% endblock file_widget %}

View File

@ -0,0 +1,34 @@
{% extends "base.html.twig" %}
{% block body %}
<div class="text-center">
{% if app.user %}
<a class="btn btn-primary" href="{{path("app_logout")}}" title="Connexion">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-6 h-6" style="width:25px; padding-right:5px">
<path fill-rule="evenodd" d="M7.5 3.75A1.5 1.5 0 006 5.25v13.5a1.5 1.5 0 001.5 1.5h6a1.5 1.5 0 001.5-1.5V15a.75.75 0 011.5 0v3.75a3 3 0 01-3 3h-6a3 3 0 01-3-3V5.25a3 3 0 013-3h6a3 3 0 013 3V9A.75.75 0 0115 9V5.25a1.5 1.5 0 00-1.5-1.5h-6zm5.03 4.72a.75.75 0 010 1.06l-1.72 1.72h10.94a.75.75 0 010 1.5H10.81l1.72 1.72a.75.75 0 11-1.06 1.06l-3-3a.75.75 0 010-1.06l3-3a.75.75 0 011.06 0z" clip-rule="evenodd" />
</svg>
Logout
</a>
{% else %}
<a class="btn btn-primary" href="{{path("app_login")}}" title="Connexion">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-6 h-6" style="width:25px; padding-right:5px">
<path fill-rule="evenodd" d="M7.5 3.75A1.5 1.5 0 006 5.25v13.5a1.5 1.5 0 001.5 1.5h6a1.5 1.5 0 001.5-1.5V15a.75.75 0 011.5 0v3.75a3 3 0 01-3 3h-6a3 3 0 01-3-3V5.25a3 3 0 013-3h6a3 3 0 013 3V9A.75.75 0 0115 9V5.25a1.5 1.5 0 00-1.5-1.5h-6zm10.72 4.72a.75.75 0 011.06 0l3 3a.75.75 0 010 1.06l-3 3a.75.75 0 11-1.06-1.06l1.72-1.72H9a.75.75 0 010-1.5h10.94l-1.72-1.72a.75.75 0 010-1.06z" clip-rule="evenodd" />
</svg>
Login
</a>
{% endif %}
</div>
{% if app.user %}
<div class="card mt-5" style="max-width:600px; margin:auto;">
<div class="card-body">
<b>Avatar</b> = {{ app.user.avatar }}<br>
<b>login</b> = {{ app.user.username }}<br>
<b>firstname</b> = {{ app.user.firstname }}<br>
<b>lastname</b> = {{ app.user.lastname }}<br>
<b>email</b> = {{ app.user.email }}<br>
</div>
</div>
{% endif %}
{% endblock %}

View File

@ -0,0 +1,37 @@
{% extends "base.html.twig" %}
{% block body %}
<div style="text-align:center">
{% if mode=="SQL" %}
{% set route="app_hydra_checkloginsql" %}
{% else %}
{% set route="app_hydra_checkloginldap" %}
{% endif %}
{{ form_start(form, {'action': path(route), 'method': 'POST'}) }}
<div class="card homecard mb-3" style="width:400px; margin:auto; text-align: left;">
<div class="card-body">
{% if error is defined and not error is empty %}
<div class='alert alert-danger' style='margin: 5px 0px'>
{{ error }}
</div>
{% endif %}
{{ form_row(form.username) }}
{{ form_row(form.password) }}
{{ form_row(form.submit) }}
</div>
</div>
{{ form_end(form) }}
</div>
{% endblock %}
{% block localscript %}
<script>
$(document).ready(function() {
$("#login_username").focus();
});
</script>
{% endblock %}

View File

@ -0,0 +1,23 @@
{% extends "base.html.twig" %}
{% block body %}
<div style="text-align:center">
{{ form_start(form, {'action': path('app_loginldapcheck'), 'method': 'POST'}) }}
<div class="card homecard mb-3" style="width:400px; margin:auto; text-align: left;">
<div class="card-body">
{{ form_row(form.username) }}
{{ form_row(form.password) }}
{{ form_row(form.submit) }}
</div>
</div>
{{ form_end(form) }}
</div>
{% endblock %}
{% block localscript %}
<script>
$(document).ready(function() {
$("#login_username").focus();
});
</script>
{% endblock %}

View File

@ -0,0 +1,35 @@
{% extends "base.html.twig" %}
{% block body %}
<div style="text-align:center">
<form action="{{ path('app_login') }}" method="post">
<div class="card homecard mb-3" style="width:400px; margin:auto">
<div class="card-body">
{% if error %}
<div class="alert alert-danger">{{ error.messageKey|trans(error.messageData, 'security') }}</div>
{% endif %}
<label for="username">Login</label>
<input type="text" id="username" name="_username" value="{{ last_username }}" class="form-control" style="margin-bottom:15px;" />
<label for="password">Password</label>
<input type="password" id="password" name="_password" class="form-control" style="margin-bottom:15px;" />
<input type="hidden" name="_csrf_token" value="{{ csrf_token('authenticate') }}">
<input type="submit" name="login" class="btn btn-success form-control" />
</div>
</div>
</form>
</div>
{% endblock %}
{% block localscript %}
<script>
$(document).ready(function() {
$("#username").focus();
});
</script>
{% endblock %}

View File

@ -2,15 +2,27 @@
<html>
<head>
<meta charset="UTF-8">
<title>{% block title %}Welcome!{% endblock %}</title>
<title>{% block title %}NUO SSO{% endblock %}</title>
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 128 128%22><text y=%221.2em%22 font-size=%2296%22>⚫️</text></svg>">
{% block stylesheets %}
<link href="{{ asset('lib/bootstrap/css/bootstrap.min.css') }}" rel="stylesheet" integrity="sha384-9ndCyUaIbzAi2FUVXJi0CjmCapSmO7SnpJef0486qhLnuZ2cdeRhO02iuK6FUUVM" crossorigin="anonymous">
{% endblock %}
{% block javascripts %}
<script src="{{ asset('lib/bootstrap/js/bootstrap.bundle.min.js') }}" integrity="sha384-geWF76RCwLtnZ8qwWowPQNguL3RmwHVBC9FhGdlKrxdiJJigb/j/68SIy3Te4Bkz" crossorigin="anonymous"></script>
{% endblock %}
</head>
<body>
{% block body %}{% endblock %}
<div class="container">
<div class="text-center mt-5 mb-5">
<img src="{{ asset('images/logo.png')}}" style="max-height:200px">
</div>
{% block body %}
{% endblock %}
</div>
</body>
{% block localscript %}
{% endblock %}
</html>