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/View/AbstractBuilder.php | 81 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 src/View/AbstractBuilder.php (limited to 'src/View/AbstractBuilder.php') diff --git a/src/View/AbstractBuilder.php b/src/View/AbstractBuilder.php new file mode 100644 index 0000000..170e871 --- /dev/null +++ b/src/View/AbstractBuilder.php @@ -0,0 +1,81 @@ +id_node = $node->getId(); + } + + protected function useChildrenBuilder(Node $node): void + { + foreach($node->getChildren() as $child_node) + { + // le double \\ permet de ne pas échapper la quote + $builder_name = 'App\View\\' . $this->snakeToPascalCase($child_node->getName()) . 'Builder'; + $builder = new $builder_name($child_node); + $this->html .= $builder->render(); + + // pages spéciales où on n'assemble pas tout + if($builder_name === 'HeadBuilder' && in_array(Model::$page_path->getString(), ['connection', 'user_edit'])) + { + foreach($node->getChildren() as $target_node){ + if($target_node->getName() === 'main'){ + $main_node = $target_node; + break; + } + } + // on construit
et on s'arrête! les autres noeuds sont ignorés + $builder_name = $this->snakeToPascalCase($main_node->getName()) . 'Builder'; + $builder = new $builder_name($main_node); + $this->html .= "\n"; + $this->html .= $builder->render() . "\n"; + $this->html .= "\n"; + break; + } + } + } + + private function snakeToPascalCase(string $input): string + { + return str_replace('_', '', ucwords($input, '_')); + } + + public function render(): string // = getHTML(), nécéssite d'être public + { + return $this->html; + } + protected function addHTML(string $html): void + { + $this->html .= $html; + } + + protected function insertSVG(string $path, array $attributes = []): string + { + $svg = file_get_contents($path); + + // modification des attributs + if(!empty($attributes)){ + $dom = new \DOMDocument(); + $dom->loadXML($svg); + $svg_elem = $dom->documentElement; + foreach($attributes as $key => $value){ + $svg_elem->setAttribute($key, $value); + } + $svg = $dom->saveXML($svg_elem); + } + return $svg; + } +} \ No newline at end of file -- cgit v1.2.3