From c0136f67ceae4371e76410ac2f75ec4353fd2b00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Georges=20Dup=C3=A9ron?= Date: Thu, 14 Oct 2010 18:27:40 +0200 Subject: [PATCH] =?UTF-8?q?Impl=C3=A9mentation=20(partielle)=20de=20plusie?= =?UTF-8?q?urs=20widgets.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cms2/code/document.php | 92 +++++++++++++++++--------------- cms2/code/page.php | 4 +- cms2/modules/galerie/galerie.php | 15 +++--- 3 files changed, 60 insertions(+), 51 deletions(-) diff --git a/cms2/code/document.php b/cms2/code/document.php index 633fa14..0243c1e 100644 --- a/cms2/code/document.php +++ b/cms2/code/document.php @@ -158,7 +158,8 @@ ElementDocument::add_type(true, "header", "title"); ElementDocument::add_type("title", "text"); ElementDocument::add_type(true, "footer", ""); ElementDocument::add_type(true, "nav", "ul"); -ElementDocument::add_type(true, "article", "ul table p form span"); // span ? +ElementDocument::add_type(true, "article", "ul hX table p form span"); // span ? +ElementDocument::add_type("hX", $inline_elems); ElementDocument::add_type("script", "", "src"); ElementDocument::add_type("style", "", "src"); ElementDocument::add_type("ul", "li"); @@ -177,57 +178,75 @@ ElementDocument::add_type("text", "", "text"); -ElementDocument::add_widget("titre", function($d, $select){ +ElementDocument::add_widget("titre", function($d, $cell){ // renvoie un

ou un selon les droits - return $d->header()->title()->text("Not Implemented Yet : w_titre($select)"); + $d->header()->title()->text("".$cell); + // TODO : modification si on a les droits. + $d->article()->hX()->text("".$cell); }); -ElementDocument::add_widget("en_tete", function($d, $select_titre, $select_description){ - //$d->w_titre($this->select("titre")); - //$d->w_description($this->select("description")); - $d->w_titre("NIY en_tete"); - $d->w_description("NIY en_tete"); +ElementDocument::add_widget("en_tete", function($d, $cell_titre, $cell_description){ + $d->w_titre($cell_titre); + $d->w_description($cell_description); }); -ElementDocument::add_widget("description", function($d, $select){ - return $d->article()->p()->text("NIY Descrption($select)"); +ElementDocument::add_widget("description", function($d, $cell){ + // TODO : modification si on a les droits. + return $d->article()->p()->text("".$cell); }); -ElementDocument::add_widget("field", function($d, $select){ +ElementDocument::add_widget("field", function($d, $cell){ $f = $d->span("field"); - $f->text("NIY : " . $select); + $f->text("NIY : " . $cell); return $f; }); -ElementDocument::add_widget("text_line", function($d, $select){ - return $d->text("Not Implemented Yet : w_text_line($select)"); +ElementDocument::add_widget("text_line", function($d, $cell){ + // TODO : modification si on a les droits. + return $d->text("".$cell); }); -ElementDocument::add_widget("text_no_space", function($d, $select){ - return $d->text("Not Implemented Yet : w_text_line($select)"); +ElementDocument::add_widget("text_nix", function($d, $cell){ + // Texte naze (sans espaces etc.) à la *nix. + // TODO : modification si on a les droits. + // TODO : vérifier que ça match [a-zA-Z][-a-zA-Z0-9_]* + return $d->text("".$cell); }); -ElementDocument::add_widget("text_rich", function($d, $select){ - return $d->text("Not Implemented Yet : w_text_rich($select)"); +ElementDocument::add_widget("text_rich", function($d, $cell){ + // TODO : modification si on a les droits. + // TODO : rendu du texte riche. + return $d->p()->text("".$cell); }); -ElementDocument::add_widget("bool", function($d, $select){ +ElementDocument::add_widget("bool", function($d, $cell){ // checkbox - return $d->text("Not Implemented Yet : w_bool($select)"); + return $d->text("Not Implemented Yet : w_bool($cell)"); }); -// Le widget w_img_file doit gérer le stockage de l'image dans un dossier, la création de la miniature et le stockage dans la BDD du chemin vers l'image. -ElementDocument::add_widget("img_file", function($d, $select){ +ElementDocument::add_widget("bouton", function($d, $texte, $page_callback, $ressource_callback, $action_callback){ + // afficher un input[type=button] + // lors du clic, appeller $action_callback sur $page_callback/?res=$ressource_callback ? + return $d->text("Not Implemented Yet : w_bouton($texte, $page_callback, $ressource_callback, $action_callback)"); + }); + + +// Le widget w_img_file doit gérer le stockage de l'image dans un dossier, +// la création de la miniature et le stockage dans la BDD du chemin vers l'image. +ElementDocument::add_widget("img_file", function($d, $cell_description, $cell_img){ + // TODO : modification si on a les droits. // input[file] et - return $d->text("Not Implemented Yet : w_img_file($select)"); + $img = $d->img("".$cell_description, "".$cell_img); + $d->w_description($cell_description); + return $img; }); @@ -237,10 +256,13 @@ ElementDocument::add_widget("date", function($d, $select){ }); -ElementDocument::add_widget("liste", function($d, $select, $function_formattage_elements) { - $l = $d->ul(); - $l->li()->text("Not Implemented Yet"); - return $l; +ElementDocument::add_widget("liste", function($d, $list_cells, $function_formattage_elements) { + $ul = $d->ul(); + foreach ($list_cells as $cell) { + $li = $ul->li(); + $function_formattage_elements($cell, $li); + } + return $ul; }); ElementDocument::add_widget("tableau", function($d, $select, $function_formattage_elements) { @@ -250,20 +272,4 @@ ElementDocument::add_widget("tableau", function($d, $select, $function_formattag return $t; }); -/* Widgets : - function liste($elts, $format) { - $d = new Document(); - $ul = $d->append->ul(); - foreach ($elts as $k => $e) { - $ul->append($format($e)); - } - return $d; - } - - function bouton($texte, $page_callback, $action_callback) { - // afficher un input - // lors du clic, appeller $action_callback sur $page_callback ? - } -*/ - ?> \ No newline at end of file diff --git a/cms2/code/page.php b/cms2/code/page.php index 62dbf59..3f93193 100644 --- a/cms2/code/page.php +++ b/cms2/code/page.php @@ -137,8 +137,8 @@ class mPage { attribut_global("date_creation", "date", "0"); attribut_global("date_modification", "date", "0"); attribut_global("publier", "bool", "false"); - attribut_global("nom_systeme", "text_no_space", ""); - attribut_global("composant_url", "text_no_space", "page"); + attribut_global("nom_systeme", "text_nix", ""); + attribut_global("composant_url", "text_nix", "page"); } public static function est_propriete_globale($prop) { diff --git a/cms2/modules/galerie/galerie.php b/cms2/modules/galerie/galerie.php index 4780521..b7539d2 100644 --- a/cms2/modules/galerie/galerie.php +++ b/cms2/modules/galerie/galerie.php @@ -14,6 +14,7 @@ abstract class mGalerieBase extends mPage { attribut("titre", "text_line", $module::$texte_titre); attribut("description", "text_rich", ""); attribut("publier", "bool", "true"); + attribut("apercu", "bool", "false"); // TODO ! } public function res_i_icone_nouvelle_page() { @@ -27,7 +28,7 @@ abstract class mGalerieBase extends mPage { public function res_h_page($d) { $d->w_en_tete($this->titre, $this->description); // En-tête standard. $l = $d->article()->w_liste($this->enfants(true, "-date_creation"), function($e, $li) { - $a = $li->a($e->uid()); + $a = $li->a($e->url()); $e->rendu("h_miniature", $a); }); $nouveau = $l->li(); @@ -45,17 +46,19 @@ abstract class mGalerieBase extends mPage { } public function res_h_miniature($d) { - $d->span("miniature")->append($this->res_h_mini_miniature()); - $d->span("titre")->_field($this->titre); + $this->res_h_mini_miniature($d->span("miniature")); + $d->span("titre")->w_field($this->titre); return $d; } public function res_h_mini_miniature($d) { $a = $this->enfants("apercu = 'true'", "-date_creation", 1); // TODO : l'aperçu devrait être défini par le parent => ajouter un attribut "virtuel". - if (count($a) != 1) + if (count($a) != 1) { $a = $this->enfants(true, "-date_creation", 1); - if (count($a) != 1) - return; // TODO : aucune photo + } + if (count($a) != 1) { + return $d->text("Aucune photo."); + } return $a[0]->rendu("h_mini_miniature", $d);; }