Add Business Class, Front Controller and config file

AdminInterface
Alexis 2 years ago
parent e1d2a44f4b
commit c38635507f

8
.idea/.gitignore vendored

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/SAE4.01_FORMULAIRE.iml" filepath="$PROJECT_DIR$/.idea/SAE4.01_FORMULAIRE.iml" />
</modules>
</component>
</project>

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="MessDetectorOptionsConfiguration">
<option name="transferred" value="true" />
</component>
<component name="PHPCSFixerOptionsConfiguration">
<option name="transferred" value="true" />
</component>
<component name="PHPCodeSnifferOptionsConfiguration">
<option name="transferred" value="true" />
</component>
<component name="PhpProjectSharedConfiguration" php_language_level="8.2" />
<component name="PhpStanOptionsConfiguration">
<option name="transferred" value="true" />
</component>
<component name="PsalmOptionsConfiguration">
<option name="transferred" value="true" />
</component>
</project>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

@ -0,0 +1,40 @@
<?php
namespace FORM_BusinessClass;
abstract class BoxQuestion extends Question
{
private array $possibleResponses; // un dictionnaire qui associe chaque réponse
// possible à un ou plusieurs objets Category
/**
* @param array $possibleResponses
* @param string $content
* @param array $categories
*/
public function __construct(array $possibleResponses, string $content, array $categories)
{
parent::__construct($content, $categories);
$this->possibleResponses = $possibleResponses;
}
public abstract function responseStrategy();
public abstract function printStrategy();
/**
* @return array
*/
public function getPossibleResponses(): array
{
return $this->possibleResponses;
}
/**
* @param array $possibleResponses
*/
public function setPossibleResponses(array $possibleResponses): void
{
$this->possibleResponses = $possibleResponses;
}
}

@ -0,0 +1,32 @@
<?php
namespace FORM_BusinessClass;
class Category
{
private string $word;
/**
* @param string $word
*/
public function __construct(string $word)
{
$this->word = $word;
}
/**
* @return string
*/
public function getWord(): string
{
return $this->word;
}
/**
* @param string $word
*/
public function setWord(string $word): void
{
$this->word = $word;
}
}

@ -0,0 +1,26 @@
<?php
namespace FORM_BusinessClass;
class CheckBoxQuestion extends BoxQuestion
{
/**
* @param array $possibleResponses
* @param string $content
* @param array $categories
*/
public function __construct(array $possibleResponses, string $content, array $categories)
{
parent::__construct($possibleResponses, $content, $categories);
}
public function responseStrategy()
{
// TODO: Implement responseStrategy() method.
}
public function printStrategy()
{
// TODO: Implement printStrategy() method.
}
}

@ -0,0 +1,70 @@
<?php
namespace FORM_BusinessClass;
class Form
{
private string $title;
private string $description;
private array $questions; // La liste des questions dans un formulaire
/**
* @param string $title
* @param string $description
* @param array $questions
*/
public function __construct(string $title, string $description, array $questions)
{
$this->title = $title;
$this->description = $description;
$this->questions = $questions;
}
/**
* @return string
*/
public function getTitle(): string
{
return $this->title;
}
/**
* @param string $title
*/
public function setTitle(string $title): void
{
$this->title = $title;
}
/**
* @return string
*/
public function getDescription(): string
{
return $this->description;
}
/**
* @param string $description
*/
public function setDescription(string $description): void
{
$this->description = $description;
}
/**
* @return array
*/
public function getQuestions(): array
{
return $this->questions;
}
/**
* @param array $questions
*/
public function setQuestions(array $questions): void
{
$this->questions = $questions;
}
}

@ -0,0 +1,8 @@
<?php
namespace FORM_BusinessClass;
interface IPrintQuestionStrategy
{
public function printStrategy();
}

@ -0,0 +1,8 @@
<?php
namespace FORM_BusinessClass;
interface IResponseProcessingStrategy
{
public function responseStrategy();
}

@ -0,0 +1,26 @@
<?php
namespace FORM_BusinessClass;
class ListBoxQuestion extends BoxQuestion
{
/**
* @param array $possibleResponses
* @param string $content
* @param array $categories
*/
public function __construct(array $possibleResponses, string $content, array $categories)
{
parent::__construct($possibleResponses, $content, $categories);
}
public function responseStrategy()
{
// TODO: Implement responseStrategy() method.
}
public function printStrategy()
{
// TODO: Implement printStrategy() method.
}
}

@ -0,0 +1,55 @@
<?php
namespace FORM_BusinessClass;
abstract class Question implements IResponseProcessingStrategy, IPrintQuestionStrategy
{
private string $content;
private array $categories; // Liste d'objets Category
/**
* @param string $content
* @param array $categories
*/
public function __construct(string $content, array $categories)
{
$this->content = $content;
$this->categories = $categories;
}
public abstract function responseStrategy();
public abstract function printStrategy();
/**
* @return string
*/
public function getContent(): string
{
return $this->content;
}
/**
* @param string $content
*/
public function setContent(string $content): void
{
$this->content = $content;
}
/**
* @return array
*/
public function getCategories(): array
{
return $this->categories;
}
/**
* @param array $categories
*/
public function setCategories(array $categories): void
{
$this->categories = $categories;
}
}

@ -0,0 +1,25 @@
<?php
namespace FORM_BusinessClass;
class TextQuestion extends Question
{
/**
* @param string $content
* @param array $categories
*/
public function __construct(string $content, array $categories)
{
parent::__construct($content, $categories);
}
public function responseStrategy()
{
// TODO: Implement responseStrategy() method.
}
public function printStrategy()
{
// TODO: Implement printStrategy() method.
}
}

@ -0,0 +1,25 @@
<?php
namespace FORM_BusinessClass;
class YesNoQuestion extends Question
{
/**
* @param string $content
* @param array $categories
*/
public function __construct(string $content, array $categories)
{
parent::__construct($content, $categories);
}
public function responseStrategy()
{
// TODO: Implement responseStrategy() method.
}
public function printStrategy()
{
// TODO: Implement printStrategy() method.
}
}

@ -0,0 +1,48 @@
<?php
class Autoload
{
private static $_instance = null;
public static function charger(): void
{
if(null !== self::$_instance) {
throw new RuntimeException(sprintf('%s is already started', __CLASS__));
}
self::$_instance = new self();
if(!spl_autoload_register(array(self::$_instance, '_autoload'), false)) {
throw new RuntimeException(sprintf('%s : Could not start the autoload', __CLASS__));
}
}
public static function shutDown(): void
{
if(null !== self::$_instance) {
if(!spl_autoload_unregister(array(self::$_instance, '_autoload'))) {
throw new RuntimeException('Could not stop the autoload');
}
self::$_instance = null;
}
}
private static function _autoload($class): void
{
global $rep;
$filename = $class.'.php';
$dir =array('BusinessClass/', 'DAL/', 'Models/', './', 'Config/', 'Controleur/');
foreach ($dir as $d){
$file=$rep.$d.$filename;
//echo $file;
if (file_exists($file))
{
include $file;
}
}
}
}

@ -0,0 +1,9 @@
<?php
$rep = __DIR__ . '/Source/FORM/';
$base="";
$login="";
$password="";
$views['form'] = 'Views/HTML/form.php';

@ -0,0 +1,36 @@
<?php
namespace FORM_Controller;
class FrontController
{
function __construct()
{
/* La liste de tous les Controller */
$listControllers = array("\\FORM_Controller\\ControllerCandidate", "\\FORM_Controller\\ControllerAdmin");
global $rep, $views; // Chemin d'accès + Vues
$dVueError = array(); // Vue d'erreur
try
{
/* Si l'action est NULL on appelle goToTestimony(), sinon on nettoie l'action */
$action = $_REQUEST['action'] ? $action = $_REQUEST['action'] : (new ControllerVisitor)->goToTestimony();
foreach ($listControllers as $controller) // Pour chaque Controller
{
/* On regarde s'il implémente une fonction du même nom que l'action reçue */
if(method_exists($controller, $action))
{
(new $controller)->$action(); // Si oui, on appelle cette fonction
}
}
} catch (PDOException|Exception $e)
{
$dVueError[] = "Erreur innatendue !"; // Ecriture du message d'erreur
require ($rep.$views['error']); // Affichage de la vue d'erreur
}
exit(0);
}
}

@ -0,0 +1,31 @@
* {
margin: 0;
padding: 0;
}
body {
background-image: url('../IMAGES/background_uca.png');
background-attachment: fixed;
background-size: cover;
background-repeat: no-repeat;
font-family : 'Poppins', 'Signika', sans-serif;
}
h1 {
text-align: center;
font-weight: bold;
font-size: 200%;
padding: 1.5%;
color: white;
background-color: rgb(23,143,150);
}
:not(h1) {
color: #5e5c5c;
}
#logoUCA {
position: absolute;
padding-left: 3%;
padding-top: 2%;
}

@ -0,0 +1,86 @@
#container_form {
display: flex;
flex-direction: row;
justify-content: center;
margin-top: 5%;
}
#container_form h2{
padding-top: 1%;
}
#container_form #button {
margin-top: 5%;
width: 20%;
height: 5%;
margin-left: 79%;
margin-bottom: 10%;
cursor: pointer;
background-color: #ebceb2;
color: black;
border-radius: 20px;
}
#container_form #button:hover {
background-color: rgb(23,143,150);
}
#container_testimony, #container_personalInfos {
display: flex;
flex-direction: column;
margin-right: 2.5%;
margin-left: 2.5%;
}
#container_personalInfos {
width: 15%;
}
#container_personalInfos .inputs {
margin-bottom: 4%;
border-radius: 10px;
height: 6%;
padding-left: 4%;
float: left;
}
#container_testimony {
width: 60%;
}
#container_testimony #description {
height: 10em;
border-radius: 20px;
padding: 3%;
font-size: 1.2em;
margin-bottom: 4%;
}
#container_testimony #video {
font-weight: bold;
}
textarea {
resize: none;
}
@media screen and (max-width: 1024px)
{
#container_form {
flex-direction: column;
align-items: center;
}
#container_personalInfos {
width: 60%;
}
#container_form #button {
margin-top: 12%;
}
#logoUCA {
display: none;
}
}

@ -0,0 +1,54 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="../CSS/form.css" />
<link rel="stylesheet" href="../CSS/base.css" />
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300&display=swap" rel="stylesheet">
<title>Formulaire de témoignage</title>
</head>
<body>
<!-- La barre bleue située en tête de page -->
<img id="logoUCA" src="https://cdn.uca.fr/images/logos/logo_uca_mini_light.png" height="35px">
<h1>Votre témoignage nous intéresse !</h1>
<!-- L'intégralité du formulaire de témoignage -->
<form id="container_form">
<!-- La partie gauche du formulaire ("Vos informations" et "Votre statut") -->
<div id="container_personalInfos">
<h2>Vos informations :</h2>
<input class="inputs" type="text" name="surname" placeholder="Saisir votre nom..."/>
<input class="inputs" type="text" name="firstname" placeholder="Saisir votre prénom..."/>
<h2>Votre statut :</h2>
<select class="inputs" name="status">
<option value="">Étudiant</option>
<option value="">Professeur</option>
<option value="">Ancien Étudiant</option>
</select>
</div>
<!-- La partie droite du formulaire ("Votre témoignage" et "Ajouter une vidéo") -->
<div id="container_testimony">
<h2>Votre témoignage :</h2>
<textarea id="description" name="description" placeholder="Saisir une description..."></textarea>
<label id="video">Ajouter une vidéo :</label>
<input id="addVideo" type="file" name="video"/>
<!-- Le bouton pour envoyer le témoignage -->
<input id="button" type="submit" value="Envoyer">
</div>
</form>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 KiB

Loading…
Cancel
Save