From f27cca08ff786ceff1870147f6d6bad14d71117f Mon Sep 17 00:00:00 2001 From: polo Date: Fri, 23 Oct 2026 00:47:32 +0200 Subject: =?UTF-8?q?dossiers=20avec=20majuscule,=20namespace=20pour=20toute?= =?UTF-8?q?s=20les=20classes,=20autoload=20psr-4,=20UserDataService::creat?= =?UTF-8?q?eZip=20d=C3=A9plac=C3=A9=20dans=20Backup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Model/Entity/AppMetadata.php | 46 ++++++++ src/Model/Entity/Article.php | 94 +++++++++++++++ src/Model/Entity/Asset.php | 68 +++++++++++ src/Model/Entity/AssetEmployment.php | 54 +++++++++ src/Model/Entity/Email.php | 131 +++++++++++++++++++++ src/Model/Entity/EmailForm.php | 57 +++++++++ src/Model/Entity/Event.php | 129 ++++++++++++++++++++ src/Model/Entity/Image.php | 89 ++++++++++++++ src/Model/Entity/Log.php | 38 ++++++ src/Model/Entity/Node.php | 167 ++++++++++++++++++++++++++ src/Model/Entity/NodeData.php | 102 ++++++++++++++++ src/Model/Entity/Page.php | 222 +++++++++++++++++++++++++++++++++++ src/Model/Entity/Presentation.php | 135 +++++++++++++++++++++ src/Model/Entity/User.php | 67 +++++++++++ 14 files changed, 1399 insertions(+) create mode 100644 src/Model/Entity/AppMetadata.php create mode 100644 src/Model/Entity/Article.php create mode 100644 src/Model/Entity/Asset.php create mode 100644 src/Model/Entity/AssetEmployment.php create mode 100644 src/Model/Entity/Email.php create mode 100644 src/Model/Entity/EmailForm.php create mode 100644 src/Model/Entity/Event.php create mode 100644 src/Model/Entity/Image.php create mode 100644 src/Model/Entity/Log.php create mode 100644 src/Model/Entity/Node.php create mode 100644 src/Model/Entity/NodeData.php create mode 100644 src/Model/Entity/Page.php create mode 100644 src/Model/Entity/Presentation.php create mode 100644 src/Model/Entity/User.php (limited to 'src/Model/Entity') diff --git a/src/Model/Entity/AppMetadata.php b/src/Model/Entity/AppMetadata.php new file mode 100644 index 0000000..b7d6923 --- /dev/null +++ b/src/Model/Entity/AppMetadata.php @@ -0,0 +1,46 @@ +key_name = $key; + $this->value = $value; + } + + public function getKey(): string + { + return $this->key_name; + } + public function getValue(): string + { + return $this->value; + } + + public function setKey(string $key): void + { + $this->key_name = $key; + } + public function setValue(string $value): void + { + $this->value = $value; + } +} \ No newline at end of file diff --git a/src/Model/Entity/Article.php b/src/Model/Entity/Article.php new file mode 100644 index 0000000..588ebd6 --- /dev/null +++ b/src/Model/Entity/Article.php @@ -0,0 +1,94 @@ + 'CURRENT_TIMESTAMP'], unique: true)] + private ?\DateTime $date_time; // le type datetime de doctrine convertit en type \DateTime de PHP + + #[ORM\Column(type: "text")] // "string" => varchar(255) => risque HTML non valide + private string $title; + + #[ORM\Column(type: "text")] + private string $preview; // une simple textarea + + #[ORM\Column(type: "text")] + private string $content; // de l'éditeur html + + #[ORM\ManyToMany(targetEntity: Image::class, inversedBy: "article")] // cascade: ['remove'] = très dangereux! + #[ORM\JoinTable( + name: TABLE_PREFIX . "article_image", + joinColumns: [new ORM\JoinColumn(name: "article_id", referencedColumnName: "id_article", onDelete: "CASCADE")], // onDelete: "CASCADE": très utile + inverseJoinColumns: [new ORM\JoinColumn(name: "image_id", referencedColumnName: "id_image", onDelete: "CASCADE")] + )] + private Collection $images; + + public function __construct(string $content, ?\DateTime $date_time = null, string $title = '', string $preview = '') + { + $this->date_time = $date_time; + $this->title = $title; + $this->preview = $preview; + $this->content = $content; + $this->images = new ArrayCollection(); // initialisation nécessaire + } + + public function getDateTime(): \DateTime + { + return $this->date_time; + } + public function setDateTime(\DateTime $date_time): void + { + $this->date_time = $date_time; + } + public function getTimestamp(): int + { + return $this->date_time->getTimestamp(); + } + public function getTitle(): string + { + return $this->title; + } + public function setTitle(string $title): void + { + $this->title = $title; + } + public function getPreview(): string + { + return $this->preview; + } + public function setPreview(string $preview): void + { + $this->preview = $preview; + } + public function getContent(): string + { + return $this->content; + } + public function setContent(string $data): void + { + $this->content = $data; + } + + public function getImages(): Collection + { + return $this->images; + } +} diff --git a/src/Model/Entity/Asset.php b/src/Model/Entity/Asset.php new file mode 100644 index 0000000..51e21fe --- /dev/null +++ b/src/Model/Entity/Asset.php @@ -0,0 +1,68 @@ +file_name = $name; + $this->mime_type = $mime_type; + $this->hash = $hash; + } + + public function getFileName(): string + { + return $this->file_name; + } + public function setFileName(string $name): void + { + $this->file_name = $name; + } + public function getMimeType(): string + { + return $this->mime_type; + } + public function setMimeType(string $mime_type): void + { + $this->mime_type = $mime_type; + } + public function getHash(): string + { + return $this->hash; + } + + public function getAssetEmployments(): Collection + { + return $this->asset_employment; + } +} diff --git a/src/Model/Entity/AssetEmployment.php b/src/Model/Entity/AssetEmployment.php new file mode 100644 index 0000000..e608af0 --- /dev/null +++ b/src/Model/Entity/AssetEmployment.php @@ -0,0 +1,54 @@ + ressource unique" (paires node_data/role uniques) +// doctrine gère mal les clés primaires triples, j'ai donc choisi une clé primaire double node_data_id/role + +declare(strict_types=1); + +namespace App\Entity; + +use Doctrine\ORM\Mapping as ORM; + +#[ORM\Entity] +#[ORM\Table(name: TABLE_PREFIX . 'asset_employment')] +class AssetEmployment +{ + // clé primaire double + #[ORM\Id] + #[ORM\ManyToOne(targetEntity: NodeData::class, inversedBy: 'asset_employment')] + #[ORM\JoinColumn(name: 'node_data_id', referencedColumnName: 'id_node_data', onDelete: 'CASCADE')] + private NodeData $node_data; + + #[ORM\Id] + #[ORM\Column(type: 'string', length: 50)] + private string $role; + + #[ORM\ManyToOne(targetEntity: Asset::class, inversedBy: 'asset_employment')] + #[ORM\JoinColumn(name: 'asset_id', referencedColumnName: 'id_asset', onDelete: 'CASCADE')] + private Asset $asset; + + public function __construct(NodeData $node_data, Asset $asset, string $role){ + $this->node_data = $node_data; + $this->asset = $asset; + $this->role = $role; + } + + /*public function getNodeData(): NodeData + { + return $this->node_data; + }*/ + public function getAsset(): Asset + { + return $this->asset; + } + public function setAsset(Asset $asset): self + { + $this->asset = $asset; + return $this; + } + public function getRole(): string + { + return $this->role; + } +} diff --git a/src/Model/Entity/Email.php b/src/Model/Entity/Email.php new file mode 100644 index 0000000..8ad66fd --- /dev/null +++ b/src/Model/Entity/Email.php @@ -0,0 +1,131 @@ + 'CURRENT_TIMESTAMP'])] + private \DateTime $date_time; + + #[ORM\Column(type: 'boolean')] + private bool $is_sensitive; // "sensitive" tout court est un mot réservé + + #[ORM\Column(type: 'datetime', options: ['default' => 'CURRENT_TIMESTAMP'])] + private \DateTime $last_contact_date; + + #[ORM\Column(type: 'datetime', nullable: true)] + private ?\DateTime $is_sensitive_since; + + #[ORM\ManyToOne(targetEntity: EmailForm::class)] + #[ORM\JoinColumn(name: "email_form_id", referencedColumnName: "id_email_form", nullable: true)] + private ?EmailForm $email_form; + + public function __construct(string $sender_name, string $sender_address, string $recipient, string $content, EmailForm $email_form, bool $sensitive = false){ + $this->sender_name = strtolower($sender_name); + $this->sender_address = strtolower($sender_address); + $this->recipient = strtolower($recipient); + $this->content = $content; + $this->date_time = new \DateTime; + $this->last_contact_date = new \DateTime; + $this->email_form = $email_form; + $this->makeSensitive($sensitive); + } + + public function getId(): int + { + return $this->id_email; + } + public function getSenderName(): string + { + return $this->sender_name; + } + public function getSenderAddress(): string + { + return $this->sender_address; + } + public function getRecipient(): string + { + return $this->recipient; + } + public function getContent(): string + { + return $this->content; + } + public function getDateTime(): \DateTime + { + return $this->date_time; + } + /*public function getLastContactDate(): \DateTime + { + return $this->last_contact_date; + }*/ + public function isSensitive(): bool + { + return $this->is_sensitive; + } + public function isSensitiveSince(): ?\DateTime + { + return $this->is_sensitive_since; + } + + public function makeSensitive(bool $sensitive = true): void + { + $this->is_sensitive = $sensitive; + if($sensitive && $this->is_sensitive_since === null){ + $this->is_sensitive_since = new \DateTime(); + } + } + + public function updateLastContactDate(): void + { + $this->last_contact_date = new \DateTime; + } + + public function getDeletionDate(): \DateTime // utilise une durée de conservation $period qui est propre au bloc formulaire (à son EmailForm) + { + // tests appliqués: + // => e-mail associé à un formulaire? + // => ce formulaire dispose d'une durée de stockage spécifique? + // => cette donnée est un entier > 0 + $key = $this->is_sensitive ? 'retention_period_sensible' : 'retention_period'; + $period = $this->email_form ? (int)($this->email_form->getData()[$key] ?? null) : null; + + $default = $this->is_sensitive ? self::DEFAULT_RETENTION_PERIOD_SENSITIVE : self::DEFAULT_RETENTION_PERIOD; + $period = ($period === null || $period <= 0) ? $default : $period; + + $date = clone ($this->is_sensitive ? $this->is_sensitive_since : $this->last_contact_date); // erreur si "sensible" mais sans date disponible (pas censé arriver) + return $date->modify('+ ' . (string)$period . ' month'); + } +} \ No newline at end of file diff --git a/src/Model/Entity/EmailForm.php b/src/Model/Entity/EmailForm.php new file mode 100644 index 0000000..5c54b86 --- /dev/null +++ b/src/Model/Entity/EmailForm.php @@ -0,0 +1,57 @@ +data = $data; + $this->node = $node; + } + + public function getId(): int + { + return $this->id_email_form; + } + + // getData et updateData sont indentiques au code dans NodeData + // plutôt qu'une interface, pourquoi pas une classe abstraite? ou peut-être un trait? + public function getData(): array + { + return $this->data; + } + public function updateData(string $key, string|int|bool|array $value = ''): void + { + if($value !== ''){ + $this->data[$key] = $value; + } + // si $value est vide, supprime la clé + elseif(isset($this->data[$key])){ + unset($this->data[$key]); + } + } + + public function setNode(?Node $node): void + { + $this->node = $node; + } +} \ No newline at end of file diff --git a/src/Model/Entity/Event.php b/src/Model/Entity/Event.php new file mode 100644 index 0000000..3b81da7 --- /dev/null +++ b/src/Model/Entity/Event.php @@ -0,0 +1,129 @@ + 255) + + #[ORM\Column(type: 'text')] + private string $description = ''; + // chatgpt: Dans un contexte API/Front comme FullCalendar, + // préférer une chaîne vide à une varaible "null" peut être plus pratique, + // car ça évite des contrôles côté JS. + + #[ORM\Column(type: 'datetime')] // chatgpt: Doctrine suppose UTC si pas de configuration spécifique + private \DateTimeInterface $start; // typage possible avec une interface, + //chatgpt: choix \DateTime par défaut, autorise \DateTimeImmutable + + #[ORM\Column(type: 'datetime')] + private \DateTimeInterface $end; + + #[ORM\Column(type: 'boolean')] + private bool $all_day; + + #[ORM\Column(type: 'string', length: 7, nullable: true)] + private ?string $color = null; + + public function __construct(array $json){ + $this->securedUpdateFromJSON($json); + } + + public function securedUpdateFromJSON(array $json): void + { + $this->title = htmlspecialchars($json['title']); + $this->description = htmlspecialchars($json['description']); + try{ + $this->start = new \Datetime($json['start']); + $this->end = new \Datetime($json['end']); + } + catch(\Exception $e){ + throw new \InvalidArgumentException('Bad date input'); + } + $all_day = filter_var($json['allDay'] ?? null, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE); + if(!is_bool($all_day)){ + throw new \InvalidArgumentException('Bad checkbox input'); + } + $this->all_day = $all_day; + $this->color = isset($json['color']) ? htmlspecialchars($json['color']) : null; + } + + public function getId(): int + { + return $this->id; + } + + public function getTitle(): string + { + return $this->title; + } + /*public function setTitle(string $title): self + { + $this->title = $title; + return $this; + }*/ + + public function getDescription(): string + { + return $this->description; + } + /*public function setDescription(string $description = ''): self + { + $this->description = $description; + return $this; + }*/ + + public function getStart(): \DateTimeInterface + { + return $this->start; + } + /*public function setStart(\DateTimeInterface $start): self + { + $this->start = $start; + return $this; + }*/ + + public function getEnd(): \DateTimeInterface + { + return $this->end; + } + /*public function setEnd(\DateTimeInterface $end): self + { + $this->end = $end; + return $this; + }*/ + + public function isAllDay(): bool + { + return $this->all_day; + } + /*public function setAllDay(bool $all_day): self + { + $this->all_day = $all_day; + return $this; + }*/ + + public function getColor(): ?string + { + return $this->color; + } + /*public function setColor(?string $color): self + { + $this->color = $color; + return $this; + }*/ +} diff --git a/src/Model/Entity/Image.php b/src/Model/Entity/Image.php new file mode 100644 index 0000000..06230ce --- /dev/null +++ b/src/Model/Entity/Image.php @@ -0,0 +1,89 @@ + Validation du type de fichier : On vérifie que le fichier est bien une image en utilisant le type MIME. On peut aussi vérifier la taille du fichier. + => Création d'un répertoire structuré : On génère un chemin dynamique basé sur la date (uploads/2024/12/24/) pour organiser les images. + => Génération d'un nom de fichier unique : On utilise uniqid() pour générer un nom unique et éviter les conflits de nom. + => Déplacement du fichier sur le serveur : Le fichier est déplacé depuis son emplacement temporaire vers le répertoire uploads/. + => Enregistrement dans la base de données : On enregistre les informations de l'image dans la base de données. */ + + #[ORM\ManyToMany(targetEntity: Article::class, mappedBy: "images")] + private Collection $article; + + public function __construct(string $name, ?string $path, ?string $path_mini, string $mime_type, string $alt) + { + $this->file_name = $name; + $this->file_path = $path; + $this->file_path_mini = $path_mini; + $this->mime_type = $mime_type; + $this->alt = $alt; + } + + public function getFileName(): string + { + return $this->file_name; + } + public function getFilePath(): string + { + return $this->file_path; + } + public function getFilePathMini(): string + { + return $this->file_path_mini; + } + public function getAlt(): string + { + return $this->alt; + } + + + // pour ViewBuilderController? + /*public function displayImage($imageId): void + { + //$imageId = 1; // Exemple d'ID d'image + $stmt = $pdo->prepare("SELECT file_path FROM images WHERE id = ?"); + $stmt->execute([$imageId]); + $image = $stmt->fetch(); + + if ($image) { + echo "Image"; + } else { + echo "Image non trouvée."; + } + }*/ +} diff --git a/src/Model/Entity/Log.php b/src/Model/Entity/Log.php new file mode 100644 index 0000000..b1cc168 --- /dev/null +++ b/src/Model/Entity/Log.php @@ -0,0 +1,38 @@ + 'CURRENT_TIMESTAMP'])] // CURRENT_TIMESTAMP "inutile", date générée par PHP + private \DateTime $date_time; // type datetime de doctrine <=> type \DateTime de PHP + + #[ORM\Column(type: "boolean")] + private bool $success; + + public function __construct(bool $success){ + $this->date_time = new \DateTime; + $this->success = $success; + } + + public function getFormatedDate(): string + { + return $this->date_time->format('d/m/Y à H\hi'); + } + public function getSuccess(): bool + { + return $this->success; + } +} diff --git a/src/Model/Entity/Node.php b/src/Model/Entity/Node.php new file mode 100644 index 0000000..07666c3 --- /dev/null +++ b/src/Model/Entity/Node.php @@ -0,0 +1,167 @@ +name_node = $name; + $this->position = $position; + $this->parent = $parent; + $this->page = $page; + $this->article = $article; + } + + // pfff... + public function getId(): ?int + { + return $this->id_node; + } + public function getName(): string + { + return $this->name_node; + } + /*public function setName(string $name): void + { + $this->name_node = $name; + }*/ + + public function getParent(): ?self + { + return $this->parent; + } + /*public function setParent(?self $parent): void + { + $this->parent = $parent; + }*/ + public function getPosition(): int + { + return $this->position; + } + public function setPosition(int $position): void + { + $this->position = $position; + } + public function getPage(): Page + { + return $this->page; + } + /*public function setPage(Page $page): void + { + $this->page = $page; + }*/ + + // utiliser l'interface de NodeData et EmailForm + public function getArticle(): Article + { + return $this->article; + } + /*public function setArticle(Article $article): void + { + $this->article = $article; + }*/ + + // une interface serait cool! + // OU possible un "héritage doctrine", faire en sorte que Node soit la mère de NodeData, EmailForm, Article... + // une seule instance est matérialisée par plusieurs tables en même temps + public function getNodeData(): NodeData|EmailForm|Presentation|null + { + // pour du polymorphisme (une unique variable $node_data): opter pour l'héritage + return match($this->name_node){ + 'form' => $this->email_form, + 'post_block', 'news_block' => $this->presentation, + default => $this->node_data, // inclut 'calendar' + }; + } + public function getChildren(): array + { + return $this->children; + } + public function getNodeByName(string $name): ?Node + { + foreach($this->children as $child){ + if($child->getName() === $name){ + return $child; + } + } + return null; + } + public function addChild(self $child): void + { + $this->children[] = $child; + + if(!Presentation::hasPresentation($this->getName())){ // post_block et news_block ont leurs enfants ordonnés avec ORDER BY + $this->sortChildren(false); + } + } + public function removeChild(self $child): void + { + foreach($this->children as $key => $object){ + if($object->getId() === $child->getId()){ + unset($this->children[$key]); + } + break; + } + $this->children = array_values($this->children); // réindexer pour supprimer la case vide + } + + public function getAdoptedChild(): ?self // peut renvoyer null + { + return $this->adopted; + } + public function setAdoptedChild(self $child): void + { + $this->adopted = $child; + } +} diff --git a/src/Model/Entity/NodeData.php b/src/Model/Entity/NodeData.php new file mode 100644 index 0000000..d81628d --- /dev/null +++ b/src/Model/Entity/NodeData.php @@ -0,0 +1,102 @@ + noeud "show_emails" + + public function __construct(array $data, Node $node, Collection $asset_employment = new ArrayCollection){ + $this->data = $data; + $this->node = $node; + $this->asset_employment = $asset_employment; + } + + public function getId(): int + { + return $this->id_node_data; + } + public function getData(): array + { + return $this->data; + } + /*public function setData(array $data): void // entrée = tableau associatif + { + $this->data = $data; + }*/ + public function updateData(string $key, string|int|bool|array $value = ''): void + { + if($value !== ''){ + $this->data[$key] = $value; + } + // si $value est vide, supprime la clé + elseif(isset($this->data[$key])){ + unset($this->data[$key]); + } + } + + public function setNode(?Node $node): void + { + $this->node = $node; + } + + public function getNodeDataAssets(): Collection + { + return $this->asset_employment; + } + public function getAssetEmploymentByRole(string $role): ?AssetEmployment + { + foreach($this->asset_employment as $nda){ + if($nda->getRole() === $role){ + return $nda; + } + } + return null; + } + public function getAssetByRole(string $role): ?Asset + { + $nda = $this->getAssetEmploymentByRole($role); + if($nda === null){ + return null; + } + return $nda->getAsset() ?? null; + } + + // pour affichage page Courriels + public function getEmails(): array // appelée dans ShowEmailsBuilder + { + return $this->emails; + } + public function setEmails(array $emails): void // appelée dans Model + { + $this->emails = $emails; + } +} \ No newline at end of file diff --git a/src/Model/Entity/Page.php b/src/Model/Entity/Page.php new file mode 100644 index 0000000..7cca3dc --- /dev/null +++ b/src/Model/Entity/Page.php @@ -0,0 +1,222 @@ +name_page = $name; + $this->end_of_path = $eop; + $this->description = $description; + $this->reachable = $reachable; + $this->in_menu = $in_menu; + $this->hidden = $hidden; + $this->position = $position; + $this->parent = $parent; + $this->children = new ArrayCollection(); + } + + // getters/setters + public function getId(): int + { + return $this->id_page; + } + public function getPageName(): string + { + return $this->name_page; + } + public function setPageName(string $name): void + { + $this->name_page = $name; + } + public function getPagePath(): string + { + return $this->page_path; + } + public function setPagePath(string $path):void + { + $this->page_path = $path; + } + public function getEndOfPath(): string + { + return $this->end_of_path; + } + public function setEndOfPath(string $end_of_path):void + { + $this->end_of_path = $end_of_path; + } + public function getDescription(): string + { + return $this->description; + } + public function setDescription(string $description): void + { + $this->description = $description; + } + + public function getCSS(): array + { + return array_merge(self::$default_css, $this->css ?? []); + } + public function addCSS(string $css): void + { + if(!in_array($css, $this->css ?? [])){ + $this->css[] = $css; + } + } + public function removeCSS(string $css): void + { + // array_diff renvoie une copie du 1er tableau alégée des élements existants aussi dans le 2è, array_values réindexe + $this->css = array_values(array_diff($this->css, [$css])); + } + public function getJS(): array + { + return array_merge(self::$default_js, $this->js ?? []); + //UPDATE `nb_page` SET `js` = NULL WHERE JSON_EQUALS(`js`, '["main"]'); + } + public function addJS(string $js): void + { + if(!in_array($js, $this->js ?? [])){ + $this->js[] = $js; + } + } + public function removeJS(string $js): void + { + $this->js = array_values(array_diff($this->js, [$js])); + } + + public function isReachable(): bool + { + return $this->reachable; + } + public function isInMenu(): bool + { + return $this->in_menu; + } + public function isHidden(): bool + { + return $this->hidden; + } + public function setHidden(bool $hidden): void + { + $this->hidden = $hidden; + } + public function getPosition(): ?int + { + return $this->position; + } + public function setPosition(int $position): void + { + $this->position = $position; + } + public function getParent(): ?Page + { + return $this->parent; + } + public function setParent(?Page $parent): void + { + $this->parent = $parent; + } + public function getChildren(): Collection + { + return $this->children; + } + + // utilisée par $menu_path + public function fillChildrenPagePath(string $parent_path = ''): void + { + $this->page_path = $parent_path != '' ? $parent_path . '/' . $this->end_of_path : $this->end_of_path; + foreach($this->getChildren() as $page){ + $page->fillChildrenPagePath($this->page_path); + } + } + + public function addChild(self $child): void + { + $this->children[] = $child; + $this->sortChildren(false); + } + public function removeChild(self $child): void + { + $this->children->removeElement($child); + $this->children = new ArrayCollection(array_values($this->children->toArray())); // réindexer en passant par un tableau + $this->sortChildren(false); + } + + public function findPageById(int $id): ?Page + { + $target = null; + foreach($this->children as $page){ + if($page->getId() === $id){ + return $page; + } + if(count($page->getChildren()) > 0){ + $target = $page->findPageById($id); + if($target !== null){ + return $target; + } + } + } + return $target; + } +} diff --git a/src/Model/Entity/Presentation.php b/src/Model/Entity/Presentation.php new file mode 100644 index 0000000..f5e3502 --- /dev/null +++ b/src/Model/Entity/Presentation.php @@ -0,0 +1,135 @@ +data = $data; + $this->node = $node; + /*if(!empty($presentation) && $presentation === 'grid'){ + $this->grid_cols_min_width = 250; + } + $this->chrono_order = $chrono_order ?? null;*/ + } + + /*public function getId(): int + { + return $this->id_presentation; + }*/ + + public function setNode(?Node $node): void + { + $this->node = $node; + } + + // un trait pour ça + public function getData(): array + { + return $this->data; + } + public function updateData(string $key, string|int|bool|array $value = ''): void + { + if($value !== ''){ + $this->data[$key] = $value; + } + // si $value est vide, supprime la clé + elseif(isset($this->data[$key])){ + unset($this->data[$key]); + } + } + + // spécifique aux blocs contenant des articles + public function getPresentation(): ?string + { + return $this->presentation; + } + public function setPresentation(string $presentation): void + { + $this->presentation = $presentation; + } + public function getColsMinWidth(): int + { + $default = 320; // pixels + return $this->grid_cols_min_width === null ? $default : $this->grid_cols_min_width; + } + public function setColsMinWidth(int $columns): void + { + $this->grid_cols_min_width = $columns; + } + public function getChronoOrder(): bool + { + return $this->chrono_order ?? false; + } + public function setChronoOrder(bool $reverse_order): void + { + $this->chrono_order = $reverse_order; + } + + public function getPaginationLimit(): ?int + { + $default = 12; // si 0 pas de pagination, 12 rend bien avec des grilles de 2, 3 ou 4 colonnes + return $this->pagination_limit === null ? $default : $this->pagination_limit; + } + public function setPaginationLimit(int $pagination_limit): void + { + $this->pagination_limit = $pagination_limit; + } + public function getNumberOfPages(): int + { + return $this->nb_pages; + } + public function setNumberOfPages(int $nb_pages): void + { + $this->nb_pages = $nb_pages; + } + + + /* -- blocs et présentations disponibles dans l'application -- */ + const BLOCKS = ['post_block' => 'Articles libres', 'news_block' => 'Actualités', + //'galery' => 'Galerie', + 'calendar' => 'Calendrier', 'form' => 'Formulaire' + ]; + const PRESENTATIONS = ['fullwidth' => 'Pleine largeur', 'grid' => 'Grille', 'mosaic' => 'Mosaïque' + //, 'carousel' => 'Carrousel' + ]; + static public function hasPresentation(string $block): bool + { + return in_array($block, ['post_block', 'news_block']) ? true : false; + } +} \ No newline at end of file diff --git a/src/Model/Entity/User.php b/src/Model/Entity/User.php new file mode 100644 index 0000000..461a5bc --- /dev/null +++ b/src/Model/Entity/User.php @@ -0,0 +1,67 @@ +login = $login; + $this->role = $role; + $this->password = $password; + } + + public function getId(): int + { + return $this->id_user; + } + + public function getLogin(): string + { + return $this->login; + } + public function setLogin(string $login): void + { + $this->login = $login; + } + public function getRole(): string + { + return $this->role; + } + public function setRole(string $role): void + { + $this->role = $role; + } + public function getPassword(): string + { + return $this->password; + } + public function setPassword(string $password): void + { + $this->password = $password; + } +} \ No newline at end of file -- cgit v1.2.3