Merge remote-tracking branch 'origin/feature/article' into pre-master

pull/2/head
Maxime POINT 1 year ago
commit 67b0b30be8

@ -2,10 +2,17 @@
<module type="WEB_MODULE" version="4"> <module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager"> <component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$"> <content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/mvc_PSR4_twig/config" isTestSource="false" packagePrefix="config\" />
<sourceFolder url="file://$MODULE_DIR$/mvc_PSR4_twig/controleur" isTestSource="false" packagePrefix="controleur\" />
<sourceFolder url="file://$MODULE_DIR$/mvc_PSR4_twig/metier" isTestSource="false" packagePrefix="modeles\" />
<excludeFolder url="file://$MODULE_DIR$/vendor/composer" /> <excludeFolder url="file://$MODULE_DIR$/vendor/composer" />
<excludeFolder url="file://$MODULE_DIR$/vendor/twig/twig" /> <excludeFolder url="file://$MODULE_DIR$/vendor/twig/twig" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-mbstring" /> <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-mbstring" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-ctype" /> <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-ctype" />
<excludeFolder url="file://$MODULE_DIR$/mvc_PSR4_twig/vendor/composer" />
<excludeFolder url="file://$MODULE_DIR$/mvc_PSR4_twig/vendor/symfony/polyfill-ctype" />
<excludeFolder url="file://$MODULE_DIR$/mvc_PSR4_twig/vendor/symfony/polyfill-mbstring" />
<excludeFolder url="file://$MODULE_DIR$/mvc_PSR4_twig/vendor/twig/twig" />
</content> </content>
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />

@ -1,14 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <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="highlightLevel" value="WARNING" />
<option name="transferred" value="true" />
</component>
<component name="PhpIncludePathManager"> <component name="PhpIncludePathManager">
<include_path> <include_path>
<path value="$PROJECT_DIR$/vendor/composer" /> <path value="$PROJECT_DIR$/vendor/composer" />
<path value="$PROJECT_DIR$/vendor/twig/twig" /> <path value="$PROJECT_DIR$/vendor/twig/twig" />
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-mbstring" /> <path value="$PROJECT_DIR$/vendor/symfony/polyfill-mbstring" />
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-ctype" /> <path value="$PROJECT_DIR$/vendor/symfony/polyfill-ctype" />
<path value="$PROJECT_DIR$/mvc_PSR4_twig/vendor/symfony/polyfill-mbstring" />
<path value="$PROJECT_DIR$/mvc_PSR4_twig/vendor/symfony/polyfill-ctype" />
<path value="$PROJECT_DIR$/mvc_PSR4_twig/vendor/composer" />
<path value="$PROJECT_DIR$/mvc_PSR4_twig/vendor/twig/twig" />
</include_path> </include_path>
</component> </component>
<component name="PhpProjectSharedConfiguration" php_language_level="8.0"> <component name="PhpProjectSharedConfiguration" php_language_level="8.0">
<option name="suggestChangeDefaultLanguageLevel" value="false" /> <option name="suggestChangeDefaultLanguageLevel" value="false" />
</component> </component>
<component name="PhpStanOptionsConfiguration">
<option name="transferred" value="true" />
</component>
<component name="PsalmOptionsConfiguration">
<option name="transferred" value="true" />
</component>
</project> </project>

@ -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"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/mvc_PSR4_twig.iml" filepath="$PROJECT_DIR$/.idea/mvc_PSR4_twig.iml" />
</modules>
</component>
</project>

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/config" isTestSource="false" packagePrefix="config\" />
<sourceFolder url="file://$MODULE_DIR$/controleur" isTestSource="false" packagePrefix="controleur\" />
<sourceFolder url="file://$MODULE_DIR$/metier" isTestSource="false" packagePrefix="modeles\" />
<sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/vendor/composer" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-ctype" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-mbstring" />
<excludeFolder url="file://$MODULE_DIR$/vendor/twig/twig" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="PhpIncludePathManager">
<include_path>
<path value="$PROJECT_DIR$/vendor/composer" />
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-ctype" />
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-mbstring" />
<path value="$PROJECT_DIR$/vendor/twig/twig" />
</include_path>
</component>
<component name="PhpProjectSharedConfiguration" php_language_level="8.0">
<option name="suggestChangeDefaultLanguageLevel" value="false" />
</component>
</project>

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

@ -0,0 +1,25 @@
<?php
namespace DAL;
use App\modeles\Article;
use PDO;
class ArticleGateway
{
private $con;
/**
* @param $con
*/
public function __construct($con)
{
$this->con = $con;
}
public function getAllArticles():array
{
$query = 'SELECT * FROM Article;';
$this->con->executeQuery($query, array());
return $this->con->getResults();
}
}

@ -1,6 +1,6 @@
<?php <?php
namespace modeles; namespace DAL;
use PDO; use PDO;

@ -1,6 +1,6 @@
<?php <?php
namespace modeles; namespace DAL;
use PDO; use PDO;

@ -7,7 +7,7 @@
"psr-4": { "psr-4": {
"controleur\\": "controleur/", "controleur\\": "controleur/",
"config\\": "config/", "config\\": "config/",
"modeles\\": "modeles/" "modeles\\": "metier/"
} }
} }
} }

@ -1,14 +1,15 @@
<?php <?php
namespace controleur; namespace controleur;
use model\ArticleModel;
class Controleur class Controleur
{ {
public function __construct() public function __construct()
{ {
global $twig; // nécessaire pour utiliser variables globales global $twig; // nécessaire pour utiliser variables globales
// on démarre ou reprend la session pas utilisée ici
session_start(); session_start();
$tabArticle[] = ArticleModel::getArticles();
//debut //debut
//on initialise un tableau d'erreur //on initialise un tableau d'erreur
@ -30,7 +31,8 @@ class Controleur
//mauvaise action //mauvaise action
default: default:
$dVueEreur[] = "Erreur d'appel php"; $dVueEreur[] = "Erreur d'appel php";
echo $twig->render('vuephp1.html', ['dVueEreur' => $dVueEreur]); $dataview = ['Article'=> $tabArticle];
echo $twig->render('listArticle.html', ['tabArticle' => $dataview, 'dVueErreur'=>$dVueEreur]);
break; break;
} }
} catch (\PDOException $e) { } catch (\PDOException $e) {
@ -67,7 +69,7 @@ class Controleur
$age = $_POST['txtAge']; $age = $_POST['txtAge'];
\config\Validation::val_form($nom, $age, $dVueEreur); \config\Validation::val_form($nom, $age, $dVueEreur);
$model = new \modeles\Simplemodel(); $model = new \metier\Simplemodel();
$data = $model->get_data(); $data = $model->get_data();
$dVue = [ $dVue = [

@ -10,7 +10,7 @@ use controleur\Controleur;
//twig //twig
$loader = new \Twig\Loader\FilesystemLoader('templates'); $loader = new \Twig\Loader\FilesystemLoader('templates');
$twig = new \Twig\Environment($loader, [ $twig = new \Twig\Environment($loader, [
'cache' => 'cache', 'cache' => false,
]); ]);
$cont = new Controleur(); $cont = new Controleur();

@ -0,0 +1,118 @@
<?php
namespace metier;
class Article
{
private int $id;
private string $title;
private string $date;
private string $description;
private string $guid;
private string $link;
private string $mediaContent;
private int $provenance;
/**
* @param int $id
* @param string $title
* @param string $date
* @param string $description
* @param string $guid
* @param string $link
* @param string $mediaContent
* @param int $provenance
*/
public function __construct(int $id, string $title, string $date, string $description, string $guid, string $link, string $mediaContent, int $provenance)
{
$this->id = $id;
$this->title = $title;
$this->date = $date;
$this->description = $description;
$this->guid = $guid;
$this->link = $link;
$this->mediaContent = $mediaContent;
$this->provenance = $provenance;
}
public function getId(): int
{
return $this->id;
}
public function setId(int $id): void
{
$this->id = $id;
}
public function getTitle(): string
{
return $this->title;
}
public function setTitle(string $title): void
{
$this->title = $title;
}
public function getDate(): string
{
return $this->date;
}
public function setDate(string $date): void
{
$this->date = $date;
}
public function getDescription(): string
{
return $this->description;
}
public function setDescription(string $description): void
{
$this->description = $description;
}
public function getGuid(): string
{
return $this->guid;
}
public function setGuid(string $guid): void
{
$this->guid = $guid;
}
public function getLink(): string
{
return $this->link;
}
public function setLink(string $link): void
{
$this->link = $link;
}
public function getMediaContent(): string
{
return $this->mediaContent;
}
public function setMediaContent(string $mediaContent): void
{
$this->mediaContent = $mediaContent;
}
public function getProvenance(): int
{
return $this->provenance;
}
public function setProvenance(int $provenance): void
{
$this->provenance = $provenance;
}
}

@ -1,6 +1,6 @@
<?php <?php
namespace modeles; namespace metier;
class Flux class Flux
{ {

@ -0,0 +1,18 @@
<?php
namespace model;
use DAL;
use metier;
class ArticleModel
{
public static function getArticles() : array
{
$gwArticle = new DAL\ArticleGateway(new DAL\Connection('mysql:host = localhost; dbname = dbrorossetto', 'rorossetto', 'tpphp'));
$res = $gwArticle->getAllArticles();
foreach($res as $row){
$tabArticle[] = new metier\Article($row['id'], $row['title'],$row['datePub'],$row['description'],$row['guid'],$row['link'],$row['mediaContent'],$row['provenance'] );
}
return $tabArticle;
}
}

@ -1,6 +1,6 @@
<?php <?php
namespace modeles; namespace model;
class FluxModel class FluxModel
{ {

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>All Articles</title>
</head>
<body>
{% for value in tabArticle.Article %}
<p>{{value}}</p>
{% endfor %}
</body>
</html>

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save