Premier commit

This commit is contained in:
2024-09-09 10:22:45 +02:00
commit bcc2604080
74 changed files with 25819 additions and 0 deletions

View File

@@ -0,0 +1,93 @@
<?php
use function Piko\I18n\__;
assert($this instanceof Piko\View);
/* @var $message array */
/* @var $user piko\user\models\User */
$this->title = __('user', 'Edit your account');
if (is_array($message)) {
$this->params['message'] = $message;
}
if (!empty($user->profil)) {
$user->profil = json_decode($user->profil);
}
?>
<div class="container mt-5">
<h1><?= $this->title ?></h1>
<form method="post" novalidate>
<div class="form-group">
<label for="username"><?= __('user', 'Username') ?> : <strong><?= $user->username ?></strong></label>
</div>
<div class="form-group">
<label for="email"><?= __('user', 'Email') ?></label>
<input type="text" class="form-control" id="email" name="email" value="<?= $user->email ?>">
<?php if (!empty($user->errors['email'])): ?>
<div class="alert alert-danger" role="alert"><?= $user->errors['email'] ?></div>
<?php endif ?>
</div>
<div class="form-group">
<label for="password"><?= __('user', 'Password (leave blank to keep the same)') ?></label>
<input type="password" class="form-control" id="password" name="password" value="" autocomplete="off">
</div>
<div class="form-row">
<div class="col-md-6 mb-3">
<label for="lastname"><?= __('user', 'Last name') ?></label>
<input type="text" class="form-control" id="lastname" name="profil[lastname]" value="<?= isset($user->profil->lastname) ? $user->profil->lastname : '' ?>">
</div>
<div class="col-md-6 mb-3">
<label for="firstname"><?= __('user', 'First name') ?></label>
<input type="text" class="form-control" id="firstname" name="profil[firstname]" value="<?= isset($user->profil->firstname) ? $user->profil->firstname : '' ?>">
</div>
</div>
<div class="form-row">
<div class="col-md-6 mb-3">
<label for="company"><?= __('user', 'Company') ?></label>
<input type="text" class="form-control" id="company" name="profil[company]" value="<?= isset($user->profil->company) ? $user->profil->company : ''?>">
</div>
<div class="col-md-6 mb-3">
<label for="telephone"><?= __('user', 'Phone number') ?></label>
<input type="text" class="form-control" id="telephone" name="profil[telephone]" value="<?= isset($user->profil->telephone) ? $user->profil->telephone : ''?>">
</div>
</div>
<div class="form-group mb-3">
<label for="address"><?= __('user', 'Address') ?></label>
<input type="text" class="form-control" id="address" name="profil[address]" value="<?= isset($user->profil->address) ? $user->profil->address : ''?>">
</div>
<div class="form-row">
<div class="col-md-4 mb-3">
<label for="zipcode"><?= __('user', 'Zip code') ?></label>
<input type="text" class="form-control" id="zipcode" name="profil[zipcode]" value="<?= isset($user->profil->zipcode) ? $user->profil->zipcode : ''?>">
</div>
<div class="col-md-4 mb-3">
<label for="city"><?= __('user', 'City') ?></label>
<input type="text" class="form-control" id="city" name="profil[city]" value="<?= isset($user->profil->city) ? $user->profil->city : ''?>">
</div>
<div class="col-md-4 mb-3">
<label for="country"><?= __('user', 'Country') ?></label>
<input type="text" class="form-control" id="country" name="profil[country]" value="<?= isset($user->profil->country) ? $user->profil->country : ''?>">
</div>
</div>
<button type="submit" class="btn btn-primary"><?= __('user', 'Save') ?></button>
<a href="<?= Piko::getAlias('@web/')?>" class="btn btn-default"><?= __('user', 'Cancel') ?></a>
</form>
</div>

View File

@@ -0,0 +1,77 @@
<?php
use function Piko\I18n\__;
assert($this instanceof Piko\View);
/**
* @var $message boolean | array
* @var $canRegister boolean
*/
$this->title = __('user', 'Login');
$this->params['breadcrumbs'][] = $this->title;
if (is_array($message)) {
$this->params['message'] = $message;
}
?>
<main class="form-signin w-100 m-auto">
<form action="<?= $this->getUrl('user/default/login') ?>" id="login-form" method="post">
<h1 class="h3 mb-3 fw-normal"><?= $this->title ?></h1>
<div class="form-floating">
<input type="text" class="form-control" id="username" name="username" autofocus="autofocus" aria-required="true"
aria-invalid="true">
<label for="username"><?= __('user', 'Username') ?></label>
</div>
<div class="form-floating">
<input type="password" class="form-control" id="loginform-password" name="password" value="" aria-required="true">
<label for="loginform-password"><?= __('user', 'Password') ?></label>
</div>
<button class="btn btn-primary w-100 py-2" type="submit"><?= __('user', 'Login') ?></button>
<p class="mt-5 mb-3 text-body-secondary">&copy; 20172023</p>
<!--
<div class="form-group row">
<label class="col-sm-3 col-form-label" for="loginform-username"><?= __('user', 'Username') ?></label>
<div class="col-sm-9">
<input type="text" id="username" class="form-control" name="username" autofocus="autofocus" aria-required="true"
aria-invalid="true">
</div>
</div>
<div class="form-group row">
<label class="col-sm-3 col-form-label" for="loginform-password"><?= __('user', 'Password') ?></label>
<div class="col-sm-9">
<input type="password" id="loginform-password" class="form-control" name="password" value="" aria-required="true">
</div>
</div>
<div class="form-group">
<div class="offset-sm-3 col-sm-9">
<button type="submit" class="btn btn-primary" name="login-button"><?= __('user', 'Login') ?></button>
</div>
</div>
-->
</form>
<?php if ($canRegister): ?>
<div class="p-3 border bg-light text-dark">
<p><?= __('user', 'No account yet?') ?></p>
<p><a href="<?= $this->getUrl('user/default/register')?>" class="btn btn-primary"><?= __('user', 'Register') ?></a></p>
<hr>
<p><a href="<?= $this->getUrl('user/default/reminder')?>"><?= __('user', 'Forget password?') ?></a></p>
</div>
<?php endif ?>
</main>

View File

@@ -0,0 +1,82 @@
<?php
use piko\Piko;
/* @var $this \piko\View */
/* @var $router \piko\Router */
/* @var $message array */
$router = Piko::get('router');
$this->title = Piko::t('user', 'Register');
if (is_array($message)) {
$this->params['message'] = $message;
return;
}
$js = <<<SCRIPT
jQuery(document).ready(function($) {
function validateField(e) {
var that = this;
$.post('{$router->getUrl('user/default/check-registration')}', $('#register-form').serialize(), function(errors) {
if (errors[that.name]) {
$(that).addClass('is-invalid')
$(that).removeClass('is-valid')
$(that).next('.invalid-feedback').text(errors[that.name])
} else {
$(that).removeClass('is-invalid')
$(that).addClass('is-valid')
}
});
}
$('#username').focusout(validateField);
$('#email').focusout(validateField);
$('#password').focusout(validateField);
$('#password2').focusout(validateField);
});
SCRIPT;
$this->registerJs($js);
?>
<div class="container mt-5">
<h1><?= $this->title ?></h1>
<form method="post" id="register-form" novalidate>
<div class="form-group">
<label for="username"><?= Piko::t('user', 'Username') ?></label>
<input type="text" class="form-control" id="username" name="username" value="">
<div class="invalid-feedback"></div>
</div>
<div class="form-group">
<label for="email"><?= Piko::t('user', 'Email') ?></label>
<input type="text" class="form-control" id="email" name="email" value="">
<div class="invalid-feedback"></div>
</div>
<div class="form-group">
<label for="password"><?= Piko::t('user', 'Password') ?></label>
<input type="password" class="form-control" id="password" name="password" value="" autocomplete="off">
<div class="invalid-feedback"></div>
</div>
<div class="form-group">
<label for="password2"><?= Piko::t('user', 'Confirm your password') ?></label>
<input type="password" class="form-control" id="password2" name="password2" value="" autocomplete="off">
<div class="invalid-feedback"></div>
</div>
<button type="submit" class="btn btn-primary"><?= Piko::t('user', 'Register') ?></button>
</form>
</div>

View File

@@ -0,0 +1,31 @@
<?php
use piko\Piko;
/* @var $this \piko\View */
/* @var $message array */
/* @var $reminder string */
$this->title = Piko::t('user', 'Forget password');
if (is_array($message)) {
$this->params['message'] = $message;
}
?>
<div class="container" style="margin-top: 100px">
<h1><?= $this->title ?></h1>
<form method="post" id="reminder-form" novalidate>
<div class="form-group">
<label for="reminder"><?= Piko::t('user', 'Your email or your username') ?></label>
<input type="text" class="form-control" id="reminder" name="reminder" value="<?= $reminder ?>" autocomplete="off">
</div>
<button type="submit" class="btn btn-primary"><?= Piko::t('user', 'Send') ?></button>
</form>
</div>

View File

@@ -0,0 +1,75 @@
<?php
use piko\Piko;
/* @var $this \piko\View */
/* @var $user piko\user\models\User */
/* @var $message array */
/* @var $router \piko\Router */
$router = Piko::get('router');
$this->title = Piko::t('user', 'Change your account ({account}) password',['account' => $user->username]);
if (is_array($message)) {
$this->params['message'] = $message;
echo '<div class="container text-center"><a class="btn btn-primary" href="'. $router->getUrl('user/default/login').'">'
. Piko::t('user', 'Login') . '</a></div>';
return;
}
$js = <<<SCRIPT
jQuery(document).ready(function($) {
function validateField(e) {
var that = this;
$.post('{$router->getUrl('user/default/check-registration')}', $('#register-form').serialize(), function(errors) {
if (errors[that.name]) {
$(that).addClass('is-invalid')
$(that).removeClass('is-valid')
$(that).next('.invalid-feedback').text(errors[that.name])
} else {
$(that).removeClass('is-invalid')
$(that).addClass('is-valid')
}
});
}
$('#password').focusout(validateField);
$('#password2').focusout(validateField);
});
SCRIPT;
$this->registerJs($js);
?>
<div class="container" style="margin-top: 100px">
<h1 class="h4"><?= $this->title ?></h1>
<form method="post" id="register-form" novalidate>
<div class="form-group">
<label for="password"><?= Piko::t('user', 'Password') ?></label>
<input type="password" class="form-control" id="password" name="password" value="" autocomplete="off">
<div class="invalid-feedback"></div>
</div>
<div class="form-group">
<label for="password2"><?= Piko::t('user', 'Confirm your password') ?></label>
<input type="password" class="form-control" id="password2" name="password2" value="" autocomplete="off">
<div class="invalid-feedback"></div>
</div>
<button type="submit" class="btn btn-primary"><?= Piko::t('user', 'Send') ?></button>
</form>
</div>