Skip to content

Commit

Permalink
Merge pull request #8 from Vanhaex/trad_english
Browse files Browse the repository at this point in the history
Trad english
  • Loading branch information
Vanhaex committed Apr 28, 2023
2 parents 2dccb2d + 91cd9bc commit 6c8cf49
Show file tree
Hide file tree
Showing 39 changed files with 358 additions and 331 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# ESLF Web Framework Change Log

## Version 2.1.1 (29/03/2032)
## Version 2.1.2 (28/04/2023)
* Complete translation from French to English

## Version 2.1.1 (29/03/2023)
* Translate README
* Adding MIT license

Expand Down
2 changes: 0 additions & 2 deletions app/controller/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,4 @@ public function index()
}
}



?>
4 changes: 3 additions & 1 deletion app/model/Home.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ class Home extends Model
*/
protected $columns =
[];
}
}

?>
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslf/vanhaex",
"version": "2.1.1",
"version": "2.1.2",
"description": "Easy, Simple and Lightweight web Framework for creating web applications",
"type": "project",
"license": "MIT",
Expand All @@ -12,6 +12,7 @@
"minimum-stability": "stable",
"require": {
"php": "^7.4",
"ext-openssl": "*",
"phpmailer/phpmailer": "^6.4",
"ext-mysqli":"*",
"ext-json": "*",
Expand Down
35 changes: 17 additions & 18 deletions config/AppConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,43 @@
class AppConfig
{
/**
* Le type d'environnement du projet (dev, recette, prod)
* Défaut : dev
* Project's environment (dev, prod, ...)
* Default : dev
*/
const CONFIG_ENVIRONMENT= "dev";

/**
* La valeur du mode debug, permet d'afficher les erreurs PHP dans les vues
* Défaut : true
* Debug mode, determine if we show PHP notice or errors messages in templates
* Default : true
*/
const CONFIG_DEBUG = true;

/**
* Indique si on doit générer des logs. Pour ne pas instancier l'objet LogWriting et éviter les erreurs
* For using logs
*/
const ACTIVATE_LOGS = false;

/**
* Le nom du dossier contenant les logs (ne doit pas finir par un "/")
* Folder's name for logs (must not finish by '/')
*/
const LOG_FILE_PATH = "log";

/**
* Indique si le projet nécessite la connexion à une base de données grâce à la lib ESDBaccess
* Pour ne pas instancier d'objet mysqli et éviter les erreurs. Utile pour les pages statiques
* Défaut : false
* Tell if we want to use ESDBaccess for retrieve and use database.
* If false, it will not be instanciated
* Default : false
*/
const ACTIVATE_DATABASE = false;

/**
* L'URI de base pour appeler une API. Peut être changé si besoin mais doit rester explicite et sans caractères exotiques
* Défaut : '/api'
* Base URI for API use. Must not contain exotic characters
* Default : '/api'
*/
const API_BASE_URI = "/api";


/**
* Retourne le type d'environnement du projet
* Return project environment value
*
* @return string
*/
Expand All @@ -51,7 +51,7 @@ public static function getEnvironment(): string
}

/**
* Retourne la valeur du mode debug
* Return debug mode value
*
* @return bool
*/
Expand All @@ -61,7 +61,7 @@ public static function getDebug(): bool
}

/**
* Retourne le dossier contenant les logs
* Return logs folder value
*
* @return string
*/
Expand All @@ -71,7 +71,7 @@ public static function getLogFilePath(): string
}

/**
* Retourne
* Return logs activation value
*
* @return bool
*/
Expand All @@ -81,7 +81,7 @@ public static function getActivateLogs(): bool
}

/**
* Retourne la valeur qui indique si le projet utilise une connexion à une base de données
* Return database use value
*
* @return bool
*/
Expand All @@ -91,13 +91,12 @@ public static function getActivateDatabase(): bool
}

/**
* Retourne l'URI de base pour appeler une API
* Return base URI for API use value
*
* @return string
*/
public static function getApiBaseUri(): string
{
return self::API_BASE_URI;
}

}
25 changes: 12 additions & 13 deletions config/DatabaseConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,37 @@
class DatabaseConfig
{
/**
* Le host de connexion à la bdd
* Host for DDB connexion
*/
const CONFIG_DATABASE_HOST = "localhost";

/**
* Le port de connexion à la bdd
* Port for DDB connexion
*/
const CONFIG_DATABASE_PORT = 3306;

/**
* Le username de connexion à la bdd
* Username for DDB connexion
*/
const CONFIG_DATABASE_USER = "";

/**
* Le password de connexion à la bdd
* Password for DDB connexion
*/
const CONFIG_DATABASE_PASSWORD = "";

/**
* Le nom de la bdd
* Database name for DDB connexion
*/
const CONFIG_DATABASE_DATABASE = "";

/**
* Si true, le mode transactionnel est activé
* If true, transaction will be activated
*/
const CONFIG_DATABASE_TRANSACTIONS = true;

/**
* Retourne le host
* Return host
*
* @return string
*/
Expand All @@ -45,7 +45,7 @@ public static function getDatabaseHost(): string
}

/**
* Retourne le port
* Return port
*
* @return int
*/
Expand All @@ -55,7 +55,7 @@ public static function getDatabasePort(): int
}

/**
* Retourne le user
* Return username
*
* @return string
*/
Expand All @@ -65,7 +65,7 @@ public static function getDatabaseUser(): string
}

/**
* Retourne le password
* Return password
*
* @return string
*/
Expand All @@ -75,7 +75,7 @@ public static function getDatabasePassword(): string
}

/**
* Retourne le nom de la bdd
* Return database name
*
* @return string
*/
Expand All @@ -85,13 +85,12 @@ public static function getDatabaseDbName(): string
}

/**
* Retourne la valeur du mode transaction
* Return transaction mode value
*
* @return bool
*/
public static function getDatabaseTransactionMode(): bool
{
return self::CONFIG_DATABASE_TRANSACTIONS;
}

}
2 changes: 1 addition & 1 deletion esbuilder
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ foreach ($commandArrays as $cmd){

$application->add($default = new VersionCommand());

// La commande about par défaut qui présente le framework
// Default command is 'about'
$application->setDefaultCommand($default->getName());
$application->run();

Expand Down
10 changes: 5 additions & 5 deletions framework/AlertMessage/AlertMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function __construct()
}

/**
* Créé un message d'alerte en tant de variable de session
* Create alert message as session variable
*
* @param $message
* @param string $status
Expand All @@ -24,7 +24,7 @@ public function addAlertMessage($message, string $status = "success")
{
if ($this->session->hasSession("alert_messages"))
{
// Pour l'instant c'est un array vide et on va ajouter le message et le statut ensuite
// For the moment, we create empty array and adding message and status later
$this->session->setSession("alert_messages", []);
}

Expand All @@ -37,15 +37,15 @@ public function addAlertMessage($message, string $status = "success")
}

/**
* Retourne les messages d'alertes
* Return alert messages
*
* @return array|false|mixed
*/
public function getAlertMessage()
{
$messages_array = $this->session->getSession("alert_messages");

// Si il n'y a aucun message, on redéclare la liste des messages par un tableau vide
// If there's no messages, we declare messages list with empty array
if(!$messages_array){
$messages_array = [];
}
Expand All @@ -56,7 +56,7 @@ public function getAlertMessage()
}

/**
* Vérifie s'il existe des messages d'alerte
* Verify if there's alert messages
*
* @return bool
*/
Expand Down
43 changes: 28 additions & 15 deletions framework/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
use Config\AppConfig;

/**
* Classe permettant de gérer les API
* Class for managing APIs
*
*/
class ApiController
{
private $path;
private $method;
private string $path;
private string $method;

public function __construct($path, $method)
{
Expand All @@ -23,21 +23,26 @@ public function getAPI($param)
{

if (!in_array($this->method, ["GET", "POST"])){
return $this->response("Méthode HTTP incorrecte.", 500);
return $this->response("Incorrect HTTP method.", 500);
}

// On va parser l'url dans un premier temps pour aller piocher ensuite
// If we just specify /api, it's not good, we inform the user
if (preg_match("/^(\\" . AppConfig::getApiBaseUri() . ")(\/){0,1}$/im", $this->path)){
return $this->response("The API name is missing.", 500);
}

// We will parse the URL first and then draw
preg_match("/^(\\" . AppConfig::getApiBaseUri() . "|\\/{1})(\\/[a-zA-Z0-9]+|\\/{1})/im", $this->path, $matches);

// Si on a pas l'uri de base qui permet d'appeler les API
if ($matches[1] !== AppConfig::getApiBaseUri()){
return $this->response("L'URI de base pour les API semble incorrecte.", 500);
// If we don't have the basic URI that allows us to call the APIs
if (count($matches) == 0 || $matches[1] !== AppConfig::getApiBaseUri()){
return $this->response("Base URI seems to be incorrect. You should use this : '" . AppConfig::getApiBaseUri() . "'." , 500);
}

// On va donc créer le nom de l'api qu'on va chercher
// We are therefore going to create the name of the API that we are going to look for
$api_name = ucfirst(str_replace("/", "", $matches[2])) . "Api";

// On vérifie s'il existe bien
// We check if there is
$api_controller = "App\\api\\" . $api_name;

if (class_exists($api_controller)) {
Expand All @@ -50,18 +55,26 @@ public function getAPI($param)

}
else {
return $this->response("La méthode de base (index) ne semble pas exister.", 500);
return $this->response("Base method (index) seems to be inexistant.", 500);
}
}
else {
return $this->response("Aucune classe API avec le nom " . $api_name . " n'existe.", 500);
return $this->response("No API class named " . $api_name . " exists.", 500);
}

return $this->response($get);
}

private function response($message, $code = 200, $content_type = 'application/json'){
header('Content-Type: '.$content_type);
/**
* Return the API response in JSON format
*
* @param $message <p>Display the result</p>
* @param int $code return http status code
* @param string $content_type The MIME type that will be used to display response
* @return false|string
*/
private function response($message, int $code = 200, string $content_type = 'application/json'){
header('Content-Type: ' . $content_type);
http_response_code($code);

$arrayResponse = [
Expand All @@ -73,7 +86,7 @@ private function response($message, $code = 200, $content_type = 'application/js
}

/**
* Permettra de capturer l'url avec les paramètres
* Will capture the url with parameters
**/
public function matchParameters($url)
{
Expand Down
Loading

0 comments on commit 6c8cf49

Please sign in to comment.