Commit 4679cecd authored by okhin's avatar okhin 🚴

Styling the error messages

parent 20d332d0
<?php
class MessageHelper
class MessageHelper extends \Prefab
{
/**
* Cette classe sert à afficher le code HTML stocké dans un tableau passé en argument
* et avec une classe éventuelle ajoutée en CSS
*/
public static function render($args)
public static function render($node)
{
$attr = $args['@attrib'];
$attr = $node['@attrib'];
if (!isset($attr['messages'])) {
return;
}
$html = '<!-- Messages -->';
$html = '';
$class = isset($attr['class']) ? $attr['class'] : "";
$messages = \Template::instance()->token($attr['messages']);
var_dump($messages);
$html .= '<?php echo \Template::instance()->build('.$messages.', "'.$class.'"); ?>';
$html .= '<?php \MessageHelper::instance()->build('.$messages.', "'.$class.'"); ?>';
return sprintf($html);
}
public function build($messages, $class)
{
$html = '';
foreach ($messages as $message) {
$html .= "<div class=\"$class\">";
$html .= $message;
$html .= "</div>";
}
echo $html;
}
}
......@@ -100,6 +100,13 @@ class Controller
return;
}
// Test si il y a des messages
if (!$f3->exists('SESSION.message')) {
$f3->push('SESSION.message', '');
}
if (!$f3->exists('SESSION.error')) {
$f3->push('SESSION.error', '');
}
// Rendu de la page
if ($this->template!='') {
echo \Template::instance()->render($this->template);
......
......@@ -8,7 +8,10 @@
<input type="hidden" name="csrf" id="csrf" value="{{ @CSRF }}" />
<fieldset class="form-group modal-form-only">
<h3>{{ _("Le site de dons a changé. À présent, utilisez votre adresse e-mail comme identifiant.") }} </h3>
<message messages="{{ @SESSION.error }}" class="modal-row alert alert-danger" />
<div class="modal-row">
<message messages="{{ @SESSION.error }}" class="alert alert-danger" />
<message messages="{{ @SESSION.message }}" class="alert alert-default" />
</div>
<div class="modal-row form-group">
<label for="email">{{ _("Adresse mail") }}</label>
<input class="form-control" type="email" name="email" id="email" required>
......@@ -151,5 +154,7 @@
</nav>
</div>
<section id="messages">
<message messages="@SESSION.message" class="alert alert-default">
<message messages="@SESSION.error" class="alert alert-danger">
</section>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment