update
This commit is contained in:
54
DEV.2.2/TP/TP2/ex5/conjuguer.php
Normal file
54
DEV.2.2/TP/TP2/ex5/conjuguer.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
// Terminaisons par temps
|
||||
$terminaisons = array(
|
||||
"present" => array("e", "es", "e", "ons", "ez", "ent"),
|
||||
"futur" => array("erai", "eras", "era", "erons", "erez", "eront"),
|
||||
"imparfait" => array("ais", "ais", "ait", "ions", "iez", "aient")
|
||||
);
|
||||
|
||||
// Pronoms personnels
|
||||
$pronoms = array("je", "tu", "il", "nous", "vous", "ils");
|
||||
|
||||
// Récupération des données POST
|
||||
$verbe = filter_input(INPUT_POST, "verbe", FILTER_SANITIZE_STRING);
|
||||
$tempsChoisis = $_POST['temps'] ?? [];
|
||||
|
||||
// Vérification que le verbe se termine par "er"
|
||||
if (!$verbe || substr($verbe, -2) !== 'er') {
|
||||
die("Le verbe doit être du premier groupe (terminé par -er).");
|
||||
}
|
||||
|
||||
$radical = substr($verbe, 0, -2); // Enlève "er"
|
||||
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Conjugaison</title>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.classless.min.css">
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<h3>Conjugaison du verbe « <?= htmlspecialchars($verbe) ?> »</h3>
|
||||
|
||||
<?php foreach ($tempsChoisis as $temps): ?>
|
||||
<?php if (isset($terminaisons[$temps])): ?>
|
||||
<section>
|
||||
<h4><?= ucfirst($temps) ?></h4>
|
||||
<ul>
|
||||
<?php foreach ($terminaisons[$temps] as $i => $terminaison): ?>
|
||||
<li><?= $pronoms[$i] . ' ' . $radical . $terminaison ?></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php if (empty($tempsChoisis)): ?>
|
||||
<p>Aucun temps sélectionné.</p>
|
||||
<?php endif; ?>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
4
DEV.2.2/TP/TP2/ex5/css/style.css
Normal file
4
DEV.2.2/TP/TP2/ex5/css/style.css
Normal file
@@ -0,0 +1,4 @@
|
||||
input[type="text"]{
|
||||
width:auto;
|
||||
|
||||
}
|
31
DEV.2.2/TP/TP2/ex5/ex5.html
Normal file
31
DEV.2.2/TP/TP2/ex5/ex5.html
Normal file
@@ -0,0 +1,31 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.classless.min.css"
|
||||
/>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<main>
|
||||
<h3>Conjugaison</h3>
|
||||
<form method="post" action="conjuguer.php">
|
||||
<fieldset>
|
||||
<label>Verbe du premier groupe<br>
|
||||
<input type=text name="verbe" required>
|
||||
</label>
|
||||
Temps
|
||||
<label class="checkbox"><input type=checkbox name="temps[]" value="present"> Présent </label>
|
||||
<label class="checkbox"><input type=checkbox name="temps[]" value="futur"> Futur </label>
|
||||
<label class="checkbox"><input type=checkbox name="temps[]" value="imparfait"> Imparfait </label>
|
||||
</fieldset>
|
||||
|
||||
<button type="submit" name="accepter">Envoyer</button>
|
||||
</form>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
12
DEV.2.2/TP/TP2/ex5/include/controller.php
Normal file
12
DEV.2.2/TP/TP2/ex5/include/controller.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
$terminaisons = array(
|
||||
"present"=>array("e","es","e","ons","ez","ent"),
|
||||
"futur"=>array("erai","eras","era","erons","erez","eront"),
|
||||
"imparfait"=>array("ais","ais","ait","ions","iez","aient")
|
||||
);
|
||||
|
||||
$pronoms=array("je","tu","il","nous","vous","ils");
|
||||
|
||||
$verbe = filter_input(INPUT_POST,"verbe",FILTER_SANITIZE_STRING);
|
||||
$radical = substr($verbe,0,strlen($verbe)-2);
|
||||
|
Reference in New Issue
Block a user