From 42b220434a594cfad6019b2ab6b7ea8f74a1389b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Georges=20Dup=C3=A9ron?= Date: Sat, 9 Oct 2010 23:54:26 +0200 Subject: [PATCH] =?UTF-8?q?Attributs=20optionnels=20pour=20les=20=C3=A9l?= =?UTF-8?q?=C3=A9ments=20(td=20:=20colspan=20rowspan,=20span=20:=20class).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cms2/code/document.php | 23 ++++++++++++++++------- cms2/modules/admin/admin-utilisateurs.php | 2 +- cms2/modules/nouveautes/nouveautes.php | 2 +- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/cms2/code/document.php b/cms2/code/document.php index c29dbf7..cbc1365 100644 --- a/cms2/code/document.php +++ b/cms2/code/document.php @@ -15,9 +15,10 @@ class ElementDocument { private $attr = array(); protected $document = null; - public static function add_type($singleton, $type, $typesEnfants = "", $attributs = "") { + public static function add_type($singleton, $type, $typesEnfants = "", $attributs_oblig = "", $attributs_opt = "") { if ($singleton !== true && $singleton !== false) { - $attributs = $typesEnfants; + $attributs_opt = $attributs_oblig; + $attributs_oblig = $typesEnfants; $typesEnfants = $type; $type = $singleton; $singleton = false; @@ -25,7 +26,8 @@ class ElementDocument { self::$types[$type] = array( "singleton" => $singleton, "enfants" => qw($typesEnfants), - "attributs" => qw($attributs) + "attributs_oblig" => qw($attributs_oblig), + "attributs_opt" => qw($attributs_opt) ); } @@ -99,12 +101,19 @@ class ElementDocument { public function créer_élément($type, $args) { $elem = new self($type, $this->document); - - foreach (self::$types[$type]["attributs"] as $i => $nom) { + + $max = 0; + foreach (self::$types[$type]["attributs_oblig"] as $i => $nom) { if (!isset($args[$i])) { Debug::error("Argument manquant : $nom pour " . $elem->type); } $elem->attr($nom, $args[$i]); + $max = $i; + } + foreach (self::$types[$type]["attributs_opt"] as $i => $nom) { + if (isset($args[$i])) { + $elem->attr($nom, $args[$i]); + } } $this->enfants[] = $elem; @@ -157,12 +166,12 @@ ElementDocument::add_type("ul", "li"); ElementDocument::add_type("table", "thead tbody tfoot"); ElementDocument::add_type("tbody", "tr"); ElementDocument::add_type("tr", "td th"); -ElementDocument::add_type("td", $inline_elems); +ElementDocument::add_type("td", $inline_elems, "", "colspan rowspan"); ElementDocument::add_type("th", $inline_elems); ElementDocument::add_type("li", $inline_elems); ElementDocument::add_type("form", "input_text_line input_text_multi input_text_rich input_file"); ElementDocument::add_type("a", $inline_elems, "href"); -ElementDocument::add_type("span", $inline_elems, "class"); +ElementDocument::add_type("span", $inline_elems, "", "class"); ElementDocument::add_type("img", "", "alt src"); ElementDocument::add_type("p", $inline_elems); ElementDocument::add_type("text", "", "text"); diff --git a/cms2/modules/admin/admin-utilisateurs.php b/cms2/modules/admin/admin-utilisateurs.php index 4dde3ae..0ba37e2 100644 --- a/cms2/modules/admin/admin-utilisateurs.php +++ b/cms2/modules/admin/admin-utilisateurs.php @@ -28,7 +28,7 @@ class AdminListeUtilisateurs extends Page { $l = $d->article()->w_tableau($this->enfants(true, "nom asc prenom asc"), function($e, $tr) { $e->rendu("h_admin", $tr); }); - $nouveau = $l->tbody(0)->tr()->td(); // TODO : colspan + $nouveau = $l->tbody(0)->tr()->td(6); $nouveau->text("Nouvel utilisateur"); return $d; } diff --git a/cms2/modules/nouveautes/nouveautes.php b/cms2/modules/nouveautes/nouveautes.php index 82876a1..ca87c52 100644 --- a/cms2/modules/nouveautes/nouveautes.php +++ b/cms2/modules/nouveautes/nouveautes.php @@ -36,7 +36,7 @@ class Nouveautes extends Page { }); $nouveau = $l->li(); $nouveau->span("miniature")->img("", $this->url("i_icône_nouvelle_page")); - $nouveau->span("titre")->text("Ajouter un article aux nouveautés."); + $nouveau->span("action")->text("Ajouter un article aux nouveautés."); return $d; } }