Widget en ériture pour text_line.

This commit is contained in:
Georges Dupéron 2010-10-16 12:28:49 +02:00
parent 5f84ce3848
commit 129dc91905
5 changed files with 54 additions and 9 deletions

View File

@ -10,4 +10,15 @@
soit il faut supprimer le fichier index.php (pour que index.php5 ait la priorité),
soit il faut transférer .htaccess (qui spécifie qu'il faut utiliser php5).
- Pouvoir ajouter des types plutôt que des widgets. Type = widget affichage + wiget modification (affichage/modification) + sérialisation (stockage) (+ autre chose ?)
- Pouvoir ajouter des types plutôt que des widgets. Type = widget affichage + wiget modification (affichage/modification) + sérialisation (stockage) (+ autre chose ?)
- r_field : read-only field
- widgets en écriture. Un form pour chaque champ. 2h
- if_perm() 3h
- modules pour le site 4h
- squelette 1h
- css pour le site 2h
==== OK.
- chercher le form parent, s'il n'y en a pas, créer un nouveau. 1h
- sécurité : if_perm quand on get_prop_direct() ou set_prop_direct() 1h
- import / export de la BDD. 2h

View File

@ -87,7 +87,11 @@ class ElementDocument {
public function to_XHTML_1_1() {
niy("to_XHTML_1_1");
}
public function url() {
return $this->document->page->url();
}
public function __construct($type = "document", &$doc = null) {
$this->type = $type;
$this->document = $doc;
@ -152,17 +156,19 @@ class ElementDocument {
class Document extends ElementDocument {
protected $singletons = array();
public function __construct() {
protected $page = null;
public function __construct($page) {
parent::__construct("document", $this);
$this->erreurs();
$this->header();
$this->nav();
$this->article();
$this->footer();
$this->page = $page;
}
}
$inline_elems = "span text a strong em img";
$inline_elems = "span text a strong em img form";
ElementDocument::add_type("document", "erreurs header footer nav article script style");
ElementDocument::add_type(true, "header", "title");
ElementDocument::add_type(true, "erreurs", "litteral");
@ -181,7 +187,9 @@ ElementDocument::add_type("tr", "td th");
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("form", "input_text_line input_text_multi input_text_rich input_file input_submit", "action");
ElementDocument::add_type("input_text_line", "", "value");
ElementDocument::add_type("input_submit", "", "label");
ElementDocument::add_type("a", $inline_elems, "href");
ElementDocument::add_type("span", $inline_elems, "", "class");
ElementDocument::add_type("img", "", "alt src");
@ -238,7 +246,6 @@ function fn_w_img_file_desc($d, $cell_img, $cell_description) {
return $img;
}
function fn_w_field($d, $cell) {
if ($cell->page()->if_perm("w", $cell->nom_attribut())) {
return call_user_func(array($d, "w_w_" . $cell->type()), $cell);
@ -247,11 +254,23 @@ function fn_w_field($d, $cell) {
}
}
function fn_w_r_field($d, $cell) {
return call_user_func(array($d, "w_r_" . $cell->type()), $cell);
}
function fn_w_r_text_line($d, $cell) {
// TODO : modification si on a les droits.
return $d->text(toString($cell));
}
function fn_w_w_text_line($d, $cell) {
$f = $d->form($d->url());
$f->input_text_line(toString($cell));
$f->input_submit("Ok");
return $f;
}
function fn_w_r_text_nix($d, $cell) {
// Texte naze (sans espaces etc.) à la *nix.
// TODO : modification si on a les droits.
@ -293,6 +312,7 @@ ElementDocument::add_widget("tableau", "fn_w_tableau");
ElementDocument::add_widget("img_file_desc", "fn_w_img_file_desc");
ElementDocument::add_widget("field");
ElementDocument::add_widget("r_field");
Module::add_type("text_line");
Module::add_type("text_nix");
Module::add_type("text_rich");

View File

@ -45,7 +45,7 @@ class mPage {
$res = $this->module['ressources_dynamiques'][0];
}
if ($d === null) {
$d = new Document();
$d = new Document($this);
}
return call_user_func(array($this, "res_" . $res), $d);
}

View File

@ -33,6 +33,20 @@
</a>
</xsl:template>
<xsl:template match="input_text_line">
<input type="text" value="{@value}"/>
</xsl:template>
<xsl:template match="input_submit">
<input type="submit" value="{@label}"/>
</xsl:template>
<xsl:template match="form">
<form action="{@action}">
<xsl:apply-templates select="*"/>
</form>
</xsl:template>
<xsl:template match="span">
<!-- TODO : mettre le class="?" ssi c'est non vide. -->
<span class="{@class}">

View File

@ -48,7 +48,7 @@ abstract class mGalerieBase extends mPage {
public function res_h_miniature($d) {
$this->res_h_mini_miniature($d->span("miniature"));
$d->span("titre")->w_field($this->titre);
$d->span("titre")->w_r_field($this->titre);
return $d;
}